cytoscape vs d3-graphviz vs dagre-d3 vs gojs vs vis-network
图形和网络可视化
cytoscaped3-graphvizdagre-d3gojsvis-network类似的npm包:

图形和网络可视化

图形和网络可视化库在Web开发中扮演着重要角色,帮助开发者以直观的方式展示复杂的数据关系。这些库提供了丰富的工具和API,用于创建交互式图表、网络图和流程图,适用于数据分析、社交网络、流程管理等领域。选择合适的可视化库可以提升应用的用户体验和数据展示效果。cytoscape 是一个强大的图形可视化库,适合处理大规模网络数据,提供丰富的布局和样式选项。d3-graphviz 结合了D3.js和Graphviz,适合生成基于DOT语言的图形,特别是在需要精确控制图形布局时。dagre-d3 专注于有向无环图(DAG)的布局,适合展示层次结构和流程图。gojs 是一个商业库,提供丰富的图形和流程图功能,支持高度定制和交互,适合企业级应用。vis-network 是一个灵活的网络可视化库,支持动态数据和交互,适合展示社交网络、知识图谱等。

npm下载趋势

3 年

GitHub Stars 排名

统计详情

npm包名称
下载量
Stars
大小
Issues
发布时间
License
cytoscape011,0125.68 MB249 天前MIT
d3-graphviz01,7982.92 MB232 年前BSD-3-Clause
dagre-d302,960-2186 年前MIT
gojs08,4379.69 MB021 天前SEE LICENSE IN license.html
vis-network03,57282.7 MB34713 天前(Apache-2.0 OR MIT)

功能对比: cytoscape vs d3-graphviz vs dagre-d3 vs gojs vs vis-network

布局算法

  • cytoscape:

    cytoscape 提供多种布局算法,包括力导向布局、圆形布局、网格布局等,适合不同类型的网络结构。

  • d3-graphviz:

    d3-graphviz 利用Graphviz的布局算法(如dot、neato、circo)进行图形布局,特别适合基于DOT语言的图形。

  • dagre-d3:

    dagre-d3 专注于有向无环图(DAG)的布局,提供层次化布局算法,适合流程图和层次结构图。

  • gojs:

    gojs 提供多种布局算法,包括树布局、层次布局、力导向布局等,支持高度定制和交互。

  • vis-network:

    vis-network 提供力导向布局、层次布局等多种布局算法,支持动态调整和交互。

交互性

  • cytoscape:

    cytoscape 支持节点和边的交互,包括拖拽、缩放、点击事件等,适合构建交互式网络图。

  • d3-graphviz:

    d3-graphviz 利用D3.js的交互能力,支持缩放、平移和节点交互,但交互功能相对简单。

  • dagre-d3:

    dagre-d3 支持基本的交互功能,如缩放和平移,但主要专注于布局和渲染。

  • gojs:

    gojs 提供丰富的交互功能,包括拖拽、连接、编辑等,适合构建复杂的交互式图形和流程图。

  • vis-network:

    vis-network 支持丰富的交互功能,如节点拖拽、缩放、点击事件等,适合构建动态和交互式网络图。

定制化

  • cytoscape:

    cytoscape 提供高度的定制化能力,支持自定义节点和边的样式,允许开发者通过CSS和JavaScript进行深度定制。

  • d3-graphviz:

    d3-graphviz 允许通过D3.js进行定制,特别是在图形渲染和交互方面,但需要一定的D3.js知识。

  • dagre-d3:

    dagre-d3 支持基本的定制化,如节点和边的样式,但定制能力相对有限。

  • gojs:

    gojs 提供全面的定制化功能,支持自定义节点、边、布局和交互,适合需要高度定制的应用。

  • vis-network:

    vis-network 支持节点和边的样式定制,允许开发者通过配置和CSS进行调整,定制能力较强。

性能

  • cytoscape:

    cytoscape 在处理大规模网络时表现良好,特别是使用其优化的渲染引擎和布局算法。

  • d3-graphviz:

    d3-graphviz 性能取决于图形的复杂性和布局算法,适合中小规模的图形渲染。

  • dagre-d3:

    dagre-d3 适合中小规模的有向无环图,性能表现良好,但对于非常大的图形可能需要优化。

  • gojs:

    gojs 性能优越,适合处理复杂和大规模的图形,特别是在商业应用中。

  • vis-network:

    vis-network 在处理中等规模的网络时性能良好,支持动态数据和实时更新。

