2

I created a chart of User registered/Month chart with Chartkick, however, some data at xAxis is not visible, such as this:

figure 1

Aralık means "December" and Şubat means "February". Even though there aret users registered at "November", there is no representing label in xAxis. There should be a label for every month, however I could not achieve it. My current rails code is this:

<%= line_chart User.group_by_month(:created_at).count %>

and the output from grouping query is this:

{Sun, 01 Nov 2015 00:00:00 UTC +00:00=>1, Tue, 01 Dec 2015 00:00:00 UTC +00:00=>1, Fri, 01 Jan 2016 00:00:00 UTC +00:00=>1, Mon, 01 Feb 2016 00:00:00 UTC +00:00=>1, Tue, 01 Mar 2016 00:00:00 UTC +00:00=>1}

I've also tried using the Google Charts library like this,

{library: {discrete: true, hAxis: {format: "MMMM yyyy", ticks: @patient_month_distribution.keys}}}

Google Charts outputs this error:

enter image description here

How can I modify my code so that every month/year is visible?

Burak Özmen
  • 865
  • 2
  • 11
  • 28
  • `ticks` are only available on a _Continuous_ axis -- but I don't think that is causing the error -- [this](http://stackoverflow.com/a/27591214/5090771) _might_ help... – WhiteHat Mar 08 '16 at 15:00
  • @WhiteHat It does not work with continuous neither. Going to take a look at your link, thanks! – Burak Özmen Mar 08 '16 at 15:25

1 Answers1

0

Use format in group_by_month function

<%= line_chart User.group_by_month(:created_at, format: "%b %y").count %>