style(图表-漏斗图): 遇到空值时,计算结果显示横杠 -

This commit is contained in:
jianneng-fit2cloud 2024-09-02 18:45:19 +08:00
parent 4b48efbf88
commit d0a7f7540e

View File

@ -149,11 +149,14 @@ export class Funnel extends G2PlotChartView<FunnelOptions, G2Funnel> {
fontSize: l.fontSize
},
formatter: datum => {
if (!datum['$$conversion$$'][0]) {
return `${conversionTagAtt.text ?? ''} -`
}
const rate = (
(datum['$$conversion$$'][1] / datum['$$conversion$$'][0]) *
100
).toFixed(conversionTagAtt.precision)
return `${conversionTagAtt.text ?? ''}${rate}%`
return `${conversionTagAtt.text ?? ''} ${rate}%`
}
}
}