From b1d7f56debdb9ef9e736f2e0198a089560a6a97a Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Thu, 18 Jan 2024 19:14:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=A7=86=E5=9B=BE-=E6=B0=B4=E6=B3=A2?= =?UTF-8?q?=E5=9B=BE):=20=E6=95=B0=E5=80=BC=E8=BF=87=E5=A4=A7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/chart/chart/liquid/liquid.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/frontend/src/views/chart/chart/liquid/liquid.js b/core/frontend/src/views/chart/chart/liquid/liquid.js index cecd718161..ff0c996817 100644 --- a/core/frontend/src/views/chart/chart/liquid/liquid.js +++ b/core/frontend/src/views/chart/chart/liquid/liquid.js @@ -8,7 +8,7 @@ let labelFormatter = null export function baseLiquid(plot, container, chart) { let value = 0 const colors = [] - let max, radius, bgColor, shape, labelContent, liquidStyle + let max, radius, bgColor, shape, labelContent, liquidStyle, originVal = 0 if (chart.data?.series.length > 0) { value = chart.data.series[0].data[0] } @@ -33,6 +33,7 @@ export function baseLiquid(plot, container, chart) { radius = parseFloat((size.liquidSize ? size.liquidSize : DEFAULT_SIZE.liquidSize) / 100) shape = size.liquidShape ? size.liquidShape : DEFAULT_SIZE.liquidShape } + originVal = (parseFloat(value) / parseFloat(max)) // label if (customAttr.label) { const label = JSON.parse(JSON.stringify(customAttr.label)) @@ -43,9 +44,8 @@ export function baseLiquid(plot, container, chart) { fontSize: parseInt(label.fontSize), color: label.color }), - formatter: function(v) { - const value = v.percent - return valueFormatter(value, labelFormatter) + formatter: () => { + return valueFormatter(originVal, labelFormatter) } } } else { @@ -58,11 +58,11 @@ export function baseLiquid(plot, container, chart) { if (senior?.threshold) { const { liquidThreshold } = senior?.threshold if (liquidThreshold) { - liquidStyle = ({ percent }) => { + liquidStyle = () => { const thresholdArr = liquidThreshold.split(',') let index = 0 thresholdArr.forEach((v, i) => { - if (percent > v / 100) { + if (originVal > v / 100) { index = i + 1 } }) @@ -93,7 +93,7 @@ export function baseLiquid(plot, container, chart) { backgroundColor: bgColor } }, - percent: (parseFloat(value) / parseFloat(max)), + percent: originVal > 1 ? 1 : originVal, radius: radius, shape: shape, statistic: {