我在使用d3.js可视化(svg)和canvas生成dataURI时,遇到了一个问题:无法使imgGraph的onLoad处理程序在加载数据URI时触发。请帮我解决这个问题。
var canvas = document.getElementById(visual + '-canvas');
if(visual == "graph"){
console.log('graph logic n stuff')
canvas.width = 558;
canvas.height = 558;
var graph = d3.select('#graph-svg').node();
var svg_xml = (new XMLSerializer()).serializeToString(graph);
var imgGraph = new Image();
var context = canvas.getContext('2d');
var imageData;
imgGraph.onload = function(){
console.log('img loaded')
context.drawImage(imgGraph, 0, 0);
imageData = getImgData(canvas);
console.log(imageData)
def.resolve(imageData)
}
console.log('setting src')
imgGraph.src = "data:image/svg+xml;base64,"+btoa(svg_xml);
}
onerror
- 因为出现了错误。 - Jaromanda XOlivier Frère
中的è
。 - Jaromanda XAdrien Ampélas
中的é
。 - Jaromanda X