-
Notifications
You must be signed in to change notification settings - Fork 71
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
Feat/axis break #3128
Merged
Merged
Feat/axis break #3128
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xile611
reviewed
Sep 9, 2024
xile611
previously approved these changes
Sep 9, 2024
xile611
approved these changes
Sep 9, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
背景
图表中的轴截断(Axis truncation)是指在图表的坐标轴上,部分数据范围被省略或不显示,以便更好地突出显示特定的数据区间。这种技术通常用于处理数据中存在极端值(离群值)或数据分布不均匀的情况,从而使得图表更易于理解和分析。
如下图所示,当图表中存在数值相差较大的场景时,我们通常会通过轴截断/轴中断(scale 分段)手段来缩小特别大的部分,增强较小部分的可读性。
前提
目前只对 CartesianLinear 坐标轴生效。
实现思路
轴截断的核心思路是对数据对应的 scale 进行分段映射的配置(scale 本身具备这个能力),比如:
涉及到的修改点:
domain
和range
的赋值&取值逻辑修改(只在用户设置了 breaks 的场景),以及这两个属性的取值,之前都默认他们的长度都为 2,所以原先去domain[1]
的地方修改为last(domain)
tick-data/continuous.ts
中 ticks 生成以及抽样逻辑修改:由于截断后ticks 的分布是不均匀的,所以生成 ticks 的逻辑这里,默认给每一段的范围都赋予原先的 count 个数,没有根据分段比例进行分配,有可能造成 count 变多的情况。另外由于 tick interval 不是均分的,抽样这里不能采用parity
,使用了目前的greedy
关于系列上的截断图形
考虑到系列上的截断图形样式没有通用化的方案,不同的业务可能需求不同,另外不是所有的系列都适用,所以就没有作为默认的功能在 vchart 中实现,图表助手中是通过自定义组件实现的,所以 VCHart 这里考虑直接在 demo 中提供方案。
🤔 This is a ...
🔗 Related issue link
Close #2102
🔗 Related PR link
@visactor/vrender-component: VisActor/VRender#1394
Axis component support render breaks, as follows:
🐞 Bugserver case id
66d683dc71a15300f7f1fb51
66d6845871a15300f7f1fb52
66d6849671a15300f7f1fb59
66d685f471a15300f7f1fb5a
66d6864771a15300f7f1fb5c
💡 Background and solution
📝 Changelog
☑️ Self-Check before Merge
🚀 Summary
copilot:summary
🔍 Walkthrough
copilot:walkthrough