fix: 修改全局设置不触发的问题
This commit is contained in:
parent
b980c79ab4
commit
d74fb21c9e
@ -9,7 +9,7 @@ import { use } from 'echarts/core'
|
|||||||
import { CanvasRenderer } from 'echarts/renderers'
|
import { CanvasRenderer } from 'echarts/renderers'
|
||||||
import { BarChart } from 'echarts/charts'
|
import { BarChart } from 'echarts/charts'
|
||||||
import config from './config'
|
import config from './config'
|
||||||
import merge from 'lodash/merge'
|
import { mergeTheme } from '@/packages/public/chart'
|
||||||
import {
|
import {
|
||||||
GridComponent,
|
GridComponent,
|
||||||
TooltipComponent,
|
TooltipComponent,
|
||||||
@ -41,7 +41,9 @@ use([
|
|||||||
TitleComponent
|
TitleComponent
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const includes = ['title', 'legend', 'xAxis', 'yAxis']
|
||||||
|
|
||||||
const option = computed(() => {
|
const option = computed(() => {
|
||||||
return merge(props.chartData.option, props.themeSetting)
|
return mergeTheme( props.chartData.option, props.themeSetting, includes)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -10,7 +10,6 @@ export default class Config extends publicConfig implements CreateComponentType
|
|||||||
|
|
||||||
// 图表配置项
|
// 图表配置项
|
||||||
public option = echartOptionProfixHandle({
|
public option = echartOptionProfixHandle({
|
||||||
backgroundColor: 'rgba(0,0,0,0)',
|
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: 'axis',
|
trigger: 'axis',
|
||||||
axisPointer: {
|
axisPointer: {
|
||||||
|
@ -42,7 +42,7 @@ use([
|
|||||||
])
|
])
|
||||||
|
|
||||||
const option = computed(() => {
|
const option = computed(() => {
|
||||||
return merge(props.chartData.option, props.themeSetting)
|
return merge(props.themeSetting, props.chartData.option)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import { use, graphic } 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 from './config'
|
import config from './config'
|
||||||
import merge from 'lodash/merge'
|
import { mergeTheme } from '@/packages/public/chart'
|
||||||
import {
|
import {
|
||||||
GridComponent,
|
GridComponent,
|
||||||
TooltipComponent,
|
TooltipComponent,
|
||||||
@ -41,7 +41,9 @@ use([
|
|||||||
TitleComponent
|
TitleComponent
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const includes = ['title', 'legend', 'xAxis', 'yAxis']
|
||||||
|
|
||||||
const option = computed(() => {
|
const option = computed(() => {
|
||||||
return merge(props.chartData.option, props.themeSetting)
|
return mergeTheme( props.chartData.option, props.themeSetting, includes)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -15,7 +15,7 @@ export default class Config extends publicConfig implements CreateComponentType
|
|||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
top: '5%',
|
top: '5%',
|
||||||
left: 'center'
|
left: 'center',
|
||||||
},
|
},
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ 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'
|
||||||
import { PieChart } from 'echarts/charts'
|
import { PieChart } from 'echarts/charts'
|
||||||
import merge from 'lodash/merge'
|
import { mergeTheme } from '@/packages/public/chart'
|
||||||
import config from './config'
|
import config from './config'
|
||||||
import {
|
import {
|
||||||
GridComponent,
|
GridComponent,
|
||||||
@ -41,7 +41,9 @@ use([
|
|||||||
TitleComponent
|
TitleComponent
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const includes = ['title', 'legend']
|
||||||
|
|
||||||
const option = computed(() => {
|
const option = computed(() => {
|
||||||
return merge(props.chartData.option, props.themeSetting)
|
return mergeTheme( props.chartData.option, props.themeSetting, includes)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import merge from 'lodash/merge'
|
||||||
|
import pick from 'lodash/pick'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * ECharts option 统一前置处理
|
* * ECharts option 统一前置处理
|
||||||
* @param option
|
* @param option
|
||||||
@ -6,3 +9,18 @@ export const echartOptionProfixHandle = (option: any) => {
|
|||||||
option['backgroundColor'] = 'rgba(0,0,0,0)'
|
option['backgroundColor'] = 'rgba(0,0,0,0)'
|
||||||
return option
|
return option
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 合并 color 和全局配置项
|
||||||
|
* @param option 配置
|
||||||
|
* @param themeSetting 设置
|
||||||
|
* @param excludes 排除元素
|
||||||
|
* @returns object
|
||||||
|
*/
|
||||||
|
export const mergeTheme = <T, U, E extends keyof U> (
|
||||||
|
option: T,
|
||||||
|
themeSetting: U,
|
||||||
|
includes: E[] = []
|
||||||
|
) => {
|
||||||
|
return merge(pick(themeSetting, includes), option)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user