* Set active elements in the tooltip * @param {array} activeElements Array of active datasetIndex/index pairs. * @param {object} eventPosition Synthetic event position used in positioning
(activeElements, eventPosition)
| 1179 | * @param {object} eventPosition Synthetic event position used in positioning |
| 1180 | */ |
| 1181 | setActiveElements(activeElements, eventPosition) { |
| 1182 | const lastActive = this._active; |
| 1183 | const active = activeElements.map(({datasetIndex, index}) => { |
| 1184 | const meta = this.chart.getDatasetMeta(datasetIndex); |
| 1185 | |
| 1186 | if (!meta) { |
| 1187 | throw new Error('Cannot find a dataset at index ' + datasetIndex); |
| 1188 | } |
| 1189 | |
| 1190 | return { |
| 1191 | datasetIndex, |
| 1192 | element: meta.data[index], |
| 1193 | index, |
| 1194 | }; |
| 1195 | }).filter(({element}) => element); |
| 1196 | // Before the "changed" test: setting the elements that are already active still makes them the code's. |
| 1197 | this._activeSetByCode = true; |
| 1198 | const changed = !_elementsEqual(lastActive, active); |
| 1199 | const positionChanged = this._positionChanged(active, eventPosition); |
| 1200 | |
| 1201 | if (changed || positionChanged) { |
| 1202 | this._active = active; |
| 1203 | this._eventPosition = eventPosition; |
| 1204 | this._ignoreReplayEvents = true; |
| 1205 | this.update(true); |
| 1206 | } |
| 1207 | } |
| 1208 | |
| 1209 | /** |
| 1210 | * Handle an event |
nothing calls this directly
no test coverage detected