Show the kind of relation between nodes in cytoscape.js

痞子三分冷 提交于 2019-12-10 22:47:32

问题


I am looking for a software that allows me to draw relations between entities with automatic drawing and with user interaction. I have saw cytoscape.js and it seems like a really good option, but I want to know if with this software you can visualize the name of the relations.

The objetive of the example is to draw two persons and show their relation, for example, that they are brothers.

Person1 ====== brother =====> Person2

Do I need to modify the code to do this?


回答1:


You don't need to modify the code. This functionality is already built in. You will need to know how to use the mappers and cytoscape stylesheet definitions.

If you take a look at the source of the demo that they used here, you'll see that when you're defining the cytoscape css style, you need to set the content attribute which you could then use the mappers and specify which attribute in the node/edge data you'd like to display. This is already done with the id attribute for nodes as follows:

style: cytoscape.stylesheet()
  .selector("node")
        .css({
            "content": "data(id)",
            "shape": "data(shape)",
            "border-width": 3,
            "background-color": "#DDD",
            "border-color": "#555",
        })

You can do the exact same for edges Hope this helps.



来源:https://stackoverflow.com/questions/14293474/show-the-kind-of-relation-between-nodes-in-cytoscape-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!