我'與角繪製的圖表:如何highchart轉換成二進制圖像使用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
。
請建議
請把代碼上的jsfiddle/plunker –