diff --git a/src/components/d3/monitoring/D3HorizontalCursor.tsx b/src/components/d3/monitoring/D3HorizontalCursor.tsx index af75ff0..2440e63 100644 --- a/src/components/d3/monitoring/D3HorizontalCursor.tsx +++ b/src/components/d3/monitoring/D3HorizontalCursor.tsx @@ -30,6 +30,25 @@ export type D3HorizontalCursorProps = D3HorizontalCursorSettings } +enum FontSize { + inherit = 'inherit', + large = '10px', + medium = '8px', + small = '7px', +} + +enum TooltipWidth { + large = 190, + medium = 160, + small = 140, +} + +enum InnerWidth { + large = 1800, + medium = 1600, + small = 1400, +} + const defaultLineStyle: SVGProps = { stroke: 'black', } @@ -85,6 +104,8 @@ const _D3HorizontalCursor = ({ const [tooltipY, setTooltipY] = useState(0) const [fixed, setFixed] = useState(false) const [lineY, setLineY] = useState(0) + const [tooltipWidth, setTooltipWidth] = useState(width) + const [fontSize, setFontSize] = useState(FontSize.inherit) const lineStyle = usePartialProps(_lineStyle, defaultLineStyle) @@ -170,6 +191,24 @@ const _D3HorizontalCursor = ({ setTooltipBodies(bodies) }, [groups, data, yAxis, lineY, fixed, mouseState.visible]) + useEffect(() => { + const innerWidth = window.innerWidth + + if (innerWidth < InnerWidth.small) { + setTooltipWidth(TooltipWidth.small) + setFontSize(FontSize.small) + } else if (innerWidth < InnerWidth.medium) { + setTooltipWidth(TooltipWidth.medium) + setFontSize(FontSize.medium) + } else if (innerWidth < InnerWidth.large) { + setTooltipWidth(TooltipWidth.large) + setFontSize(FontSize.large) + } else { + setTooltipWidth(width) + setFontSize(FontSize.inherit) + } + }, [window.innerWidth]) + return ( ({ {groups.map((_, i) => ( ({
-
+
{tooltipBodies[i]}
diff --git a/src/pages/Telemetry/TelemetryView/index.jsx b/src/pages/Telemetry/TelemetryView/index.jsx index 884b23c..bb9b144 100755 --- a/src/pages/Telemetry/TelemetryView/index.jsx +++ b/src/pages/Telemetry/TelemetryView/index.jsx @@ -295,7 +295,7 @@ const TelemetryView = memo(() => { plugins={{ menu: { enabled: false }, cursor: { - width: 220, + width: 230, render: cursorRender, }, }}