提交 172a0fb0 authored 作者: junjun's avatar junjun

feat: 仪表盘阈值

上级 c87f3ead
...@@ -53,14 +53,24 @@ export function baseGaugeOption(chart_option, chart) { ...@@ -53,14 +53,24 @@ export function baseGaugeOption(chart_option, chart) {
// threshold // threshold
if (chart.senior) { if (chart.senior) {
const range = [] const range = []
let index = 0
let flag = false
const senior = JSON.parse(chart.senior) const senior = JSON.parse(chart.senior)
const threshold = JSON.parse(JSON.stringify(senior.threshold ? senior.threshold : DEFAULT_THRESHOLD)) const threshold = JSON.parse(JSON.stringify(senior.threshold ? senior.threshold : DEFAULT_THRESHOLD))
if (threshold.gaugeThreshold && threshold.gaugeThreshold !== '') { if (threshold.gaugeThreshold && threshold.gaugeThreshold !== '') {
const arr = threshold.gaugeThreshold.split(',') const arr = threshold.gaugeThreshold.split(',')
const per = parseFloat(chart.data.series[0].data[0]) / parseFloat(chart_option.series[0].max)
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
const ele = arr[i] const ele = arr[i]
const p = parseInt(ele) / 100 const p = parseInt(ele) / 100
range.push([p, hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)]) range.push([p, hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)])
if (!flag && per <= p) {
flag = true
index = i
}
}
if (!flag) {
index = arr.length
} }
range.push([1, hexColorToRGBA(customAttr.color.colors[arr.length % 9], customAttr.color.alpha)]) range.push([1, hexColorToRGBA(customAttr.color.colors[arr.length % 9], customAttr.color.alpha)])
...@@ -71,7 +81,7 @@ export function baseGaugeOption(chart_option, chart) { ...@@ -71,7 +81,7 @@ export function baseGaugeOption(chart_option, chart) {
} }
chart_option.series[0].itemStyle = { chart_option.series[0].itemStyle = {
color: 'auto' color: hexColorToRGBA(customAttr.color.colors[index], customAttr.color.alpha)
} }
chart_option.series[0].progress = { chart_option.series[0].progress = {
show: false show: false
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论