@ts-graphviz/react
@ts-graphviz/react
npm i @ts-graphviz/react
@ts-graphviz/react

@ts-graphviz/react

⚛︎ Graphviz-dot Renderer using React.

by ts-graphviz

0.9.1 (see all)License:MITTypeScript:Built-In
npm i @ts-graphviz/react
Readme

NodeCI npm version License: MIT PRs Welcome tested with jest code style: prettier Open in Visual Studio Code All Contributors

@ts-graphviz/react

Graphviz-dot Renderer using React.

Installation

The module can then be installed using npm:

NPM

# yarn
$ yarn add @ts-graphviz/react react
# or npm
$ npm install -S @ts-graphviz/react react

Install React as peerDependencies at the same time.

Example

import React from 'react';
import { Digraph, Node, Subgraph, Edge, DOT, renderToDot } from '@ts-graphviz/react';

const Example = () => (
  <Digraph
    rankdir="TB"
    edge={{
      color: 'blue',
      fontcolor: 'blue',
    }}
    node={{
      shape: 'none',
    }}
  >
    <Node
      id="nodeA"
      shape="none"
      label={
        <DOT.TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
          <DOT.TR>
            <DOT.TD>left</DOT.TD>
            <DOT.TD PORT="m">middle</DOT.TD>
            <DOT.TD PORT="r">right</DOT.TD>
          </DOT.TR>
        </DOT.TABLE>
      }
    />

    <Subgraph id="cluster" label="Cluster" labeljust="l">
      <Node id="nodeB" label="This is label for nodeB." />
    </Subgraph>
    <Edge targets={['nodeB', 'nodeA:m']} comment="Edge from node A to B" label={<DOT.B>A to B</DOT.B>} />
  </Digraph>
);

const dot = renderToDot(<Example />);

console.log(dot);

Output dot

digraph {
  rankdir = "TB";
  edge [
    color = "blue",
    fontcolor = "blue",
  ];
  node [
    shape = "none",
  ];
  "nodeA" [
    shape = "none",
    label = <<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0"><TR><TD>left</TD><TD PORT="m">middle</TD><TD PORT="r">right</TD></TR></TABLE>>,
  ];
  subgraph "cluster" {
    labeljust = "l";
    label = "Cluster";
    "nodeB" [
      label = "This is label for nodeB.",
    ];
  }
  // Edge from node A to B
  "nodeB" -> "nodeA":"m" [
    label = <<B>A to B</B>>,
  ];
}

dot

See Also

Graphviz-dot Test and Integration

  • ts-graphviz
    • Graphviz library for TypeScript.
  • jest-graphviz
    • Jest matchers that supports graphviz integration.
  • setup-graphviz
    • GitHub Action to set up Graphviz cross-platform(Linux, macOS, Windows).

Contributors

Thanks goes to these wonderful people (emoji key):


Yuki Yamazaki

💻 ⚠️ 🤔 📖

nagasawaryoya

💻 ⚠️

YukiSasaki

💻 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

License

This software is released under the MIT License, see LICENSE.

No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate