I want to create an event handler for Chart component from react-google-charts
Off. documentation has an example.
<Chart
chartType="ScatterChart"
rows={this.state.rows}
columns={this.state.columns}
options={this.state.options}
graph_id="ScatterChart"
width="100%"
height="400px"
chartEvents={this.chartEvents} // <- this is event handler
/>
chartEvents looks like
this.chartEvents=[
{
eventName : 'select',
callback : function(Chart) {
console.log("Selected ",Chart.chart.getSelection());
}
}
];
How can I refer to class context from the callback function? I want to change my local state.
this.chartEvents=[
{
eventName : 'select',
callback : function(Chart) {
// here I want to refer to this.setState
console.log("Selected ",Chart.chart.getSelection());
}
}
];