I am using Ag-Grid React, which I'm new to. I have a drop-down that allows you to switch to different data sets that are being called from AWS into a line chart via the refreshCells function. The chart refreshes fine when you select something from the drop-down but I would also like to change the subtitle of the line chart to match the data being pulled (the selected drop-down value). Is this possible to do with the refreshCells function after the page has initially loaded?
while defining your gridOptions
object define processChartOptions
as shown below.
this method gets called whenever chart is redrawn due to change in underlying data. you can use the params object to dynamically set the title/subtitle values.
function processChartOptions(params) {
var options = params.options;
console.log('chart options:', options);
options.title.enabled = true;
options.title.text = 'your title here';
options.title.fontStyle = 'italic';
options.title.fontWeight = '600';
options.title.fontSize = 18;
options.title.fontFamily = 'Impact, sans-serif';
options.title.color = '#414182';
options.subtitle.enabled = true;
options.subtitle.text = 'your subtitle here';
options.subtitle.fontSize = 14;
options.subtitle.fontFamily = 'Monaco, monospace';
options.subtitle.color = 'rgb(100, 100, 100)';
return options;
}
here is a demo.