Changeset 4fceaf1d5abd353562fe27a897a3597cdceca6b3

Show
Ignore:
Timestamp:
04/11/11 15:21:44 (3 years ago)
Author:
Theo Schlossnagle <jesus@lethargy.org>
git-committer:
Theo Schlossnagle <jesus@lethargy.org> 1302535304 +0800
git-parent:

[7e50a5307c7dde3ddf2578515805919083b7018f]

git-author:
Michal Taborsky <michal@taborsky.cz> 1302527569 +0800
Message:

Export graph as PNG using dataUri from canvas

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ui/web/htdocs/graph_panel.inc

    r7e50a53 r4fceaf1  
    434434<span class="blankGraph">New Blank</span> 
    435435<span class="exportcsv" id="exportcsvg"><a>CSV</a></span> 
     436<span class="exportcsv" id="exportpngg" onclick="exportCanvasAsPNG('#maingraph')">PNG</span> 
    436437<span class="stream_controls"> 
    437438<span id="play_pause_graph">PLAY</span> 
  • ui/web/htdocs/js/recon.js

    r7e50a53 r4fceaf1  
    281281    var newvalue = s.shift(); 
    282282    return newvalue; 
     283} 
     284 
     285function exportCanvasAsPNG(startfrom) { 
     286        srccanvas = $(startfrom + " .plot-area canvas"); 
     287        nc = $("<canvas width="+srccanvas.attr('width')+" height="+srccanvas.attr('height')+" />").get(0); 
     288        ctx = nc.getContext("2d"); 
     289        layers = $(startfrom + " .plot-area canvas").get(); 
     290        for (i=0; i<layers.length; i++) { 
     291                ctx.drawImage(layers[i],0,0); 
     292        } 
     293         
     294        data = nc.toDataURL("image/png"); 
     295        window.location = data; 
    283296} 
    284297 
     
    12081221            mheader.append(stream_controls); 
    12091222            mheader.append("<span class='exportcsv' id='exportcsv'><a href='"+exportcsvlink+"'>CSV</a></span>"); 
     1223            mheader.append("<span class='exportcsv' id='exportpng' onclick='exportCanvasAsPNG(\"#drawing_board\")'>PNG</span>"); 
    12101224             
    12111225            stream_graph.prepend(mheader); 
     
    13341348                // after the graph is refresehd, might be worth some investigation 
    13351349                mheader.append("<span class='exportcsv' id='exportcsv'><a href='"+exportcsvlink+"'>CSV</a></span>"); 
     1350                mheader.append("<span class='exportcsv' id='exportpng' onclick='exportCanvasAsPNG(\".modalData\")'>PNG</span>"); 
    13361351                mheader.append(get_stream_controls()); 
    13371352