项目作者: gmamaladze

项目描述 :
This module provides D3js compatible library to parse and load files in graphviz DOT (.dot) (graph description language) format.
高级语言: HTML
项目地址: git://github.com/gmamaladze/d3-dot-graph.git
创建时间: 2017-08-31T10:26:34Z
项目社区:https://github.com/gmamaladze/d3-dot-graph

开源协议:MIT License

下载


d3-dot-graph

This module provides D3js compatible library to parse and load files in graphviz DOT (.dot) (graph description language) format.

why?

While working on Java Platform Module System migration projects coming with Java 9 (as of August 2017), I am heavily using jdeps which is generating DOT (.dot) files. These are usually visualised using dot tool of graphviz.

In most cases it is enough, but I wanted to have nicer D3js visualisation and interaction.

example

See sample summary.dot file generated by jdeps visualised using D3js here: index.html

Inspired by Mike Bostock’s Mobile Patent Suits

usage

  1. d3.dot(url, callback);

Usage is identical with well known d3.json([url], [callback]) or d3.csv([url], [callback]).

  1. <script src="https://cdn.jsdelivr.net/gh/gmamaladze/d3-dot-graph@1.0.0/build/d3-dot-graph.min.js"></script>
  2. <script>
  3. d3.dot("/path/to/graph.dot", function(error, graph) {
  4. if (error) throw error;
  5. console.log(JSON.stringify(graph, null, true));
  6. //{
  7. // "nodes": [ {"id": "Myriel"}, {"id": "Napoleon"}],
  8. // "links": [ {"source": "Myriel"}, {"target": "Napoleon"}]
  9. //}
  10. });
  11. </script>

parser

The parser was generated using PEG.js. The grammer is taken from here cpettitt/graphlib-dot. Thanks to Chris Pettitt.

You can also use parser independently from loader and converter.

build

  1. npm install #install dependencies and build
  2. npm run build #generate parser, and rollup
  3. rollup -c -w (rollup --config --watch) #very convenient rolls the whenever sources are changed