Skip to content
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(gauge): 仪表盘 percent 0 时,数据被过滤重新添加回来 #3265

Merged
merged 5 commits into from
Jul 12, 2022

Conversation

ai-qing-hai
Copy link
Contributor

@ai-qing-hai ai-qing-hai commented Jun 27, 2022

仪表盘 percent 0 时,数据被过滤. 导致 geometry 渲染第一个 range 直接为 1

Before After
image image

fixed #3262

@github-actions
Copy link
Contributor

github-actions bot commented Jun 27, 2022

🎊 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 Show resolved Hide resolved
@hustcc
Copy link
Member

hustcc commented Jun 28, 2022

单侧报错。

@@ -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();
Copy link
Member

Choose a reason for hiding this comment

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

为什么加这个?

Copy link
Member

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);

Copy link
Contributor Author

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 的数据会用掉一个颜色,导致颜色显示差一位。

@ai-qing-hai
Copy link
Contributor Author

单侧报错。
桑基图的 label 问题。 不知道什么原因就是不渲染。 上次 techvis 复现了,但是没有头绪解决。

image

@visiky
Copy link
Member

visiky commented Jul 12, 2022

单侧报错。
桑基图的 label 问题。 不知道什么原因就是不渲染。 上次 techvis 复现了,但是没有头绪解决。

image

这个 PR 我先合并了。然后复现 桑基图测试问题的 demo 链接有吗?

@visiky visiky merged commit dd090c2 into master Jul 12, 2022
@visiky visiky deleted the fix-gauge-parcent branch July 12, 2022 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🤔 [QUESTION] 仪表盘percent为0时,仪表盘渲染了整个弧度
3 participants