@hestia-earth/ui-components 0.41.20 → 0.41.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5259,23 +5259,15 @@ const axisHoverPlugin = {
|
|
|
5259
5259
|
id: 'axisHover',
|
|
5260
5260
|
afterEvent(chart, args) {
|
|
5261
5261
|
const { event } = args;
|
|
5262
|
-
const { maxDistance = 15, onHoverLabel } = (chart.config.options.plugins.axisHover ||
|
|
5262
|
+
const { maxDistance = 15, onHoverLabel } = (chart.config.options.plugins.axisHover ||
|
|
5263
|
+
{});
|
|
5263
5264
|
const yScale = chart.scales.y;
|
|
5264
5265
|
const isOverYAxis = event.x >= yScale.left && event.x <= yScale.right;
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
const tickY = yScale.getPixelForTick(index);
|
|
5271
|
-
if (Math.abs(event.y - tickY) < maxDistance) {
|
|
5272
|
-
label = chart.data.labels[tick.value];
|
|
5273
|
-
// Provide page coordinates for the tooltip placement
|
|
5274
|
-
position = { x: event.native.pageX, y: event.native.pageY };
|
|
5275
|
-
}
|
|
5276
|
-
});
|
|
5277
|
-
}
|
|
5278
|
-
onHoverLabel({ label, ...position });
|
|
5266
|
+
const closestTick = isOverYAxis
|
|
5267
|
+
? yScale.getTicks().find((tick, index) => Math.abs(event.y - yScale.getPixelForTick(index)) < maxDistance)
|
|
5268
|
+
: null;
|
|
5269
|
+
const label = closestTick ? chart.data.labels[closestTick.value] : '';
|
|
5270
|
+
onHoverLabel({ label, event });
|
|
5279
5271
|
}
|
|
5280
5272
|
};
|
|
5281
5273
|
|