aboutsummaryrefslogtreecommitdiff
path: root/src/map.js
diff options
context:
space:
mode:
authorVincent Peugnet <33429034+vincent-peugnet@users.noreply.github.com>2020-03-25 19:55:25 +0100
committerGitHub <noreply@github.com>2020-03-25 19:55:25 +0100
commita17b7fc6aa87341c51e68baf3f217f709eb817d7 (patch)
treeba6958ba93e76d2464ad9ae068b9bd56400d5294 /src/map.js
parentfa92ec6b40676677595047b71b3c2fafb1bf89ea (diff)
parentd17713051ca2fef29de8025fe876d417838cea7f (diff)
downloadwcms-a17b7fc6aa87341c51e68baf3f217f709eb817d7.tar.gz
wcms-a17b7fc6aa87341c51e68baf3f217f709eb817d7.zip
Merge pull request #72 from n-peugnet/implement-cytoscape.js
Implement cytoscape.js
Diffstat (limited to 'src/map.js')
-rw-r--r--src/map.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/map.js b/src/map.js
new file mode 100644
index 0000000..4723318
--- /dev/null
+++ b/src/map.js
@@ -0,0 +1,32 @@
+import cytoscape from 'cytoscape';
+import coseBilkent from 'cytoscape-cose-bilkent';
+
+cytoscape.use(coseBilkent);
+
+let options = {
+ container: document.getElementById('graph'),
+};
+
+Object.assign(options, data);
+
+let cy = cytoscape(options);
+
+cy.on('tap', 'node', function() {
+ try {
+ // your browser may block popups
+ window.open(this.data('id'));
+ } catch (e) {
+ // fall back on url change
+ window.location.href = this.data('id');
+ }
+});
+
+cy.on('cxttap', 'node', function() {
+ try {
+ // your browser may block popups
+ window.open(this.data('edit'));
+ } catch (e) {
+ // fall back on url change
+ window.location.href = this.data('edit');
+ }
+});