简体   繁体   English

如何打印角度图

[英]How to print angular-chart

I am using "angular-chart.js" 我正在使用“ angular-chart.js”

and want to print this chart. 并希望打印此图表。 My code is, 我的代码是

<html>
<head>Chart</head>
<body>
    <div class="row"><b>Patient Report</b>
        <div>
            <canvas id="line" class="chart chart-line" data="agedata" colours="colours"
                labels="labels" legend="true" series="series"click="onClick"></canvas>
        </div>
    </div>
    <div class="row">
        <a href="javascript:window.print()" class="btn btn-success">Print</a>
    </div>
</body>

But it prints nothing. 但是它什么也不打印。 Can Anyone suggest me methods to print chart? 有人可以建议我打印图表的方法吗?

You can use the toDataURL() to make the canvas into an image (and you could use media specific CSS to hide the canvas and swap in the img with src as the Data URL when printing) 您可以使用toDataURL()将画布变成图像(并且可以使用特定于媒体的CSS隐藏画布,并在打印时以src作为数据URL交换img中的img)

Remember to wait for the animation to end before generating the data URI or you end up with a blank image. 请记住,在生成数据URI之前要等待动画结束,否则最终将得到空白图像。

Chart.js relies on a HTML5 canvas to render its charts however canvas objects cannot be printed by browsers. Chart.js依靠HTML5画布呈现其图表,但是浏览器无法打印画布对象。
The solution to bypass this limitation is to transform the canvas into an image when printing as described in this post . 绕过这个限制的解决方案是如描述在打印时画布变换成图像此篇

Cheers, 干杯,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM