-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
props.js
183 lines (179 loc) · 5.19 KB
/
props.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
* 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 { NetworkDefaultProps } from '@nivo/network'
import { motionProperties, groupProperties } from '../../../lib/componentProperties'
const props = [
{
key: 'width',
enableControlForFlavors: ['api'],
help: 'Chart width.',
description: `
Not required if using responsive component.
`,
type: 'number',
required: true,
controlType: 'range',
group: 'Base',
controlOptions: {
unit: 'px',
min: 100,
max: 1000,
step: 5,
},
},
{
key: 'height',
enableControlForFlavors: ['api'],
help: 'Chart height.',
description: `
Not required if using responsive component.
`,
type: 'number',
required: true,
controlType: 'range',
group: 'Base',
controlOptions: {
unit: 'px',
min: 100,
max: 1000,
step: 5,
},
},
{
key: 'pixelRatio',
flavors: ['canvas'],
help: `Adjust pixel ratio, useful for HiDPI screens.`,
defaultValue: 'Depends on device',
type: `number`,
controlType: 'range',
group: 'Base',
controlOptions: {
min: 1,
max: 2,
},
},
{
key: 'margin',
group: 'Base',
type: 'object',
help: 'Chart margin.',
controlType: 'margin',
group: 'Base',
},
{
key: 'linkDistance',
group: 'Simulation',
type: 'number | string | (link: Link) => number',
help: `Control links' distance.`,
description: `
If you set a **number**, this value will be used for all links.
If you use a **string**, this will be used to pick the distance
from the corresponding link property, thus, this property
should exist on each link.
If you use a **function**, it will receive a link and must return
the desired distance.
`,
},
{
key: 'repulsivity',
group: 'Simulation',
type: 'number',
help: 'Control how nodes repel each other.',
description: `
This value will also affect the strength
of \`distanceMin\` and \`distanceMax\`.
`,
controlType: 'range',
controlOptions: {
min: 1,
max: 100,
},
defaultValue: NetworkDefaultProps.repulsivity,
},
{
key: 'distanceMin',
group: 'Simulation',
type: 'number',
help: 'Sets the minimum distance between nodes for the many-body force.',
defaultValue: NetworkDefaultProps.distanceMin,
},
{
key: 'distanceMax',
group: 'Simulation',
help: 'Sets the maximum distance between nodes for the many-body force.',
defaultValue: NetworkDefaultProps.distanceMax,
},
{
key: 'iterations',
group: 'Simulation',
help: 'Adjust the simulation quality.',
description: `
Increasing this number will result in a **more accurate simulation**,
however it will also involve more computing.
`,
type: 'number',
defaultValue: NetworkDefaultProps.iterations,
controlType: 'range',
controlOptions: {
min: 60,
max: 260,
},
},
{
key: 'nodeColor',
group: 'Nodes',
type: 'string | (node: Node) => string',
help: `Control nodes' color.`,
},
{
key: 'nodeBorderWidth',
group: 'Nodes',
type: 'number | (node: Node) => number',
help: `Control nodes' border width.`,
defaultValue: NetworkDefaultProps.nodeBorderWidth,
controlType: 'lineWidth',
},
{
key: 'nodeBorderColor',
group: 'Nodes',
type: 'string | object | (link: Link) => string',
help: `Control nodes' border color.`,
defaultValue: NetworkDefaultProps.nodeBorderColor,
controlType: 'inheritedColor',
},
{
key: 'linkThickness',
enableControlForFlavors: ['canvas'],
group: 'Links',
type: 'number | (link: Link) => number',
help: `Control links' thickness.`,
defaultValue: NetworkDefaultProps.linkThickness,
controlType: 'lineWidth',
},
{
key: 'linkColor',
group: 'Links',
type: 'string | (link: Link) => string',
help: `Control links' color.`,
defaultValue: NetworkDefaultProps.linkColor,
controlType: 'inheritedColor',
controlOptions: {
inheritableProperties: ['source.color', 'target.color'],
},
},
{
key: 'layers',
group: 'Customization',
help: 'Defines the order of layers and add custom layers.',
required: false,
defaultValue: NetworkDefaultProps.layers,
},
...motionProperties(['svg'], NetworkDefaultProps),
]
export const groups = groupProperties(props)