Search code examples
ruby-on-rails-3.2linegraphchartkick

Chartkiq Line Graph plotting X-axis values differently


I am using the gem 'chartkiq' for plotting graphs in my Rails App. It is working fine with bar and column types, not with line graph.

        <%= line_chart array_of_values %>
        array_ofvalues = [{:name=>"Last Year Net Sales", :data=>[[0, 1110.0],1,6450.0],[2, 13234.0], [3, 11234.0]]}, {:name=>"This Year Target Net Sales", :data=>[[0, 12000.0], [1, 5678.0], [2, 12222.0], [3, 12345.0]]}, {:name=>"This Year Net Sales", :data=>[[0, 1110.0], [1, 6450.0], [2, 13234.0], [3, 11234.0]]}]

Here, 0,1,2 and 3 are the expected values on X-axis, but what is shown on the x-axis is '5:30:00 AM 5:30:00 AM 5:30:01 AM 5:30:01 AM 5:30:02 AM 5:30:02 AM 5:30:03 AM'

Does anyone know why this happens?


Solution

  • Chartkick does not support discrete values for line charts at the moment.

    https://github.com/ankane/chartkick/issues/38