antvis/G2

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

SGAMERyu posted onGitHub

  • 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 })

<!-- generated by antv-issue-helper. DO NOT REMOVE -->


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

chart.scale({
  tickMethod: 'd3-linear'
})
posted by pearmini over 3 years ago

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

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

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

posted by SGAMERyu over 3 years ago

给一个复线 demo 我看看?

posted by pearmini over 3 years ago

给一个复线 demo 我看看?

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

posted by SGAMERyu over 3 years ago

设置 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,
}
posted by pearmini over 3 years ago

设置 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的时候,就会只出现一条线,这个是要开发者进行自己判断是吗?

posted by SGAMERyu over 3 years ago

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

posted by pearmini over 3 years ago

Fund this Issue

$0.00
Funded

Pull requests