Adding extra values to tooltip lazy high charts mapping

261 views Asked by At

I'm trying to add extra data to the tooltip in highcharts by passing a hash to the series data however it doesn't seem to be working and is possibly a date issue.

The following code is based on the lazy high charts example.

For the the three f.series lines. If I run them without the other the first two work and produce data on the graph but the last one does not.

         @chart = LazyHighCharts::HighChart.new('graph') do |f|
           f.title(:text => "Thing")
           f.chart(:type => "line")
           f.series(:name => "Tasks", :data => [ { x: 1, y: 2 }, { x: 1, y: 3 }])
           f.series(:name => "Tasks", :data => @tasks.map{|t|  [t.completed_at, 0] })
           f.series(:name => "Tasks", :data => @tasks.map{|t| { x: t.completed_at, y: 0 } })
           require 'pry'; binding.pry

           f.yAxis [
             {:title => {:text => "GDP in Billions", :margin => 70} },
             {:title => {:text => "Population in Millions"}, :opposite => true},
           ]

         end

Output from pry

    => #<LazyHighCharts::HighChart:0x007f81294da920
 @html_options={},
 @options=
  {:title=>{:text=>"Thing"},
   :legend=>{:layout=>"vertical", :style=>{}},
   :xAxis=>{},
   :yAxis=>{:title=>{:text=>nil}, :labels=>{}},
   :tooltip=>{:enabled=>true},
   :credits=>{:enabled=>false},
   :plotOptions=>{:areaspline=>{}},
   :chart=>{:type=>"line"},
   :subtitle=>{}},
 @placeholder="graph",
 @series_data=
  [{:name=>"Tasks", :data=>[{:x=>1, :y=>2}, {:x=>1, :y=>3}]},
   {:name=>"Tasks",
    :data=>
     [[Wed, 25 Mar 2015 00:00:00 UTC +00:00, 0],
      [Sun, 22 Mar 2015 09:09:34 UTC +00:00, 0]]},
   {:name=>"Tasks",
    :data=>
     [{:x=>Wed, 25 Mar 2015 00:00:00 UTC +00:00, :y=>0},
      {:x=>Sun, 22 Mar 2015 09:09:34 UTC +00:00, :y=>0}]}]>

So the last one is in the same format as the first and contains the same data as the second but does not work. Is it possibly the comma after the day of the week. If so what format should it be in for highcharts to accept

0

There are 0 answers