mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
fix: 解决不能预览渐变色的问题
This commit is contained in:
parent
3560effe2c
commit
0ee76c1579
@ -1,6 +1,7 @@
|
|||||||
import { echartOptionProfixHandle, publicConfig } from '@/packages/public'
|
import { echartOptionProfixHandle, publicConfig } from '@/packages/public'
|
||||||
import { LineCommonConfig } from './index'
|
import { LineCommonConfig } from './index'
|
||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
|
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
|
||||||
|
|
||||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||||
|
|
||||||
@ -36,16 +37,16 @@ export const option = {
|
|||||||
colorStops: [
|
colorStops: [
|
||||||
{
|
{
|
||||||
offset: 0,
|
offset: 0,
|
||||||
color: '#42a5f5' // 0% 处的颜色
|
color: chartColorsSearch[defaultTheme][0] // 0% 处的颜色
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
offset: 1,
|
offset: 1,
|
||||||
color: '#48D8BF' // 100% 处的颜色
|
color: chartColorsSearch[defaultTheme][1] // 100% 处的颜色
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
globalCoord: false // 缺省为 false
|
globalCoord: false // 缺省为 false
|
||||||
},
|
},
|
||||||
shadowColor: 'rgba(68, 181, 226, 0.3)',
|
shadowColor: chartColorsSearch[defaultTheme][2],
|
||||||
shadowBlur: 10,
|
shadowBlur: 10,
|
||||||
shadowOffsetY: 20
|
shadowOffsetY: 20
|
||||||
},
|
},
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, PropType, watch, reactive, watchEffect } from 'vue';
|
import { PropType, watch, reactive } from 'vue';
|
||||||
import VChart from 'vue-echarts'
|
import VChart from 'vue-echarts'
|
||||||
import { use, graphic } from 'echarts/core'
|
import { use } from 'echarts/core'
|
||||||
import { CanvasRenderer } from 'echarts/renderers'
|
import { CanvasRenderer } from 'echarts/renderers'
|
||||||
import { LineChart } from 'echarts/charts'
|
import { LineChart } from 'echarts/charts'
|
||||||
import config, { includes } from './config'
|
import config, { includes } from './config'
|
||||||
@ -42,12 +42,9 @@ const option = reactive({
|
|||||||
options: {}
|
options: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
watchEffect(()=> {
|
// 初始化与渐变色处理
|
||||||
option.options = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
watch(() => chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof typeof chartColorsSearch) => {
|
||||||
})
|
if (!document.location.hash.includes('preview')) {
|
||||||
|
|
||||||
// 渐变色处理
|
|
||||||
watch(()=>chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof typeof chartColorsSearch) => {
|
|
||||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||||
props.chartConfig.option.series.forEach((value: any) => {
|
props.chartConfig.option.series.forEach((value: any) => {
|
||||||
value.lineStyle.shadowColor = themeColor[2]
|
value.lineStyle.shadowColor = themeColor[2]
|
||||||
@ -55,6 +52,7 @@ watch(()=>chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof t
|
|||||||
v.color = themeColor[i]
|
v.color = themeColor[i]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
}
|
||||||
option.options = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
option.options = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@ import { echartOptionProfixHandle, publicConfig } from '@/packages/public'
|
|||||||
import { LineGradientSingleConfig } from './index'
|
import { LineGradientSingleConfig } from './index'
|
||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import { graphic } from 'echarts/core'
|
import { graphic } from 'echarts/core'
|
||||||
|
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
|
||||||
|
|
||||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||||
|
|
||||||
@ -40,11 +41,11 @@ const options = {
|
|||||||
color: new graphic.LinearGradient(0, 0, 0, 1, [
|
color: new graphic.LinearGradient(0, 0, 0, 1, [
|
||||||
{
|
{
|
||||||
offset: 0,
|
offset: 0,
|
||||||
color: 'rgba(25,163,223,.5)'
|
color: chartColorsSearch[defaultTheme][3]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
offset: 1,
|
offset: 1,
|
||||||
color: 'rgba(25,163,223, 0)'
|
color: 'rgba(0,0,0,0)'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, watchEffect, watch, PropType } from 'vue'
|
import { reactive, watch, PropType } from 'vue'
|
||||||
import VChart from 'vue-echarts'
|
import VChart from 'vue-echarts'
|
||||||
import { use, graphic } from 'echarts/core'
|
import { use, graphic } from 'echarts/core'
|
||||||
import { CanvasRenderer } from 'echarts/renderers'
|
import { CanvasRenderer } from 'echarts/renderers'
|
||||||
@ -42,12 +42,9 @@ const option = reactive({
|
|||||||
options: {}
|
options: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
watchEffect(()=> {
|
|
||||||
option.options = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
|
||||||
})
|
|
||||||
|
|
||||||
// 渐变色处理
|
// 渐变色处理
|
||||||
watch(()=>chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof typeof chartColorsSearch) => {
|
watch(()=>chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof typeof chartColorsSearch) => {
|
||||||
|
if (!document.location.hash.includes('preview')) {
|
||||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||||
props.chartConfig.option.series.forEach((value: any, index: number) => {
|
props.chartConfig.option.series.forEach((value: any, index: number) => {
|
||||||
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
|
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
|
||||||
@ -62,6 +59,7 @@ watch(()=>chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof t
|
|||||||
])
|
])
|
||||||
themeColor[index]
|
themeColor[index]
|
||||||
})
|
})
|
||||||
|
}
|
||||||
option.options = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
option.options = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@ import { echartOptionProfixHandle, publicConfig } from '@/packages/public'
|
|||||||
import { LineGradientsConfig } from './index'
|
import { LineGradientsConfig } from './index'
|
||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import { graphic } from 'echarts/core'
|
import { graphic } from 'echarts/core'
|
||||||
|
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
|
||||||
|
|
||||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||||
|
|
||||||
@ -40,11 +41,11 @@ const option = {
|
|||||||
color: new graphic.LinearGradient(0, 0, 0, 1, [
|
color: new graphic.LinearGradient(0, 0, 0, 1, [
|
||||||
{
|
{
|
||||||
offset: 0,
|
offset: 0,
|
||||||
color: 'rgba(25,163,223,.3)'
|
color: chartColorsSearch[defaultTheme][3]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
offset: 1,
|
offset: 1,
|
||||||
color: 'rgba(25,163,223, 0)'
|
color: 'rgba(0,0,0,0)'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
@ -64,11 +65,11 @@ const option = {
|
|||||||
color: new graphic.LinearGradient(0, 0, 0, 1, [
|
color: new graphic.LinearGradient(0, 0, 0, 1, [
|
||||||
{
|
{
|
||||||
offset: 0,
|
offset: 0,
|
||||||
color: 'rgba(0,202,149,0.3)'
|
color: chartColorsSearch[defaultTheme][4]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
offset: 1,
|
offset: 1,
|
||||||
color: 'rgba(0,202,149,0)'
|
color: 'rgba(0,0,0,0)'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, watchEffect, watch, PropType } from 'vue'
|
import { reactive, watch, PropType } from 'vue'
|
||||||
import VChart from 'vue-echarts'
|
import VChart from 'vue-echarts'
|
||||||
import { use, graphic } from 'echarts/core'
|
import { use, graphic } from 'echarts/core'
|
||||||
import { CanvasRenderer } from 'echarts/renderers'
|
import { CanvasRenderer } from 'echarts/renderers'
|
||||||
@ -41,12 +41,10 @@ const chartEditStore = useChartEditStore()
|
|||||||
const option = reactive({
|
const option = reactive({
|
||||||
options: {}
|
options: {}
|
||||||
})
|
})
|
||||||
watchEffect(()=> {
|
|
||||||
option.options = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
|
||||||
})
|
|
||||||
|
|
||||||
// 渐变色处理
|
// 渐变色处理
|
||||||
watch(()=>chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof typeof chartColorsSearch) => {
|
watch(()=>chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof typeof chartColorsSearch) => {
|
||||||
|
if (!document.location.hash.includes('preview')) {
|
||||||
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
|
||||||
props.chartConfig.option.series.forEach((value: any, index: number) => {
|
props.chartConfig.option.series.forEach((value: any, index: number) => {
|
||||||
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
|
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
|
||||||
@ -60,6 +58,7 @@ watch(()=>chartEditStore.getEditCanvasConfig.chartThemeColor, (newColor: keyof t
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
}
|
||||||
option.options = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
option.options = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user