diff --git a/src/components/d3/monitoring/D3HorizontalCursor.tsx b/src/components/d3/monitoring/D3HorizontalCursor.tsx index 2440e63..6ab096c 100644 --- a/src/components/d3/monitoring/D3HorizontalCursor.tsx +++ b/src/components/d3/monitoring/D3HorizontalCursor.tsx @@ -30,24 +30,6 @@ 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', @@ -104,8 +86,6 @@ 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) @@ -191,24 +171,6 @@ 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/styles/d3.less b/src/styles/d3.less index 6ec1bb0..3bc9dc6 100644 --- a/src/styles/d3.less +++ b/src/styles/d3.less @@ -9,6 +9,10 @@ width: 100%; height: 100%; + + left: 0; + right: 0; + margin: 0 auto; font-size: 13px; color: @color; @@ -110,3 +114,30 @@ height: 100%; } } + +@media (max-width: 1800px) { + .asb-d3-chart { + & .tooltip { + width: 190px; + font-size: 10px; + } + } +} + +@media (max-width: 1600px) { + .asb-d3-chart { + & .tooltip { + width: 160px; + font-size: 8px; + } + } +} + +@media (max-width: 1400px) { + .asb-d3-chart { + & .tooltip { + width: 140px; + font-size: 7px; + } + } +} \ No newline at end of file