2011-11-29 50 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'」錯誤。

有什麼想法?

回答