* Handle an event * @param {ChartEvent} e - The event to handle * @param {boolean} [replay] - This is a replayed event (from update) * @param {boolean} [inChartArea] - The event is inside chartArea * @returns {boolean} true if the tooltip changed
(e, replay, inChartArea = true)
| 1137 | * @returns {boolean} true if the tooltip changed |
| 1138 | */ |
| 1139 | handleEvent(e, replay, inChartArea = true) { |
| 1140 | if (replay && this._ignoreReplayEvents) { |
| 1141 | return false; |
| 1142 | } |
| 1143 | this._ignoreReplayEvents = false; |
| 1144 | |
| 1145 | const options = this.options; |
| 1146 | const lastActive = this._active || []; |
| 1147 | const active = this._getActiveElements(e, lastActive, replay, inChartArea); |
| 1148 | |
| 1149 | // When there are multiple items shown, but the tooltip position is nearest mode |
| 1150 | // an update may need to be made because our position may have changed even though |
| 1151 | // the items are the same as before. |
| 1152 | const positionChanged = this._positionChanged(active, e); |
| 1153 | |
| 1154 | // Remember Last Actives |
| 1155 | const changed = replay || !_elementsEqual(active, lastActive) || positionChanged; |
| 1156 | |
| 1157 | // Only handle target event on tooltip change |
| 1158 | if (changed) { |
| 1159 | this._active = active; |
| 1160 | |
| 1161 | if (options.enabled || options.external) { |
| 1162 | this._eventPosition = { |
| 1163 | x: e.x, |
| 1164 | y: e.y |
| 1165 | }; |
| 1166 | |
| 1167 | this.update(true, replay); |
| 1168 | } |
| 1169 | } |
| 1170 | |
| 1171 | return changed; |
| 1172 | } |
| 1173 | |
| 1174 | /** |
| 1175 | * Helper for determining the active elements for event |
no test coverage detected