Commit cfc7d5f6 authored by 李纪文's avatar 李纪文

fix: 图表支持主题

parent 8d167bbb
import _ from 'lodash'; import _ from 'lodash';
import * as echarts from 'echarts/core'; import * as echarts from 'echarts/core';
import { globalConfig } from 'antd/lib/config-provider';
const BASE_COLORS = [
'#1685ff',
'#00b809',
'#ffa200',
'#00d0c7',
'#ff6b37',
'#986aff',
'#2f54eb',
'#ff9e69',
'#ffcb66',
'#99ceff',
];
const THEME_LIST = {
'#009C73': ['#01AA55', '#1685FF', '#FFB424', '#19D2BA', '#5842FF'],
'#0087F7': BASE_COLORS,
'#1890FF': BASE_COLORS,
};
const THEME = window.globalConfig?.variableTheme?.primaryColor;
/** /**
* 16进制颜色值转rgba颜色值 * 16进制颜色值转rgba颜色值
...@@ -17,18 +39,7 @@ export const hexToRgba = (hex, opacity = 1) => { ...@@ -17,18 +39,7 @@ export const hexToRgba = (hex, opacity = 1) => {
}; };
// 图表基础配色 // 图表基础配色
export const DEF_COLORS = [ export const DEF_COLORS = THEME ? THEME_LIST[THEME] || BASE_COLORS : BASE_COLORS;
'#1685ff',
'#00b809',
'#ffa200',
'#00d0c7',
'#ff6b37',
'#986aff',
'#2f54eb',
'#ff9e69',
'#ffcb66',
'#99ceff',
];
// 图表基础配色对应的线性渐变色, 适用面积曲线图 // 图表基础配色对应的线性渐变色, 适用面积曲线图
export const DEF_GRAD_COLORS = DEF_COLORS.map((color) => { export const DEF_GRAD_COLORS = DEF_COLORS.map((color) => {
......
...@@ -3,6 +3,7 @@ import { buildDefaultOption, buildSpecificOption } from './default'; ...@@ -3,6 +3,7 @@ import { buildDefaultOption, buildSpecificOption } from './default';
import * as color from './color'; import * as color from './color';
const buildOption = (option) => { const buildOption = (option) => {
option = option || {};
const exports = {}; const exports = {};
const defaultOption = buildDefaultOption(option); const defaultOption = buildDefaultOption(option);
const specificOption = buildSpecificOption(option); const specificOption = buildSpecificOption(option);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment