-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathattributes.js
More file actions
176 lines (159 loc) · 7.28 KB
/
attributes.js
File metadata and controls
176 lines (159 loc) · 7.28 KB
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
'use strict';
const { hovertemplateAttrs, texttemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var makeFillcolorAttr = require('../scatter/fillcolor_attribute');
var scatterAttrs = require('../scatter/attributes');
var baseAttrs = require('../../plots/attributes');
var colorAttributes = require('../../components/colorscale/attributes');
var dash = require('../../components/drawing/attributes').dash;
var extendFlat = require('../../lib/extend').extendFlat;
var overrideAll = require('../../plot_api/edit_types').overrideAll;
var scatterMarkerAttrs = scatterAttrs.marker;
var scatterLineAttrs = scatterAttrs.line;
var scatterMarkerLineAttrs = scatterMarkerAttrs.line;
const breakingChangeWarning = [
'The library used by the *country names* `locationmode` option is changing in an upcoming version.',
'Country names in existing plots may not work in the new version.'
].join(' ');
module.exports = overrideAll(
{
lon: {
valType: 'data_array',
description: 'Sets the longitude coordinates (in degrees East).'
},
lat: {
valType: 'data_array',
description: 'Sets the latitude coordinates (in degrees North).'
},
locations: {
valType: 'data_array',
description: [
'Sets the coordinates via location IDs or names.',
'Coordinates correspond to the centroid of each location given.',
'See `locationmode` for more info.'
].join(' ')
},
locationmode: {
valType: 'enumerated',
values: ['ISO-3', 'USA-states', 'country names', 'geojson-id'],
dflt: 'ISO-3',
description: [
breakingChangeWarning,
'Determines the set of locations used to match entries in `locations`',
'to regions on the map.',
'Values *ISO-3*, *USA-states*, *country names* correspond to features on',
'the base map and value *geojson-id* corresponds to features from a custom',
'GeoJSON linked to the `geojson` attribute.'
].join(' ')
},
geojson: {
valType: 'any',
editType: 'calc',
description: [
'Sets optional GeoJSON data associated with this trace.',
'If not given, the features on the base map are used when `locations` is set.',
'It can be set as a valid GeoJSON object or as a URL string.',
'Note that we only accept GeoJSONs of type *FeatureCollection* or *Feature*',
'with geometries of type *Polygon* or *MultiPolygon*.'
// TODO add topojson support with additional 'topojsonobject' attr?
// https://github.com/topojson/topojson-specification/blob/master/README.md
].join(' ')
},
featureidkey: {
valType: 'string',
editType: 'calc',
dflt: 'id',
description: [
'Sets the key in GeoJSON features which is used as id to match the items',
'included in the `locations` array.',
'Only has an effect when `geojson` is set.',
'Support nested property, for example *properties.name*.'
].join(' ')
},
mode: extendFlat({}, scatterAttrs.mode, { dflt: 'markers' }),
text: extendFlat({}, scatterAttrs.text, {
description: [
'Sets text elements associated with each (lon,lat) pair',
'or item in `locations`.',
'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 (lon,lat) or `locations` coordinates.",
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
'these elements will be seen in the hover labels.'
].join(' ')
}),
texttemplate: texttemplateAttrs({ editType: 'plot' }, { keys: ['lat', 'lon', 'location', 'text'] }),
texttemplatefallback: templatefallbackAttrs({ editType: 'plot' }),
hovertext: extendFlat({}, scatterAttrs.hovertext, {
description: [
'Sets hover text elements associated with each (lon,lat) pair',
'or item in `locations`.',
'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 (lon,lat) or `locations` coordinates.",
'To be seen, trace `hoverinfo` must contain a *text* flag.'
].join(' ')
}),
textfont: scatterAttrs.textfont,
textposition: scatterAttrs.textposition,
line: {
color: scatterLineAttrs.color,
width: scatterLineAttrs.width,
dash: dash
},
connectgaps: scatterAttrs.connectgaps,
marker: extendFlat(
{
symbol: scatterMarkerAttrs.symbol,
opacity: scatterMarkerAttrs.opacity,
angle: scatterMarkerAttrs.angle,
angleref: extendFlat({}, scatterMarkerAttrs.angleref, {
values: ['previous', 'up', 'north'],
description: [
'Sets the reference for marker angle.',
'With *previous*, angle 0 points along the line from the previous point to this one.',
'With *up*, angle 0 points toward the top of the screen.',
'With *north*, angle 0 points north based on the current map projection.'
].join(' ')
}),
standoff: scatterMarkerAttrs.standoff,
size: scatterMarkerAttrs.size,
sizeref: scatterMarkerAttrs.sizeref,
sizemin: scatterMarkerAttrs.sizemin,
sizemode: scatterMarkerAttrs.sizemode,
colorbar: scatterMarkerAttrs.colorbar,
line: extendFlat(
{
width: scatterMarkerLineAttrs.width,
dash: scatterMarkerLineAttrs.dash
},
colorAttributes('marker.line')
),
gradient: scatterMarkerAttrs.gradient
},
colorAttributes('marker')
),
fill: {
valType: 'enumerated',
values: ['none', 'toself'],
dflt: 'none',
description: [
'Sets the area to fill with a solid color.',
'Use with `fillcolor` if not *none*.',
'*toself* connects the endpoints of the trace (or each segment',
'of the trace if it has gaps) into a closed shape.'
].join(' ')
},
fillcolor: makeFillcolorAttr(),
selected: scatterAttrs.selected,
unselected: scatterAttrs.unselected,
hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
flags: ['lon', 'lat', 'location', 'text', 'name']
}),
hovertemplate: hovertemplateAttrs(),
hovertemplatefallback: templatefallbackAttrs()
},
'calc',
'nested'
);