title: Rails Chartkick. Multiple Series line chart with nested hash
body: <p>Trying to do a multiple series line chart. (Visualizer is Chartjs.) From the <code>README</code>:</p>
  
  <pre><code>&lt;%= line_chart [
    {name: "Series A", data: series_a},
    {name: "Series B", data: series_b}
  ] %&gt;
  </code></pre>
  
  <p>My data is coming in JSON format already, but takes a little manipulation to get right. Raw form looks like this:</p>
  
  <pre><code>=&gt; [{"id"=&gt;30,
    "runner"=&gt;"Golden State Warriors",
    "price"=&gt;1.51,
    "histories"=&gt;[{"price"=&gt;1.51, "created_at"=&gt;"2016-11-19T17:42:18.699Z"}, {"price"=&gt;1.51, "created_at"=&gt;"2016-11-20T07:56:55.662Z"}]},
   {"id"=&gt;32, ETC
  </code></pre>
  
  <p>So, with
  <code>markets.map{ |m| [name: m['runner'], data: m['histories'].map{|h| [h['created_at'], 1/h['price']] }]}.flatten!</code>
  which yields: </p>
  
  <pre><code>=&gt; [
  {:name=&gt;"Golden State Warriors", :data=&gt;[["2016-11-19T17:42:18.699Z", 0.6622516556291391], ["2016-11-20T07:56:55.662Z", 0.6622516556291391]]},
  {:name=&gt;"Los Angeles Clippers", :data=&gt;[["2016-11-19T17:42:18.795Z", 0.1], ["2016-11-20T07:56:55.717Z", 0.1]]}, ETC
  </code></pre>
  
  <p>Although I don't get an error, the chart is an empty quadrant with <code>[object Object]</code> at 0,0.</p>
  
  <p>The chart is in an <code>@markets.each</code> block in my view because I want to create multiple charts the page showing the same thing with different data. I played around with an <code>.each_with_index</code> and I can get the chart to show partially by just manually inputting the data as the <code>README</code> shows: </p>
  
  <pre><code>&lt;%= line_chart [
        {name: markets[i]['runner'], data: markets[i]['histories'].map{|h| [h['created_at'], 1/h['price']]}},
        {name: markets[i+1]['runner'], data: markets[i+1]['histories'].map{|h| [h['created_at'], 1/h['price']]}}
      ] %&gt;
  </code></pre>
  
  <p>Which shows the first two series on the chart, but can't be the right way as there are different i elements for each chart.</p>
  
  <p>What can I do?</p>