I use Highcharts in my chart rendering application. Everything works fine, except when I want to convert a chart page to PDF. I am using wicked_pdf . Here is my show method:
format.pdf do render :pdf => "report", :template => "/quarters/report.pdf.erb", end
The file My / quarters / report.pdf.erb looks like in my show.html.erb for high maps:
<div id="testcollections" style="width: 600px;"></div> <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>
And on my show page, this is the link to download the PDF file:
<%= link_to 'PDF', { :action => "show", :format => :pdf } %> |
The problem is that the chart is not displayed, it is just empty. I know from here that you should call "wicked_pdf_javascript_include_tag", but that gives me the error "undefined method` javascript_src_tag ".
Any thoughts?