@gram-data/d3-gram
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

D3 support for the gram text format of graph data. (a)-->(b)<--(c)

How to d3-gram

d3Gram() parses text in the gram format, producing a graph of nodes and links that is ready to be used in a d3-force simulation.

import * as d3 from "d3";
import {parse, layout, draw, drag, updateNodes, updateLinks} from 'd3-gram';

d3.text("https://raw.githubusercontent.com/gram-data/d3-gram/master/public/miserables.gram").then( gramSource => {

  let graph = parse(gramSource);

  let simulation = layout(graph);

  const {nodeSelection, linkSelection} = draw(graph, "svg");

  nodeSelection.call(drag(simulation));

  simulation.on("tick", () => {
    updateNodes(nodeSelection);
    updateLinks(linkSelection);
  });
}

Readme

Keywords

Package Sidebar

Install

npm i @gram-data/d3-gram

Weekly Downloads

2

Version

0.3.1

License

MIT

Unpacked Size

1.52 MB

Total Files

26

Last publish

Collaborators

  • akollegger