aboutsummaryrefslogtreecommitdiff
path: root/src/map.js
blob: 4723318e9050523d1cf1a12888ccba512b511647 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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');
    }
});