From fae73913deaa9a49879b35570c21f5b03f1632df Mon Sep 17 00:00:00 2001 From: jialin Date: Wed, 30 Apr 2025 16:39:28 +0800 Subject: [PATCH] style: gauge dark style --- src/components/echarts/config.ts | 5 ++++- src/components/echarts/gauge.tsx | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/echarts/config.ts b/src/components/echarts/config.ts index 42ccb443..9d5aac25 100644 --- a/src/components/echarts/config.ts +++ b/src/components/echarts/config.ts @@ -31,13 +31,16 @@ export default function useChartConfig() { const { useToken } = theme; const { token } = useToken(); + console.log('token:', token); + const chartColorMap = useMemo(() => { return { titleColor: token.colorText, splitLineColor: token.colorBorder, tickLineColor: token.colorSplit, axislabelColor: token.colorTextTertiary, - gaugeSplitLineColor: isDarkTheme ? '#b8b8b8' : 'rgba(255, 255, 255, 1)', + gaugeBgColor: token.colorFillSecondary, + gaugeSplitLineColor: isDarkTheme ? '#ccc' : 'rgba(255, 255, 255, 1)', colorBgContainerHover: isDarkTheme ? '#424242' : '#fff' }; }, [userSettings.theme, isDarkTheme]); diff --git a/src/components/echarts/gauge.tsx b/src/components/echarts/gauge.tsx index faf9f69c..ae84c10b 100644 --- a/src/components/echarts/gauge.tsx +++ b/src/components/echarts/gauge.tsx @@ -7,7 +7,11 @@ import { ChartProps } from './types'; const GaugeChart: React.FC> = ( props ) => { - const { gaugeItemConfig, title: titleConfig } = useChartConfig(); + const { + gaugeItemConfig, + title: titleConfig, + chartColorMap + } = useChartConfig(); const { value, height, width, labelFormatter, title, color } = props; if (!value && value !== 0) { return ; @@ -30,7 +34,7 @@ const GaugeChart: React.FC> = ( ...gaugeItemConfig.axisLine.lineStyle, color: [ [value / 100, color], - [1, 'rgba(221, 221, 221, 0.5)'] + [1, chartColorMap.gaugeBgColor] ] } },