Commit f5e4ead6 authored by Mikael Salson's avatar Mikael Salson

browser/js: SVG export with sample name

This is thus more similar to the previous export method.
parent 3eb36527
Pipeline #39911 failed with stages
in 5 minutes and 16 seconds
......@@ -130,8 +130,8 @@
</div>
<div class="menu_box">
<a class="buttonSelector" id="export_analysis" onclick="javascript:m.saveAnalysis()">export analysis</a>
<a class="buttonSelector" id="export_svg1" onclick="javascript:exportD3ToPNG(document.querySelector('#visu2_svg'))">export top graph</a>
<a class="buttonSelector" id="export_svg2" onclick="javascript:exportD3ToPNG(document.querySelector('#visu_svg'))">export bottom graph</a>
<a class="buttonSelector" id="export_svg1" onclick="javascript:m.exportViewToPNG(document.querySelector('#visu2_svg'))">export top graph (PNG)</a>
<a class="buttonSelector" id="export_svg2" onclick="javascript:m.exportViewToPNG(document.querySelector('#visu_svg'))">export bottom graph (PNG)</a>
<a class="buttonSelector" id="export_csv" onclick="javascript:m.exportCSV()">export csv (visible clones)</a>
<a class="buttonSelector" id="export_fasta" onclick="javascript:m.exportFasta()">export fasta (selected clones)</a>
</div>
......
......@@ -93,7 +93,7 @@ function getSVGString( svgNode ) {
}
function svgString2Image( svgString, width, height, format, callback ) {
function svgString2Image( svgString, width, height, format, name, callback ) {
var format = format ? format : 'png';
var imgsrc = 'data:image/svg+xml;base64,'+ btoa( unescape( encodeURIComponent( svgString ) ) ); // Convert SVG string to data URL
......@@ -111,7 +111,7 @@ function svgString2Image( svgString, width, height, format, callback ) {
canvas.toBlob( function(blob) {
var filesize = Math.round( blob.length/1024 ) + ' KB';
if ( callback ) callback( blob, filesize );
if ( callback ) callback( blob, filesize, name );
});
......@@ -120,11 +120,11 @@ function svgString2Image( svgString, width, height, format, callback ) {
image.src = imgsrc;
}
function saveD3ToPNG( dataBlob, filesize ){
saveAs( dataBlob, 'export.png' ); // FileSaver.js function
function saveD3ToPNG( dataBlob, filesize, filename ){
saveAs( dataBlob, filename ); // FileSaver.js function
}
function exportD3ToPNG(svgTag) {
function exportD3ToPNG(svgTag, filename) {
var svgString = getSVGString(svgTag);
svgString2Image( svgString, 2*svgTag.width.baseVal.value, 2*svgTag.height.baseVal.value, 'png', saveD3ToPNG ); // passes Blob and filesize String to the callback
svgString2Image( svgString, 2*svgTag.width.baseVal.value, 2*svgTag.height.baseVal.value, 'png', filename+'.png', saveD3ToPNG ); // passes Blob and filesize String to the callback
}
......@@ -2136,6 +2136,10 @@ changeAlleleNotation: function(alleleNotation) {
}
},
exportViewToPNG: function(tag) {
exportD3ToPNG(tag, decodeURIComponent(this.getPrintableAnalysisName().replace(/[ \/\\:]/,'_')));
},
/**
* produce an html systemBox of the given system
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment