Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add English api documents for graphs #2742

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions site/docs/options/general-properties.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: General Properties
---

> Tips: The following general properties apply to chart components. Components that do not support these properties will be specifically noted.

| Parameter | Description | Type | Default |
| ------------------- | ----------------------------------------------------------- | ------------------------------- | ------- |
| containerStyle | Configures the style of the chart container, accepts an object with CSS properties and values | `React.CSSProperties` | - |
| containerAttributes | Adds custom HTML attributes to the chart container | `Record<string, any>` | - |
| className | Adds a className to the outermost component wrapper | `string` | - |
| loading | Indicates whether the chart is in a loading state | `boolean` | `false` |
| loadingTemplate | Custom loading template, the element displayed when the chart is loading | `React.ReactElement` | - |
| errorTemplate | Custom error template, a function that returns the error information to display when the chart encounters an error | `(e: Error) => React.ReactNode` | - |
39 changes: 39 additions & 0 deletions site/docs/options/graphs/dendrogram.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: Dendrogram
order: 3
---

A dendrogram breaks down items or phenomena into a tree-like structure to systematically display their composition or internal logic.

```js
import { Dendrogram } from '@ant-design/graphs';
```

## When to Use

It is suitable for displaying hierarchical data relationships, clarifying key points of an issue, and outlining logical steps to achieve a goal.

## Code Examples

<code id="demo-dendrogram-default" src="./demos/dendrogram/default.tsx" description="A simple demonstration.">Basic Usage</code>

<code id="demo-dendrogram-direction" src="./demos/dendrogram/direction.tsx" description="Use the syntax sugar `direction` to set the arrangement of child nodes as `vertical` or `radial`. If `direction` is not set, the default is `horizontal`. Note that the label placement will adjust based on the `direction`, but if `node.style.labelPlacement` is set, it takes precedence.">Arrangement Direction</code>

<code id="demo-dendrogram-compact" src="./demos/dendrogram/compact.tsx" description="Use the `compact` configuration for compact mode.">Compact Mode</code>

<code id="demo-dendrogram-collapse-expand" src="./demos/dendrogram/collapse-expand.tsx" description="Add G6's built-in CollapseExpand interaction, allowing nodes to expand/collapse on double-click. For more built-in interactions, refer to [here](https://g6.antv.antgroup.com/en/manual/core-concept/behavior).">Expand/Collapse Nodes</code>

## API

