/* * @Author: changjun * @FilePath: /yuan-qingdao-zld-browser/src/components/chart/options/common.ts * @Date: 2022-08-27 17:06:55 * @Description: 图表的公共配置项 * @LastEditTime: 2022-09-06 11:01:41 * @LastEditors: changjun */ import { isObject } from '../../../utils/is' /** * @desc: 定义图表的公共色值盘,对于数据项不定的从这里取色 * @author: changjun */ export const colorList = ['#0095FF', '#E65857', '#FE7F09', '#4E9B40', '#45BCCA', '#677DFF', '#9E7AFE', '#F7C424', '#F481FF', '#DB00BC'] export const funnelColorList = ['rgba(0, 149, 255, 1)', 'rgba(0, 149, 255, .9)', 'rgba(0, 149, 255, .8)', 'rgba(0, 149, 255, .7)', 'rgba(0, 149, 255, .6)', 'rgba(0, 149, 255, .5)', 'rgba(0, 149, 255, .4)', 'rgba(0, 149, 255, .3)', 'rgba(0, 149, 255, .2)', 'rgba(0, 149, 255, .1)'] /** * @author changjun * @description 空心圆点 主要用于折线图 * @date 2022/09/01 */ export const circleIconPath = 'path://M881.387 297.813c38.08 65.387 57.28 136.747 57.28 214.187s-19.094 148.8-57.28 214.187c-38.187 65.28-89.92 117.12-155.2 155.2S589.44 938.667 512 938.667s-148.8-19.094-214.187-57.28c-65.28-38.08-117.013-89.814-155.306-155.307C104.427 660.8 85.333 589.44 85.333 512c0-77.333 19.094-148.693 57.28-214.187 38.08-65.28 89.814-117.013 155.307-155.306C363.2 104.533 434.56 85.333 512 85.333c77.333 0 148.693 19.094 214.187 57.28 65.28 38.187 117.013 89.92 155.2 155.2z m-217.707-47.36C617.387 223.467 566.827 209.92 512 209.92s-105.387 13.547-151.68 40.533-82.987 63.68-109.973 109.974c-26.987 46.293-40.534 96.853-40.534 151.68s13.547 105.386 40.534 151.68c26.986 46.293 63.68 82.986 109.973 109.973 46.293 26.987 96.853 40.533 151.68 40.533s105.387-13.546 151.68-40.533c46.293-26.987 82.987-63.68 109.973-109.973 26.987-46.294 40.534-96.854 40.534-151.68s-13.547-105.387-40.534-151.68c-27.093-46.294-63.786-82.987-109.973-109.974z' /** * @author changjun * @description 合并两个对象,主要是用于封装的 echarts 组件中需要手动设置额外的配置项 如果属性一样覆盖 * @param { Object } source 源对象 * @param { Object } other 要合并的额外属性 * @date 2022/09/01 */ export const mergeOptions = (source, other) => { if (!isObject(source) || !isObject(other)) { return other === undefined ? source : other } return Object.keys({ ...source, ...other }).reduce((acc, key) => { // 递归合并 value acc[key] = mergeOptions(source[key], other[key]) return acc }, Array.isArray(source) ? [] : {}) } export const mapNameJoint = (name) => { return name.includes('市') ? name : `${name}市` } export function getGradientColorList(count, colors, color) { const maxColor = colors[0]; const minColor = colors[colors.length - 1]; return Array.from({ length: count }, (item, index) => { if(index === 0) return maxColor if(index === count - 1) return minColor return `rgba(${color}, ${Math.abs(index / count - 1).toFixed(2)})` }) }