Skip to content

Commit 01d1041

Browse files
committed
581a dry colors - put color spec as the last prop block; use extendFlat everywhere
1 parent 7e89f81 commit 01d1041

File tree

11 files changed

+69
-57
lines changed

11 files changed

+69
-57
lines changed

src/traces/bar/attributes.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010

1111
var scatterAttrs = require('../scatter/attributes');
1212
var colorAttributes = require('../../components/colorscale/color_attributes');
13-
var extendDeep = require('../../lib/extend').extendDeep;
13+
var extendFlat = require('../../lib/extend').extendFlat;
1414

1515
var scatterMarkerAttrs = scatterAttrs.marker;
1616
var scatterMarkerLineAttrs = scatterMarkerAttrs.line;
1717

18-
1918
module.exports = {
2019
x: scatterAttrs.x,
2120
x0: scatterAttrs.x0,
@@ -34,12 +33,14 @@ module.exports = {
3433
'along the vertical (horizontal).'
3534
].join(' ')
3635
},
37-
marker: extendDeep({}, colorAttributes('marker'), {
36+
marker: extendFlat({}, {
3837
showscale: scatterMarkerAttrs.showscale,
39-
line: extendDeep({}, colorAttributes('marker.line'), {
40-
width: scatterMarkerLineAttrs.width
41-
})
42-
}),
38+
line: extendFlat({},
39+
{width: scatterMarkerLineAttrs.width},
40+
colorAttributes('marker.line')
41+
)},
42+
colorAttributes('marker')
43+
),
4344

4445
r: scatterAttrs.r,
4546
t: scatterAttrs.t,

src/traces/choropleth/attributes.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var extendFlat = require('../../lib/extend').extendFlat;
1515

1616
var ScatterGeoMarkerLineAttrs = ScatterGeoAttrs.marker.line;
1717

18-
module.exports = extendFlat({}, colorscaleAttrs, {
18+
module.exports = extendFlat({}, {
1919
locations: {
2020
valType: 'data_array',
2121
description: [
@@ -44,4 +44,6 @@ module.exports = extendFlat({}, colorscaleAttrs, {
4444
_nestedModules: {
4545
'colorbar': 'Colorbar'
4646
}
47-
});
47+
},
48+
colorscaleAttrs
49+
);

src/traces/contour/attributes.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ var extendFlat = require('../../lib/extend').extendFlat;
1616
var scatterLineAttrs = scatterAttrs.line;
1717

1818
module.exports = extendFlat({},
19-
colorscaleAttrs,
20-
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})},
2119
{
2220
z: heatmapAttrs.z,
2321
x: heatmapAttrs.x,
@@ -118,4 +116,7 @@ module.exports = extendFlat({},
118116
_nestedModules: {
119117
'colorbar': 'Colorbar'
120118
}
121-
});
119+
},
120+
colorscaleAttrs,
121+
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})}
122+
);

src/traces/heatmap/attributes.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ var colorscaleAttrs = require('../../components/colorscale/attributes');
1313

1414
var extendFlat = require('../../lib/extend').extendFlat;
1515

16-
1716
module.exports = extendFlat({},
18-
colorscaleAttrs,
19-
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})},
2017
{
2118
z: {
2219
valType: 'data_array',
@@ -83,4 +80,7 @@ module.exports = extendFlat({},
8380
_nestedModules: {
8481
'colorbar': 'Colorbar'
8582
}
86-
});
83+
},
84+
colorscaleAttrs,
85+
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})}
86+
);

src/traces/histogram/attributes.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var barAttrs = require('../bar/attributes');
1312
var colorAttributes = require('../../components/colorscale/color_attributes');
1413

15-
var extendFlat = require('../../lib').extendFlat;
16-
var extendDeep = require('../../lib/extend').extendDeep;
14+
var extendFlat = require('../../lib/extend').extendDeep;
1715

1816
var barMarkerAttrs = barAttrs.marker;
1917
var barMarkerLineAttrs = barMarkerAttrs.line;
2018

