-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📝 docs(common): new inner shape demo
- Loading branch information
萌萌的老胖子
committed
Apr 21, 2020
1 parent
4c0519d
commit 7abb7d1
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
packages/graphin-site/examples/shape/node/demo/CanonicalShape.jsx
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,46 @@ | ||
/* eslint-disable no-undef */ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import Graphin, { Utils } from '@antv/graphin'; | ||
import '@antv/graphin/dist/index.css'; // 引入Graphin CSS | ||
|
||
/** | ||
* Graphin 内置几种预定义的节点样式,您可以根据需要选择合适的样式 | ||
*/ | ||
const INNER_SHAPES = [ | ||
'CanonicalStubNode', | ||
'CanonicalCircleNode', | ||
'CanonicalHexagonNode', | ||
'CanonicalPointNode', | ||
'CanonicalRectNode', | ||
]; | ||
|
||
const data = Utils.mock(20).random().graphin(); | ||
data.nodes = data.nodes.map((node) => { | ||
node.shape = INNER_SHAPES[Math.floor(Math.random() * INNER_SHAPES.length)]; | ||
node.style = node.style || {}; | ||
// 修改节点大小 | ||
node.style.nodeSize = 36; | ||
return node; | ||
}); | ||
data.edges = data.edges.map((edge, index) => { | ||
edge.shape = 'CanonicalLineEdge'; | ||
edge.style = edge.style || { | ||
line: {}, | ||
}; | ||
// 设置Edge虚实 | ||
edge.style.line.dash = index % 3 === 0 ? [2, 2] : null; | ||
// 设置Edge的宽度 | ||
edge.style.line.width = index % 3 === 1 ? 3 : 1; | ||
return edge; | ||
}); | ||
|
||
const App = () => { | ||
return ( | ||
<div> | ||
<Graphin data={data} /> | ||
</div> | ||
); | ||
}; | ||
const rootElement = document.getElementById('container'); | ||
ReactDOM.render(<App />, rootElement); |
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