Home forums Using CanvasJS Graph doesn't scale when printing

This topic contains 4 replies, has 4 voices, and was last updated by  monba 1 year, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5923

    majkilde
    Participant

    Have tried with the example found here -> http://canvasjs.com/editor/?id=http://canvasjs.com/example/gallery/column/oil_reserves/
    When I print this graph, China and US are ‘cutoff’
    How do I scale the graph when printing the page?

    #5929

    Sunil Urs
    Keymaster

    Hi,

    I just observed that the issue exists on IE & Firefox. Chrome is printing properly. So one option is to use chrome for printing the same. Another option is to resize the browser width on IE/Firefox so that the chart’s width reduces slightly before taking the print.


    Sunil Urs

    #8077

    monba
    Participant

    Hi,
    I have used this library for drawing in my web page. Frame containing the chart is in a div. i want to print div content. when i use this cod, in print dialog box, i see 2 diffrent page; one of them contain the table and another one contain the chart. i want to see the chart under the table in one page. ? can anyone help me?
    the code is:

    
    <script>
    function printDiv(divName) {
         var printContents = document.getElementById(divName).innerHTML;
         var originalContents = document.body.innerHTML;
         
         var frm = document.getElementById("ifrm").contentWindow;
               frm.focus();
               frm.print();
         document.body.innerHTML = printContents+frm;
         window.print();
         document.body.innerHTML = originalContents;
    }
    </script>
    
    <div id="printableArea" >
          <table>
                ....
          </table>
          <ifram id="ifrm" name="ifrm" src="...">
                /*   frame content is the canvasjs chart     */
          </ifram>
    </div>
    <a href="" class="btn btn-primary" onclick="printDiv('printableArea')">print</a>
    
    • This reply was modified 1 year, 10 months ago by  monba.
    #8085

    Anjali
    Participant

    monba,

    Can you please try with the below code:

    function printDiv(divName) {
    	
    	   window.print();
    	
    }
    #8117

    monba
    Participant

    Hi Anjali;
    Thanks a lot.
    I wrote the code in a new page and then use window.print(); in onload=”” body tag.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.