21-
2219
module.exports = {
2320
x: {
2421
valType: 'data_array',
@@ -115,12 +112,14 @@ module.exports = {
115112
},
116113
ybins: makeBinsAttr('y'),
117114

118-
marker: extendDeep({}, colorAttributes('marker'), {
115+
marker: extendFlat({}, {
119116
showscale: barMarkerAttrs.showscale,
120-
line: extendDeep({}, colorAttributes('marker.line'), {
121-
width: extendFlat({}, barMarkerLineAttrs.width, {dflt: 0})
122-
})
123-
}),
117+
line: extendFlat({},
118+
{width: extendFlat({}, barMarkerLineAttrs.width, {dflt: 0})},
119+
colorAttributes('marker.line'))
120+
},
121+
colorAttributes('marker')
122+
),
124123

125124
_nestedModules: {
126125
'error_y': 'ErrorBars',

src/traces/histogram2d/attributes.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ var colorscaleAttrs = require('../../components/colorscale/attributes');
1515
var extendFlat = require('../../lib/extend').extendFlat;
1616

1717
module.exports = extendFlat({},
18-
colorscaleAttrs,
19-
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})},
2018
{
2119
x: histogramAttrs.x,
2220
y: histogramAttrs.y,
@@ -46,4 +44,7 @@ module.exports = extendFlat({},
4644
_nestedModules: {
4745
'colorbar': 'Colorbar'
4846
}
49-
});
47+
},
48+
colorscaleAttrs,
49+
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})}
50+
);

src/traces/histogram2dcontour/attributes.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var colorscaleAttrs = require('../../components/colorscale/attributes');
1414

1515
var extendFlat = require('../../lib/extend').extendFlat;
1616

