Skip to content

Commit

Permalink
Merge pull request #791 from dondi/mihirsamdarshi
Browse files Browse the repository at this point in the history
Add save graph as PNG to GRNsight
  • Loading branch information
dondi authored Aug 12, 2019
2 parents ddbbcb8 + ccdca31 commit 1bbc4ce
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,13 @@ coverage/
*.synctex.gz

.vscode

*.tmp

# Microsoft Office temporary files
~$*.doc*
Backup of *.doc*
~$*.xls*
*.xlk
~$*.ppt*
*.~vsd*
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"node-xlsx": "0.7.2",
"nodemon": "1.11.0",
"parallelshell": "3.0.1",
"save-svg-as-png": "^1.4.14",
"serve-static": "1.13.1",
"should": "11.2.0",
"stylus": "0.54.5",
Expand Down
2 changes: 2 additions & 0 deletions web-client/public/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const SCHADE_OUTPUT_ID = "#schadeOutput";
export const SCHADE_OUTPUT_PATH = "demo/schadeOutput";
export const SCHADE_OUTPUT_NAME = "Demo #4: Weighted GRN (21 genes, 31 edges, Schade et al. 2004 data)";

export const SAVE_IMAGE = "#saveImage";

export const DEMO_INFORMATION = [
[ WEIGHTED_DEMO_ID, WEIGHTED_DEMO_PATH, WEIGHTED_DEMO_NAME ],
[ UNWEIGHTED_DEMO_ID, UNWEIGHTED_DEMO_PATH, UNWEIGHTED_DEMO_NAME ],
Expand Down
12 changes: 10 additions & 2 deletions web-client/public/js/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import {
ZOOM_PERCENT,
ZOOM_SLIDER,
ZOOM_DISPLAY_MINIMUM_VALUE,
ZOOM_DISPLAY_MAXIMUM_VALUE
ZOOM_DISPLAY_MAXIMUM_VALUE,
SAVE_IMAGE
} from "./constants";

import { saveSvgAsPng } from "save-svg-as-png";

/* globals d3 */
/* eslint-disable no-use-before-define, func-style */
/*
Expand Down Expand Up @@ -193,7 +196,8 @@ export var drawGraph = function (network) {

var svg = d3.select($container[0]).append("svg")
.attr("width", width)
.attr("height", height);
.attr("height", height)
.attr("id", "exportContainer");

var zoomContainer = svg.append("g") // required for zoom to work
.attr("class", "boundingBox")
Expand Down Expand Up @@ -1460,4 +1464,8 @@ export var drawGraph = function (network) {
modifyLinkDistanceParameter(grnState.linkDistanceSlider.currentVal);

$(".startDisabled").removeClass("disabled");

$(SAVE_IMAGE).click(() => {
saveSvgAsPng(document.getElementById("exportContainer"), grnState.name + ".png");
});
};
5 changes: 5 additions & 0 deletions web-client/views/upload.jade
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ html
a(href='#' id='printGraph')
span(class='glyphicon glyphicon-print')
|   Print
li(class='divider')
li(class=' startDisabled disabled')
a(href='#' id='saveImage')
span(class='glyphicon glyphicon-picture')
|   Save Graph As PNG

li(class='dropdown')
a(href='#' class='dropdown-toggle' data-toggle='dropdown') View
Expand Down

0 comments on commit 1bbc4ce

Please sign in to comment.