-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9da0e36
commit 727011d
Showing
4 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,7 @@ nav: | |
## 基本介绍 | ||
|
||
<code src='./demos/node.tsx'> | ||
|
||
## DefaultNode | ||
|
||
<code src='./demos/defaultNode.tsx'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: 更新元素 | ||
group: | ||
path: /render | ||
nav: | ||
title: Graphin | ||
path: /graphin | ||
order: 1 | ||
--- | ||
|
||
<code src='./node.tsx'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import Graphin, { Utils, Behaviors, GraphinContext } from '@antv/graphin'; | ||
import { ContextMenu } from '@antv/graphin-components'; | ||
|
||
const { FitView } = Behaviors; | ||
const { Menu } = ContextMenu; | ||
|
||
const data = Utils.mock(5).circle().graphin(); | ||
const layout = { | ||
type: 'concentric', | ||
minNodeSpacing: 50, | ||
}; | ||
|
||
const UpdateNode = () => { | ||
const { graph } = React.useContext(GraphinContext); | ||
const handleChange = (option, item) => { | ||
console.log(option, item); | ||
// 方法一:直接更新,不持久化到数据中 | ||
graph.updateItem(item.id, { | ||
style: { | ||
// @ts-ignore | ||
label: { | ||
value: 'rename', | ||
}, | ||
keyshape: { | ||
size: 80, | ||
}, | ||
}, | ||
}); | ||
}; | ||
return ( | ||
<ContextMenu bindType="node"> | ||
<Menu bindType="node" options={[{ name: 'RENAME' }]} onChange={handleChange} /> | ||
</ContextMenu> | ||
); | ||
}; | ||
|
||
export default () => { | ||
return ( | ||
<div> | ||
<Graphin data={data} layout={layout}> | ||
<FitView /> | ||
<UpdateNode /> | ||
</Graphin> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters