antvis / antvis/F2

[解决思路]柱状图设置圆角,差值太多,圆角会出现兼容问题

Open
#1,111 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
8k
Forks
637
PR merge metrics
No merged PRs in 30d

Description

兄弟问题:https://github.com/antvis/F2/issues/742

用到的版本是低版本的(试了下最新版本的,这个兼容问题不存在了,但是如果相差太多,低数值的就基本上不显示了),最大最小值相差太多,数值小的就会出现变形问题,最开始想到的也是设置最小高度,但是看了文档好像不可以,那就要考虑一下使用自定义形状,但对我来说成本有点高,所以就还是从现有的基础上去想办法,那就还从最小高度上的下手,思来想去还是从数据源上下手,最后终于给解决了,分享下思路给大家。

思路:
1:取到数据源数值绝对值(如果有负值)中的最大值
2:取最大值的0.02(根据自己的情况设置)
3:重新处理数据,如果数据源中的数值的绝对值小于取到的最大值比例,则给对应值加上或减去比例值,否则不变
4:处理显示的时候,正常显示原有数据数值,但是柱体使用刚才处理过的新数据,这样就相当于给了最小值,并且最小值是根据数据中的最大值来变化的。

完美解决。

Contributor guide

Open the contributing guide

Research direction

Start by reading the related F2 issue 742 and reproducing the described rounded-bar behavior when values differ greatly. Compare the workaround's displayed labels with the bar geometry; done would require a confirmed project change or an updated, documented resolution, neither of which this issue specifies.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.