Ease of Use: Code Examples

  • cytoscape:

    cytoscape 示例:创建一个简单的网络图

    const 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: 'bc', source: 'b', target: 'c' } }
      ],
      style: [
        {
          selector: 'node',
          style: {
            'background-color': '#666',
            'label': 'data(id)'
          }
        },
        {
          selector: 'edge',
          style: {
            'width': 3,
            'line-color': '#ccc'
          }
        }
      ],
      layout: {
        name: 'grid',
        rows: 1
      }
    });
    
  • d3-graphviz:

    d3-graphviz 示例:使用DOT语言创建图形

    const graphviz = d3.select('#graph').graphviz();
    graphviz.renderDot(`
      digraph G {
        A -> B;
        B -> C;
        A -> C;
      }
    `);
    
  • dagre-d3:

    dagre-d3 示例:创建有向无环图(DAG)

    const g = new dagreD3.graphlib.Graph().setGraph({});
    g.setNode('a', { label: 'A' });
    g.setNode('b', { label: 'B' });
    g.setNode('c', { label: 'C' });
    g.setEdge('a', 'b');
    g.setEdge('b', 'c');
    const svg = d3.select('svg');
    const inner = svg.select('g');
    const render = new dagreD3.render();
    render(inner, g);
    
  • gojs:

    gojs 示例:创建简单的流程图

    const $ = go.GraphObject.make;
    const diagram = $(go.Diagram, 'myDiagramDiv', {
      'undoManager.isEnabled': true
    });
    diagram.nodeTemplate = $(go.Node, 'Auto',
      $(go.Shape, 'RoundedRectangle', { strokeWidth: 0, fill: 'lightblue' }),
      $(go.TextBlock, { margin: 8 }, new go.Binding('text', 'key'))
    );
    diagram.model = new go.GraphLinksModel([
      { key: 'Start' },
      { key: 'Process' },
      { key: 'End' }
    ], [
      { from: 'Start', to: 'Process' },
      { from: 'Process', to: 'End' }
    ]);
    
  • vis-network:

    vis-network 示例:创建交互式网络图

    const nodes = new vis.DataSet([
      { id: 1, label: 'Node 1' },
      { id: 2, label: 'Node 2' },
      { id: 3, label: 'Node 3' }
    ]);
    const edges = new vis.DataSet([
      { from: 1, to: 2 },
      { from: 1, to: 3 }
    ]);
    const container = document.getElementById('network');
    const data = { nodes, edges };
    const options = {};
    const network = new vis.Network(container, data, options);
    

如何选择: cytoscape vs d3-graphviz vs dagre-d3 vs gojs vs vis-network

  • cytoscape:

    如果您需要处理大规模网络数据,进行复杂的图形分析,并且希望拥有丰富的布局和样式选项,选择 cytoscape。它特别适合生物信息学、社交网络分析等领域。

  • d3-graphviz:

    如果您需要基于DOT语言创建图形,并且希望利用D3.js的强大功能进行定制,选择 d3-graphviz。它适合需要精确控制图形布局的应用。

  • dagre-d3:

    如果您的应用主要涉及有向无环图(DAG),例如流程图、层次结构图,选择 dagre-d3。它提供了专门针对DAG的布局算法,易于集成。

  • gojs:

    如果您需要一个功能全面、支持高度定制和交互的图形库,特别是在企业级应用中,选择 gojs。虽然是商业库,但提供了丰富的功能和支持。

  • vis-network:

    如果您需要一个开源、灵活且易于使用的网络可视化库,支持动态数据和交互,选择 vis-network。它适合展示社交网络、知识图谱等。

cytoscape的README

GitHub repo News and tutorials License npm DOI npm installs Automated tests Extensions Cloudflare

Created at the University of Toronto and published in Oxford Bioinformatics (2016, 2023).
Authored by: Max Franz, Christian Lopes, Dylan Fong, Mike Kucera, ..., Gary Bader

Cytoscape.js

Graph theory (network) library for visualisation and analysis : https://js.cytoscape.org

Description

Cytoscape.js is a fully featured graph theory library. Do you need to model and/or visualise relational data, like biological data or social networks? If so, Cytoscape.js is just what you need.

Cytoscape.js contains a graph theory model and an optional renderer to display interactive graphs. This library was designed to make it as easy as possible for programmers and scientists to use graph theory in their apps, whether it's for server-side analysis in a Node.js app or for a rich user interface.

You can get started with Cytoscape.js with one line:

var cy = cytoscape({ elements: myElements, container: myDiv });

Learn more about the features of Cytoscape.js by reading its documentation.

Example

The Tokyo railway stations network can be visualised with Cytoscape:

