I want to implement a spider chart (High chart) in my rails application inside pdf for PDF I've used Prawn PDF gem. So anyone has any idea about implementing a spider chart in pdf. I also have a reference screenshot of the high chart spider chart the same chart I want to implement in my rails app pdf thanks in advance.
Spider Chart (High Chart) in rails with Prawn PDF How to generate?
511 Views Asked by Shubham Singh AtThere are 2 best solutions below
On
There's prawn-svg that can render SVGs into prawn, and so you can make a svg graph and render it inside your pdf.
Highcharts can export SVGs, but to run you should have a javascript runtime, which is possible, but will take some effort to setup and run. So some ruby-level chart library may be more preferable (it you can find one, as most current charting libraries are for client side javacsript).
Easier solution is to use a html-to-pdf converter, like wkhtmltopdf, that popupar wicked-pdf gem is based on. It runs a headless browser, renders the page and exports to pdf. The process is much slower, because for each pdf a separate process with browser in it has to run, and resulting pdf is larger, but you can use familiar web techniques in markup and reuse html views.
As you can find on the SO forum a lot of users suggest to use wkhtmltopdf to do it. Suggested solutions:
Can I use highcharts in a pdf generate with prawn in Rails?
Wkhtmltopdf fails to printing SVG path (highchart)
Using wkhtmltopdf with highcharts shows blank chart
And here is an example of how to create a spider chart in the JavaScript which you should easily rebuild in your project:
Demo: https://jsfiddle.net/BlackLabel/n1e0pmtv/
I am also attaching the link to the blog with instruction of implementing Highcharts with Ruby.
https://www.highcharts.com/blog/post/i-am-ruby-developer-how-can-i-use-highcharts/