cytoscape.js

Cytoscape js - Call a function whenever a node is clicked

亡梦爱人 提交于 2021-02-10 20:31:02
问题 I initialized the cytoscape like this: var cy = cytoscape({ container: document.getElementById('cy'), elements: [ { data: { id: 'a' } }, { data: { id: 'b' } }, { data: { id: 'c' } }, { data: { id: 'ab', source: 'a', target: 'b' } }, { data: { id: 'ac', source: 'a', target: 'c' } }] }); Then I added a function which adds a new node whenever the user double clicks on the viewport. var nid = 1; document.getElementById("cy").ondblclick = function(e) { cy.add({ data: { id: nid }, renderedPosition:

Cytoscape js - Call a function whenever a node is clicked

烈酒焚心 提交于 2021-02-10 20:28:04
问题 I initialized the cytoscape like this: var cy = cytoscape({ container: document.getElementById('cy'), elements: [ { data: { id: 'a' } }, { data: { id: 'b' } }, { data: { id: 'c' } }, { data: { id: 'ab', source: 'a', target: 'b' } }, { data: { id: 'ac', source: 'a', target: 'c' } }] }); Then I added a function which adds a new node whenever the user double clicks on the viewport. var nid = 1; document.getElementById("cy").ondblclick = function(e) { cy.add({ data: { id: nid }, renderedPosition:

How to listen to drag event of CytoscapeJS node (including only the one directly under the cursor/finger)

时间秒杀一切 提交于 2021-01-29 16:24:17
问题 I am using Cytoscape JS to create a web browser-based graph manipulation tool. I am facing a problem in listening the drag event of multiple selection of nodes. I could listen to 'drag' event of nodes using the following code: cy.on('drag', 'node', function (e) { let draggedNode = e.target ... } However, when I drag several nodes at once, the event is triggered to all selected nodes individually. What I want to accomplish is to listen to drag event of a node where several nodes are currently

simplest build system for cytoscape.js?

ε祈祈猫儿з 提交于 2021-01-28 14:08:58
问题 I maintain two R packages which depend on cytoscape.js (cyjShiny and RCyjs). I use webpack and npm to build a bundle, which I then combine with my relatively short R/Javascript wrapper. My problem: I return maybe twice yearly to the packages, rerun webpack, see 1000 modules install, see cryptic error reports concerning deprecated modules. Then webpack runs - which I never really understood - and if problems occur, I scratch my head till I have hacked out a path through my cognitive jungle.

How to set background image which will be zoom and drag?

◇◆丶佛笑我妖孽 提交于 2021-01-28 11:21:00
问题 I want to create a map with some nodes. Adding nodes works great but setting the background image does not. The docs don't describe, how to add something besides nodes and edges. Then I tried to add the map as a background image of a node like [this]( https://codesandbox.io/s/thirsty-hamilton-wqyvn) This solution has some problems: The edge is under the node. The docs say, that edges will be always under nodes. Z-index don't resolve the problem. The map node has a border which I don't need.

What is a proper way to remove the gray circle on panning the graph in cytoscape?

左心房为你撑大大i 提交于 2021-01-28 10:52:04
问题 I've looked into this and tried like, style: [ // the stylesheet for the graph { selector: 'core', style: { 'active-bg-size': 0 } }, on initializing the cy instance. Though it works, it gives me a compile error so I'm wondering if there's a proper or recommended way to achieve this. Would appreciate any help! 来源: https://stackoverflow.com/questions/58231913/what-is-a-proper-way-to-remove-the-gray-circle-on-panning-the-graph-in-cytoscape

Conditionnal styles for cytoscape.js graph

℡╲_俬逩灬. 提交于 2021-01-28 02:46:30
问题 I want to change the style of my graph according to global Javascript variables. For exemple, assumung my edges got name and price attributes, I would like to make the labels of edges different, depending on a global label_type variable : let lable_type = 'I_want_name_labels' switch(lable_type) { case 'I_want_name_labels': cy.style().selector('edge').style({'label': 'data(name)'}); break; case 'I_want_price_labels': cy.style().selector('edge').style({'label': 'data(price)'}); break; } The

cytoscape.js. For edge segment, transforming coordinates onto segment-distances and segment-weights

喜欢而已 提交于 2021-01-27 11:39:45
问题 I'd like to share with community an useful function that returns segment-distances and segment-weights from a coordinate (PointX, PointY). I create diagrams from tool (such as draw.io) and when making edge (segment style) with multiple waypoints, the freeware provides waypoints by its coordinates. Unfortunately latest version of cytoscape.js (at the time I wrote this post) dont include this capability (apologies if it does) and only segment-distances and segment-weights are used. Therefore I

Avoid edge-node overlapping in cytoscape.js

元气小坏坏 提交于 2021-01-27 04:26:48
问题 Created graph using cytoscape.js. I have set the layout to 'grid'. Need to resolve following problem: original graph- There is edge from Host3 to Host1 as well as from Host5 to host1,Edge from Host 5 to Host 1 overlapping the edge from Host3 to Host1. Overlapping edge should appear like: How to do it? Thanks ! 回答1: That's a research problem in graph theory. You can (1) use a different layout or parameters, or (2) develop a layout with less overlap for your specific usecase, or (3) invent and

Rendering a family tree with d3 or cytoscape

孤街浪徒 提交于 2021-01-02 06:31:25
问题 I'm having problems generating a good looking family tree with Javascript. Requirements: Each child should be connected to two parents in the tree, not one as in some graphs I've like spouses to be next to each other in the tree (same vertical position) I'd like to organize the nodes by generation vertically, so that you can see people born in the same decade at a glance. One person can have multiple spouses over time, and children with each of them Parents and children can be added freely in