Cytoscape.js
Graph theory (a.k.a. network) library for analysis and visualisation
Official site
Setup
like most drawing library, the setup processdure is same:
include the libraries
1<script src="http://cdn.bootcss.com/cytoscape/2.7.8/cytoscape.js"></script>init with a canvas
1<div id="cy"></div>using a drawing config to create a cytoscape graphic.
1var cy = window.cy = cytoscape(config)
HelloWorld
using the setup example in the official site, combine with what we mentioned up, we can setup a hello world page:
code
|
|
result
next, will only provide the changed config.
config
the config, and showed in last section, describe what(the nodes and edges) and how(styles) in the map.
elements, it contains the nodes and the edges
1elements: []layout, the layout methods, if you want to set the fixed position, using the preset:
123layout: {name: preset,}style: a list of css-style tell cy how to render objects
1style: []