2016-11-16 51 views
0

在Y軸僅整數我想如果你使用谷歌圖表,那麼你可以做這樣的只顯示整數在Y軸如何顯示在chartkick

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

enter image description here

回答

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