For general configuration, refer to: [Common Graph Properties](./graphs/overview#common-graph-properties)

### Dendrogram

| Property | Description | Type | Default Value |
| --- | --- | --- | --- |
| direction | Syntax sugar to set the arrangement direction of tree nodes. When `layout.direction` is set, it takes precedence. | `'vertical'` \| `'horizontal'` \| `'radial'` | `'horizontal'` |
| compact | Whether to enable compact mode | `boolean` | `false` |
| layout | Tree layout configuration | [DendrogramLayoutOptions](https://g6.antv.antgroup.com/en/api/layouts/dendrogram-layout) | `{ type: 'dendrogram' }` |
| behaviors | Set user interaction events. Also supports G6 built-in interactions. For more configuration details, refer to [here](https://g6.antv.antgroup.com/en/api/behaviors/brush-select) | `BehaviorOptions \| ((this: Graph, behaviors: BehaviorOptions) => BehaviorOptions)` | - |
| plugins | Set canvas plugins for rendering logic and additional components. Also supports G6 built-in plugins. For more configuration details, refer to [here](https://g6.antv.antgroup.com/en/api/plugins/background) | `PluginOptions \| ((this: Graph, plugins: PluginOptions) => PluginOptions)` | - |
| transforms | Configure data transformations to handle user input and convert it into internal data flows. Also supports G6 built-in data transformers. For more configuration details, refer to [here](https://g6.antv.antgroup.com/en/api/transforms/map-node-size) | `TransformOptions \| ((this: Graph, behaviors: TransformOptions) => TransformOptions)` | - |
10 changes: 5 additions & 5 deletions site/docs/options/graphs/dendrogram.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Dendrogram } from '@ant-design/graphs';

<code id="demo-dendrogram-compact" src="./demos/dendrogram/compact.tsx" description="通过 `compact` 配置紧凑模式">紧凑模式</code>

<code id="demo-dendrogram-collapse-expand" src="./demos/dendrogram/collapse-expand.tsx" description="添加 G6 内置 CollapseExpand 交互,双击触发展开/收起。更多 G6 内置交互请查阅[此处](https://g6-next.antv.antgroup.com/manual/core-concept/behavior)。">展开/收起节点</code>
<code id="demo-dendrogram-collapse-expand" src="./demos/dendrogram/collapse-expand.tsx" description="添加 G6 内置 CollapseExpand 交互,双击触发展开/收起。更多 G6 内置交互请查阅[此处](https://g6.antv.antgroup.com/manual/core-concept/behavior)。">展开/收起节点</code>

## API

Expand All @@ -33,7 +33,7 @@ import { Dendrogram } from '@ant-design/graphs';
| --- | --- | --- | --- |
| direction | 语法糖,设置树图节点的排布方向。当设置 `layout.direction` 时会以后者为准 | `'vertical'` \| `'horizontal'` \| `'radial'` | `'horizontal'` |
| compact | 是否为紧凑模式 | `boolean` | `false` |
| layout | 树图布局配置 | [DendrogramLayoutOptions](https://g6-next.antv.antgroup.com/api/layouts/dendrogram-layout) | `{ type: 'dendrogram' }` |
| behaviors | 设置用户交互事件,同样支持 G6 内置交互,了解相关配置项请查阅[此处](https://g6-next.antv.antgroup.com/api/behaviors/brush-select) | `BehaviorOptions \| ((this: Graph, behaviors: BehaviorOptions) => BehaviorOptions)` | - |
| plugins | 设置画布插件,处理画布的渲染逻辑、额外组件渲染等,同样支持 G6 内置插件,了解相关配置项请查阅[此处](https://g6-next.antv.antgroup.com/api/plugins/background) | `PluginOptions \| ((this: Graph, plugins: PluginOptions) => PluginOptions)` | - |
| transforms | 设置数据转换,处理用户输入数据并转换为适合后续处理的内部流转数据,同样支持 G6 内置数据转换器,了解相关配置项请查阅[此处](https://g6-next.antv.antgroup.com/api/transforms/map-node-size) | `TransformOptions \| ((this: Graph, behaviors: TransformOptions) => TransformOptions)` | - |
| layout | 树图布局配置 | [DendrogramLayoutOptions](https://g6.antv.antgroup.com/api/layouts/dendrogram-layout) | `{ type: 'dendrogram' }` |
| behaviors | 设置用户交互事件,同样支持 G6 内置交互,了解相关配置项请查阅[此处](https://g6.antv.antgroup.com/api/behaviors/brush-select) | `BehaviorOptions \| ((this: Graph, behaviors: BehaviorOptions) => BehaviorOptions)` | - |
| plugins | 设置画布插件,处理画布的渲染逻辑、额外组件渲染等,同样支持 G6 内置插件,了解相关配置项请查阅[此处](https://g6.antv.antgroup.com/api/plugins/background) | `PluginOptions \| ((this: Graph, plugins: PluginOptions) => PluginOptions)` | - |
| transforms | 设置数据转换,处理用户输入数据并转换为适合后续处理的内部流转数据,同样支持 G6 内置数据转换器,了解相关配置项请查阅[此处](https://g6.antv.antgroup.com/api/transforms/map-node-size) | `TransformOptions \| ((this: Graph, behaviors: TransformOptions) => TransformOptions)` | - |
29 changes: 29 additions & 0 deletions site/docs/options/graphs/flow-direction-graph.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Flow Direction Graph
order: 6
---

Used to visually display flow paths and value changes.

```js
import { FlowDirectionGraph } from '@ant-design/graphs';
```

## When to Use

Ideal for complex information that requires clear logical relationships or decision support. It visually and clearly shows data flow and relationships, improving understanding and decision-making efficiency.

## Code Examples

<code id="demo-flow-direction-graph-default" src="./demos/flow-direction-graph/default.tsx" description="A simple demonstration.<br> Adjust `edge.style.lineWidth` via the interaction `map-edge-line-width`. It includes the following properties:<br> - `value` (number or function to compute the value of the edge)<br> - `minValue` and `maxValue` (optional, minimum and maximum values, can be numbers or functions)<br> - `minLineWidth` and `maxLineWidth` (optional, minimum and maximum line widths, can be numbers or functions)<br> - `scale` (optional, interpolation function to map values to line widths, supports `'linear'`, `'log'`, `'pow'`, `'sqrt'`, and custom interpolation functions)">Basic Usage</code>

## API

For general configuration, refer to: [Common Graph Properties](./graphs/overview#common-graph-properties)

| Property | Description | Type | Default Value |
| --- | --- | --- | --- |
| layout | AntV Dagre layout configuration | [AntVDagreLayoutOptions](https://g6.antv.antgroup.com/en/api/layouts/antv-dagre-layout) | `{ type: 'antv-dagre' }` |
| behaviors | Set user interaction events, also supports G6 built-in interactions. For more details, refer to [here](https://g6.antv.antgroup.com/en/api/behaviors/brush-select) | `BehaviorOptions \| ((this: Graph, behaviors: BehaviorOptions) => BehaviorOptions)` | - |
| plugins | Set canvas plugins to handle rendering logic and additional component rendering. Also supports G6 built-in plugins. For more details, refer to [here](https://g6.antv.antgroup.com/en/api/plugins/background) | `PluginOptions \| ((this: Graph, plugins: PluginOptions) => PluginOptions)` | - |
| transforms | Configure data transformations to process user input and convert it into internal data flows. Also supports G6 built-in transformers. For more details, refer to [here](https://g6.antv.antgroup.com/en/api/transforms/map-node-size) | `TransformOptions \| ((this: Graph, behaviors: TransformOptions) => TransformOptions)` | - |
8 changes: 4 additions & 4 deletions site/docs/options/graphs/flow-direction-graph.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { FlowDirectionGraph } from '@ant-design/graphs';

| 属性 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| layout | AntV Dagre 布局配置 | [AntVDagreLayoutOptions](https://g6-next.antv.antgroup.com/api/layouts/antv-dagre-layout) | `{ type: 'antv-dagre' }` |
| behaviors | 设置用户交互事件,同样支持 G6 内置交互,了解相关配置项请查阅[此处](https://g6-next.antv.antgroup.com/api/behaviors/brush-select) | `BehaviorOptions \| ((this: Graph, behaviors: BehaviorOptions) => BehaviorOptions)` | - |
| plugins | 设置画布插件,处理画布的渲染逻辑、额外组件渲染等,同样支持 G6 内置插件,了解相关配置项请查阅[此处](https://g6-next.antv.antgroup.com/api/plugins/background) | `PluginOptions \| ((this: Graph, plugins: PluginOptions) => PluginOptions)` | - |
| transforms | 设置数据转换,处理用户输入数据并转换为适合后续处理的内部流转数据,同样支持 G6 内置数据转换器,了解相关配置项请查阅[此处](https://g6-next.antv.antgroup.com/api/transforms/map-node-size) | `TransformOptions \| ((this: Graph, behaviors: TransformOptions) => TransformOptions)` | - |
| layout | AntV Dagre 布局配置 | [AntVDagreLayoutOptions](https://g6.antv.antgroup.com/api/layouts/antv-dagre-layout) | `{ type: 'antv-dagre' }` |
| behaviors | 设置用户交互事件,同样支持 G6 内置交互,了解相关配置项请查阅[此处](https://g6.antv.antgroup.com/api/behaviors/brush-select) | `BehaviorOptions \| ((this: Graph, behaviors: BehaviorOptions) => BehaviorOptions)` | - |
| plugins | 设置画布插件,处理画布的渲染逻辑、额外组件渲染等,同样支持 G6 内置插件,了解相关配置项请查阅[此处](https://g6.antv.antgroup.com/api/plugins/background) | `PluginOptions \| ((this: Graph, plugins: PluginOptions) => PluginOptions)` | - |
| transforms | 设置数据转换,处理用户输入数据并转换为适合后续处理的内部流转数据,同样支持 G6 内置数据转换器,了解相关配置项请查阅[此处](https://g6.antv.antgroup.com/api/transforms/map-node-size) | `TransformOptions \| ((this: Graph, behaviors: TransformOptions) => TransformOptions)` | - |
37 changes: 37 additions & 0 deletions site/docs/options/graphs/flow-graph.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: Flow Graph
order: 5
---

Used to visually represent the steps and decision points of a process or system.

```js
import { FlowGraph } from '@ant-design/graphs';
```

## When to Use

A flowchart shows the entire process from start to finish. Each node represents a specific step or decision point, and the edges indicate the sequence and relationships between steps.

- Suitable for scenarios that require displaying linear processes or steps.
- Useful for planning and tracking project progress, clarifying task order and dependencies.
- Ideal for building decision trees, showing different decision points and paths.

## Code Examples

<code id="demo-flow-graph-default" src="./demos/flow-graph/default.tsx" description="A simple demonstration.">Basic Usage</code>

<code id="demo-flow-graph-hover" src="./demos/flow-graph/hover-activate-chain.tsx" description="By adding hover-highlight interaction (registered as `hover-activate-chain`), elements and their associated chains are highlighted on hover.">Highlight Elements and Their Chains</code>

<code id="demo-flow-graph-custom-node" src="./demos/flow-graph/custom-node.tsx" description="Customize nodes using `node.component`, which needs to be paired with `node.size` to work properly.">Custom Nodes</code>

## API

For general configuration, refer to: [Common Graph Properties](./graphs/overview#common-graph-properties)

| Property | Description | Type | Default Value |
| --- | --- | --- | --- |
| layout | AntV Dagre layout configuration | [AntVDagreLayoutOptions](https://g6.antv.antgroup.com/en/api/layouts/antv-dagre-layout) | `{ type: 'antv-dagre' }` |
| behaviors | Set user interaction events, also supports G6 built-in interactions. For more details, refer to [here](https://g6.antv.antgroup.com/en/api/behaviors/brush-select) | `BehaviorOptions \| ((this: Graph, behaviors: BehaviorOptions) => BehaviorOptions)` | - |
| plugins | Set canvas plugins to handle rendering logic and additional component rendering. Also supports G6 built-in plugins. For more details, refer to [here](https://g6.antv.antgroup.com/en/api/plugins/background) | `PluginOptions \| ((this: Graph, plugins: PluginOptions) => PluginOptions)` | - |
| transforms | Configure data transformations to process user input and convert it into internal data flows. Also supports G6 built-in transformers. For more details, refer to [here](https://g6.antv.antgroup.com/en/api/transforms/map-node-size) | `TransformOptions \| ((this: Graph, behaviors: TransformOptions) => TransformOptions)` | - |
8 changes: 4 additions & 4 deletions site/docs/options/graphs/flow-graph.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { FlowGraph } from '@ant-design/graphs';

| 属性 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| layout | AntV Dagre 布局配置 | [AntVDagreLayoutOptions](https://g6-next.antv.antgroup.com/api/layouts/antv-dagre-layout) | `{ type: 'antv-dagre' }` |
| behaviors | 设置用户交互事件,同样支持 G6 内置交互,了解相关配置项请查阅[此处](https://g6-next.antv.antgroup.com/api/behaviors/brush-select) | `BehaviorOptions \| ((this: Graph, behaviors: BehaviorOptions) => BehaviorOptions)` | - |
| plugins | 设置画布插件,处理画布的渲染逻辑、额外组件渲染等,同样支持 G6 内置插件,了解相关配置项请查阅[此处](https://g6-next.antv.antgroup.com/api/plugins/background) | `PluginOptions \| ((this: Graph, plugins: PluginOptions) => PluginOptions)` | - |
| transforms | 设置数据转换,处理用户输入数据并转换为适合后续处理的内部流转数据,同样支持 G6 内置数据转换器,了解相关配置项请查阅[此处](https://g6-next.antv.antgroup.com/api/transforms/map-node-size) | `TransformOptions \| ((this: Graph, behaviors: TransformOptions) => TransformOptions)` | - |
| layout | AntV Dagre 布局配置 | [AntVDagreLayoutOptions](https://g6.antv.antgroup.com/api/layouts/antv-dagre-layout) | `{ type: 'antv-dagre' }` |
| behaviors | 设置用户交互事件,同样支持 G6 内置交互,了解相关配置项请查阅[此处](https://g6.antv.antgroup.com/api/behaviors/brush-select) | `BehaviorOptions \| ((this: Graph, behaviors: BehaviorOptions) => BehaviorOptions)` | - |
| plugins | 设置画布插件,处理画布的渲染逻辑、额外组件渲染等,同样支持 G6 内置插件,了解相关配置项请查阅[此处](https://g6.antv.antgroup.com/api/plugins/background) | `PluginOptions \| ((this: Graph, plugins: PluginOptions) => PluginOptions)` | - |
| transforms | 设置数据转换,处理用户输入数据并转换为适合后续处理的内部流转数据,同样支持 G6 内置数据转换器,了解相关配置项请查阅[此处](https://g6.antv.antgroup.com/api/transforms/map-node-size) | `TransformOptions \| ((this: Graph, behaviors: TransformOptions) => TransformOptions)` | - |
Loading
Loading