angular-chart.js
angular-chart.js copied to clipboard
Figuring out which series have been clicked in the onclick event
In the on click event the info that comes in has information about all the serieses for that particulat dot. How can I tell which exact series have been clicked? Thanks!
There should be three arguments for the onClick handler. The third argument is the ChartElement. You can get the data series index point by accessing the _datasetIndex.
For a line graph the click handler receives two arguments; the first is an array of data points but the second is just isTrusted:true - no _datasetIndex in sight
Any other way to sort out the index of the data that was clicked?
$scope.onClick = function() { console.log('clicked ' + JSON.stringify(arguments,0,1) ) }
=>
clicked { "0": [ { "value": "123", "label": "2017-02-13", "datasetLabel": "Google Analytics", "strokeColor": "rgba(64,153,255,0.8)", "fillColor": "#fff", "highlightFill": "#fff", "highlightStroke": "rgba(64,153,255,0.8)", "_saved": { "value": "123", "label": "2017-02-13", "datasetLabel": "Google Analytics", "strokeColor": "#fff", "fillColor": "rgba(64,153,255,1)", "highlightFill": "#fff", "highlightStroke": "rgba(64,153,255,0.8)", "x": 433, "y": 177.77212519488552 }, "x": 433, "y": 136.9921823969437, "controlPoints": { "inner": { "x": 418.84868642508735, "y": 148.5465823589157 }, "outer": { "x": 445.64868642508736, "y": 126.66466183319082 } } } ], "1": { "isTrusted": true } }