* 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)
| 1104 | * @param {object} eventPosition Synthetic event position used in positioning |
| 1105 | */ |
| 1106 | setActiveElements(activeElements, eventPosition) { |
| 1107 | const lastActive = this._active; |
| 1108 | const active = activeElements.map(({datasetIndex, index}) => { |
| 1109 | const meta = this.chart.getDatasetMeta(datasetIndex); |
| 1110 | |
| 1111 | if (!meta) { |
| 1112 | throw new Error('Cannot find a dataset at index ' + datasetIndex); |
| 1113 | } |
| 1114 | |
| 1115 | return { |
| 1116 | datasetIndex, |
| 1117 | element: meta.data[index], |
| 1118 | index, |
| 1119 | }; |
| 1120 | }); |
| 1121 | const changed = !_elementsEqual(lastActive, active); |
| 1122 | const positionChanged = this._positionChanged(active, eventPosition); |
| 1123 | |
| 1124 | if (changed || positionChanged) { |
| 1125 | this._active = active; |
| 1126 | this._eventPosition = eventPosition; |
| 1127 | this._ignoreReplayEvents = true; |
| 1128 | this.update(true); |
| 1129 | } |
| 1130 | } |
| 1131 | |
| 1132 | /** |
| 1133 | * Handle an event |
nothing calls this directly
no test coverage detected