Morris图表导出为PDF格式? [英] Morris Graphs Export as PDF?

查看:118
本文介绍了Morris图表导出为PDF格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Morris.js创建图表。我要求将图形导出为pdf。我可以看到图形是svg元素。我该怎么做才能实现这一目标。

I am using Morris.js to create graphs. I have requirement to export graphs as pdf. I can see that graphs are svg elements. What should i do to achieve this.

推荐答案

我拿了一个Morris样本并为你做了一个小提琴:

I took one of the Morris samples and made a fiddle for you:

http://jsfiddle.net/1roLdqte/48/

我添加了一个简单的调用,只用morris图表格式化现有div:

I added a simple call to format to PDF the existing div with just the morris chart:

$('#print').click(function () {
printMe();
});
function printMe() {
  xepOnline.Formatter.Format('line-example',{render:'download', srctype:'svg'});
 }

运行小提琴并按下PDF按钮。

Run the fiddle and push the PDF button.

请注意,此处有更多参数,您可以格式化更多内容,而不仅仅是morris.js图表​​,控制页面大小,添加页眉/页脚等。这仅将图表单独(srctype:'svg')格式化为PDF作为矢量图像(不是光栅)。

Note there are many more parameters available here, you can format much more content than just the morris.js chart, control page sizes, add header/footers and such. This only formats the chart alone (srctype:'svg') to PDF as a vector image (not raster).

这篇关于Morris图表导出为PDF格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