Skip to content

Commit 9849958

Browse files
committed
fix:(Chart) fix default colors
1 parent be5cc71 commit 9849958

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

frontend/src/app/components/ChartGraph/PivotSheetChart/PivotSheetChart.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
toFormattedValue,
3333
transformToDataSet,
3434
} from 'app/utils/chartHelper';
35+
import { PIVOT_THEME_LIST } from '../../FormGenerator/Customize/PivotSheetTheme/theme';
3536
import AntVS2Wrapper from './AntVS2Wrapper';
3637
import Config from './config';
3738
import { AndvS2Config } from './types';
@@ -277,7 +278,7 @@ class PivotSheetChart extends ReactChart {
277278

278279
private getThemeColorList(style: ChartStyleConfig[]): Array<string> {
279280
const [basicColors] = getStyles(style, ['theme'], ['themeType']);
280-
return basicColors?.colors || [];
281+
return basicColors?.colors || PIVOT_THEME_LIST[basicColors?.themeType || 0];
281282
}
282283

283284
private getRowAndColStyle(

frontend/src/app/components/FormGenerator/Customize/PivotSheetTheme/PivotSheetTheme.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { updateByKey } from 'app/utils/mutation';
2121
import { FC, memo, useCallback, useEffect, useMemo } from 'react';
2222
import styled from 'styled-components/macro';
2323
import { SPACE } from '../../../../../styles/StyleConstants';
24-
import { isNumber } from '../../../../utils/number';
2524
import { ItemLayout } from '../../Layout';
2625
import { ItemLayoutProps } from '../../types';
2726
import { itemLayoutComparer } from '../../utils';
@@ -127,13 +126,13 @@ const PivotSheetTheme: FC<ItemLayoutProps<ChartStyleConfig>> = memo(
127126
);
128127

129128
useEffect(() => {
130-
if (!data.value?.colors?.length && isNumber(data.value?.themeType)) {
129+
if (!data.value?.colors?.length) {
131130
handleSettingChange({
132-
themeType: data.value.themeType,
133-
colors: PIVOT_THEME_LIST[data.value.themeType],
131+
themeType: data.value?.themeType || 0,
132+
colors: PIVOT_THEME_LIST[data.value?.themeType || 0],
134133
});
135134
}
136-
}, [data, handleSettingChange]);
135+
}, [data.value?.themeType, data.value, handleSettingChange]);
137136

138137
const handlePickerSelect = useCallback(
139138
index => (_, colorConfig) => {

0 commit comments

Comments
 (0)