Here is my code. Please help merge the two charts into one chart. I am trying to merge the first dataset from the data table with the one in image collection on the same axis. The idea is to merge demand and the supply.
//feature collection for Aoi
var table =ee.Geometry.Polygon(
[[[37.55303819518035, 0.3541521362992195],
[37.55303819518035, 0.33389645906159726],
[37.596554354237966, 0.33389645906159726],
[37.596554354237966, 0.3541521362992195]]], null, false);
//external dataset
var myTable = {
cols: [
{id: 'name', label: 'month', type: 'string'},
{id: 'name', label: 'demand', type: 'number'},
{id: 'name', label: 'supply', type: 'number'}],
rows: [
{c: [{v: 'Jan'}, {v: 38253956}]},
{c: [{v: 'Feb'}, {v: 10978102}]},
{c: [{v: 'Mar'}, {v: 12030632}]},
{c: [{v: 'Apr'}, {v: 908340}]},
{c: [{v: 'May'},{v: 303074}]}
],
};
//defining the header
var header = ui.Label(' Demand Curve', {fontSize: '30px', color: 'black',fontWeight: 'bold'});
print(header)
var chart = new ui.Chart(myTable, 'LineChart');
chart.setSeriesNames([' Demand'])
chart.setOptions({
title: 'Demand Curve',
hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true},gridlines: {count: 27}},
vAxis: {
title: ' Demand',
titleTextStyle: {italic: false, bold: true}
},
lineWidth: 1,
colors: [ 'FF0000'],
curveType: 'line',
maxPixels:90e9
});
print(chart);
//---End Of the external data--------
//Getting image collection data fir the ndvi
Map=ui.Map();
var s2a = ee.ImageCollection('COPERNICUS/S2_SR')
.filter(ee.Filter.date('2019-01-01', '2019-03-31'))
.select('B1','B2','B3','B4','B5','B6','B7','B8','B8A','B9','B11','B12')
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 10))
.sort('system:time_start')
.map(function(s2a){return s2a.clip(table)})
// .set('system:time_start',date_start)
// .set('system:time_end',date_end)
// .sort('DATE_ACQUIRED');
Map.setCenter (37.577717495842506,0.3597340638009545,5);
var subndvi = s2a.map(
function(image) {
var ndvi = image.normalizedDifference(['B8', 'B4']).rename('NDVI')
var ndvi2 =ndvi.gt(0.18).and(ndvi.lte(0.22)).clip(table)
.copyProperties(image,['system:time_start','system:time_end','system:index'])
var ndvi3 = ndvi.gt(0.22).and(ndvi.lte(0.27))
.copyProperties(image,['system:time_start','system:time_end'])
return ndvi2
})
var ndviChart = ui.Chart.image.series(subndvi, table, ee.Reducer.mean(), 1000);
ndviChart.setOptions({
title: 'NDVI(Supply Curve)',
vAxis: {title: 'NDVI', maxValue: 1},
hAxis: {title: 'Date', format: 'MM-yy', gridlines: {count: 7}},
maxPixels:90e9,
});
print(ndviChart)
//-----End Of Ndvi Data--------
The below image shows the two charts from the code above.