A live demo and source code are available for the Tokyo railway stations graph. More demos are available in the documentation.

Documentation

You can find the documentation and downloads on the project website.

Roadmap

Future versions of Cytoscape.js are planned in the milestones of the Github issue tracker. You can use the milestones to see what's currently planned for future releases.

Contributing to Cytoscape.js

Would you like to become a Cytoscape.js contributor? You can contribute in technical roles (e.g. features, testing) or non-technical roles (e.g. documentation, outreach), depending on your interests. Get in touch with us by posting a GitHub discussion.

For the mechanics of contributing a pull request, refer to CONTRIBUTING.md.

Feature releases are made monthly, while patch releases are made weekly. This allows for rapid releases of first- and third-party contributions.

Citation

To cite Cytoscape.js in a paper, please cite the Oxford Bioinformatics issue:

Cytoscape.js: a graph theory library for visualisation and analysis

Franz M, Lopes CT, Huck G, Dong Y, Sumer O, Bader GD

Bioinformatics (2016) 32 (2): 309-311 first published online September 28, 2015 doi:10.1093/bioinformatics/btv557 (PDF)

Build dependencies

Install node and npm. Run npm install before using npm run.

Build instructions

Run npm run <target> in the console. The main targets are:

Building:

  • build: do all builds of the library (umd, min, cjs, esm)
  • build:min : do the unminified build with bundled dependencies (for simple html pages, good for novices)
  • build:umd : do the umd (cjs/amd/globals) build
  • build:esm : do the esm (ES 2015 modules) build
  • clean : clean the build directory
  • docs : build the docs into documentation
  • release : build all release artifacts
  • watch : automatically build lib for debugging (with sourcemap, no babel, very quick)
    • good for general testing on debug/index.html
    • served on http://localhost:8080 or the first available port thereafter, with livereload on debug/index.html
  • watch:babel : automatically build lib for debugging (with sourcemap, with babel, a bit slower)
    • good for testing performance or for testing out of date browsers
    • served on http://localhost:8080 or the first available port thereafter, with livereload on debug/index.html
  • watch:umd : automatically build prod umd bundle (no sourcemap, with babel)
    • good for testing cytoscape in another project (with a "cytoscape": "file:./path/to/cytoscape" reference in your project's package.json)
    • no http server
  • dist : update the distribution js for npm etc.

Testing:

The default test scripts run directly against the source code. Tests can alternatively be run on a built bundle. The library can be built on node>=6, but the library's bundle can be tested on node>=0.10.

  • test : run all testing & linting
  • test:js : run the mocha tests on the public API of the lib (directly on source files)
    • npm run test:js -- -g "my test name" runs tests on only the matching test cases
  • test:build : run the mocha tests on the public API of the lib (on a built bundle)
    • npm run build should be run beforehand on a recent version of node
    • npm run test:build -- -g "my test name" runs build tests on only the matching test cases
  • test:modules : run unit tests on private, internal API
    • npm run test:modules -- -g "my test name" runs modules tests on only the matching test cases
  • lint : lint the js sources via eslint
  • benchmark : run all benchmarks
  • benchmark:single : run benchmarks only for the suite specified in benchmark/single

Release instructions

Background

  • Ensure that a milestone exists for the release you want to make, with all the issues for that release assigned in the milestone.
  • Bug fixes should be applied to both the master and unstable branches. PRs can go on either branch, with the patch applied to the other branch after merging.
  • When a patch release is made concurrently with a feature release, the patch release should be made first. Wait 5 minutes after the patch release completes before starting the feature release -- otherwise Zenodo doesn't pick up releases properly.

Patch version

  1. Go to Actions > Patch release
  2. Go to the 'Run workflow' dropdown
  3. [Optional] The 'master' branch should be preselected for you
  4. Press the green 'Run workflow' button
  5. Close the milestone for the release

Feature version

  1. Go to Actions > Feature release
  2. Go to the 'Run workflow' dropdown
  3. [Optional] The 'unstable' branch should be preselected for you
  4. Press the green 'Run workflow' button
  5. Close the milestone for the release
  6. Make the release announcement on the blog

Notes on GitHub Actions UI

  • 'Use workflow from' in the GitHub UI selects the branch from which the workflow YML file is selected. Since the workflow files should usually be the same on the master and unstable branches, it shouldn't matter what's selected.
  • 'Branch to run the action on' in the GitHub UI is preselected for you. You don't need to change it.

Tests

Mocha tests are found in the test directory. The tests can be run in the browser or they can be run via Node.js (npm run test:js).