是否可以在Echarts中将图表另存为图像而无需工具箱交互?

cga*_*gat 3 echarts

我想将echart保存为图片。如果该toolbox.saveAsImage选项设置为true,我可以使用工具箱操作来保存图表。但是,我想知道是否可以通过编程方式完成?

Ovi*_*lia 10

这应该通过来实现echartsInstance.getDataURL,您可以通过设置图像格式,像素比率等。

(opts: {
    // Exporting format, can be either png, or jpeg
    type?: string,
    // Resolution ratio of exporting image, 1 by default.
    pixelRatio?: number,
    // Background color of exporting image, use backgroundColor in option by default.
    backgroundColor?: string,
    // Excluded components list. e.g. ['toolbox']
    excludeComponents?: Array.<string>
}) => string
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参见ECharts文档