-
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
45a730f
commit 0886341
Showing
2 changed files
with
95 additions
and
26 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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import * as React from 'react'; | ||
import Graphin, { Utils } from '@antv/graphin'; | ||
import iconsLoader from '@antv/graphin-icons'; | ||
import { Legend } from '@antv/graphin-components'; | ||
|
||
const icons = Graphin.registerFontFamily(iconsLoader); | ||
|
||
const data = Utils.mock(5).circle().graphin(); | ||
|
||
const Color = { | ||
company: { | ||
primaryColor: '#ffc107', | ||
secondaryColor: Utils.hexToRgba('#ffc107', '0.2'), | ||
}, | ||
person: { | ||
primaryColor: '#28a52d', | ||
secondaryColor: Utils.hexToRgba('#28a52d', '0.2'), | ||
}, | ||
}; | ||
data.nodes.forEach((node, index) => { | ||
const isCompany = index % 3 === 0; | ||
node.data.type = isCompany ? 'company' : 'person'; | ||
const iconType = node.data.type; | ||
node.type = 'graphin-circle'; | ||
|
||
node.style = { | ||
keyshape: { | ||
stroke: Color[iconType].primaryColor, | ||
size: [30], | ||
fill: Color[iconType].secondaryColor, | ||
}, | ||
icon: { | ||
type: 'font', | ||
fontFamily: 'graphin', | ||
value: isCompany ? icons.company : icons.user, | ||
size: 14, | ||
fill: Color[iconType].primaryColor, | ||
}, | ||
status: { | ||
active: { | ||
halo: { | ||
visible: false, | ||
}, | ||
keyshape: { | ||
lineWidth: 8, | ||
}, | ||
}, | ||
inactive: { | ||
halo: { | ||
visible: false, | ||
}, | ||
keyshape: { | ||
fill: '#eee', | ||
stroke: '#eee', | ||
}, | ||
icon: { | ||
fill: '#eee', | ||
}, | ||
}, | ||
}, | ||
}; | ||
}); | ||
|
||
const Demo = () => { | ||
return ( | ||
<Graphin data={data}> | ||
<Legend bindType="node" sortKey="data.type" colorKey="style.keyshape.stroke"> | ||
<Legend.Node /> | ||
</Legend> | ||
</Graphin> | ||
); | ||
}; | ||
|
||
export default Demo; |
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