diff --git a/frontend/packages/core/package.json b/frontend/packages/core/package.json index 2f8c2cb6513c5261e50043c7f601efcf59a279c2..d186d0d150727d6f864b86491c9eb373421823d1 100644 --- a/frontend/packages/core/package.json +++ b/frontend/packages/core/package.json @@ -74,6 +74,7 @@ "@babel/preset-env": "7.11.5", "@babel/preset-react": "7.10.4", "@baiducloud/sdk": "1.0.0-rc.22", + "@simbathesailor/use-what-changed": "0.1.25", "@snowpack/app-scripts-react": "1.10.0", "@snowpack/plugin-dotenv": "2.0.1", "@snowpack/plugin-optimize": "0.2.1", diff --git a/frontend/packages/core/src/hooks/useECharts.ts b/frontend/packages/core/src/hooks/useECharts.ts index a5278e203d2fdcb420ef343438eefee87cfa5a86..fde7b1b73a5975dc55a91303974197c816dd63a5 100644 --- a/frontend/packages/core/src/hooks/useECharts.ts +++ b/frontend/packages/core/src/hooks/useECharts.ts @@ -146,7 +146,77 @@ export const Wrapper = styled.div` export const useChartTheme = (gl?: boolean) => { const theme = useTheme(); const tt = useMemo(() => themes[theme], [theme]); - if (gl) { + const result = useMemo(() => { + if (gl) { + return { + title: { + textStyle: { + color: tt.textColor + } + }, + tooltip: { + backgroundColor: tt.tooltipBackgroundColor, + borderColor: tt.tooltipBackgroundColor, + textStyle: { + color: tt.tooltipTextColor + } + }, + xAxis3D: { + nameTextStyle: { + color: tt.textLighterColor + }, + axisLabel: { + color: tt.textLighterColor + }, + axisLine: { + lineStyle: { + color: tt.borderColor + } + }, + splitLine: { + lineStyle: { + color: tt.borderColor + } + } + }, + yAxis3D: { + nameTextStyle: { + color: tt.textLighterColor + }, + axisLabel: { + color: tt.textLighterColor + }, + axisLine: { + lineStyle: { + color: tt.borderColor + } + }, + splitLine: { + lineStyle: { + color: tt.borderColor + } + } + }, + zAxis3D: { + nameTextStyle: { + color: tt.textLighterColor + }, + axisLabel: { + color: tt.textLighterColor + }, + axisLine: { + lineStyle: { + color: tt.borderColor + } + }, + splitLine: { + lineStyle: { + color: tt.borderColor + } + } + } + }; + } return { title: { textStyle: { @@ -160,7 +230,7 @@ export const useChartTheme = (gl?: boolean) => { color: tt.tooltipTextColor } }, - xAxis3D: { + xAxis: { nameTextStyle: { color: tt.textLighterColor }, @@ -178,25 +248,7 @@ export const useChartTheme = (gl?: boolean) => { } } }, - yAxis3D: { - nameTextStyle: { - color: tt.textLighterColor - }, - axisLabel: { - color: tt.textLighterColor - }, - axisLine: { - lineStyle: { - color: tt.borderColor - } - }, - splitLine: { - lineStyle: { - color: tt.borderColor - } - } - }, - zAxis3D: { + yAxis: { nameTextStyle: { color: tt.textLighterColor }, @@ -215,55 +267,6 @@ export const useChartTheme = (gl?: boolean) => { } } }; - } - return { - title: { - textStyle: { - color: tt.textColor - } - }, - tooltip: { - backgroundColor: tt.tooltipBackgroundColor, - borderColor: tt.tooltipBackgroundColor, - textStyle: { - color: tt.tooltipTextColor - } - }, - xAxis: { - nameTextStyle: { - color: tt.textLighterColor - }, - axisLabel: { - color: tt.textLighterColor - }, - axisLine: { - lineStyle: { - color: tt.borderColor - } - }, - splitLine: { - lineStyle: { - color: tt.borderColor - } - } - }, - yAxis: { - nameTextStyle: { - color: tt.textLighterColor - }, - axisLabel: { - color: tt.textLighterColor - }, - axisLine: { - lineStyle: { - color: tt.borderColor - } - }, - splitLine: { - lineStyle: { - color: tt.borderColor - } - } - } - }; + }, [tt, gl]); + return result; }; diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 7c88b7f83001c8b2708363f9d28c256f289e469e..4343c34cf00edf731541626f303ba02194555436 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -2549,6 +2549,11 @@ estree-walker "^1.0.1" picomatch "^2.2.2" +"@simbathesailor/use-what-changed@0.1.25": + version "0.1.25" + resolved "https://registry.yarnpkg.com/@simbathesailor/use-what-changed/-/use-what-changed-0.1.25.tgz#adf9373fb8d71dd8ab41c7cd789d8dd1fd80a058" + integrity sha512-hBzjQYMaSd/IFiFW3XEs4V+Cjklv65XSvtS1nCCsX07J5PjQWXR52AL+fZfJgw52RvgyrVFVRcT611/UffBmhg== + "@sindresorhus/is@^0.14.0": version "0.14.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"