Skip to content

Commit

Permalink
Revert "Try adding copy-image functionality"
Browse files Browse the repository at this point in the history
This reverts commit 55331cd.
  • Loading branch information
mlochbaum committed Jun 28, 2020
1 parent 55331cd commit 1dadc78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
15 changes: 11 additions & 4 deletions graphtool.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ doc.html(`
</div>
<div class="miscTools">
<button id="inspector">╞ inspect</button>
<button id="label">▭ label</button>
<button id="download"><u>⇩</u> screenshot</button>
<button id="copy"><u>c</u> copy</button>
<button id="recolor">○ recolor</button>
</div>
<svg id="expandTools" viewBox="0 0 14 12">
Expand Down Expand Up @@ -316,8 +316,14 @@ dB.updatey = function (dom) {
let getFullName = p => p.dispBrand+" "+p.dispName,
getChannelName = p => n => getFullName(p) + " ("+n+")";

let labelButton = doc.select("#label"),
labelsShown = false;
function setLabelButton(l) {
labelButton.classed("selected", labelsShown = l);
}
function clearLabels() {
gr.selectAll(".lineLabel").remove();
setLabelButton(false);
}

function drawLabels() {
Expand Down Expand Up @@ -451,10 +457,13 @@ function drawLabels() {
}
g.attr("transform",(_,i)=>"translate("+tr[i].join(",")+")");
g.attr("opacity",null);
setLabelButton(true);
}

labelButton.on("click", () => (labelsShown?clearLabels:drawLabels)());

function saveGraph(ext) {
let fn = {png:saveSvgAsPng, svg:saveSvg, copy:copySvgAsPng}[ext];
let fn = {png:saveSvgAsPng, svg:saveSvg}[ext];
let showControls = s => dB.all.attr("visibility",s?null:"hidden");
gpath.selectAll("path").classed("highlight",false);
drawLabels();
Expand All @@ -479,8 +488,6 @@ doc.select("#download")
});
b.on("blur", ()=>choice.remove());
});
doc.select("#copy")
.on("click", () => saveGraph("copy"));


// Graph smoothing
Expand Down
9 changes: 0 additions & 9 deletions saveSvgAsPng.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,4 @@ THE SOFTWARE.
.then(el => out$.svgAsPngUri(el, options || {}))
.then(uri => out$.download(name, uri, downloadOpts));
};

out$.copySvgAsPng = (el, _, options) => {
return requireDomNodePromise(el)
.then(el => out$.svgAsPngUri(el, options || {}))
.then(uri => navigator.clipboard.write([
new ClipboardItem({'image/png':uriToBlob(uri)})
]))
.catch(fail=>console.error(fail));
}
})();

0 comments on commit 1dadc78

Please sign in to comment.