Merge pull request #7706 from dataease/pr@dev@fix_liquid_big_number

fix(视图-水波图): 数值过大显示异常
This commit is contained in:
wisonic-s 2024-01-18 19:16:03 +08:00 committed by GitHub
commit c8e9dfc948
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: {