Skip to content

Commit b9826c8

Browse files
committed
change overrideAll API to nested/from-root only
turns out we weren't using the default no-containers at all
1 parent 284c87f commit b9826c8

File tree

11 files changed

+28
-33
lines changed

11 files changed

+28
-33
lines changed

src/components/annotations3d/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ module.exports = overrideAll({
9090
// xref: 'x'
9191
// yref: 'y
9292
// zref: 'z'
93-
}, 'docalc', true);
93+
}, 'docalc', 'from-root');

src/components/colorbar/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,4 @@ module.exports = overrideAll({
192192
'with respect to the color bar.'
193193
].join(' ')
194194
}
195-
}, 'docolorbars', true);
195+
}, 'docolorbars', 'from-root');

src/components/sliders/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,4 @@ module.exports = overrideAll({
285285
role: 'style',
286286
description: 'Sets the length in pixels of minor step tick marks'
287287
}
288-
}, 'doarraydraw', true);
288+
}, 'doarraydraw', 'from-root');

src/plot_api/edit_types.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,20 @@ module.exports = {
6565
overrideAll: overrideAll
6666
};
6767

68-
/*
68+
/**
6969
* For attributes that are largely copied from elsewhere into a plot type that doesn't
7070
* support partial redraws - overrides the editType field of all attributes in the object
7171
*
7272
* @param {object} attrs: the attributes to override. Will not be mutated.
7373
* @param {string} editTypeOverride: the new editType to use
74-
* @param {bool|'nested'} overrideContainers: should we override editType for containers or just
75-
* `valObject`s? 'nested' will override editType for all but the top level. Containers below
76-
* the absolute top level (trace or layout root) DO need an editType, to handle the case
77-
* where you edit the whole container, but in some cases you want to provide it explicitly
78-
* as it may be more expansive than the attribute editTypes, since you don't know if there
79-
* is a data array in the container (which if provided directly triggers an automatic docalc)
74+
* @param {'nested'|'from-root'} overrideContainers:
75+
* - 'nested' will override editType for nested containers but not the root.
76+
* - 'from-root' will also override editType of the root container.
77+
* Containers below the absolute top level (trace or layout root) DO need an
78+
* editType even if they are not `valObject`s themselves (eg `scatter.marker`)
79+
* to handle the case where you edit the whole container.
80+
*
81+
* @return {object} a new attributes object with `editType` modified as directed
8082
*/
8183
function overrideAll(attrs, editTypeOverride, overrideContainers) {
8284
var out = extendFlat({}, attrs);
@@ -86,7 +88,7 @@ function overrideAll(attrs, editTypeOverride, overrideContainers) {
8688
out[key] = overrideOne(attr, editTypeOverride, overrideContainers, key);
8789
}
8890
}
89-
if(overrideContainers === true) out.editType = editTypeOverride;
91+
if(overrideContainers === 'from-root') out.editType = editTypeOverride;
9092

9193
return out;
9294
}
@@ -99,14 +101,14 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) {
99101
if(Array.isArray(attr.items)) {
100102
out.items = new Array(attr.items.length);
101103
for(var i = 0; i < attr.items.length; i++) {
102-
out.items[i] = overrideOne(attr.items[i], editTypeOverride, !!overrideContainers);
104+
out.items[i] = overrideOne(attr.items[i], editTypeOverride, 'from-root');
103105
}
104106
}
105107
return out;
106108
}
107109
else {
108110
// don't provide an editType for the _deprecated container
109111
return overrideAll(attr, editTypeOverride,
110-
(key.charAt(0) === '_') ? overrideContainers && 'nested' : !!overrideContainers);
112+
(key.charAt(0) === '_') ? 'nested' : 'from-root');
111113
}
112114
}

src/plots/geo/layout/layout_attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,4 @@ module.exports = overrideAll({
255255
},
256256
lonaxis: geoAxesAttrs,
257257
lataxis: geoAxesAttrs
258-
}, 'doplot', true);
258+
}, 'doplot', 'from-root');

