mirror of
https://gitee.com/dromara/go-view.git
synced 2025-05-21 23:09:16 +08:00
36 lines
913 B
TypeScript
36 lines
913 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 (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
|
|
}
|