-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(liquid): add liquid percent.toFixed #5648
Conversation
ai-qing-hai
commented
Oct 17, 2023
•
edited
Loading
edited
src/mark/liquid.ts
Outdated
@@ -89,7 +89,7 @@ export const Liquid: CC<LiquidOptions> = (options) => { | |||
}), | |||
deepMix({}, DEFAULT_TEXT_OPTIONS, { | |||
style: { | |||
text: `${percent * 100} %`, | |||
text: `${(percent * 100).toFixed(2)} %`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉不能简单的toFixed, 例如 0.55 这种会被转换为 55.00%
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
全局搜索 prettyNumber 这个函数,把它抽出来放在 src/utils/number.ts
里面,然后在这里使用:避免精度问题。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同时修改水波图的测试案例为这个特殊的文本,然后更新截图
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好了
src/mark/liquid.ts
Outdated
@@ -89,7 +89,7 @@ export const Liquid: CC<LiquidOptions> = (options) => { | |||
}), | |||
deepMix({}, DEFAULT_TEXT_OPTIONS, { | |||
style: { | |||
text: `${percent * 100} %`, | |||
text: `${(percent * 100).toFixed(2)} %`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
全局搜索 prettyNumber 这个函数,把它抽出来放在 src/utils/number.ts
里面,然后在这里使用:避免精度问题。
src/mark/liquid.ts
Outdated
@@ -89,7 +89,7 @@ export const Liquid: CC<LiquidOptions> = (options) => { | |||
}), | |||
deepMix({}, DEFAULT_TEXT_OPTIONS, { | |||
style: { | |||
text: `${percent * 100} %`, | |||
text: `${(percent * 100).toFixed(2)} %`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同时修改水波图的测试案例为这个特殊的文本,然后更新截图
这里 rebase 一下 v5,不要用 merge |
#5788 重新创建一个 pr |