1
votes

I'm using ChartKick gem and Google Charts library. HAML:

= line_chart @data.group(:date).average(:measure), discrete: true, library: {hAxis: {slantedText: true, slantedTextAngle: 45, gridlines: {units: {years: {format: 'yy'}}}}}

Results so far:

enter image description here

Docs: https://developers.google.com/chart/interactive/docs/gallery/linechart#configuration-options and http://icu-project.org/apiref/icu4c/classSimpleDateFormat.html#details

I also tried

hAxis: {format: 'yy-MM-dd', slantedText: true, slantedTextAngle: 45}

Also, how do I stop from truncating the labels?

1

1 Answers

1
votes

I use groupdate gem for rails. My line chart:

= line_chart Visit.group(:user_id).group_by_day(:created_at, format: "%d %b").count, discrete: true

In your case you can use something like this:

group_by_year(:date, format: "%y-%m-%d")

I hope it helps