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

Method setActiveElements

src/core/core.controller.js:1100–1122  ·  view source on GitHub ↗

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

(activeElements)

Source from the content-addressed store, hash-verified

1098 * @param {array} activeElements New active data points
1099 */
1100 setActiveElements(activeElements) {
1101 const lastActive = this._active || [];
1102 const active = activeElements.map(({datasetIndex, index}) => {
1103 const meta = this.getDatasetMeta(datasetIndex);
1104 if (!meta) {
1105 throw new Error('No dataset found at index ' + datasetIndex);
1106 }
1107
1108 return {
1109 datasetIndex,
1110 element: meta.data[index],
1111 index,
1112 };
1113 }).filter(({element}) => element);
1114 const changed = !_elementsEqual(active, lastActive);
1115
1116 if (changed) {
1117 this._active = active;
1118 // Make sure we don't use the previous mouse event to override the active elements in update.
1119 this._lastEvent = null;
1120 this._updateHoverStyles(active, lastActive);
1121 }
1122 }
1123
1124 /**
1125 * Calls enabled plugins on the specified hook and with the given args.

Callers

nothing calls this directly

Calls 3

getDatasetMetaMethod · 0.95
_updateHoverStylesMethod · 0.95
_elementsEqualFunction · 0.85

Tested by

no test coverage detected