Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2025

Conversation

jianneng-fit2cloud
Copy link
Contributor

What this PR does / why we need it?

Summary of your change

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

name: source + ' -> ' + target,
value: valueFormatter(value, t.tooltipFormatter) + ` (${ratio}%)`
name: `${source} -> ${target}`,
value: valueFormatter(value, t.tooltipFormatter) + ` (${ratioStr})`
}
}
return {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码中的 tooltipFormatter 对象中 type 属性被忽略,只考虑了默认情况下的 decimalCount。如果需要自定义类型且有其他配置选项(例如精度),应该根据这些选项决定如何格式化比率。

if (t.tooltipFormatter.showTotalPercent && t.tooltipFormatter.type === 'custom') {
  const { precision, formatFunction } = t.tooltipFormatter;
  const ratio = (value / outTotal[source]).toFixed(precision);
  const customFormattedRatio = formatFunction(ratio); // 假设 formatFunction 格式化输出
  return {
    name: source + ' -> ' + target,
    value: valueFormatter(value, t.tooltipFormatter) + ' (' + customFormattedRatio + ')'
  };
}

通过这种方式可以使代码更加灵活,并确保符合各种可能的需求配置。

@jianneng-fit2cloud jianneng-fit2cloud merged commit af826bb into dev-v2 Jul 22, 2025
3 of 4 checks passed
@jianneng-fit2cloud jianneng-fit2cloud deleted the pr@dev-v2@chart-sankey-style branch July 22, 2025 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants