Skip to content

Commit 25c2951

Browse files
committed
replace useExpandedTraceDefaultColor with smarter DRYer logic
- now, Plots.clearExpandedTraceDefaultColors clears any trace attributes with valType: color and no set dflt.
1 parent 2ceac06 commit 25c2951

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

src/components/colorscale/color_attributes.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ module.exports = function makeColorScaleAttributes(context) {
2323
' or an array of numbers that are mapped to the colorscale',
2424
' relative to the max and min values of the array or relative to',
2525
' `cmin` and `cmax` if set.'
26-
].join(''),
27-
useExpandedTraceDefaultColor: true
26+
].join('')
2827
},
2928
colorscale: extendDeep({}, colorScaleAttributes.colorscale, {
3029
description: [

src/plots/plots.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,8 @@ plots.linkSubplots = function(newFullData, newFullLayout, oldFullData, oldFullLa
659659
}
660660
};
661661

662-
// This function clears any attributes with useExpandedTraceDefaultColor
663-
// set to true in the plot schema. This is needed because groupby (which
662+
// This function clears any trace attributes with valType: color and
663+
// no set dflt filed in the plot schema. This is needed because groupby (which
664664
// is the only transform for which this currently applies) supplies parent
665665
// trace defaults, then expanded trace defaults. The result is that `null`
666666
// colors are default-supplied and inherited as a color instead of a null.
@@ -675,7 +675,7 @@ plots.clearExpandedTraceDefaultColors = function(trace) {
675675
function locateColorAttrs(attr, attrName, attrs, level) {
676676
path[level] = attrName;
677677
path.length = level + 1;
678-
if(attr.useExpandedTraceDefaultColor) {
678+
if(attr.valType === 'color' && attr.dflt === undefined) {
679679
colorAttrs.push(path.join('.'));
680680
}
681681
}

src/traces/scatter/attributes.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ module.exports = {
124124
color: {
125125
valType: 'color',
126126
role: 'style',
127-
description: 'Sets the line color.',
128-
useExpandedTraceDefaultColor: true
127+
description: 'Sets the line color.'
129128
},
130129
width: {
131130
valType: 'number',
@@ -204,7 +203,6 @@ module.exports = {
204203
fillcolor: {
205204
valType: 'color',
206205
role: 'style',
207-
useExpandedTraceDefaultColor: true,
208206
description: [
209207
'Sets the fill color.',
210208
'Defaults to a half-transparent variant of the line color,',

test/jasmine/tests/plotschema_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('plot schema', function() {
7676
var valObject = valObjects[attr.valType],
7777
opts = valObject.requiredOpts
7878
.concat(valObject.otherOpts)
79-
.concat(['valType', 'description', 'role', 'editType', 'useExpandedTraceDefaultColor']);
79+
.concat(['valType', 'description', 'role', 'editType']);
8080

8181
Object.keys(attr).forEach(function(key) {
8282
expect(opts.indexOf(key) !== -1).toBe(true, key, attr);

0 commit comments

Comments
 (0)