angular-chart.js icon indicating copy to clipboard operation
angular-chart.js copied to clipboard

Figuring out which series have been clicked in the onclick event

Open americanslon opened this issue 7 years ago • 2 comments

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!

americanslon avatar Mar 01 '17 16:03 americanslon

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.

SwagMuffinMcYoloPants avatar Mar 07 '17 21:03 SwagMuffinMcYoloPants

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 } }

gregory-h avatar Apr 12 '17 19:04 gregory-h