7
function getImage (type, canvas, width, height) {
9
// TODO add scaling for w / h
12
data = canvas.toDataURL(mime),
18
Flotr.addPlugin('download', {
20
saveImage: function (type, width, height, replaceCanvas) {
22
if (Flotr.isIE && Flotr.isIE < 9) {
23
image = '<html><body>'+this.canvas.firstChild.innerHTML+'</body></html>';
24
return window.open().document.write(image);
27
if (type !== 'jpeg' && type !== 'png') return;
29
image = getImage(type, this.canvas, width, height);
31
if (_.isElement(image) && replaceCanvas) {
32
this.download.restoreCanvas();
35
D.setStyles({position: 'absolute'});
36
D.insert(this.el, image);
37
this.saveImageElement = image;
39
return window.open(image.src);
43
restoreCanvas: function() {
46
if (this.saveImageElement) this.el.removeChild(this.saveImageElement);
47
this.saveImageElement = null;