-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathlayout_attributes.js
351 lines (331 loc) · 13.4 KB
/
layout_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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
'use strict';
var Lib = require('../../lib');
var defaultLine = require('../../components/color').defaultLine;
var domainAttrs = require('../domain').attributes;
var fontAttrs = require('../font_attributes');
var textposition = require('../../traces/scatter/attributes').textposition;
var overrideAll = require('../../plot_api/edit_types').overrideAll;
var templatedArray = require('../../plot_api/plot_template').templatedArray;
var constants = require('./constants');
var fontAttr = fontAttrs({
noFontVariant: true,
noFontShadow: true,
noFontLineposition: true,
noFontTextcase: true,
description: [
'Sets the icon text font (color=mapbox.layer.paint.text-color, size=mapbox.layer.layout.text-size).',
'Has an effect only when `type` is set to *symbol*.'
].join(' ')
});
fontAttr.family.dflt = 'Open Sans Regular, Arial Unicode MS Regular';
var attrs = module.exports = overrideAll({
_arrayAttrRegexps: [Lib.counterRegex('mapbox', '.layers', true)],
domain: domainAttrs({name: 'mapbox'}),
accesstoken: {
valType: 'string',
noBlank: true,
strict: true,
description: [
'Sets the mapbox access token to be used for this mapbox map.',
'Alternatively, the mapbox access token can be set in the',
'configuration options under `mapboxAccessToken`.',
'Note that accessToken are only required when `style`',
'(e.g with values :', constants.styleValuesMapbox.join(', '), ')',
'and/or a layout layer references the Mapbox server.'
].join(' ')
},
style: {
valType: 'any',
values: constants.styleValuesMapbox.concat(constants.styleValuesNonMapbox),
dflt: constants.styleValueDflt,
description: [
'Defines the map layers that are rendered by default below the trace layers defined in `data`,',
'which are themselves by default rendered below the layers defined in `layout.mapbox.layers`.',
'',
'These layers can be defined either explicitly as a Mapbox Style object which can contain multiple',
'layer definitions that load data from any public or private Tile Map Service (TMS or XYZ) or Web Map Service (WMS)',
'or implicitly by using one of the built-in style objects which use WMSes which do not require any',
'access tokens, or by using a default Mapbox style or custom Mapbox style URL, both of',
'which require a Mapbox access token',
'',
'Note that Mapbox access token can be set in the `accesstoken` attribute',
'or in the `mapboxAccessToken` config option.',
'',
'Mapbox Style objects are of the form described in the Mapbox GL JS documentation available at',
'https://docs.mapbox.com/mapbox-gl-js/style-spec',
'',
'The built-in plotly.js styles objects are:', constants.styleValuesNonMapbox.join(', '),
'',
'The built-in Mapbox styles are:', constants.styleValuesMapbox.join(', '),
'',
'Mapbox style URLs are of the form: mapbox://mapbox.mapbox-<name>-<version>'
].join(' ')
},
center: {
lon: {
valType: 'number',
dflt: 0,
description: 'Sets the longitude of the center of the map (in degrees East).'
},
lat: {
valType: 'number',
dflt: 0,
description: 'Sets the latitude of the center of the map (in degrees North).'
}
},
zoom: {
valType: 'number',
dflt: 1,
description: 'Sets the zoom level of the map (mapbox.zoom).'
},
bearing: {
valType: 'number',
dflt: 0,
description: 'Sets the bearing angle of the map in degrees counter-clockwise from North (mapbox.bearing).'
},
pitch: {
valType: 'number',
dflt: 0,
description: [
'Sets the pitch angle of the map',
'(in degrees, where *0* means perpendicular to the surface of the map) (mapbox.pitch).'
].join(' ')
},
bounds: {
west: {
valType: 'number',
description: [
'Sets the minimum longitude of the map (in degrees East)',
'if `east`, `south` and `north` are declared.'
].join(' ')
},
east: {
valType: 'number',
description: [
'Sets the maximum longitude of the map (in degrees East)',
'if `west`, `south` and `north` are declared.'
].join(' ')
},
south: {
valType: 'number',
description: [
'Sets the minimum latitude of the map (in degrees North)',
'if `east`, `west` and `north` are declared.'
].join(' ')
},
north: {
valType: 'number',
description: [
'Sets the maximum latitude of the map (in degrees North)',
'if `east`, `west` and `south` are declared.'
].join(' ')
}
},
layers: templatedArray('layer', {
visible: {
valType: 'boolean',
dflt: true,
description: [
'Determines whether this layer is displayed'
].join(' ')
},
sourcetype: {
valType: 'enumerated',
values: ['geojson', 'vector', 'raster', 'image'],
dflt: 'geojson',
description: [
'Sets the source type for this layer,',
'that is the type of the layer data.'
].join(' ')
},
source: {
valType: 'any',
description: [
'Sets the source data for this layer (mapbox.layer.source).',
'When `sourcetype` is set to *geojson*, `source` can be a URL to a GeoJSON',
'or a GeoJSON object.',
'When `sourcetype` is set to *vector* or *raster*, `source` can be a URL or',
'an array of tile URLs.',
'When `sourcetype` is set to *image*, `source` can be a URL to an image.'
].join(' ')
},
sourcelayer: {
valType: 'string',
dflt: '',
description: [
'Specifies the layer to use from a vector tile source (mapbox.layer.source-layer).',
'Required for *vector* source type that supports multiple layers.'
].join(' ')
},
sourceattribution: {
valType: 'string',
description: [
'Sets the attribution for this source.'
].join(' ')
},
type: {
valType: 'enumerated',
values: ['circle', 'line', 'fill', 'symbol', 'raster'],
dflt: 'circle',
description: [
'Sets the layer type,',
'that is the how the layer data set in `source` will be rendered',
'With `sourcetype` set to *geojson*, the following values are allowed:',
'*circle*, *line*, *fill* and *symbol*.',
'but note that *line* and *fill* are not compatible with Point',
'GeoJSON geometries.',
'With `sourcetype` set to *vector*, the following values are allowed:',
' *circle*, *line*, *fill* and *symbol*.',
'With `sourcetype` set to *raster* or `*image*`, only the *raster* value is allowed.'
].join(' ')
},
coordinates: {
valType: 'any',
description: [
'Sets the coordinates array contains [longitude, latitude] pairs',
'for the image corners listed in clockwise order:',
'top left, top right, bottom right, bottom left.',
'Only has an effect for *image* `sourcetype`.'
].join(' ')
},
// attributes shared between all types
below: {
valType: 'string',
description: [
'Determines if the layer will be inserted',
'before the layer with the specified ID.',
'If omitted or set to \'\',',
'the layer will be inserted above every existing layer.'
].join(' ')
},
color: {
valType: 'color',
dflt: defaultLine,
description: [
'Sets the primary layer color.',
'If `type` is *circle*, color corresponds to the circle color (mapbox.layer.paint.circle-color)',
'If `type` is *line*, color corresponds to the line color (mapbox.layer.paint.line-color)',
'If `type` is *fill*, color corresponds to the fill color (mapbox.layer.paint.fill-color)',
'If `type` is *symbol*, color corresponds to the icon color (mapbox.layer.paint.icon-color)'
].join(' ')
},
opacity: {
valType: 'number',
min: 0,
max: 1,
dflt: 1,
description: [
'Sets the opacity of the layer.',
'If `type` is *circle*, opacity corresponds to the circle opacity (mapbox.layer.paint.circle-opacity)',
'If `type` is *line*, opacity corresponds to the line opacity (mapbox.layer.paint.line-opacity)',
'If `type` is *fill*, opacity corresponds to the fill opacity (mapbox.layer.paint.fill-opacity)',
'If `type` is *symbol*, opacity corresponds to the icon/text opacity (mapbox.layer.paint.text-opacity)'
].join(' ')
},
minzoom: {
valType: 'number',
min: 0,
max: 24,
dflt: 0,
description: [
'Sets the minimum zoom level (mapbox.layer.minzoom).',
'At zoom levels less than the minzoom, the layer will be hidden.',
].join(' ')
},
maxzoom: {
valType: 'number',
min: 0,
max: 24,
dflt: 24,
description: [
'Sets the maximum zoom level (mapbox.layer.maxzoom).',
'At zoom levels equal to or greater than the maxzoom, the layer will be hidden.'
].join(' ')
},
// type-specific style attributes
circle: {
radius: {
valType: 'number',
dflt: 15,
description: [
'Sets the circle radius (mapbox.layer.paint.circle-radius).',
'Has an effect only when `type` is set to *circle*.'
].join(' ')
}
},
line: {
width: {
valType: 'number',
dflt: 2,
description: [
'Sets the line width (mapbox.layer.paint.line-width).',
'Has an effect only when `type` is set to *line*.'
].join(' ')
},
dash: {
valType: 'data_array',
description: [
'Sets the length of dashes and gaps (mapbox.layer.paint.line-dasharray).',
'Has an effect only when `type` is set to *line*.'
].join(' ')
}
},
fill: {
outlinecolor: {
valType: 'color',
dflt: defaultLine,
description: [
'Sets the fill outline color (mapbox.layer.paint.fill-outline-color).',
'Has an effect only when `type` is set to *fill*.'
].join(' ')
}
},
symbol: {
icon: {
valType: 'string',
dflt: 'marker',
description: [
'Sets the symbol icon image (mapbox.layer.layout.icon-image).',
'Full list: https://www.mapbox.com/maki-icons/'
].join(' ')
},
iconsize: {
valType: 'number',
dflt: 10,
description: [
'Sets the symbol icon size (mapbox.layer.layout.icon-size).',
'Has an effect only when `type` is set to *symbol*.'
].join(' ')
},
text: {
valType: 'string',
dflt: '',
description: [
'Sets the symbol text (mapbox.layer.layout.text-field).'
].join(' ')
},
placement: {
valType: 'enumerated',
values: ['point', 'line', 'line-center'],
dflt: 'point',
description: [
'Sets the symbol and/or text placement (mapbox.layer.layout.symbol-placement).',
'If `placement` is *point*, the label is placed where the geometry is located',
'If `placement` is *line*, the label is placed along the line of the geometry',
'If `placement` is *line-center*, the label is placed on the center of the geometry',
].join(' ')
},
textfont: fontAttr,
textposition: Lib.extendFlat({}, textposition, { arrayOk: false })
}
})
}, 'plot', 'from-root');
// set uirevision outside of overrideAll so it can be `editType: 'none'`
attrs.uirevision = {
valType: 'any',
editType: 'none',
description: [
'Controls persistence of user-driven changes in the view:',
'`center`, `zoom`, `bearing`, `pitch`. Defaults to `layout.uirevision`.'
].join(' ')
};