MCPcopy Create free account
hub / github.com/chartjs/Chart.js / _getActiveElements

Method _getActiveElements

src/plugins/plugin.tooltip.js:1183–1208  ·  view source on GitHub ↗

* Helper for determining the active elements for event * @param {ChartEvent} e - The event to handle * @param {InteractionItem[]} lastActive - Previously active elements * @param {boolean} [replay] - This is a replayed event (from update) * @param {boolean} [inChartArea] - The event is insid

(e, lastActive, replay, inChartArea)

Source from the content-addressed store, hash-verified

1181 * @private
1182 */
1183 _getActiveElements(e, lastActive, replay, inChartArea) {
1184 const options = this.options;
1185
1186 if (e.type === 'mouseout') {
1187 return [];
1188 }
1189
1190 if (!inChartArea) {
1191 // Let user control the active elements outside chartArea. Eg. using Legend.
1192 // But make sure that active elements are still valid.
1193 return lastActive.filter(i => {
1194 // The controller is missing when the dataset metas have been destroyed, eg. after the canvas is detached.
1195 const controller = this.chart.data.datasets[i.datasetIndex] && this.chart.getDatasetMeta(i.datasetIndex).controller;
1196 return controller && controller.getParsed(i.index) !== undefined;
1197 });
1198 }
1199
1200 // Find Active Elements for tooltips
1201 const active = this.chart.getElementsAtEventForMode(e, options.mode, options, replay);
1202
1203 if (options.reverse) {
1204 active.reverse();
1205 }
1206
1207 return active;
1208 }
1209
1210 /**
1211 * Determine if the active elements + event combination changes the

Callers 1

handleEventMethod · 0.95

Calls 3

getDatasetMetaMethod · 0.80
getParsedMethod · 0.80

Tested by

no test coverage detected