我正在使用 highchart 绘制带有角度的图形:
HTML:
<highchart id="chart" class="plotchartCntr" config="chart"></highchart>
JS:
$scope.chart = {
options: {
chart: {
type: 'column'
}
},
xAxis: {
categories: [] // dynamically loaded after search
},
yAxis: {
title: {
text: 'Counts'
},
labels: {
formatter: function() {
return this.value
}
}
},
tooltip: {
crosshairs: true,
shared: true
},
series: [] // dynamically loaded after search
}
我必须将其保存为图像。
我的代码(从堆栈溢出中获得):
var canvas = document.createElement("chart");
canvas.width = 200;
canvas.height = 500;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL("image/png");
console.log(dataURL);
但我收到错误canvas.getContext is not a function
。
请建议