未验证 提交 0ce28973 编写于 作者: P Peter Pan 提交者: GitHub

fix: unnecessary render of histogram chart axis label (#824)

上级 75634f7a
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
"@babel/preset-env": "7.11.5", "@babel/preset-env": "7.11.5",
"@babel/preset-react": "7.10.4", "@babel/preset-react": "7.10.4",
"@baiducloud/sdk": "1.0.0-rc.22", "@baiducloud/sdk": "1.0.0-rc.22",
"@simbathesailor/use-what-changed": "0.1.25",
"@snowpack/app-scripts-react": "1.10.0", "@snowpack/app-scripts-react": "1.10.0",
"@snowpack/plugin-dotenv": "2.0.1", "@snowpack/plugin-dotenv": "2.0.1",
"@snowpack/plugin-optimize": "0.2.1", "@snowpack/plugin-optimize": "0.2.1",
......
...@@ -146,7 +146,77 @@ export const Wrapper = styled.div` ...@@ -146,7 +146,77 @@ export const Wrapper = styled.div`
export const useChartTheme = (gl?: boolean) => { export const useChartTheme = (gl?: boolean) => {
const theme = useTheme(); const theme = useTheme();
const tt = useMemo(() => themes[theme], [theme]); 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 { return {
title: { title: {
textStyle: { textStyle: {
...@@ -160,7 +230,7 @@ export const useChartTheme = (gl?: boolean) => { ...@@ -160,7 +230,7 @@ export const useChartTheme = (gl?: boolean) => {
color: tt.tooltipTextColor color: tt.tooltipTextColor
} }
}, },
xAxis3D: { xAxis: {
nameTextStyle: { nameTextStyle: {
color: tt.textLighterColor color: tt.textLighterColor
}, },
...@@ -178,25 +248,7 @@ export const useChartTheme = (gl?: boolean) => { ...@@ -178,25 +248,7 @@ export const useChartTheme = (gl?: boolean) => {
} }
} }
}, },
yAxis3D: { yAxis: {
nameTextStyle: {
color: tt.textLighterColor
},
axisLabel: {
color: tt.textLighterColor
},
axisLine: {
lineStyle: {
color: tt.borderColor
}
},
splitLine: {
lineStyle: {
color: tt.borderColor
}
}
},
zAxis3D: {
nameTextStyle: { nameTextStyle: {
color: tt.textLighterColor color: tt.textLighterColor
}, },
...@@ -215,55 +267,6 @@ export const useChartTheme = (gl?: boolean) => { ...@@ -215,55 +267,6 @@ export const useChartTheme = (gl?: boolean) => {
} }
} }
}; };
} }, [tt, gl]);
return { return result;
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
}
}
}
};
}; };
...@@ -2549,6 +2549,11 @@ ...@@ -2549,6 +2549,11 @@
estree-walker "^1.0.1" estree-walker "^1.0.1"
picomatch "^2.2.2" 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": "@sindresorhus/is@^0.14.0":
version "0.14.0" version "0.14.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册