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

折线图当数据值较小的时候,例如count为1的时候,坐标轴显示小数,期望显示整数 #3574

Closed
1 task
SGAMERyu opened this issue Aug 16, 2021 · 7 comments

Comments

@SGAMERyu
Copy link

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

What problem does this feature solve?

解决了,某些场景下不会出现小数的数据

What does the proposed API look like?

chart.scale({
minInterval: 1
})

@pearmini
Copy link
Member

可以设置 tickMethod 防止小数的出现:

chart.scale({
  tickMethod: 'd3-linear'
})

@SGAMERyu
Copy link
Author

可以设置 tickMethod 防止小数的出现:

chart.scale({
  tickMethod: 'd3-linear'
})

采用d3-linear 并没有生效,这个d3-linear 是要引入npm包吗

@pearmini
Copy link
Member

给一个复线 demo 我看看?

@pearmini pearmini reopened this Aug 20, 2021
@SGAMERyu
Copy link
Author

给一个复线 demo 我看看?

demo 如下
https://codesandbox.io/s/young-dew-s08nr?file=/index.ts

@pearmini
Copy link
Member

设置 tickCount 为 1 就可以,因为 d3-linear 是保证在 tickCount <= max - min 的时候生成整数的 ticks。可以参考这里:https://github.com/antvis/scale/blob/master/docs/api/tick-methods.md

value: {
    min: 0,
    nice: true,
    tickMethod: "d3-linear",
    tickCount: 1,
}

@SGAMERyu
Copy link
Author

设置 tickCount 为 1 就可以,因为 d3-linear 是保证在 tickCount <= max - min 的时候生成整数的 ticks。可以参考这里:https://github.com/antvis/scale/blob/master/docs/api/tick-methods.md

value: {
    min: 0,
    nice: true,
    tickMethod: "d3-linear",
    tickCount: 1,
}

image
但是设置tickCount 为1的时候,就会只出现一条线,这个是要开发者进行自己判断是吗?

@pearmini pearmini reopened this Aug 23, 2021
@pearmini
Copy link
Member

嗯嗯,是可以的,因为 tickCount 其实可以根据 max - min 去设置。

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