-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathattributes.js
113 lines (99 loc) · 3.56 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
/**
* Copyright 2012-2019, 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 choroplethAttrs = require('../choropleth/attributes');
var colorScaleAttrs = require('../../components/colorscale/attributes');
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
var extendFlat = require('../../lib/extend').extendFlat;
module.exports = extendFlat({
locations: {
valType: 'data_array',
editType: 'calc',
description: [
'Sets which features found in *geojson* to plot using',
'their feature `id` field.'
].join(' ')
},
// TODO
// Maybe start with only one value (that we could name e.g. 'geojson-id'),
// but eventually:
// - we could also support for our own dist/topojson/*
// - some people might want `geojson-properties-name` to map data arrays to
// GeoJSON features
// locationmode: choroplethAttrs.locationmode,
z: {
valType: 'data_array',
editType: 'calc',
description: 'Sets the color values.'
},
// TODO maybe we could also set a "key" to dig out values out of the
// GeoJSON feature `properties` fields?
geojson: {
valType: 'any',
role: 'info',
editType: 'calc',
description: [
'Sets the GeoJSON data associated with this trace.',
'Can be set as a valid GeoJSON object or as URL string',
'Note that we only accept GeoJSON of type *FeatureCollection* and *Feature*',
'with geometries of type *Polygon* and *MultiPolygon*.'
].join(' ')
},
// TODO agree on name / behaviour
//
// 'below' is used currently for layout.mapbox.layers,
// even though it's not very plotly-esque.
//
// Note also, that the mapbox-gl style don't all have the same layers,
// see https://codepen.io/etpinard/pen/ydVMwM for full list
below: {
valType: 'string',
role: 'info',
editType: 'plot',
description: [
'Determines if the choropleth polygons will be inserted',
'before the layer with the specified ID.',
'By default, choroplethmapbox traces are placed above the water layers.',
'If set to \'\',',
'the layer will be inserted above every existing layer.'
].join(' ')
},
text: choroplethAttrs.text,
hovertext: choroplethAttrs.hovertext,
marker: {
line: {
color: extendFlat({}, choroplethAttrs.marker.line.color, {editType: 'plot'}),
width: extendFlat({}, choroplethAttrs.marker.line.width, {editType: 'plot'}),
editType: 'calc'
},
// TODO maybe having a dflt less than 1, together with `below:''` would be better?
opacity: extendFlat({}, choroplethAttrs.marker.opacity, {editType: 'plot'}),
editType: 'calc'
},
selected: {
marker: {
opacity: extendFlat({}, choroplethAttrs.selected.marker.opacity, {editType: 'plot'}),
editType: 'plot'
},
editType: 'plot'
},
unselected: {
marker: {
opacity: extendFlat({}, choroplethAttrs.unselected.marker.opacity, {editType: 'plot'}),
editType: 'plot'
},
editType: 'plot'
},
hoverinfo: choroplethAttrs.hoverinfo,
hovertemplate: hovertemplateAttrs({}, {keys: ['properties']})
},
colorScaleAttrs('', {
cLetter: 'z',
editTypeOverride: 'calc'
})
);