antvis/G2

条形图scale设置nice:true时,不显示annotation #3408

quicklearning123 posted onGitHub

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

https://g2.antv.vision/zh/examples/case/bar#bar1

Steps to reproduce

设置 chart.scale('value', { nice: true }); 时 必现

期望在红框处显示实际的value

image

Environment Info
g2 4.1.16
System mac
Browser chrome

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


image

posted by quicklearning123 almost 4 years ago

下面这样写没有问题:

chart.scale({
  value: {
    max: 1400,
    min: 0,
    nice: true
  }
});

你后面对 value 的配置覆盖了之前的,导致 max:1000,所以将金融保险的 label 绘制在可视区域之外了。

posted by pearmini almost 4 years ago

image 这就是我提的问题啊,为啥没解决就关掉了…… 1400是我写死测试用的代码。。我希望nice时界面能兼容显示正常(不用指定max和min,否则需要费劲去算max设成多大)

posted by quicklearning123 almost 4 years ago

之前太久没有回复所以就把 issue 关了,可以设置 scale 的 range,使用方法如下:

chart.scale({
  value: {
    range: [0, 0.9],
    alias: '销量(百万)',
  },
});

这个问题和 nice 关系不大,在官方网站案例中你把 max: 1400 去掉后,有没有 nice 都会出现问题,上面的 range 的意思是在这个范围内绘制图形:[width * 0, width * 0.9]

posted by pearmini almost 4 years ago

Fund this Issue

$0.00
Funded

Pull requests