将图表从dojo图表导出/转换为图像 [英] export/convert chart from dojo charting to image

查看:265
本文介绍了将图表从dojo图表导出/转换为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我是否可以将dojo图表对象转换成îmage文件?
我需要这个,因为我想从包含一些数据和代表图表的网页导出Excel文件。



我发现的唯一的东西是
http://dojotoolkit.org/参考指南/ dojox / gfx / utils / toSvg.html#dojox-gfx-utils-tosvg



但我真的不知道如何继续该功能的输出。



谢谢!

解决方案

只要您知道如何使用SVG(例如,使用蜡染或其他工具进行光栅化),您会发现您将会工作。主要示例将会起作用,因为任何图表对象都具有一个表面属性。所以做这样的事情:

  dojox.gfx.utils.toSvg(chart.surface).then(
函数(svg){
alert(svg);
},
函数(错误){
alert(发生错误+错误);
}
);

另一个选择是切换 dojox.gfx 进入画布模式,并直接从Canvas获取结果作为光栅图像。 Dojo没有帮助者,但是相对容易做到。


can anyone tell me if it is possible to convert a dojo charting object into an îmage file? I need this as I want to export an Excel file from a webpage containing some data and the representing chart.

The only thing I found is http://dojotoolkit.org/reference-guide/dojox/gfx/utils/toSvg.html#dojox-gfx-utils-tosvg

but I do not really know how to proceed with the output of that function.

Thanks you!

解决方案

What you found will work as long as you know what to do with SVG (e.g., rasterize it using Batik or other tools). The main example will work because any chart object has a surface property. So do something like that:

dojox.gfx.utils.toSvg(chart.surface).then(
  function(svg){
    alert(svg);
  },
  function(error){
    alert("Error occurred: " + error);
  }
);

Another alternative is to switch dojox.gfx into Canvas mode, and grab the result as a raster image directly from Canvas. There is no helper for that in Dojo, but it is relatively easy to do.

这篇关于将图表从dojo图表导出/转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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