Haseeb Ahmad
Haseeb Ahmad

Reputation: 8730

How to show only integers in YAxis in chartkick

I want to show only integers in YAxis

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

enter image description here

Upvotes: 0

Views: 352

Answers (1)

yenshirak
yenshirak

Reputation: 3106

If you use Google Charts then you can do it like this:

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

Upvotes: 1

Related Questions