forked from plotly/plotly.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattributes.js
178 lines (167 loc) · 5.75 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
/**
* Copyright 2012-2017, 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 scatterAttrs = require('../scatter/attributes');
var colorAttributes = require('../../components/colorscale/color_attributes');
var errorBarAttrs = require('../../components/errorbars/attributes');
var DASHES = require('../../constants/gl3d_dashes');
var MARKER_SYMBOLS = require('../../constants/gl_markers');
var extendFlat = require('../../lib/extend').extendFlat;
var scatterLineAttrs = scatterAttrs.line,
scatterMarkerAttrs = scatterAttrs.marker,
scatterMarkerLineAttrs = scatterMarkerAttrs.line;
function makeProjectionAttr(axLetter) {
return {
show: {
valType: 'boolean',
role: 'info',
dflt: false,
description: [
'Sets whether or not projections are shown along the',
axLetter, 'axis.'
].join(' ')
},
opacity: {
valType: 'number',
role: 'style',
min: 0,
max: 1,
dflt: 1,
description: 'Sets the projection color.'
},
scale: {
valType: 'number',
role: 'style',
min: 0,
max: 10,
dflt: 2 / 3,
description: [
'Sets the scale factor determining the size of the',
'projection marker points.'
].join(' ')
}
};
}
module.exports = {
x: {
valType: 'data_array',
description: 'Sets the x coordinates.'
},
y: {
valType: 'data_array',
description: 'Sets the y coordinates.'
},
z: {
valType: 'data_array',
description: 'Sets the z coordinates.'
},
text: extendFlat({}, scatterAttrs.text, {
description: [
'Sets text elements associated with each (x,y,z) triplet.',
'If a single string, the same string appears over',
'all the data points.',
'If an array of string, the items are mapped in order to the',
'this trace\'s (x,y,z) coordinates.',
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
'these elements will be seen in the hover labels.'
].join(' ')
}),
hovertext: extendFlat({}, scatterAttrs.hovertext, {
description: [
'Sets text elements associated with each (x,y,z) triplet.',
'If a single string, the same string appears over',
'all the data points.',
'If an array of string, the items are mapped in order to the',
'this trace\'s (x,y,z) coordinates.',
'To be seen, trace `hoverinfo` must contain a *text* flag.'
].join(' ')
}),
mode: extendFlat({}, scatterAttrs.mode, // shouldn't this be on-par with 2D?
{dflt: 'lines+markers'}),
surfaceaxis: {
valType: 'enumerated',
role: 'info',
values: [-1, 0, 1, 2],
dflt: -1,
description: [
'If *-1*, the scatter points are not fill with a surface',
'If *0*, *1*, *2*, the scatter points are filled with',
'a Delaunay surface about the x, y, z respectively.'
].join(' ')
},
surfacecolor: {
valType: 'color',
role: 'style',
description: 'Sets the surface fill color.'
},
projection: {
x: makeProjectionAttr('x'),
y: makeProjectionAttr('y'),
z: makeProjectionAttr('z')
},
connectgaps: scatterAttrs.connectgaps,
line: extendFlat({}, {
width: scatterLineAttrs.width,
dash: {
valType: 'enumerated',
values: Object.keys(DASHES),
dflt: 'solid',
role: 'style',
description: 'Sets the dash style of the lines.'
},
showscale: {
valType: 'boolean',
role: 'info',
dflt: false,
description: [
'Has an effect only if `line.color` is set to a numerical array.',
'Determines whether or not a colorbar is displayed.'
].join(' ')
}
},
colorAttributes('line')
),
marker: extendFlat({}, { // Parity with scatter.js?
symbol: {
valType: 'enumerated',
values: Object.keys(MARKER_SYMBOLS),
role: 'style',
dflt: 'circle',
arrayOk: true,
description: 'Sets the marker symbol type.'
},
size: extendFlat({}, scatterMarkerAttrs.size, {dflt: 8}),
sizeref: scatterMarkerAttrs.sizeref,
sizemin: scatterMarkerAttrs.sizemin,
sizemode: scatterMarkerAttrs.sizemode,
opacity: extendFlat({}, scatterMarkerAttrs.opacity, {
arrayOk: false,
description: [
'Sets the marker opacity.',
'Note that the marker opacity for scatter3d traces',
'must be a scalar value for performance reasons.',
'To set a blending opacity value',
'(i.e. which is not transparent), set *marker.color*',
'to an rgba color and use its alpha channel.'
].join(' ')
}),
showscale: scatterMarkerAttrs.showscale,
colorbar: scatterMarkerAttrs.colorbar,
line: extendFlat({},
{width: extendFlat({}, scatterMarkerLineAttrs.width, {arrayOk: false})},
colorAttributes('marker.line')
)
},
colorAttributes('marker')
),
textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center'}),
textfont: scatterAttrs.textfont,
error_x: errorBarAttrs,
error_y: errorBarAttrs,
error_z: errorBarAttrs,
};