You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.3 KiB

2 months ago
import merge from 'lodash/merge'
import pick from 'lodash/pick'
import { EchartsDataType } from '../index.d'
import { globalThemeJson } from '@/settings/chartThemes/index'
import type VChart from 'vue-echarts'
/**
* * color
* @param option
* @param themeSetting
* @param excludes
* @returns object
*/
export const mergeTheme = <T, U>(option: T, themeSetting: U, includes: string[]) => {
return (option = merge({}, pick(themeSetting, includes), option))
}
/**
* * ECharts option
* @param option
* @return option
*/
export const echartOptionProfixHandle = (option: any, includes: string[] = []) => {
option['backgroundColor'] = 'rgba(0,0,0,0)'
return mergeTheme(option, globalThemeJson, includes)
}
/**
* *
* @param option
* @return option
*/
export const setData = (option: any, data: EchartsDataType) => {
option.dataset = data
return option
}
/**
* * setOption
* @param instance
* @param data
*/
export const setOption = <T extends typeof VChart | undefined, D>(instance: T, data: D, notMerge = true) => {
if (!instance) return
const option = instance.getOption()
option.dataset = null
instance.setOption(data, {
notMerge: notMerge
})
}