cytoscape.js

Show and hide node info on mouseover in cytoscape

不羁岁月 提交于 2020-01-13 10:28:06
问题 I am working on a cytoscape.js graph in browser. I want to show some information of nodes (e.g. node label) as the mouse hovers over the nodes in a cytoscape graph. The following code is working for console.log() but I want to show the information in the browser: cy.on('mouseover', 'node', function(evt){ var node = evt.target; console.log( 'mouse on node' + node.data('label') ); }); Please help ! 回答1: Cytoscape.js has popper.js with tippy. I can give you a working exapmle for popper.js:

Unlock nodes on grab/mousedown event, can not move them immediately in Cytoscape.js

时间秒杀一切 提交于 2020-01-05 11:03:48
问题 At first all my nodes are locked . I would like to unlock all of them on drag event. I tried the following solution with no success: cy.nodes().on('grab', function() { cy.nodes().unlock(); }); I realized that 'grab' event does not occur on locked nodes , so I changed it to 'mousedown' instead . Now if I click on a node and hold it, every node unlocks as expected, but I can not move immediately the node I clicked, I have to release the button then drag the node again. Is there a solution to

Cytoscape dynamically style last added node only

允我心安 提交于 2020-01-04 14:17:17
问题 I'm in the beginning phase of using Cytoscape.js and I'm trying to style the last added node to my dagre-layout tree. For context, I'm trying to visualize the Git workflow as I make a Git commit. The current nodes on the tree are colored green. When I make a Git commit, a new node will be added to the end of the Git (dagre) tree with a color of red. Once I make another commit, a new red node will be added... but I want the previous node that was red, to be green like the other nodes. cy.add([

Export cytoscape graph as png image: how to put png tag on cytoscape graph

微笑、不失礼 提交于 2020-01-04 07:57:25
问题 I an novice in js and cytoscape. I want to display cytoscape graph in server with an save button for saving it as png. I checked cytoscape documentation but did not understand how to put an image tag on cytoscape graph. Please help me. I checked earlier posts in stackoverflow and github also. My js script is here : $(function(){ // var cy = cytoscape({ container: document.getElementById('cy'), style: cytoscape.stylesheet() .selector('node') .css({ 'label': 'data(label)', 'width': '60px',

Export selected node and edge in cytoscape.js

瘦欲@ 提交于 2020-01-04 04:33:29
问题 is there a way that I can export selected node and edge from graph and display the selected ones in another graph. maxkfranz said that we can export as json. Do you have any idea how I can do that? Thanks。 回答1: Have you tried something along the lines of: cy.$(':selected').json() Edit : The API now also allows for multiple elements, e.g. cy.$(':selected').jsons() 来源: https://stackoverflow.com/questions/19620146/export-selected-node-and-edge-in-cytoscape-js

Styling edges in Cytoscape.js for a Family Tree

你说的曾经没有我的故事 提交于 2020-01-03 01:35:07
问题 I have a Family Tree application that uses Django and I am trying to use http://js.cytoscape.org for the UI. I would like to style edges between romantic partners like this: http://www.eprintablecalendars.com/images/arts-and-crafts/family-tree.jpg which is what you commonly see (the square-U). I am completely new to Cytoscape.js, and haven't been able to find any answers in the docs or other threads. 回答1: What you're describing is not edges but hyperedges. A hyperedge has multiple sources and

How to dynamically add nodes to cytoscape graph

心不动则不痛 提交于 2019-12-31 02:35:05
问题 Is there a way to add nodes and edges to Cytoscape graph with concentric layout? Cy.add() function adds the nodes and edges to the graph without the init styling. Only way I can this, is by building the graph everytime I add a new node or edge 回答1: When you add a node, it is positioned where you specify -- in the position field in its JSON. If you don't want to manually specify a position, then run a layout. In your specific case, you should probably be running the concentric layout again

Cytoscape position ignored if locked: false

倖福魔咒の 提交于 2019-12-25 16:57:37
问题 When I add a position property on a node, it is ignored unless I also specify locked: true. I would like to specify initial positions on some nodes, yet still allow the user to move those nodes around. Related (I think) - is there a way to let Cytoscape use a layout to determine node positions, then do a second pass and change them for any nodes that have a position property specified? It would also work to have the layout ignore or not process any nodes that have positions specified. That's

Node clustering with Cytoscape.js

99封情书 提交于 2019-12-25 09:27:41
问题 Does anyone know if it is possible to do clustering in the way that vis.js supports it with cytoscape.js? Here are some examples: http://visjs.org/examples/network/other/clusteringByZoom.html http://visjs.org/examples/network/other/clustering.html The basic idea is that a node can represent a cluster of child nodes and zooming or double clicking on the node will "explode" it to show all the children. 回答1: You can achieve the same effect using cy.on('zoom') with cy.add() and cy.remove() . That

Perform Centrality Functions on all Nodes using Cytoscape.js

跟風遠走 提交于 2019-12-25 08:01:28
问题 I need to calculate degree, closeness and betweenness centrality for every node on a graph. I'm currently using the functions built into Cytoscape.js on each node after the cy.ready() event. However, as the graphs are quite large (250+ Nodes, 650+ Connections) it's taking too long to compute. Can anyone suggest a more efficient method? var calculateSNA = function() { // Don't run if already set... if(data.sna) return false console.log('Running SNA') _.map(nodes, function(node) { var target =