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

Method setActiveElements

src/core/core.controller.js:1179–1203  ·  view source on GitHub ↗

* Set active (hovered) elements * @param {array} activeElements New active data points

(activeElements)

Source from the content-addressed store, hash-verified

1177 * @param {array} activeElements New active data points
1178 */
1179 setActiveElements(activeElements) {
1180 const lastActive = this._active || [];
1181 const active = this._filterActive(activeElements.map(({datasetIndex, index}) => {
1182 const meta = this.getDatasetMeta(datasetIndex);
1183 if (!meta) {
1184 throw new Error('No dataset found at index ' + datasetIndex);
1185 }
1186
1187 return {
1188 datasetIndex,
1189 element: meta.data[index],
1190 index,
1191 };
1192 }).filter(({element}) => element));
1193 // Before the "changed" test: setting the elements that are already active still makes them the code's.
1194 this._activeSetByCode = true;
1195 const changed = !_elementsEqual(active, lastActive);
1196
1197 if (changed) {
1198 this._active = active;
1199 // Make sure we don't use the previous mouse event to override the active elements in update.
1200 this._lastEvent = null;
1201 this._updateHoverStyles(active, lastActive);
1202 }
1203 }
1204
1205 /**
1206 * Calls enabled plugins on the specified hook and with the given args.

Callers

nothing calls this directly

Calls 4

_filterActiveMethod · 0.95
getDatasetMetaMethod · 0.95
_updateHoverStylesMethod · 0.95
_elementsEqualFunction · 0.85

Tested by

no test coverage detected