How to print a chart rendered by code
<p>I am using ChartJS library to generate a report at runtime, and on the page we also have a print button, the button prints a div:</p>

<pre><code>&lt;div id="printThis"&gt;
    &lt;h3 id="titulo_grafica"&gt;&lt;/h3&gt;
    &lt;canvas id="graficaMedidas" width="200" height="100"&gt;&lt;/canvas&gt;
&lt;/div&gt;
</code></pre>

<p>I dont think I need to paste the code here to render the picture, but its a nice looking line chart.</p>

<p>the javacript is this:</p>

<pre><code>  document.getElementById("btnPrint").onclick = function () {
            printElement(document.getElementById("printThis"));
            printElement(document.getElementById("printThis2"), true, "&lt;hr /&gt;");
            window.print();
        }
</code></pre>