|
| 1 | +# @ts-graphviz/react |
| 2 | + |
| 3 | +Graphviz-dot Renderer for React. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +The module can then be installed using [npm](https://www.npmjs.com/): |
| 8 | + |
| 9 | +[](https://nodei.co/npm/@ts-graphviz/react/) |
| 10 | + |
| 11 | +```bash |
| 12 | +# yarn |
| 13 | +$ yarn add @ts-graphviz/react |
| 14 | +# or npm |
| 15 | +$ npm install @ts-graphviz/react |
| 16 | +``` |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +### Example |
| 21 | + |
| 22 | +#### Script |
| 23 | + |
| 24 | +```typescript-react |
| 25 | +import React, { FC } from 'react'; |
| 26 | +import { Digraph, Node, Subgraph, renderToDot, Edge } from '../src'; |
| 27 | +
|
| 28 | +const Example: FC = () => ( |
| 29 | + <Digraph dpi={150}> |
| 30 | + <Node id="nodeA" /> |
| 31 | +
|
| 32 | + <Subgraph id="cluster" label="Cluster" labeljust="l"> |
| 33 | + <Node id="nodeB" label="This is label for nodeB." /> |
| 34 | + </Subgraph> |
| 35 | + <Edge targets={['nodeA', 'nodeB']} comment="Edge from node A to B" label={<b>A to B</b>} /> |
| 36 | + </Digraph> |
| 37 | +); |
| 38 | +
|
| 39 | +const dot = renderToDot(<Example />); |
| 40 | +
|
| 41 | +console.log(dot); |
| 42 | +``` |
| 43 | + |
| 44 | +#### Output dot |
| 45 | + |
| 46 | +```graphviz |
| 47 | +digraph { |
| 48 | + dpi = 150; |
| 49 | + "nodeA"; |
| 50 | + "nodeB"; |
| 51 | + subgraph "cluster" { |
| 52 | + labeljust = "l"; |
| 53 | + label = "Cluster"; |
| 54 | + "nodeB" [ |
| 55 | + label = "This is label for nodeB.", |
| 56 | + ]; |
| 57 | + } |
| 58 | + // Edge from node A to B |
| 59 | + "nodeA" -> "nodeB" [ |
| 60 | + label = <<b>A to B</b>>, |
| 61 | + ]; |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +## See Also |
| 68 | + |
| 69 | +Graphviz-dot Test and Integration |
| 70 | + |
| 71 | +- [ts-graphviz](https://github.com/ts-graphviz/ts-graphviz) |
| 72 | + - Graphviz library for TypeScript. |
| 73 | +- [jest-graphviz](https://github.com/ts-graphviz/jest-graphviz) |
| 74 | + - Jest matchers that supports graphviz integration. |
| 75 | +- [setup-graphviz](https://github.com/kamiazya/setup-graphviz) |
| 76 | + - GitHub Action to set up Graphviz cross-platform(Linux, macOS, Windows). |
| 77 | + |
| 78 | +## License |
| 79 | + |
| 80 | +This software is released under the MIT License, see [LICENSE](./LICENSE). |
0 commit comments