function downloadVectorAsPng(vectorName) {
var mySvg = document.getElementById(vectorName);
var myCanvas = document.createElement('canvas');
myCanvas.style = "display: none;";
myCanvas.width = mySvg.clientWidth*5;
myCanvas.height = mySvg.clientHeight*5;
document.body.appendChild(myCanvas);
var ctx = myCanvas.getContext('2d');
var svgData = (new XMLSerializer()).serializeToString(mySvg);
var DOMURL = window.URL || window.webkitURL || window;
var img = new Image();
var svgBlob = new Blob([svgData], {type: 'image/svg+xml;charset=utf-8'});
var url = DOMURL.createObjectURL(svgBlob);
img.onload = function () {
ctx.fillStyle = "#fff";
ctx.fillRect(0, 0, myCanvas.width, myCanvas.height);
ctx.drawImage(img, 0, 0);
DOMURL.revokeObjectURL(url);
var imgURI = myCanvas
.toDataURL('image/png')
.replace('image/png', 'image/octet-stream');
var evt = new MouseEvent('click', {
view: window,
bubbles: false,
cancelable: true
});
var a = document.createElement('a');
a.setAttribute('download', 'VectorDiagram_' + new Date().toLocaleDateString() + '.png');
a.setAttribute('href', imgURI);
a.setAttribute('target', '_blank');
a.dispatchEvent(evt);
};
img.src = url;
}