17-
module.exports = extendFlat({}, colorscaleAttrs, {
17+
module.exports = extendFlat({}, {
1818
x: histogram2dAttrs.x,
1919
y: histogram2dAttrs.y,
2020
z: histogram2dAttrs.z,
@@ -37,4 +37,6 @@ module.exports = extendFlat({}, colorscaleAttrs, {
3737
_nestedModules: {
3838
'colorbar': 'Colorbar'
3939
}
40-
});
40+
},
41+
colorscaleAttrs
42+
);

src/traces/scatter/attributes.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ var Drawing = require('../../components/drawing');
1414

1515
var constants = require('./constants');
1616

17-
var extendDeep = require('../../lib/extend').extendDeep;
18-
17+
var extendFlat = require('../../lib/extend').extendFlat;
1918

2019
module.exports = {
2120
x: {
@@ -185,7 +184,7 @@ module.exports = {
185184
'marker color, or marker line color, whichever is available.'
186185
].join(' ')
187186
},
188-
marker: extendDeep({}, colorAttributes('marker'), {
187+
marker: extendFlat({}, {
189188
symbol: {
190189
valType: 'enumerated',
191190
values: Drawing.symbolList,
@@ -266,16 +265,20 @@ module.exports = {
266265
'Determines whether or not a colorbar is displayed.'
267266
].join(' ')
268267
},
269-
line: extendDeep({}, colorAttributes('marker.line'), {
268+
line: extendFlat({}, {
270269
width: {
271270
valType: 'number',
272271
min: 0,
273272
arrayOk: true,
274273
role: 'style',
275274
description: 'Sets the width (in px) of the lines bounding the marker points.'
276275
}
277-
})
278-
}),
276+
},
277+
colorAttributes('marker.line')
278+
)
279+
},
280+
colorAttributes('marker')
281+
),
279282
textposition: {
280283
valType: 'enumerated',
281284
values: [

src/traces/scatter3d/attributes.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
109
'use strict';
1110

1211
var scatterAttrs = require('../scatter/attributes');
1312
var colorAttributes = require('../../components/colorscale/color_attributes');
1413

1514
var MARKER_SYMBOLS = require('../../constants/gl_markers');
1615
var extendFlat = require('../../lib/extend').extendFlat;
17-
var extendDeep = require('../../lib/extend').extendDeep;
1816

1917
var scatterLineAttrs = scatterAttrs.line,
2018
scatterMarkerAttrs = scatterAttrs.marker,
@@ -104,7 +102,7 @@ module.exports = {
104102
width: scatterLineAttrs.width,
105103
dash: scatterLineAttrs.dash
106104
},
107-
marker: extendDeep({}, colorAttributes('marker'), { // Parity with scatter.js?
105+
marker: extendFlat({}, { // Parity with scatter.js?
108106
symbol: {
109107
valType: 'enumerated',
110108
values: Object.keys(MARKER_SYMBOLS),
@@ -129,10 +127,13 @@ module.exports = {
129127
].join(' ')
130128
}),
131129
showscale: scatterMarkerAttrs.showscale,
132-
line: extendDeep({}, colorAttributes('marker.line'), {
133-
width: extendFlat({}, scatterMarkerLineAttrs.width, {arrayOk: false})
134-
})
135-
}),
130+
line: extendFlat({},
131+
{width: extendFlat({}, scatterMarkerLineAttrs.width, {arrayOk: false})},
132+
colorAttributes('marker.line')
133+
)
134+
},
135+
colorAttributes('marker')
136+
),
136137
textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center'}),
137138
textfont: scatterAttrs.textfont,
138139
_nestedModules: {

src/traces/scattergeo/attributes.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ var plotAttrs = require('../../plots/attributes');
1313
var colorAttributes = require('../../components/colorscale/color_attributes');
1414

1515
var extendFlat = require('../../lib/extend').extendFlat;
16-
var extendDeep = require('../../lib/extend').extendDeep;
1716

1817
var scatterMarkerAttrs = scatterAttrs.marker,
1918
scatterLineAttrs = scatterAttrs.line,
2019
scatterMarkerLineAttrs = scatterMarkerAttrs.line;
2120

22-
2321
module.exports = {
2422
lon: {
2523
valType: 'data_array',
@@ -63,18 +61,21 @@ module.exports = {
6361
width: scatterLineAttrs.width,
6462
dash: scatterLineAttrs.dash
6563
},
66-
marker: extendDeep({}, colorAttributes('marker'), {
64+
marker: extendFlat({}, {
6765
symbol: scatterMarkerAttrs.symbol,
6866
opacity: scatterMarkerAttrs.opacity,
6967
size: scatterMarkerAttrs.size,
7068
sizeref: scatterMarkerAttrs.sizeref,
7169
sizemin: scatterMarkerAttrs.sizemin,
7270
sizemode: scatterMarkerAttrs.sizemode,
7371
showscale: scatterMarkerAttrs.showscale,
74-
line: extendDeep({}, colorAttributes('marker.line'), {
75-
width: scatterMarkerLineAttrs.width
76-
})
77-
}),
72+
line: extendFlat({},
73+
{width: scatterMarkerLineAttrs.width},
74+
colorAttributes('marker.line')
75+
)
76+
},
77+
colorAttributes('marker')
78+
),
7879
textfont: scatterAttrs.textfont,
7980
textposition: scatterAttrs.textposition,
8081
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {

src/traces/scatterternary/attributes.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ var plotAttrs = require('../../plots/attributes');
1313
var colorAttributes = require('../../components/colorscale/color_attributes');
1414

1515
var extendFlat = require('../../lib/extend').extendFlat;
16-
var extendDeep = require('../../lib/extend').extendDeep;
1716

1817
var scatterMarkerAttrs = scatterAttrs.marker,
1918
scatterLineAttrs = scatterAttrs.line,
2019
scatterMarkerLineAttrs = scatterMarkerAttrs.line;
2120

22-
2321
module.exports = {
2422
a: {
2523
valType: 'data_array',
@@ -98,7 +96,7 @@ module.exports = {
9896
].join(' ')
9997
}),
10098
fillcolor: scatterAttrs.fillcolor,
101-
marker: extendDeep({}, colorAttributes('marker'), {
99+
marker: extendFlat({}, {
102100
symbol: scatterMarkerAttrs.symbol,
103101
opacity: scatterMarkerAttrs.opacity,
104102
maxdisplayed: scatterMarkerAttrs.maxdisplayed,
@@ -107,10 +105,13 @@ module.exports = {
107105
sizemin: scatterMarkerAttrs.sizemin,
108106
sizemode: scatterMarkerAttrs.sizemode,
109107
showscale: scatterMarkerAttrs.showscale,
110-
line: extendDeep({}, colorAttributes('marker'.line), {
111-
width: scatterMarkerLineAttrs.width
112-
})
113-
}),
108+
line: extendFlat({},
109+
{width: scatterMarkerLineAttrs.width},
110+
colorAttributes('marker'.line)
111+
)
112+
},
113+
colorAttributes('marker')
114+
),
114115
textfont: scatterAttrs.textfont,
115116
textposition: scatterAttrs.textposition,
116117
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {

0 commit comments

Comments
 (0)