Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Releases: ts-graphviz/react

v0.4.0 🌈

03 May 12:01
Compare
Choose a tag to compare

🚀 Features

Web Module

The Graphviz component of @ts-graphviz/react/web can be rendered directly in the browser.

Since this component uses the function of @hpcc-js/wasm internally, it is necessary to host @hpcc-js/wasm/dist/graphviz.wasm and specify its directory with wasmFolder.

For development, I recommend using the one hosted by unpkg.

import React, { FC } from 'react';
import ReactDOM from 'react-dom';
import { Digraph, Node, Edge } from '@ts-graphviz/react';
import { Graphviz } from '@ts-graphviz/react/web';
import { wasmFolder } from '@hpcc-js/wasm';

wasmFolder('https://unpkg.com/@hpcc-js/wasm/dist/');

const App: FC = () => (
  <Graphviz>
    <Digraph>
      <Node id="n1" />
      <Node id="n2" />
      <Node id="n3" />
      <Edge targets={['n1', 'n2', 'n3']} />
      <Edge targets={['n1', 'n3']} />
    </Digraph>
  </Graphviz>
);

ReactDOM.render(<App />, document.getElementById('root'));

v0.3.0 🌈

29 Apr 07:50
Compare
Choose a tag to compare

🚀 Features

Changes

v0.2.1 🌈

26 Apr 14:46
Compare
Choose a tag to compare

Changes

🚀 Features

v0.2.0 🌈

23 Apr 17:01
Compare
Choose a tag to compare

🚀 Features

Changes

Script

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

const Example: FC = () => (
  <Digraph dpi={150}>
    <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 {
  dpi = 150;
  "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>>,
  ];
  "nodeB";
  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>>,
  ];
}

example

v0.1.0 🌈

20 Apr 14:41
Compare
Choose a tag to compare

Add README.

Usage

Example

Script

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

const Example: FC = () => (
  <Digraph dpi={150}>
    <Node id="nodeA" />

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

const dot = renderToDot(<Example />);

console.log(dot);

Output dot

digraph {
  dpi = 150;
  "nodeA";
  "nodeB";
  subgraph "cluster" {
    labeljust = "l";
    label = "Cluster";
    "nodeB" [
      label = "This is label for nodeB.",
    ];
  }
  // Edge from node A to B
  "nodeA" -> "nodeB" [
    label = <<b>A to B</b>>,
  ];
}

v0.0.1 🌈

20 Apr 14:38
Compare
Choose a tag to compare

Changes