Skip to content

Commit 40ade69

Browse files
author
fanyang
committed
docs: 官网文案和demo优化
1 parent 23c35f5 commit 40ade69

File tree

5 files changed

+19
-91
lines changed

5 files changed

+19
-91
lines changed

sites/docs/docs/api/nodeModelApi.en-US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The data attributes of a node are the data that the LogicFlow diagram data is us
3434
| type | String || Node type |
3535
| x | number || Node center x-axis coordinate |
3636
| y | number || Node center y-axis coordinates |
37-
| text | TextObject | | Node Text |
37+
| text | TextObject/String | | Node Text |
3838
| properties | Object | | Node Business Custom Attributes |
3939

4040
**TextObject**

sites/docs/docs/api/nodeModelApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ nodeModel 上节点属性有很多,由于用途不一样,我们对其进行
3434
| type | String || 节点类型 |
3535
| x | number || 节点中心 x 轴坐标 |
3636
| y | number || 节点中心 y 轴坐标 |
37-
| text | TextObject | | 节点文本 |
37+
| text | TextObject/String | | 节点文本 |
3838
| properties | Object | | 包含节点样式、形状属性和业务自定义属性 |
3939

4040
**TextObject**

sites/docs/docs/tutorial/basic-class.en-US.md

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -42,68 +42,12 @@ Inside LogicFlow, we think of a flowchart as a graph consisting of nodes and edg
4242

4343
`edges`: Contains all edges, connecting two nodes through `sourceNodeId` and `targetNodeId`. Each edge's data attributes are detailed in the <a href="../api/edgeModelApi.en-US.md#DataAttributes">EdgeModel</a>.
4444

45-
<!-- ```jsx | pure
46-
const graphData = {
47-
nodes: [
48-
{
49-
id: "node_id_1",
50-
type: "rect",
51-
x: 100,
52-
y: 100,
53-
text: { x: 100, y: 100, value: '节点1' },
54-
properties: {}
55-
},
56-
{
57-
id: "node_id_2",
58-
type: "circle",
59-
x: 200,
60-
y: 300,
61-
text: { x: 300, y: 300, value: '节点2' },
62-
properties: {}
63-
}
64-
],
65-
edges: [
66-
{
67-
id: "edge_id",
68-
type: "polyline",
69-
sourceNodeId: "node_id_1",
70-
targetNodeId: "node_id_2",
71-
text: { x: 139, y: 200, value: "连线" },
72-
startPoint: { x: 100, y: 140 },
73-
endPoint: { x: 200, y: 250 },
74-
pointsList: [ { x: 100, y: 140 }, { x: 100, y: 200 }, { x: 200, y: 200 }, { x: 200, y: 250 } ],
75-
properties: {}
76-
}
77-
]
78-
}
79-
```
80-
- Why does node text need to have coordinates, can't we just use the node's coordinates directly?
81-
82-
`text` can be used directly as a string, at this time, if it is the text of a node, we will automatically adopt the node coordinates as the node text coordinates, if it is the text of a connection, we will calculate a suitable coordinate as the node coordinates based on the different types of connections.
83-
In some application scenarios, our text can be dragged, in order to keep the consistency, our LogicFlow exported text data will take the coordinates with it.
84-
85-
86-
- Why are the connecting `startPoint`, `endPoint` data and `pointsList` duplicated?
8745

88-
Currently, LogicFlow has built-in `line`, `polyline`, and `bezier` lines, which all have `startPoint` and `endPoint` data. But the data exported by `line` will not take `pointsList` with it. For `polyline`, `pointsList` represents all points of the polyline. For `bezier`, `pointsList` represents `['start point', 'first control point', 'second control point', 'end point']`.
89-
90-
91-
- What is `properties` used for?
92-
93-
The LogicFlow of `properties` is reserved for data used in specific business scenarios.
94-
For example, in an approval flow scenario, we define a certain node, which passes, the node is green, and does not pass the node is red. Then the data description of the node could be.
95-
```jsx | pure
96-
{
97-
type: 'apply',
98-
properties: {
99-
isPass: true
100-
}
101-
}
102-
```
46+
`type`: Indicates the type of node or edge, which can be a basic type built into LogicFlow such as `rect` or `polyline`, or a custom type defined by users based on these basic types.
10347

104-
- What is `type`?
48+
`text`: `text` can represent either node text or edge text. For node text, the node coordinates are automatically used as the text coordinates. For edge text, an appropriate coordinate is computed based on the type of edge. In some scenarios, text positions can be adjusted and dragged. Therefore, our text data in LogicFlow provides coordinate attributes.
10549

