-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
canvas.js
76 lines (68 loc) · 2.18 KB
/
canvas.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React from 'react'
import { ResponsiveNetworkCanvas, NetworkCanvasDefaultProps } from '@nivo/network'
import ComponentTemplate from '../../components/components/ComponentTemplate'
import meta from '../../data/components/network/meta.yml'
import { groups } from '../../data/components/network/props'
import { generateData } from '../../data/components/network/generator'
const initialProperties = Object.freeze({
pixelRatio:
typeof window !== 'undefined' && window.devicePixelRatio ? window.devicePixelRatio : 1,
margin: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
linkDistance: 'distance',
repulsivity: 4,
iterations: 60,
nodeColor: node => node.color,
nodeBorderWidth: 1,
nodeBorderColor: { theme: 'background' },
linkColor: NetworkCanvasDefaultProps.linkColor,
linkThickness: 1,
isInteractive: true,
})
const NetworkCanvas = () => {
return (
<ComponentTemplate
name="NetworkCanvas"
meta={meta.NetworkCanvas}
icon="network"
flavors={meta.flavors}
currentFlavor="canvas"
properties={groups}
initialProperties={initialProperties}
defaultProperties={NetworkCanvasDefaultProps}
generateData={() =>
generateData({
rootNodeRadius: 10,
maxMidNodes: 32,
midNodeRadius: 6,
leafRadius: 3,
})
}
getDataSize={data => data.nodes.length}
>
{(properties, data, theme, logAction) => {
return (
<ResponsiveNetworkCanvas
nodes={data.nodes}
links={data.links}
{...properties}
theme={theme}
/>
)
}}
</ComponentTemplate>
)
}
export default NetworkCanvas