gpt4 book ai didi

javascript - 使用canvas.js在单个页面中导出多个图表

转载 作者:行者123 更新时间:2023-12-01 02:33:47 25 4
gpt4 key购买 nike

我最近才开始使用canvas.js,我正在尝试创建一个包含多个图表的页面,所以我首先尝试了这个示例。 https://canvasjs.com/samples/dashboards/annual-sales/

现在我希望能够一一获取图表的图像,在执行此操作时,我遇到了一个错误,名为Uncaught TypeError: productsRevenuePieChart.exportChart2 is not a function。对于第一个图表,我能够导出它,但是当我尝试对第二个图表执行此操作时,会出现此错误。有人可以帮我吗?非常感谢

导出部分是给出错误的部分:

//chart data information

productsRevenuePieChart.render();
document.getElementById("exportChart2").addEventListener("click",function(){
productsRevenuePieChart.exportChart2({format: "jpg"});
});

//more chart data information, this part works
ordersSplineChart.render();
document.getElementById("exportChart").addEventListener("click",function(){
ordersSplineChart.exportChart({format: "jpg"});
});

//button used
<button id="exportChart2">Export Chart</button>
<button id="exportChart">Export Chart</button>

最佳答案

CanvasJS中没有exportChart2方法https://canvasjs.com/docs/charts/methods/chart/export-chart/ 。看起来,您只需从exportChart2() 中删除2 即可。

关于javascript - 使用canvas.js在单个页面中导出多个图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48105848/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com