[Reconnoiter-devel] [reconnoiter commit] Reconnoiter branch, master, updated. 4fceaf1d5abd353562fe27a897a3597cdceca6b3

git at labs.omniti.com git at labs.omniti.com
Mon Apr 11 11:21:56 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Reconnoiter".

The branch, master has been updated
       via  4fceaf1d5abd353562fe27a897a3597cdceca6b3 (commit)
      from  7e50a5307c7dde3ddf2578515805919083b7018f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4fceaf1d5abd353562fe27a897a3597cdceca6b3
Author: Michal Taborsky <michal at taborsky.cz>
Date:   Mon Apr 11 21:12:49 2011 +0800

    Export graph as PNG using dataUri from canvas

diff --git a/ui/web/htdocs/graph_panel.inc b/ui/web/htdocs/graph_panel.inc
index 8d58598..e162b09 100644
--- a/ui/web/htdocs/graph_panel.inc
+++ b/ui/web/htdocs/graph_panel.inc
@@ -433,6 +433,7 @@ function fetch_graph_info(id) {
 <span class="rememberGraph"></span>
 <span class="blankGraph">New Blank</span>
 <span class="exportcsv" id="exportcsvg"><a>CSV</a></span>
+<span class="exportcsv" id="exportpngg" onclick="exportCanvasAsPNG('#maingraph')">PNG</span>
 <span class="stream_controls">
 <span id="play_pause_graph">PLAY</span>
 <span id="stopstream_graph">STOP</span>
diff --git a/ui/web/htdocs/js/recon.js b/ui/web/htdocs/js/recon.js
index 12536cf..4020838 100644
--- a/ui/web/htdocs/js/recon.js
+++ b/ui/web/htdocs/js/recon.js
@@ -282,6 +282,19 @@ function my_rpn_eval(expr, meta) {
     return newvalue;
 }
 
+function exportCanvasAsPNG(startfrom) {
+	srccanvas = $(startfrom + " .plot-area canvas");
+	nc = $("<canvas width="+srccanvas.attr('width')+" height="+srccanvas.attr('height')+" />").get(0);
+	ctx = nc.getContext("2d");
+	layers = $(startfrom + " .plot-area canvas").get();
+	for (i=0; i<layers.length; i++) {
+		ctx.drawImage(layers[i],0,0);
+	}
+	
+	data = nc.toDataURL("image/png");
+	window.location = data;
+}
+
 (function($) {
     var ReconGraph = function() {
         var displayinfo = {
@@ -1207,6 +1220,7 @@ var worksheet = (function($) {
             stream_controls = get_stream_controls();
             mheader.append(stream_controls);
             mheader.append("<span class='exportcsv' id='exportcsv'><a href='"+exportcsvlink+"'>CSV</a></span>");
+            mheader.append("<span class='exportcsv' id='exportpng' onclick='exportCanvasAsPNG(\"#drawing_board\")'>PNG</span>");
             
             stream_graph.prepend(mheader);
             stream_graph.append("<div id='streambox' style='display:none'></div>");
@@ -1333,6 +1347,7 @@ var worksheet = (function($) {
                 // but apparently this snippet gets added 
                 // after the graph is refresehd, might be worth some investigation
                 mheader.append("<span class='exportcsv' id='exportcsv'><a href='"+exportcsvlink+"'>CSV</a></span>");
+                mheader.append("<span class='exportcsv' id='exportpng' onclick='exportCanvasAsPNG(\".modalData\")'>PNG</span>");
                 mheader.append(get_stream_controls());
                 
                 stream_graph.prepend(mheader);

-----------------------------------------------------------------------

Summary of changes:
 ui/web/htdocs/graph_panel.inc |    1 +
 ui/web/htdocs/js/recon.js     |   15 +++++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
Reconnoiter


More information about the Reconnoiter-devel mailing list