From 172a0fb004fc357d2fcd6101e655c72c6d7797d4 Mon Sep 17 00:00:00 2001 From: junjun Date: Tue, 8 Mar 2022 16:42:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=AA=E8=A1=A8=E7=9B=98=E9=98=88?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/chart/chart/gauge/gauge.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/chart/chart/gauge/gauge.js b/frontend/src/views/chart/chart/gauge/gauge.js index c58cfeac61..15054a3074 100644 --- a/frontend/src/views/chart/chart/gauge/gauge.js +++ b/frontend/src/views/chart/chart/gauge/gauge.js @@ -53,14 +53,24 @@ export function baseGaugeOption(chart_option, chart) { // threshold if (chart.senior) { const range = [] + let index = 0 + let flag = false const senior = JSON.parse(chart.senior) const threshold = JSON.parse(JSON.stringify(senior.threshold ? senior.threshold : DEFAULT_THRESHOLD)) if (threshold.gaugeThreshold && threshold.gaugeThreshold !== '') { 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++) { const ele = arr[i] const p = parseInt(ele) / 100 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)]) @@ -71,7 +81,7 @@ export function baseGaugeOption(chart_option, chart) { } chart_option.series[0].itemStyle = { - color: 'auto' + color: hexColorToRGBA(customAttr.color.colors[index], customAttr.color.alpha) } chart_option.series[0].progress = { show: false