106-
The `type` represents the type of the node or line, which can be not only LogicFlow's built-in base type such as `rect`, `polyline`, but also user-defined type based on the base type. -->
50+
`properties`: Each node and edge has properties including node style, shape attributes, and business-specific properties reserved for particular business scenarios. Examples include node shape attributes like `width` and `height`, `style` attributes, and business-specific properties like `isPass`.
10751

10852
## Diagram Rendering
10953

sites/docs/docs/tutorial/basic-class.md

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,15 @@ const lf = new LogicFlow({
3939

4040
<code id="graphData" src="../../src/tutorial/basic/instance/graphData"></code>
4141

42-
`nodes`: 包含所有的节点。每个节点的数据属性参见 <a href="../api/nodeModelApi.md#数据属性">nodeModel</a> 。
42+
`nodes`: 包含所有的节点。每个节点的数据属性详见 <a href="../api/nodeModelApi.md#数据属性">nodeModel</a> 。
4343

44-
`edges`: 包含所有的边,通过起始 `sourceNodeId``targetNodeId` 将两个节点相连。每个节点的数据属性参见 <a href="../api/edgeModelApi.md#数据属性">EdgeModel</a>。
44+
`edges`: 包含所有的边,通过起始 `sourceNodeId``targetNodeId` 将两个节点相连。每个边的数据属性详见 <a href="../api/edgeModelApi.md#数据属性">edgeModel</a>。
4545

46-
<!-- - 为什么节点文本还要有坐标,直接用节点的坐标不行吗?
46+
`type`: 表示节点或者边的类型,这里的类型不仅可以是`rect`,`polyline`这种LogicFlow内置的基础类型,也可以是用户基于基础类型自定义的类型。
4747

48-
`text`可以是节点文本,也可以是连线文本,如果是节点文本,默认自动采用节点坐标作为节点文本坐标,如果是连线文本,我们会基于不同的连线类型计算一个合适的坐标作为节点坐标。
49-
50-
在有些应用场景下,我们的文本位置是可以改变的和拖动的,基于此,我们LogicFlow的文本数据提供坐标属性。
48+
`text`: `text`可以是节点文本,也可以是连线文本,如果是节点文本,默认自动采用节点坐标作为节点文本坐标,如果是连线文本,我们会基于不同的连线类型计算一个合适的坐标作为节点坐标。在有些应用场景下,我们的文本位置是可以改变的和拖动的,基于此,我们LogicFlow的文本数据提供坐标属性。
5149

52-
53-
- 连线`startPoint`、`endPoint`数据和`pointsList`为什么是重复的?
54-
55-
目前,在LogicFlow内部内置了`line`, `polyline`, `bezier`三种基础连线,这三种连线都有`startPoint`、`endPoint`数据。但是其中`line`连线是不会带上`pointsList`。对于`polyline`, `pointsList`表示折线所有的点。对于`bezier`,`pointsList`表示`['起点', '第一个控制点','第二个控制点', '终点']`。
56-
57-
58-
- `properties`是用来做什么的?
59-
60-
`properties`是LogicFlow保留给具体业务场景使用的数据。
61-
例如:在审批流场景,我们定义某个节点,这个节点通过了,节点为绿色,不通过节点为红色。那么节点的数据描述可以为:
62-
```jsx | pure
63-
{
64-
type: 'apply',
65-
properties: {
66-
isPass: true
67-
}
68-
}
69-
```
70-
71-
- `type`是什么?
72-
73-
`type`表示节点或者连线的类型,这里的类型不仅可以是`rect`,`polyline`这种LogicFlow内置的基础类型,也可以是用户基于基础类型自定义的类型。 -->
50+
`properties`: 每个节点和边都有properties属性,包含节点样式、形状属性和业务自定义属性(保留给具体业务场景使用的数据),比如节点自身的形状属性`width`,`height`,样式属性`style`和业务自定义属性`isPass`等。
7451

7552
## 图渲染
7653

sites/docs/src/tutorial/basic/instance/graphData/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,22 @@ const graphData = {
1313
x: 50,
1414
y: 50,
1515
text: { x: 100, y: 100, value: '节点1' }, // 节点文本
16-
properties: {}, // 每个节点和边都有properties属性,后续会介绍到
16+
properties: {
17+
width: 80,
18+
height: 80,
19+
style: {
20+
stroke: 'blue',
21+
},
22+
isPass: 'true', //例如:在审批流场景,我们定义某个节点,这个节点通过了,节点为绿色,不通过节点为红色。
23+
},
1724
},
1825
// 节点2
1926
{
2027
id: 'node_id_2',
2128
type: 'circle',
2229
x: 200,
2330
y: 300,
24-
text: { x: 300, y: 300, value: '节点2' }, // 节点文本
31+
text: { x: 300, y: 300, value: '节点2' },
2532
properties: {},
2633
},
2734
],

0 commit comments

Comments
 (0)