wicked pdf doesn't show LazyHighCharts

127 views Asked by At

I can't generate LazyHighCharts in wicked pdf.

Controller:

class GeneratepdfsController < ApplicationController
layout false

  def index
      @test = "hey" 
      @bar = LazyHighCharts::HighChart.new('column') do |f|
      f.series(:name=>'John',:data=> [3, 20, 3, 5, 4, 10, 12 ])
      f.series(:name=>'Jane',:data=>[1, 3, 4, 3, 3, 5, 4,-46] )     
      f.title({ :text=>"example test title from controller"})

      ## or options for column
      f.options[:chart][:defaultSeriesType] = "column"
      f.plot_options({:column=>{:stacking=>"percent"}})

      render  :pdf => "file.pdf", :template =>'generatepdfs/index.html.erb'
  end
end

view: index.html.erb

<%= high_chart("my_bar_div", @bar) %>
<p><%= @test %></p>

Result: The string "hey" appears in PDF but the chart doesn't appear and I don't know why.

1

There are 1 answers

0
Unixmonkey On

Try setting animations to false as shown here

$('#chart-container').highcharts({
  chart: {
    animation:false,
    // other options and stuff

Your chart may be being rendered before it has started (and finished) animating.