diff --git a/web_graph_radar/static/src/js/web_graph_radar.js b/web_graph_radar/static/src/js/web_graph_radar.js
index a4e3639c..338a6c64 100644
--- a/web_graph_radar/static/src/js/web_graph_radar.js
+++ b/web_graph_radar/static/src/js/web_graph_radar.js
@@ -80,6 +80,41 @@ openerp.web_graph_radar = function(instance) {
return chart;
});
- }
+ },
+ option_selection: function (event) {
+ this._super(event);
+ if (event.currentTarget.getAttribute('data-choice') == 'export_png') {
+ var svg = document.querySelector("svg");
+
+ if (typeof window.XMLSerializer != "undefined") {
+ var svgData = (new XMLSerializer()).serializeToString(svg);
+ } else if (typeof svg.xml != "undefined") {
+ var svgData = svg.xml;
+ }
+
+ var canvas = document.createElement("canvas");
+ var svgSize = svg.getBoundingClientRect();
+ canvas.width = svgSize.width;
+ canvas.height = svgSize.height;
+ var ctx = canvas.getContext("2d");
+ //set background color
+ ctx.fillStyle = 'white';
+ //draw background / rect on entire canvas
+ ctx.fillRect(0,0,canvas.width,canvas.height);
+
+ var img = document.createElement("img");
+ img.setAttribute("src", "data:image/svg+xml;base64," + btoa(unescape(encodeURIComponent(svgData))) );
+ img.onload = function() {
+ ctx.drawImage(img, 0, 0);
+ var imgsrc = canvas.toDataURL("image/png", 1.0);
+ var a = document.createElement("a");
+ a.download = "graph"+".png";
+ a.href = imgsrc;
+ document.body.appendChild(a);
+ a.click();
+ a.remove();
+ };
+ }
+ },
});
}
diff --git a/web_graph_radar/static/src/xml/web_graph_radar.xml b/web_graph_radar/static/src/xml/web_graph_radar.xml
index 9e5bf4ac..761f15cc 100644
--- a/web_graph_radar/static/src/xml/web_graph_radar.xml
+++ b/web_graph_radar/static/src/xml/web_graph_radar.xml
@@ -9,6 +9,11 @@
+
+
+
\ No newline at end of file