0

I'm currently trying to display some data using chartkick in Rails. I have a 4 sets of data already on the chart where each point contains the same x data, the create at date for the klass_result_set.

I now want to add a list of tasks to be displayed on the grid and was happy to settle for now with points along the bottom of the chart however if I try and add these tasks the datapoints stop joining up.

Is there a way to get this to work correctly? Do I need to concat the dates for both sets and use null/nil values?

Image

http://s9.postimg.org/l4pu1pl67/chartkick_issue.png

Code snippets:

      <h4>History</h4>
  <% sets = @klass.klass_result_sets %>
  <% tasks = @klass.project.tasks.where(complete: true) %>

...

<div class="col-md-6">
   <%= line_chart [
       {name: "Total Variables", data: sets.map{|s| [s.created_at, s.variables] }},
       {name: "Public Variables", data: sets.map{|s| [s.created_at, s.public_variables] }},
       {name: "Protected Variables", data: sets.map{|s| [s.created_at, s.protected_variables] }},
        {name: "Private Variables", data: sets.map{|s| [s.created_at, s.private_variables] }}, 
        {name: "Tasks", data: tasks.map{|t|  [t.completed_at, 0] }}
      ] %>
    </div>

Cheers

4

1 回答 1

0

这实际上只是一个使用谷歌图表的错误。HighCharts 似乎可以找到

任何有问题的人都可以尝试使用 highcharts,或者如果这不起作用,我实际上找到了安装 highchart-rails gem 的答案

于 2015-03-25T18:45:15.733 回答