0

我无法在 wicked pdf 中生成 LazyHighCharts。

控制器:

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

视图:index.html.erb

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

结果:字符串“hey”出现在 PDF 中,但图表没有出现,我不知道为什么。

4

1 回答 1

0

尝试设置animationsfalse如图所示here

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

您的图表可能在开始(和完成)动画之前被渲染。

于 2016-07-12T18:35:26.970 回答