fix: 修复状态文档中关于状态样式示例代码错误 (#5875)

This commit is contained in:
SevenNorth 2024-06-17 14:23:26 +08:00 committed by GitHub
parent e0b4e44358
commit fcf71e0b2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 16 deletions

View File

@ -37,18 +37,24 @@ Currently, G6 supports configuring state styles within style mappings, for examp
{
node: {
style: {/** Default State Style */},
selected: {/** Selected State Style */},
[State name]: {/** State Style */}
state: {
selected: {/** Selected State Style */},
[State name]: {/** State Style */}
}
},
edge: {
style: {/** Default State Style */},
selected: {/** Selected State Style */},
[State name]: {/** State Style */}
style: {/** Default State Style */},
state: {
selected: {/** Selected State Style */},
[State name]: {/** State Style */}
}
},
combo: {
style: {/** Default State Style */},
selected: {/** Selected State Style */},
[State name]: {/** State Style */}
state: {
selected: {/** Selected State Style */},
[State name]: {/** State Style */}
}
}
}
```
@ -136,7 +142,9 @@ To customize states, simply add them to the style mapping, for example:
{
node: {
// Custom state name: 'custom-state'
'custom-state': {/** Custom State Style */}
state: {
'custom-state': {/** Custom State Style */}
}
},
}
```

View File

@ -11,7 +11,7 @@ order: 3
## 状态类型
G6 中的状态类型是一个字符串数组(`number[]`),即一个元素可以同时存在多个状态,例如一个节点可以同时处于**选中**和**悬停**状态。
G6 中的状态类型是一个字符串数组(`string[]`),即一个元素可以同时存在多个状态,例如一个节点可以同时处于**选中**和**悬停**状态。
G6 预设的状态包括:
@ -38,18 +38,24 @@ G6 预设的状态包括:
{
node: {
style: {/** 默认状态样式 */},
selected: {/** 选中状态样式 */},
[状态名]: {/** 状态样式 */}
state: {
selected: {/** 选中状态样式 */},
[状态名]: {/** 状态样式 */}
}
},
edge: {
style: {/** 默认状态样式 */},
selected: {/** 选中状态样式 */},
[状态名]: {/** 状态样式 */}
state: {
selected: {/** 选中状态样式 */},
[状态名]: {/** 状态样式 */}
}
},
combo: {
style: {/** 默认状态样式 */},
selected: {/** 选中状态样式 */},
[状态名]: {/** 状态样式 */}
state: {
selected: {/** 选中状态样式 */},
[状态名]: {/** 状态样式 */}
}
}
}
```
@ -137,7 +143,9 @@ graph.setElementState('node-1', []);
{
node: {
// 自定义状态名为:'custom-state'
'custom-state': {/** 自定义状态样式 */}
state: {
'custom-state': {/** 自定义状态样式 */}
}
},
}
```