style(图表): 桑基图提示占比的显示优化

This commit is contained in:
jianneng-fit2cloud
2025-07-22 11:10:40 +08:00
committed by jianneng-fit2cloud
parent d868fdfd83
commit af826bb872

View File

@@ -195,12 +195,11 @@ export class SankeyBar extends G2PlotChartView<SankeyOptions, Sankey> {
const { source, target, value } = datum
// 总出占比
if (t.tooltipFormatter.showTotalPercent) {
const decimalCount =
t.tooltipFormatter.type !== 'auto' ? t.tooltipFormatter.decimalCount : 2
const ratio = (value / outTotal[source]).toFixed(decimalCount)
const { decimalCount = 2 } = t.tooltipFormatter
const ratioStr = ((value / outTotal[source]) * 100).toFixed(decimalCount) + '%'
return {
name: source + ' -> ' + target,
value: valueFormatter(value, t.tooltipFormatter) + ` (${ratio}%)`
name: `${source} -> ${target}`,
value: valueFormatter(value, t.tooltipFormatter) + ` (${ratioStr})`
}
}
return {