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

Commit 3977b94

Browse files
committed
add README
1 parent 6d930b1 commit 3977b94

File tree

5 files changed

+98
-19
lines changed

5 files changed

+98
-19
lines changed

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
.vscode
88
config
99
coverage
10-
example
1110
jest.config.js
1211
LICENSE
1312
rollup.config.js

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
[![NPM](https://nodei.co/npm/@ts-graphviz/react.png)](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+
![dot](./example/example.png)
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).

example/example.png

23.4 KB
Loading

example/example.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React, { FC } from 'react';
2+
import { Digraph, Node, Subgraph, renderToDot, Edge } from '../src';
3+
4+
const Example: FC = () => (
5+
<Digraph dpi={150}>
6+
<Node id="nodeA" />
7+
8+
<Subgraph id="cluster" label="Cluster" labeljust="l">
9+
<Node id="nodeB" label="This is label for nodeB." />
10+
</Subgraph>
11+
<Edge targets={['nodeA', 'nodeB']} comment="Edge from node A to B" label={<b>A to B</b>} />
12+
</Digraph>
13+
);
14+
15+
const dot = renderToDot(<Example />);
16+
17+
// eslint-disable-next-line no-console
18+
console.log(dot);

example/sample.tsx

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)