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