JSReport 1.x + Google charts + wkhtmltopdf - is there a way to ensure that charts are loaded before rendering the report?



  • We have a situation where from time to time the Google charts components are not rendered in the PDF.
    The only reason I can think of is that Google charts JS code is not loaded in time for rendering.
    There is a parameter javascriptdelay that can be set for wkhtmltopdf which we currently have set to 3000 but this is a very imprecise way of trying to address this issue.
    Is there any way to truly wait for the JS to completely load?



  • I am afraid there is no other way with the current implementation of wkhtmltopdf recipe.

    I see there is another way described here
    It could be integrated into the recipe, but I am not sure if we find time for it.
    The wkhtmltopdf is quite a history.



  • What renderer would you suggest to use when we switch to JSReport 2.x?



  • What renderer would you suggest to use when we switch to JSReport 2.x?

    Definitely chrome-pdf recipe.


    In case you just want to do a dirty fix of your current problem with current jsreport, you can add somewhere to this line a code like this

    params.push('--window-status')
    params.push('ready_to_print')
    

    and to your html

    somekind.of.google.charts.finish.event = function () {
      window.status = 'ready_to_print'
    }
    


  • Thank you! I think the --window-status is already passed to the engine since it is one of the params that can be set in the designer so no need for the wkhtmltopdf.js change



  • YES! It is there. I missed it. So great, that should solve your problem.



  • yep, in testing so far seems to be working as expected, thank you!



  • Unfortunately we still experiencing this issue with google charts not showing up in some renders of the same report.
    How much likely that this will resolve if we migrate to JSReport 2.x and chrome-pdf ?



  • It is hard to say. I recommend to try it out.

    It could work that you export your data from the current instance and import it to the v2 one and then just change the recipe to chrome-pdf.
    If that won't work you can try this:

    Run the template with html recipe.
    Run a separate v2 instance.
    Copy the html and paste it to an extra template with chrome-pdf.
    Run and see. You may need to configure the print triggers there.



  • The problem is that it happens only in production and pretty intermittently but thank you for the suggestion.
    By the way, to your knowledge did anyone complained about similar problem as well?



  • Hm, maybe some issues with bing maps and phantomjs I remember but that is long time ago.
    Perhaps you can also try also another charting library if it helps.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.