update pay function
This commit is contained in:
@@ -14,15 +14,27 @@ export const EChartsRenderer = ({ option, height = 400 }) => {
|
||||
const chartRef = useRef(null);
|
||||
const chartInstance = useRef(null);
|
||||
const bgColor = useColorModeValue('white', 'gray.800');
|
||||
const isDarkMode = useColorModeValue(false, true);
|
||||
|
||||
useEffect(() => {
|
||||
if (!chartRef.current || !option) return;
|
||||
|
||||
// 初始化图表
|
||||
// 初始化图表(支持深色模式)
|
||||
if (!chartInstance.current) {
|
||||
chartInstance.current = echarts.init(chartRef.current);
|
||||
chartInstance.current = echarts.init(chartRef.current, isDarkMode ? 'dark' : null);
|
||||
}
|
||||
|
||||
// 深色模式下的默认文字颜色
|
||||
const darkModeTextStyle = isDarkMode
|
||||
? {
|
||||
textStyle: { color: '#e5e7eb' },
|
||||
title: { textStyle: { color: '#f3f4f6' }, ...option?.title },
|
||||
legend: { textStyle: { color: '#d1d5db' }, ...option?.legend },
|
||||
xAxis: { axisLabel: { color: '#9ca3af' }, axisLine: { lineStyle: { color: '#4b5563' } }, ...option?.xAxis },
|
||||
yAxis: { axisLabel: { color: '#9ca3af' }, axisLine: { lineStyle: { color: '#4b5563' } }, splitLine: { lineStyle: { color: '#374151' } }, ...option?.yAxis },
|
||||
}
|
||||
: {};
|
||||
|
||||
// 设置默认主题配置
|
||||
const defaultOption = {
|
||||
backgroundColor: 'transparent',
|
||||
@@ -33,6 +45,7 @@ export const EChartsRenderer = ({ option, height = 400 }) => {
|
||||
containLabel: true,
|
||||
},
|
||||
...option,
|
||||
...darkModeTextStyle,
|
||||
};
|
||||
|
||||
// 设置图表配置
|
||||
@@ -49,7 +62,7 @@ export const EChartsRenderer = ({ option, height = 400 }) => {
|
||||
window.removeEventListener('resize', handleResize);
|
||||
// chartInstance.current?.dispose(); // 不要销毁,避免重新渲染时闪烁
|
||||
};
|
||||
}, [option]);
|
||||
}, [option, isDarkMode]);
|
||||
|
||||
// 组件卸载时销毁图表
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user