2011-11-29 49 views
2

我在我的应用程序中使用Highcharts来渲染图表。一切工作正常,除了当我要将具有图表的页面转换为PDF。我正在使用wicked_pdf。这里是展示方法我的控制器:在wicked_pdf中渲染jQuery

format.pdf do 
      render :pdf => "report", 
       :template => "/quarters/report.pdf.erb", 
    end 

我/quarters/report.pdf.erb文件看起来像它在我show.html.erb为highcharts:

<div id="testcollections" style="width: 600px;"></div> 

<!-- jQuery for testing collections charts --> 
<script type="text/javascript" charset="utf-8"> 
$(function() { 
    new Highcharts.Chart({ 
    chart: { renderTo: 'testcollections' }, 
    title: { text: 'Test Collections' }, 
    plotOptions: { 
      series: { 
       dataLabels: { 
        enabled: true, 
        formatter: function() { 
         return this.y; 
        } 
       } 
      } 
     }, 

    series: [{ 
    name: 'Collections', 
    type: 'area', 
    color: '#5b81b4', 
    data: <%= Quarter.where('quarters.client_id=?',  @quarter.client_id).map(&:collections) %> 
    }, 
    { 
    name:'Average Collections', 
    type: 'area', 
    color: '#999', 
    data: <%= Quarter.includes(:client).group('clients.specialty',  'quarters.year', 'quarters.quarter') 
    .average('quarters.collections').values.map(&:to_f).to_json %> 
    }] 
    }); 
}); 
</script> 

而且在我型我秀页面这是链接下载PDF文件:

<%= link_to 'PDF', { :action => "show", :format => :pdf } %> | 

问题是图表不显示,它只是空白。我从here知道你应该调用“wicked_pdf_javascript_include_tag”,但它给了我一个“undefined method`javascript_src_tag'”错误。

有什么想法?

回答