Chartjs-ChartJS: Get value from another another Chart

0👍

I found this thread describing getting data from click events: Click events on Pie Charts in Chart.js

I made also made a new fiddle here where it logs a chart object containing the chart data on chart click: https://jsfiddle.net/btnL9d2a/16/

 myChart1Canvas.onclick = function(evt) {
   var activePoints = myChart.getElementsAtEvent(evt);
   if (activePoints[0]) {
   var chartData = activePoints[0]['_chart'].config.data;
   // `chartData` will be an object in the format {'Labels' : Array, 'datasets' : Array}.
   console.log(chartData);
 }
}; 

chartData.datasets[0].data is an array of the clicked-on chart’s data.

Leave a comment