Is there a way to include a variable as plot title? I'd like my title to be depending on the value of a certain integer (depending here on iC_FC_size).
var text = ee.String('Landsat Mission 4-8 - GEE image availability: ').cat(iC_FC_size)
var options1 = {
title: 'Landsat Mission 4-8 - GEE image availability Suriname',
hAxis: {title: 'Year'},
vAxis: {title: 'Image count'},
colors: ['red']
}; // options for plotting histogram
var histogram = ui.Chart.feature.histogram({
features: iC_FC,
property: 'year',
minBucketWidth: 1
}).setOptions(options1);
var panel = ui.Panel({
layout: ui.Panel.Layout.flow('vertical'),
style: {position: 'bottom-right', height: '500px', width:'350px'}
}); // create panel for plotting
ui.root.add(panel);
panel.widgets().set(0, histogram); // plot the histogram
Wondering if this is even possible?
Regards!
This script includes a variable into the title above a chart:
var ic = ee.ImageCollection('LANDSAT/LT05/C01/T1_SR');
var size= ic.size().getInfo();
var some_title = 'How many LS5 scenes are there? Exactly ' + size+ ' scenes!';
var some_chart = ui.Chart.array.values(ee.Array([1,5,6,8,6]), 0).setOptions({title: some_title});
print(some_chart);
The ".getInfo()" method pulls the value from the server-side to the client-side (i.e. your browser). Then you can construct the string you want as a title with any Javascript commands (e.g. using the "+").
Another way would be to build the string server side and then pull it like this:
var string_size = ee.String(ic.size());
var some_title = ee.String('How many LS5 scenes are there? Exactly ').cat(string_size).cat(' scenes!').getInfo();