UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

40 lines (39 loc) 1.12 kB
import * as echarts from 'echarts'; import tinycolor from 'tinycolor2'; import { colorRgba } from './color'; export function getGaugeColorRange(percentage, color, backgroundColor) { var color2 = tinycolor(color.color).spin(-5).brighten(20).toHslString(); if (percentage > 0) { return [ [ percentage, new echarts.graphic.LinearGradient(0, 1, 1, 0, [ { offset: 0, color: color2 }, { offset: 1, color: color.color } ]) ], [percentage + 0.01, colorRgba(color.color, 0.3)], [1, backgroundColor] ]; } else { return [[1, backgroundColor]]; } } export function getCircularColorRange(percentage, color, backgroundColor) { if (percentage > 0) { return [ [percentage, color.color], [1, backgroundColor] ]; } else { return [[1, backgroundColor]]; } }