MCPcopy
hub / github.com/chartjs/Chart.js / _getActiveElements

Method _getActiveElements

src/plugins/plugin.tooltip.js:1183–1207  ·  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 this.chart.data.datasets[i.datasetIndex] &&
1195 this.chart.getDatasetMeta(i.datasetIndex).controller.getParsed(i.index) !== undefined
1196 );
1197 }
1198
1199 // Find Active Elements for tooltips
1200 const active = this.chart.getElementsAtEventForMode(e, options.mode, options, replay);
1201
1202 if (options.reverse) {
1203 active.reverse();
1204 }
1205
1206 return active;
1207 }
1208
1209 /**
1210 * Determine if the active elements + event combination changes the

Callers 1

handleEventMethod · 0.95

Calls 3

getParsedMethod · 0.80
getDatasetMetaMethod · 0.80

Tested by

no test coverage detected