-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathattributes.js
192 lines (181 loc) · 6.34 KB
/
attributes.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
184
185
186
187
188
189
190
191
192
/**
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
var fontAttrs = require('../../plots/font_attributes');
var plotAttrs = require('../../plots/attributes');
var colorAttrs = require('../../components/color/attributes');
var fxAttrs = require('../../components/fx/attributes');
var domainAttrs = require('../../plots/domain').attributes;
var extendFlat = require('../../lib/extend').extendFlat;
var overrideAll = require('../../plot_api/edit_types').overrideAll;
var attrs = module.exports = overrideAll({
domain: domainAttrs({name: 'sankey', trace: true}),
orientation: {
valType: 'enumerated',
values: ['v', 'h'],
dflt: 'h',
role: 'style',
description: 'Sets the orientation of the Sankey diagram.'
},
valueformat: {
valType: 'string',
dflt: '.3s',
role: 'style',
description: [
'Sets the value formatting rule using d3 formatting mini-language',
'which is similar to those of Python. See',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
].join(' ')
},
valuesuffix: {
valType: 'string',
dflt: '',
role: 'style',
description: [
'Adds a unit to follow the value in the hover tooltip. Add a space if a separation',
'is necessary from the value.'
].join(' ')
},
arrangement: {
valType: 'enumerated',
values: ['snap', 'perpendicular', 'freeform', 'fixed'],
dflt: 'snap',
role: 'style',
description: [
'If value is `snap` (the default), the node arrangement is assisted by automatic snapping of elements to',
'preserve space between nodes specified via `nodepad`.',
'If value is `perpendicular`, the nodes can only move along a line perpendicular to the flow.',
'If value is `freeform`, the nodes can freely move on the plane.',
'If value is `fixed`, the nodes are stationary.'
].join(' ')
},
textfont: fontAttrs({
description: 'Sets the font for node labels'
}),
node: {
label: {
valType: 'data_array',
dflt: [],
role: 'info',
description: 'The shown name of the node.'
},
color: {
valType: 'color',
role: 'style',
arrayOk: true,
description: [
'Sets the `node` color. It can be a single value, or an array for specifying color for each `node`.',
'If `node.color` is omitted, then the default `Plotly` color palette will be cycled through',
'to have a variety of colors. These defaults are not fully opaque, to allow some visibility of',
'what is beneath the node.'
].join(' ')
},
line: {
color: {
valType: 'color',
role: 'style',
dflt: colorAttrs.defaultLine,
arrayOk: true,
description: [
'Sets the color of the `line` around each `node`.'
].join(' ')
},
width: {
valType: 'number',
role: 'style',
min: 0,
dflt: 0.5,
arrayOk: true,
description: [
'Sets the width (in px) of the `line` around each `node`.'
].join(' ')
}
},
pad: {
valType: 'number',
arrayOk: false,
min: 0,
dflt: 20,
role: 'style',
description: 'Sets the padding (in px) between the `nodes`.'
},
thickness: {
valType: 'number',
arrayOk: false,
min: 1,
dflt: 20,
role: 'style',
description: 'Sets the thickness (in px) of the `nodes`.'
},
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {flags: []}),
hoverlabel: fxAttrs.hoverlabel, // needs editType override,
description: 'The nodes of the Sankey plot.'
},
link: {
label: {
valType: 'data_array',
dflt: [],
role: 'info',
description: 'The shown name of the link.'
},
color: {
valType: 'color',
role: 'style',
arrayOk: true,
description: [
'Sets the `link` color. It can be a single value, or an array for specifying color for each `link`.',
'If `link.color` is omitted, then by default, a translucent grey link will be used.'
].join(' ')
},
line: {
color: {
valType: 'color',
role: 'style',
dflt: colorAttrs.defaultLine,
arrayOk: true,
description: [
'Sets the color of the `line` around each `link`.'
].join(' ')
},
width: {
valType: 'number',
role: 'style',
min: 0,
dflt: 0,
arrayOk: true,
description: [
'Sets the width (in px) of the `line` around each `link`.'
].join(' ')
}
},
source: {
valType: 'data_array',
role: 'info',
dflt: [],
description: 'An integer number `[0..nodes.length - 1]` that represents the source node.'
},
target: {
valType: 'data_array',
role: 'info',
dflt: [],
description: 'An integer number `[0..nodes.length - 1]` that represents the target node.'
},
value: {
valType: 'data_array',
dflt: [],
role: 'info',
description: 'A numeric value representing the flow volume value.'
},
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {flags: []}),
hoverlabel: fxAttrs.hoverlabel, // needs editType override,
description: 'The links of the Sankey plot.'
},
}, 'calc', 'nested');
// hide unsupported top-level properties from plot-schema
attrs.hoverinfo = undefined;
attrs.hoverlabel = undefined;