How to show only integers (no decimals) in chart API x/y-axis labels

前端 未结 11 1332
予麋鹿
予麋鹿 2021-02-03 23:10

I\'m using a column chart with the Google Chart JS Api. I\'m displaying some values (total orders by day) that can only be represented as integers.

Everything is work

11条回答
  •  执念已碎
    2021-02-03 23:47

    I prefer the gridlines: { count: -1 } option, but you can always explicitly specify the values you want with ticks. Cool thing about this is they don't even have to be evenly spaced - you could do [1, 10, 100, 200, 500, 1000] if you wanted:

    options: { vAxis: { ticks: [1,2,3,4,5,6,7,8,9,10] } }

    Depending upon your data you may want to hardcode this or use thresholds.

提交回复
热议问题