You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Contrary to the docs, getElementAtEvent() returns an array containing a single ChartElement. Observed while implementing custom click behavior on a pie chart.
The text was updated successfully, but these errors were encountered:
// Get the single element that was clicked on
// @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw
getElementAtEvent: function(e) {
var me = this;
var eventPosition = helpers.getRelativePosition(e, me.chart);
var elementsArray = [];
helpers.each(me.data.datasets, function(dataset, datasetIndex) {
if (me.isDatasetVisible(datasetIndex)) {
var meta = me.getDatasetMeta(datasetIndex);
helpers.each(meta.data, function(element) {
if (element.inRange(eventPosition.x, eventPosition.y)) {
elementsArray.push(element);
return elementsArray;
}
});
}
});
return elementsArray.slice(0, 1);
},
return elementsArray.slice(0, 1) could be replaced with something like return elementsArray[0], but at this point that would probably cause backwards compatibility problems. It might be better just to change the documentation.
Contrary to the docs, getElementAtEvent() returns an array containing a single ChartElement. Observed while implementing custom click behavior on a pie chart.
The text was updated successfully, but these errors were encountered: