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

雷达图网格线数量控制,tickCount属性设置与表现时常不一致 #3580

Closed
1 task
machen8812 opened this issue Aug 19, 2021 · 1 comment
Closed
1 task

Comments

@machen8812
Copy link

machen8812 commented Aug 19, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

修改scale下的tickCount属性,tickCount =3或者tickCount =4,图形上都只有2个网格线。tickCount=5时,展示4个网格线

Environment Info
g2 4.1.24
System windows10
Browser Google Chrome 92.0.4515.131(正式版本) (64 位)
@pearmini
Copy link
Member

pearmini commented Aug 19, 2021

tickCount 只是一个提示,并不是最终的生成的 ticks 的数量。因为需要保证 tick 的可读性(尽量是 1,2,5,10 的倍数),所以会调整 tick 的数量。如何希望 ticks 的数量和 tickCount 一致,可以自定义 tickMethod 方法。(如下)

chart.scale("score", {
  min: 0,
  // max: 80,
  nice: true,
  // 网格隐藏
  tickCount: 5,
  tickMethod: ({min, max, tickCount}) => {
    const step = (max - min) / tickCount;
    return new Array(tickCount).fill(0).map((_,  i) => min + i * step);
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants