},
getDatasetAtEvent: function(e) {
- var eventPosition = helpers.getRelativePosition(e, this.chart);
- var elementsArray = [];
+ var elementsArray = this.getElementAtEvent(e);
- helpers.each(this.data.datasets, function(dataset, datasetIndex) {
- if (helpers.isDatasetVisible(dataset)) {
- helpers.each(dataset.metaData, function(element, elementIndex) {
- if (element.inLabelRange(eventPosition.x, eventPosition.y)) {
- helpers.each(dataset.metaData, function(element, index) {
- elementsArray.push(element);
- }, this);
- }
- }, this);
- }
- }, this);
+ if (elementsArray.length > 0) {
+ elementsArray = this.data.datasets[elementsArray[0]._datasetIndex].metaData;
+ }
- return elementsArray.length ? elementsArray : [];
+ return elementsArray;
},
generateLegend: function generateLegend() {