如何在图表法中仅显示YAxis中的整数

时间:2016-11-16 19:46:04

标签: ruby-on-rails ruby charts chartkick

我想只显示YAxis中的整数

PaymentTransaction.group_by_day(:created_at, format: "%b %d, %Y").count,discrete: true, allowDecimals: false,yAxis: {allowDecimals: false}

enter image description here

1 个答案:

答案 0 :(得分:1)

如果你使用谷歌图表,那么你可以这样做:

data = PaymentTransaction.group_by_day(:created_at, format: "%b %d, %Y").count
y = data.map(&:last)
y_discrete = ((y.min.floor)..(y.max.ceil)).to_a
options = { vAxis: { ticks: y_discrete } }
line_chart(data, { library: options })