Skip to content

Commit ff75a14

Browse files
committed
feat(platform): chart support locale
1 parent 3d3fa93 commit ff75a14

File tree

1 file changed

+6
-3
lines changed
  • packages/platform/src/app/components/chart

1 file changed

+6
-3
lines changed

packages/platform/src/app/components/chart/Chart.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import type { AppTheme } from '../../utils/types';
2+
import type { DLang } from '@react-devui/ui/utils/types';
23

34
import * as echarts from 'echarts';
45
import { cloneDeep, merge } from 'lodash';
56
import { useEffect, useRef, useState } from 'react';
67

7-
import { useAsync, useResize } from '@react-devui/hooks';
8+
import { useAsync, useResize, useStorage } from '@react-devui/hooks';
89
import { getClassName } from '@react-devui/utils';
910

11+
import { STORAGE_KEY } from '../../config/storage';
1012
import chartTheme from './theme.json';
1113

1214
export interface AppChartProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
@@ -34,6 +36,7 @@ export function AppChart(props: AppChartProps): JSX.Element | null {
3436
const async = useAsync();
3537

3638
const [theme, setTheme] = useState<AppTheme | null>(null);
39+
const languageStorage = useStorage<DLang>(...STORAGE_KEY.language);
3740

3841
useEffect(() => {
3942
for (const theme of ['light', 'dark'] as const) {
@@ -65,15 +68,15 @@ export function AppChart(props: AppChartProps): JSX.Element | null {
6568
}
6669
)
6770
),
68-
{ renderer: aRenderer }
71+
{ renderer: aRenderer, locale: languageStorage.value === 'zh-CN' ? 'ZH' : 'EN' }
6972
);
7073
onInit(instance);
7174
return () => {
7275
instance.dispose();
7376
};
7477
}
7578
// eslint-disable-next-line react-hooks/exhaustive-deps
76-
}, [aRenderer, theme]);
79+
}, [aRenderer, theme, languageStorage.value]);
7780

7881
useResize(elRef, () => {
7982
dataRef.current.clearTid?.();

0 commit comments

Comments
 (0)