src/plots/gl2d/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ exports.attributes = require('../cartesian/attributes');
3434
// this could potentially be just `layoutAttributes` but it would
3535
// still need special handling somewhere to give it precedence over
3636
// the svg version when both are in use on one plot
37-
exports.layoutAttrOverrides = overrideAll(Cartesian.layoutAttributes, 'doplot', true);
37+
exports.layoutAttrOverrides = overrideAll(Cartesian.layoutAttributes, 'doplot', 'from-root');
3838

3939
// similar overrides for base plot attributes (and those added by components)
4040
exports.baseLayoutAttrOverrides = overrideAll({

src/plots/gl3d/layout/axis_attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,4 @@ module.exports = overrideAll({
113113
zeroline: axesAttrs.zeroline,
114114
zerolinecolor: axesAttrs.zerolinecolor,
115115
zerolinewidth: axesAttrs.zerolinewidth
116-
}, 'doplot', true);
116+
}, 'doplot', 'from-root');

src/plots/mapbox/layout_attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,4 @@ module.exports = overrideAll({
263263
textposition: Lib.extendFlat({}, textposition, { arrayOk: false })
264264
}
265265
}
266-
}, 'doplot', true);
266+
}, 'doplot', 'from-root');

src/plots/ternary/layout/layout_attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ module.exports = overrideAll({
6161
aaxis: ternaryAxesAttrs,
6262
baxis: ternaryAxesAttrs,
6363
caxis: ternaryAxesAttrs
64-
}, 'doplot', true);
64+
}, 'doplot', 'from-root');

src/traces/scattermapbox/attributes.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ module.exports = overrideAll({
6262

6363
line: {
6464
color: lineAttrs.color,
65-
width: lineAttrs.width,
66-
editType: 'docalc'
65+
width: lineAttrs.width
6766

6867
// TODO
6968
// dash: dash
@@ -98,7 +97,6 @@ module.exports = overrideAll({
9897
reversescale: markerAttrs.reversescale,
9998
showscale: markerAttrs.showscale,
10099
colorbar: colorbarAttrs,
101-
editType: 'docalc'
102100

103101
// line
104102
},
@@ -112,4 +110,4 @@ module.exports = overrideAll({
112110
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {
113111
flags: ['lon', 'lat', 'text', 'name']
114112
})
115-
}, 'docalc');
113+
}, 'docalc', 'nested');

src/traces/surface/attributes.js

+6-11
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ function makeContourAttr(axLetter) {
4545
project: {
4646
x: makeContourProjAttr('x'),
4747
y: makeContourProjAttr('y'),
48-
z: makeContourProjAttr('z'),
49-
editType: 'docalc'
48+
z: makeContourProjAttr('z')
5049
},
5150
color: {
5251
valType: 'color',
@@ -94,8 +93,7 @@ function makeContourAttr(axLetter) {
9493
max: 16,
9594
dflt: 2,
9695
description: 'Sets the width of the highlighted contour lines.'
97-
},
98-
editType: 'docalc'
96+
}
9997
};
10098
}
10199

@@ -138,8 +136,7 @@ module.exports = overrideAll({
138136
contours: {
139137
x: makeContourAttr('x'),
140138
y: makeContourAttr('y'),
141-
z: makeContourAttr('z'),
142-
editType: 'docalc'
139+
z: makeContourAttr('z')
143140
},
144141
hidesurface: {
145142
valType: 'boolean',
@@ -177,8 +174,7 @@ module.exports = overrideAll({
177174
max: 1e5,
178175
dflt: 0,
179176
description: 'Numeric vector, representing the Z coordinate for each vertex.'
180-
},
181-
editType: 'docalc'
177+
}
182178
},
183179

184180
lighting: {
@@ -224,8 +220,7 @@ module.exports = overrideAll({
224220
'Represents the reflectance as a dependency of the viewing angle; e.g. paper is reflective',
225221
'when viewing it from the edge of the paper (almost 90 degrees), causing shine.'
226222
].join(' ')
227-
},
228-
editType: 'docalc'
223+
}
229224
},
230225

231226
opacity: {
@@ -248,4 +243,4 @@ module.exports = overrideAll({
248243
description: 'Obsolete. Use `cmax` instead.'
249244
})
250245
}
251-
}, 'docalc');
246+
}, 'docalc', 'nested');

0 commit comments

Comments
 (0)