Wicked_pdf Gem + Highcharts
Solution 1:
Finally solved.
Some steps were not necessary, but I will note it anyways to help the most people :
1.- Change wkhtmltopdf version, I was using 0.12 , now I installed
gem 'wkhtmltopdf-binary'
This gem works with 0.9 version of wkhtmltopdf
2.- Remove animation and other stuff from Highcharts. Seems like works without it too, buts its better to be sure, I'm testing locally and things like animation increases the risk of not rendering the complete chart in time.
Add this config to charts container file :
plotOptions: {
series: {
enableMouseTracking:false,
shadow:false,
animation:false
}
},
****Note : check if you already set plotOptions in another part of your chart, if you already did just add the lines to the existent plotOptions , if you write it twice it wont work.***
3.- Add HTML structure to the layout html file, remember that wicked_pdf can't see your assets pipeline.
<HTML><HEAD> scripts </HEAD><BODY> charts and text </BODY></HTML>
4.- Include both internal and external JS files (include CSS files if you have) in the PDF layout view (HEAD tag), in my case I used js files to store my chart templates and generate dynamic charts like this :
<scriptsrc="https://code.jquery.com/jquery-2.2.2.min.js"integrity="sha256-36cp2Co+/62rEAAYHLmRCPIych47CvdM+uTBJwSzWjI="crossorigin="anonymous"></script><scriptsrc="https://code.highcharts.com/highcharts.js"></script><scriptsrc="https://code.highcharts.com/modules/exporting.js"></script><scriptsrc="https://code.highcharts.com/modules/heatmap.js"></script>
<%= wicked_pdf_javascript_include_tag "chart_templates/chart_bar_combined" %>
Hope it helps, this answer combines some short and less explained solutions.
Regards
Post a Comment for "Wicked_pdf Gem + Highcharts"