I am using ReactHighCharts where I have barChartConfiguration like this:
let data = {1: {value: 9000}, 2: {value: 12500}}
let categories = [];
Object.keys(data).forEach(obj => {
let id = obj;
let value = obj[id].value;
categories.push(value)
}
);
So now,
categories = [9000, 12500]
barChartConfig: {
chart: {
type: "column"
},
title: {
text: "Playback Summary"
},
xAxis: {
categories,
crosshair: true
},
yAxis: {
min: 0,
title: {
text: "Counts (numbers)"
}
},
tooltip: {
headerFormat:
'<span style="font-size:10px">{point.key}</span><table>',
pointFormat:
'<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} Count</b></td></tr>',
footerFormat: "</table>",
shared: true,
useHTML: true
},
plotOptions: {
series: {
cursor: 'pointer',
point: {
events: {
click: (e) => { this.props.history.push(`/showdata/${id}`) }
}
}
}
},
series
};
And passing this barChartConfiguration to
<ReactHighcharts config={barChartConfiguration} />
I have added onClick event to each bar, where I have to navigate to another screen. But the issue is that I am unable to pass the 'id' to the route. How can I send the id (the id is where I am mapping the data array)