-
Notifications
You must be signed in to change notification settings - Fork 601
fix(gauge): 仪表盘 percent 0 时,数据被过滤重新添加回来 #3265
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
Conversation
🎊 PR Preview d715457 has been successfully built and deployed to https://antvis-G2Plot-preview-pr-3265.surge.sh?type=diff&date=2022-06-30 🕐 Build time: 70.313s 🤖 By Surge Ui Insight |
单侧报错。 |
src/plots/gauge/utils.ts
Outdated
@@ -37,6 +35,7 @@ export function getIndicatorData(percent: GaugeOptions['percent']): Data { | |||
export function getRangeData(percent: GaugeOptions['percent'], range?: GaugeOptions['range']): GaugeRangeData { | |||
const ticks = get(range, ['ticks'], []); | |||
|
|||
const clampTicks = size(ticks) ? ticks : [0, clamp(percent, 0, 1), 1]; | |||
const clampTicks = size(ticks) ? uniq(ticks) : [0, clamp(percent, 0, 1), 1]; | |||
!clampTicks[0] && clampTicks.shift(); |
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.
如果 clampTicks[0] 等于 0,不就是被过滤掉了吗?
按照下面的方式,在最后的时候,去重下就好了?
const clampTicks = size(ticks) ? ticks : [0, clamp(percent, 0, 1), 1];
processRangeData(uniq(clampTicks) as number[], percent);
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.
原先解决的问题 是 percent 为 0 时 被过滤掉 只有一个 1 的数据, 导致 仪表盘 percent 为0 时 显示为 100%. 现在的解法是去除 为 0 的过滤, 把 ticks 去重。 关键点: 第一个为 0 的数据 是不渲染的,如果单单 uniq 则会让 第一个为 0 的数据会用掉一个颜色,导致颜色显示差一位。
仪表盘 percent 0 时,数据被过滤. 导致 geometry 渲染第一个 range 直接为 1
fixed #3262