Printing Jchartfx chart

247 Views Asked by At

I'm not really sure on how to do this. I can get it to print by doing the code below however it comes out in black and white and there are 2 of them when I recreate the chart multiple times, but never more than two

          var PrintString = "";
           var c = $('.classcontainingChart').find('.jchartfx');
           $(c).each(function (i, chart) {
                PrintString += $(chart).html();
           });

           var PrintWindow = window.open('');
           PrintWindow.document.write(PrintString);
           PrintWindow.print();
           PrintWindow.close();
1

There are 1 best solutions below

0
On

I'm not sure on what you want here but I tried modifying your code snippet:

   var PrintString = "";
       var c = $('.classcontainingChart').find('.jchartfx');
       $(c).each(function (i, chart) {
            PrintString += $(chart).html();
       });

        var win = window.open("");
        var windowContainer = win.document;
        windowContainer.open();
        windowContainer.write("<!DOCTYPE html><html><head></head><body><div id='div1'>" + PrintString +"</div></body></html>");
        windowContainer.close();
        win.print();

And when I loaded it, I am able to see all my charts ready for print: enter image description here

Also need to make sure that popups are enabled to do this.