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

前端 未结 11 1333
予麋鹿
予麋鹿 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:52

    I'm using the Guava Multiset as my data. Cagy79's trick is the only one that I was able to get working. I also tried generating my own lines using an IntStream, but still had fractional numbers for some of the graphs. As mentioned above, just setting the format will create a graph where the hover over value and the gridline differ.

    Multiset items = TreeMultiset.create();

    Items added using .add and .addAll

    Make sure the items are sorted:

    occurrences = Multisets.copyHighestCountFirst(items);

    String option = "hAxis : { title : 'Count', gridlines : { count:" + ((max >=12) ? 4 : max+1) + } }")

提交回复
热议问题