diff --git a/packages/osd-charts/src/chart_types/xy_chart/renderer/dom/_crosshair.scss b/packages/osd-charts/src/chart_types/xy_chart/renderer/dom/_crosshair.scss index eb6c2040f910..71bd90d8ae8a 100644 --- a/packages/osd-charts/src/chart_types/xy_chart/renderer/dom/_crosshair.scss +++ b/packages/osd-charts/src/chart_types/xy_chart/renderer/dom/_crosshair.scss @@ -2,5 +2,7 @@ .echCrosshair__cursor, .echCrosshair__crossLine { position: absolute; + top: 0; + left: 0; pointer-events: none; } diff --git a/packages/osd-charts/src/chart_types/xy_chart/renderer/dom/crosshair.tsx b/packages/osd-charts/src/chart_types/xy_chart/renderer/dom/crosshair.tsx index 4a9db4dcaf3e..88632c82f334 100644 --- a/packages/osd-charts/src/chart_types/xy_chart/renderer/dom/crosshair.tsx +++ b/packages/osd-charts/src/chart_types/xy_chart/renderer/dom/crosshair.tsx @@ -57,6 +57,7 @@ class CrosshairComponent extends React.Component { renderCursor() { const { + zIndex, theme: { crosshair: { band, line }, }, @@ -72,15 +73,34 @@ class CrosshairComponent extends React.Component { const { x1, x2, y1, y2 } = cursorPosition; const { strokeWidth, stroke, dash } = line; const strokeDasharray = (dash ?? []).join(' '); - return ; + return ( + + + + ); } const { x, y, width, height } = cursorPosition; const { fill } = band; - return ; + return ( + + ; + + ); } renderCrossLine() { const { + zIndex, theme: { crosshair: { crossLine }, }, @@ -99,25 +119,18 @@ class CrosshairComponent extends React.Component { strokeDasharray: (dash ?? []).join(' '), }; - return ; + return ( + + + + ); } render() { - const { zIndex, cursorPosition } = this.props; return ( <> - - {this.renderCursor()} - - - - {this.renderCrossLine()} - + {this.renderCursor()} + {this.renderCrossLine()} ); } diff --git a/packages/osd-charts/src/components/__snapshots__/chart.test.tsx.snap b/packages/osd-charts/src/components/__snapshots__/chart.test.tsx.snap index 81330afa13d6..f1520a0d6a46 100644 --- a/packages/osd-charts/src/components/__snapshots__/chart.test.tsx.snap +++ b/packages/osd-charts/src/components/__snapshots__/chart.test.tsx.snap @@ -66,10 +66,7 @@ exports[`Chart should render the legend name test 1`] = `
- - - - + @@ -92,11 +89,7 @@ exports[`Chart should render the legend name test 1`] = ` - - - - - + diff --git a/packages/osd-charts/src/components/tooltip/tooltip.tsx b/packages/osd-charts/src/components/tooltip/tooltip.tsx index 79c10a304e64..9d2c6f884bcb 100644 --- a/packages/osd-charts/src/components/tooltip/tooltip.tsx +++ b/packages/osd-charts/src/components/tooltip/tooltip.tsx @@ -204,6 +204,9 @@ const TooltipComponent = ({ }; }, [settings, chartRef, rotation]); + if (!visible) { + return null; + } return (