diff --git a/src/chart_types/xy_chart/renderer/dom/_crosshair.scss b/src/chart_types/xy_chart/renderer/dom/_crosshair.scss index eb6c2040f9..71bd90d8ae 100644 --- a/src/chart_types/xy_chart/renderer/dom/_crosshair.scss +++ b/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/src/chart_types/xy_chart/renderer/dom/crosshair.tsx b/src/chart_types/xy_chart/renderer/dom/crosshair.tsx index 4a9db4dcaf..88632c82f3 100644 --- a/src/chart_types/xy_chart/renderer/dom/crosshair.tsx +++ b/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/src/components/__snapshots__/chart.test.tsx.snap b/src/components/__snapshots__/chart.test.tsx.snap index 81330afa13..f1520a0d6a 100644 --- a/src/components/__snapshots__/chart.test.tsx.snap +++ b/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/src/components/tooltip/tooltip.tsx b/src/components/tooltip/tooltip.tsx index 79c10a304e..9d2c6f884b 100644 --- a/src/components/tooltip/tooltip.tsx +++ b/src/components/tooltip/tooltip.tsx @@ -204,6 +204,9 @@ const TooltipComponent = ({ }; }, [settings, chartRef, rotation]); + if (!visible) { + return null; + } return (