because my Echars is bound to div, it is not easy to print directly. It is said on the Internet that I want to convert the chart into picture format and skip pages, but the specific operation is not very detailed, and I do not quite understand how to achieve it. Then I try to bind it directly to canvas, but the page effect of Echars is gone, and the horizontal and vertical coordinates of legend information are also gone when printing. Here are the methods I currently use. So how to change it now
function print_voucher () {/ / the main method of printing
var win=window.open();
win.document.write("<br><img src=""+canvas.toDataURL("image/png")+""/>");
win.print();
win.location.reload();
}
$(function(){
var canvas=document.getElementById("bar_left");
var ctx=canvas.getContext("2d");
ctx.fillStyle="gold";
ctx.strokeStyle="blue";
ctx.lineWidth=5;
ctx.scale(2,2);
ctx.rect(50,50,100,100);
ctx.fill();
ctx.stroke();
function print_voucher(){
var win=window.open();
win.document.write("<br><img src=""+canvas.toDataURL()+""/>");
win.print();
win.location.reload();
}
$("-sharpprintVoucher").click(function(){ print_voucher(); });