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

Added a JS lib to help download graph image #387

Merged
merged 20 commits into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a2aaebb
update IP to new node
daming-lu Apr 2, 2018
d9aec25
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 2, 2018
c8ff8a4
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 3, 2018
9996d42
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 4, 2018
f609af0
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 5, 2018
7a897fc
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 5, 2018
df70d96
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 6, 2018
da74c18
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 6, 2018
3922cd2
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 7, 2018
f274b78
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 9, 2018
1eb7a81
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 10, 2018
fdf7ab1
hardcoding styles to nodes and edges
daming-lu Apr 10, 2018
e719dfd
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 10, 2018
dba5bad
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 10, 2018
3cbf005
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 11, 2018
4f0630d
add SVG_TO_PNG download helper
daming-lu Apr 11, 2018
9526d1b
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 11, 2018
2180524
Merge branch 'develop' into svg_downloaded_shadows
daming-lu Apr 11, 2018
19f87ae
tiny
daming-lu Apr 11, 2018
29f3e78
add copyright to the author
daming-lu Apr 11, 2018
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
2 changes: 0 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"dependencies": {
"axios": "^0.16.1",
"csshint": "^0.3.3",
"cytoscape": "^3.2.11",
"cytoscape-dagre": "^2.2.0",
"d3": "^4.7.4",
"d3-format": "^1.2.1",
"dagre": "^0.8.2",
Expand Down
30 changes: 5 additions & 25 deletions frontend/src/graph/ui/Chart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
// service
import {getPluginGraphsGraph} from '../../service';

// The name 'svgToPngDownloadHelper' is just a placeholder.
// Loading the JS lib file will bind saveSvgAsPng to window.
import * as svgToPngDownloadHelper from './svgToPngDownloadHelper.js';

// for d3 drawing
import * as d3 from 'd3';

Expand All @@ -31,32 +35,8 @@ export default {
watch: {
doDownload: function(val) {
if (this.doDownload) {
// TODO(daming-lu): .svg is ugly and colorless.
let svg = this.$refs.graphSvg;

// get svg source.
let serializer = new XMLSerializer();
let source = serializer.serializeToString(svg);

// add name spaces.
if (!source.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)) {
source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"');
}
if (!source.match(/^<svg[^>]+"http\:\/\/www\.w3\.org\/1999\/xlink"/)) {
source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
}

// add xml declaration
source = '<?xml version="1.0" standalone="no"?>\r\n' + source;

// convert svg source to URI data scheme.
let url = 'data:image/svg+xml;charset=utf-8,'+encodeURIComponent(source);

let a = document.createElement('a');
a.download = 'graph.svg';
a.href = url;
a.click();

saveSvgAsPng(svg, "graph.png", {scale: 1.0});
this.$emit('triggerDownload', false);
}
},
Expand Down
Loading