frankyorg
frankyorg

Reputation: 63

Gem Chartkick charts not rendering on PDF

I'm using Rails 5.2.4, Gem Chartkick(3.3.1) and wicked_pdf(1.4.0). As many people wrote, I can also not display a pie chart on pdf through Chartkick and wicked_pdf, just "loading" is shown. The chart is correctly showing on html.

If someone could already solve this problem, please let me know which version of Chartkick and wicked_pdf was used?

I tried as below but no success:

  1. Add into box_report.pdf.erb
<%= wicked_pdf_javascript_include_tag "application", "chartkick" %>
  1. Add into controller
window_status: "FLAG_FOR_PDF"

plus add into application.js

setTimeout((function () {
    window.status = "FLAG_FOR_PDF";
    Object.keys(Chartkick.charts).forEach(function (key) {
        Chartkick.charts[key].redraw();
    });
}), 3000);
  1. Add wicked_pdf.rb
WickedPdf.config = {
  javascript_delay: 3000,
...
}
  1. Add into controller
javascript_delay: 3000,

Upvotes: 3

Views: 256

Answers (1)

maxagno3
maxagno3

Reputation: 196

For displaying Pie chart you need to use <%= pie_chart #count, width, height, id, and other options goes here %>. Make sure to use it in the template file you will be using.

Upvotes: -2

Related Questions