Timeseries: Change mouse cursors to indicate active x-axis and y-axis zoom interactions (#113465)

* feat(panel-zoom): change mouse cursor when zooming x-axis or y-axis

* test(panel-zoom): browser test mouse cursor change interactions

* fix(mouse-cursor-styles): no need for important
This commit is contained in:
Jesse David Peterson
2025-11-10 11:26:00 -04:00
committed by GitHub
parent f094a9d5e5
commit 243f1fc64b
3 changed files with 121 additions and 0 deletions
@@ -340,6 +340,30 @@ export const TooltipPlugin2 = ({
);
}
// add zoom-in cursor during drag-to-zoom interaction
if (queryZoom != null || clientZoom) {
u.over.addEventListener(
'mousedown',
(e) => {
if (!maybeZoomAction(e)) {
return;
}
if (e.button === 0) {
u.over.classList.add('zoom-drag');
let onUp = () => {
u.over.classList.remove('zoom-drag');
document.removeEventListener('mouseup', onUp, true);
};
document.addEventListener('mouseup', onUp, true);
}
},
true
);
}
// this handles pinning, 0-width range selection, and one-click
u.over.addEventListener('click', (e) => {
if (e.target === u.over) {
@@ -12,6 +12,10 @@ export function getUplotStyles(theme: GrafanaTheme2) {
background: 'rgba(120, 120, 130, 0.2)',
},
'.u-over.zoom-drag': {
cursor: 'zoom-in',
},
'.u-hz .u-cursor-x, .u-vt .u-cursor-y': {
borderRight: '1px dashed rgba(120, 120, 130, 0.5)',
},