Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add save graph as PNG to GRNsight #791

Merged
merged 5 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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