mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Minor improvement to code that gets active elements
This commit is contained in:
parent
2efb974189
commit
0a17edd1ae
@ -420,30 +420,23 @@
|
||||
this.active = [];
|
||||
this.tooltipActive = [];
|
||||
} else {
|
||||
this.active = function() {
|
||||
switch (this.options.hover.mode) {
|
||||
|
||||
var _this = this;
|
||||
function getItemsForMode(mode) {
|
||||
switch (mode) {
|
||||
case 'single':
|
||||
return this.getElementAtEvent(e);
|
||||
return _this.getElementAtEvent(e);
|
||||
case 'label':
|
||||
return this.getElementsAtEvent(e);
|
||||
return _this.getElementsAtEvent(e);
|
||||
case 'dataset':
|
||||
return this.getDatasetAtEvent(e);
|
||||
return _this.getDatasetAtEvent(e);
|
||||
default:
|
||||
return e;
|
||||
}
|
||||
}.call(this);
|
||||
this.tooltipActive = function() {
|
||||
switch (this.options.tooltips.mode) {
|
||||
case 'single':
|
||||
return this.getElementAtEvent(e);
|
||||
case 'label':
|
||||
return this.getElementsAtEvent(e);
|
||||
case 'dataset':
|
||||
return this.getDatasetAtEvent(e);
|
||||
default:
|
||||
return e;
|
||||
}
|
||||
}.call(this);
|
||||
}
|
||||
|
||||
this.active = getItemsForMode(this.options.hover.mode);
|
||||
this.tooltipActive = getItemsForMode(this.options.tooltips.mode);
|
||||
}
|
||||
|
||||
// On Hover hook
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user