Skip to content

Commit 238e248

Browse files
committed
preserve impliedEdits: {key: undefined} by extendDeepAll
or better yet don't do deep extend, simplify to extendFlat also fix a weird bug with calendars and box plots
1 parent cb94e95 commit 238e248

File tree

11 files changed

+80
-84
lines changed

11 files changed

+80
-84
lines changed

src/components/calendars/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ module.exports = {
206206
traces: {
207207
scatter: xyAttrs,
208208
bar: xyAttrs,
209+
box: xyAttrs,
209210
heatmap: xyAttrs,
210211
contour: xyAttrs,
211212
histogram: xyAttrs,

src/components/sliders/attributes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
var fontAttrs = require('../../plots/font_attributes');
1212
var padAttrs = require('../../plots/pad_attributes');
13-
var extendDeep = require('../../lib/extend').extendDeep;
13+
var extendDeepAll = require('../../lib/extend').extendDeepAll;
1414
var overrideAll = require('../../plot_api/edit_types').overrideAll;
1515
var animationAttrs = require('../../plots/animation_attributes');
1616
var constants = require('./constants');
@@ -128,7 +128,7 @@ module.exports = overrideAll({
128128
role: 'style',
129129
description: 'Sets the x position (in normalized coordinates) of the slider.'
130130
},
131-
pad: extendDeep({}, padAttrs, {
131+
pad: extendDeepAll({}, padAttrs, {
132132
description: 'Set the padding of the slider component along each side.'
133133
}, {t: {dflt: 20}}),
134134
xanchor: {

src/plot_api/plot_schema.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var polarAxisAttrs = require('../plots/polar/axis_attributes');
2424
var editTypes = require('./edit_types');
2525

2626
var extendFlat = Lib.extendFlat;
27-
var extendDeep = Lib.extendDeep;
27+
var extendDeepAll = Lib.extendDeepAll;
2828

2929
var IS_SUBPLOT_OBJ = '_isSubplotObj';
3030
var IS_LINKED_TO_ARRAY = '_isLinkedToArray';
@@ -140,7 +140,7 @@ exports.crawl = function(attrs, callback, specifiedLevel, attrString) {
140140

141141
if(exports.isValObject(attr)) return;
142142

143-
if(Lib.isPlainObject(attr)) {
143+
if(Lib.isPlainObject(attr) && attrName !== 'impliedEdits') {
144144
exports.crawl(attr, callback, level + 1, fullAttrString);
145145
}
146146
});
@@ -428,14 +428,14 @@ function getTraceAttributes(type) {
428428
attributes.type = null;
429429

430430
// base attributes (same for all trace types)
431-
extendDeep(attributes, baseAttributes);
431+
extendDeepAll(attributes, baseAttributes);
432432

433433
// module attributes
434-
extendDeep(attributes, _module.attributes);
434+
extendDeepAll(attributes, _module.attributes);
435435

436436
// subplot attributes
437437
if(basePlotModule.attributes) {
438-
extendDeep(attributes, basePlotModule.attributes);
438+
extendDeepAll(attributes, basePlotModule.attributes);
439439
}
440440

441441
// 'type' gets overwritten by baseAttributes; reset it here
@@ -450,7 +450,7 @@ function getTraceAttributes(type) {
450450
if(_module.layoutAttributes) {
451451
var layoutAttributes = {};
452452

453-
extendDeep(layoutAttributes, _module.layoutAttributes);
453+
extendDeepAll(layoutAttributes, _module.layoutAttributes);
454454
out.layoutAttributes = formatAttributes(layoutAttributes);
455455
}
456456

@@ -462,7 +462,7 @@ function getLayoutAttributes() {
462462
var key, _module;
463463

464464
// global layout attributes
465-
extendDeep(layoutAttributes, baseLayoutAttributes);
465+
extendDeepAll(layoutAttributes, baseLayoutAttributes);
466466

467467
// add base plot module layout attributes
468468
for(key in Registry.subplotsRegistry) {
@@ -518,7 +518,7 @@ function getLayoutAttributes() {
518518

519519
function getTransformAttributes(type) {
520520
var _module = Registry.transformsRegistry[type];
521-
var attributes = extendDeep({}, _module.attributes);
521+
var attributes = extendDeepAll({}, _module.attributes);
522522

523523
// add registered components transform attributes
524524
Object.keys(Registry.componentsRegistry).forEach(function(k) {
@@ -538,7 +538,7 @@ function getTransformAttributes(type) {
538538

539539
function getFramesAttributes() {
540540
var attrs = {
541-
frames: Lib.extendDeep({}, frameAttributes)
541+
frames: Lib.extendDeepAll({}, frameAttributes)
542542
};
543543

544544
formatAttributes(attrs);
@@ -621,7 +621,7 @@ function assignPolarLayoutAttrs(layoutAttributes) {
621621

622622
function handleBasePlotModule(layoutAttributes, _module, astr) {
623623
var np = Lib.nestedProperty(layoutAttributes, astr),
624-
attrs = extendDeep({}, _module.layoutAttributes);
624+
attrs = extendDeepAll({}, _module.layoutAttributes);
625625

626626
attrs[IS_SUBPLOT_OBJ] = true;
627627
np.set(attrs);
@@ -630,5 +630,5 @@ function handleBasePlotModule(layoutAttributes, _module, astr) {
630630
function insertAttrs(baseAttrs, newAttrs, astr) {
631631
var np = Lib.nestedProperty(baseAttrs, astr);
632632

633-
np.set(extendDeep(np.get() || {}, newAttrs));
633+
np.set(extendDeepAll(np.get() || {}, newAttrs));
634634
}

src/registry.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var noop = require('./lib/noop');
1414
var pushUnique = require('./lib/push_unique');
1515
var ExtendModule = require('./lib/extend');
1616
var extendFlat = ExtendModule.extendFlat;
17-
var extendDeep = ExtendModule.extendDeep;
17+
var extendDeepAll = ExtendModule.extendDeepAll;
1818

1919
var basePlotAttributes = require('./plots/attributes');
2020
var baseLayoutAttributes = require('./plots/layout_attributes');
@@ -140,7 +140,7 @@ exports.registerComponent = function(_module) {
140140
}
141141

142142
if(_module.schema && _module.schema.layout) {
143-
extendDeep(baseLayoutAttributes, _module.schema.layout);
143+
extendDeepAll(baseLayoutAttributes, _module.schema.layout);
144144
}
145145
};
146146

@@ -169,7 +169,7 @@ function mergeComponentAttrsToTrace(componentName, traceType) {
169169

170170
var traceAttrs = componentSchema.traces[traceType];
171171
if(traceAttrs) {
172-
extendDeep(exports.modules[traceType]._module.attributes, traceAttrs);
172+
extendDeepAll(exports.modules[traceType]._module.attributes, traceAttrs);
173173
}
174174
}
175175

@@ -179,7 +179,7 @@ function mergeComponentAttrsToTransform(componentName, transformType) {
179179

180180
var transformAttrs = componentSchema.transforms[transformType];
181181
if(transformAttrs) {
182-
extendDeep(exports.transformsRegistry[transformType].attributes, transformAttrs);
182+
extendDeepAll(exports.transformsRegistry[transformType].attributes, transformAttrs);
183183
}
184184
}
185185

@@ -194,7 +194,7 @@ function mergeComponentAttrsToSubplot(componentName, subplotName) {
194194

195195
var componentLayoutAttrs = componentSchema.subplots[subplotAttr];
196196
if(subplotAttrs && componentLayoutAttrs) {
197-
extendDeep(subplotAttrs, componentLayoutAttrs);
197+
extendDeepAll(subplotAttrs, componentLayoutAttrs);
198198
}
199199
}
200200

src/traces/box/attributes.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ module.exports = {
6363
'missing and the position axis is categorical'
6464
].join(' ')
6565
},
66-
xcalendar: scatterAttrs.xcalendar,
67-
ycalendar: scatterAttrs.ycalendar,
6866
whiskerwidth: {
6967
valType: 'number',
7068
min: 0,

src/traces/candlestick/attributes.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,25 @@
99

1010
'use strict';
1111

12-
var Lib = require('../../lib');
12+
var extendFlat = require('../../lib').extendFlat;
1313
var OHLCattrs = require('../ohlc/attributes');
1414
var boxAttrs = require('../box/attributes');
1515

16-
var directionAttrs = {
17-
name: OHLCattrs.increasing.name,
18-
showlegend: OHLCattrs.increasing.showlegend,
16+
function directionAttrs(lineColorDefault) {
17+
return {
18+
name: OHLCattrs.increasing.name,
19+
showlegend: OHLCattrs.increasing.showlegend,
1920

20-
line: {
21-
color: Lib.extendFlat({}, boxAttrs.line.color),
22-
width: Lib.extendFlat({}, boxAttrs.line.width),
23-
editType: 'style'
24-
},
21+
line: {
22+
color: extendFlat({}, boxAttrs.line.color, {dflt: lineColorDefault}),
23+
width: boxAttrs.line.width,
24+
editType: 'style'
25+
},
2526

26-
fillcolor: Lib.extendFlat({}, boxAttrs.fillcolor),
27-
editType: 'style'
28-
};
27+
fillcolor: boxAttrs.fillcolor,
28+
editType: 'style'
29+
};
30+
}
2931

3032
module.exports = {
3133
x: OHLCattrs.x,
@@ -35,7 +37,7 @@ module.exports = {
3537
close: OHLCattrs.close,
3638

3739
line: {
38-
width: Lib.extendFlat({}, boxAttrs.line.width, {
40+
width: extendFlat({}, boxAttrs.line.width, {
3941
description: [
4042
boxAttrs.line.width.description,
4143
'Note that this style setting can also be set per',
@@ -46,14 +48,10 @@ module.exports = {
4648
editType: 'style'
4749
},
4850

49-
increasing: Lib.extendDeep({}, directionAttrs, {
50-
line: { color: { dflt: OHLCattrs.increasing.line.color.dflt } }
51-
}),
51+
increasing: directionAttrs(OHLCattrs.increasing.line.color.dflt),
5252

53-
decreasing: Lib.extendDeep({}, directionAttrs, {
54-
line: { color: { dflt: OHLCattrs.decreasing.line.color.dflt } }
55-
}),
53+
decreasing: directionAttrs(OHLCattrs.decreasing.line.color.dflt),
5654

5755
text: OHLCattrs.text,
58-
whiskerwidth: Lib.extendFlat({}, boxAttrs.whiskerwidth, { dflt: 0 })
56+
whiskerwidth: extendFlat({}, boxAttrs.whiskerwidth, { dflt: 0 })
5957
};

src/traces/choropleth/attributes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var plotAttrs = require('../../plots/attributes');
1515

1616
var extend = require('../../lib/extend');
1717
var extendFlat = extend.extendFlat;
18-
var extendDeep = extend.extendDeep;
18+
var extendDeepAll = extend.extendDeepAll;
1919

2020
var ScatterGeoMarkerLineAttrs = ScatterGeoAttrs.marker.line;
2121

@@ -52,7 +52,7 @@ module.exports = extendFlat({
5252
flags: ['location', 'z', 'text', 'name']
5353
}),
5454
},
55-
extendDeep({}, colorscaleAttrs, {
55+
extendDeepAll({}, colorscaleAttrs, {
5656
zmax: {editType: 'calc'},
5757
zmin: {editType: 'calc'}
5858
}),

src/traces/ohlc/attributes.js

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
'use strict';
1111

12-
var Lib = require('../../lib');
12+
var extendFlat = require('../../lib').extendFlat;
1313
var scatterAttrs = require('../scatter/attributes');
1414
var dash = require('../../components/drawing/attributes').dash;
1515

@@ -18,36 +18,38 @@ var DECREASING_COLOR = '#FF4136';
1818

1919
var lineAttrs = scatterAttrs.line;
2020

21-
var directionAttrs = {
22-
name: {
23-
valType: 'string',
24-
role: 'info',
25-
editType: 'style',
26-
description: [
27-
'Sets the segment name.',
28-
'The segment name appear as the legend item and on hover.'
29-
].join(' ')
30-
},
31-
32-
showlegend: {
33-
valType: 'boolean',
34-
role: 'info',
35-
dflt: true,
36-
editType: 'style',
37-
description: [
38-
'Determines whether or not an item corresponding to this',
39-
'segment is shown in the legend.'
40-
].join(' ')
41-
},
21+
function directionAttrs(lineColorDefault) {
22+
return {
23+
name: {
24+
valType: 'string',
25+
role: 'info',
26+
editType: 'style',
27+
description: [
28+
'Sets the segment name.',
29+
'The segment name appear as the legend item and on hover.'
30+
].join(' ')
31+
},
4232

43-
line: {
44-
color: lineAttrs.color,
45-
width: lineAttrs.width,
46-
dash: dash,
33+
showlegend: {
34+
valType: 'boolean',
35+
role: 'info',
36+
dflt: true,
37+
editType: 'style',
38+
description: [
39+
'Determines whether or not an item corresponding to this',
40+
'segment is shown in the legend.'
41+
].join(' ')
42+
},
43+
44+
line: {
45+
color: extendFlat({}, lineAttrs.color, {dflt: lineColorDefault}),
46+
width: lineAttrs.width,
47+
dash: dash,
48+
editType: 'style'
49+
},
4750
editType: 'style'
48-
},
49-
editType: 'style'
50-
};
51+
};
52+
}
5153

5254
module.exports = {
5355

@@ -89,15 +91,15 @@ module.exports = {
8991
},
9092

9193
line: {
92-
width: Lib.extendFlat({}, lineAttrs.width, {
94+
width: extendFlat({}, lineAttrs.width, {
9395
description: [
9496
lineAttrs.width,
9597
'Note that this style setting can also be set per',
9698
'direction via `increasing.line.width` and',
9799
'`decreasing.line.width`.'
98100
].join(' ')
99101
}),
100-
dash: Lib.extendFlat({}, dash, {
102+
dash: extendFlat({}, dash, {
101103
description: [
102104
dash.description,
103105
'Note that this style setting can also be set per',
@@ -108,13 +110,9 @@ module.exports = {
108110
editType: 'style'
109111
},
110112

111-
increasing: Lib.extendDeep({}, directionAttrs, {
112-
line: { color: { dflt: INCREASING_COLOR } }
113-
}),
113+
increasing: directionAttrs(INCREASING_COLOR),
114114

115-
decreasing: Lib.extendDeep({}, directionAttrs, {
116-
line: { color: { dflt: DECREASING_COLOR } }
117-
}),
115+
decreasing: directionAttrs(DECREASING_COLOR),
118116

119117
text: {
120118
valType: 'string',

src/traces/parcoords/attributes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var axesAttrs = require('../../plots/cartesian/layout_attributes');
1515
var fontAttrs = require('../../plots/font_attributes');
1616

1717
var extend = require('../../lib/extend');
18-
var extendDeep = extend.extendDeep;
18+
var extendDeepAll = extend.extendDeepAll;
1919
var extendFlat = extend.extendFlat;
2020

2121
module.exports = {
@@ -137,7 +137,7 @@ module.exports = {
137137
line: extendFlat(
138138
// the default autocolorscale isn't quite usable for parcoords due to context ambiguity around 0 (grey, off-white)
139139
// autocolorscale therefore defaults to false too, to avoid being overridden by the blue-white-red autocolor palette
140-
extendDeep(
140+
extendDeepAll(
141141
colorAttributes('line', 'calc'),
142142
{
143143
colorscale: {dflt: colorscales.Viridis},

0 commit comments

Comments
 (0)