mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-19 20:16:24 +08:00
40 lines
910 B
TypeScript
40 lines
910 B
TypeScript
import merge from 'lodash/merge'
|
|
import pick from 'lodash/pick'
|
|
import { EchartsDataType } from '../index.d'
|
|
import { globalThemeJson } from '@/settings/chartThemes/index'
|
|
|
|
/**
|
|
* * 合并 color 和全局配置项
|
|
* @param option 配置
|
|
* @param themeSetting 设置
|
|
* @param excludes 排除元素
|
|
* @returns object
|
|
*/
|
|
export const mergeTheme = <T, U>(
|
|
option: T,
|
|
themeSetting: U,
|
|
includes: string[]
|
|
) => {
|
|
return 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
|
|
}
|