feat: 支持渐变色全局变换

This commit is contained in:
MTrun
2022-03-11 10:22:54 +08:00
parent 0abcbbae53
commit 3560effe2c
7 changed files with 113 additions and 60 deletions
@@ -46,7 +46,7 @@ export const option = {
globalCoord: false // 缺省为 false
},
shadowColor: 'rgba(68, 181, 226, 0.3)',
shadowBlur: 5,
shadowBlur: 10,
shadowOffsetY: 20
},
data: [120, 200, 150, 80, 70, 110, 130]
@@ -47,10 +47,17 @@ watchEffect(()=> {
})
// 渐变色处理
watch(()=>chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: string) => {
const themeColor = (chartColorsSearch as any)[newColor] || chartColorsSearch[defaultTheme]
props.chartConfig.option.series[0].lineStyle.color.colorStops[0].color = themeColor[0]
props.chartConfig.option.series[0].lineStyle.color.colorStops[1].color = themeColor[1]
option.options = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
})
</script>
watch(()=>chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof typeof chartColorsSearch) => {
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
props.chartConfig.option.series.forEach((value: any) => {
value.lineStyle.shadowColor = themeColor[2]
value.lineStyle.color.colorStops.forEach((v: {color: string}, i:number) => {
v.color = themeColor[i]
})
})
option.options = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
},
{
immediate: true
})
</script>