Skip to content

Commit def6aa5

Browse files
authored
Merge pull request #2879 from plotly/scatter3d-attributes
Scatter3d attributes fixups
2 parents 41d870b + 07a2d3b commit def6aa5

File tree

3 files changed

+36
-26
lines changed

3 files changed

+36
-26
lines changed

src/components/colorscale/defaults.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce,
4040

4141
// handles both the trace case (autocolorscale is false by default) and
4242
// the marker and marker.line case (autocolorscale is true by default)
43-
var autoColorscaleDftl;
44-
if(sclIn !== undefined) autoColorscaleDftl = !isValidScale(sclIn);
45-
coerce(prefix + 'autocolorscale', autoColorscaleDftl);
43+
var autoColorscaleDflt;
44+
if(sclIn !== undefined) autoColorscaleDflt = !isValidScale(sclIn);
45+
coerce(prefix + 'autocolorscale', autoColorscaleDflt);
4646
var sclOut = coerce(prefix + 'colorscale');
4747

4848
// reversescale is handled at the containerOut level
@@ -52,11 +52,13 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce,
5252
// ... until Scatter.colorbar can handle marker line colorbars
5353
if(prefix === 'marker.line.') return;
5454

55-
// handle both the trace case where the dflt is listed in attributes and
56-
// the marker case where the dflt is determined by hasColorbar
57-
var showScaleDftl;
58-
if(prefix) showScaleDftl = hasColorbar(containerIn);
59-
var showScale = coerce(prefix + 'showscale', showScaleDftl);
55+
if(!opts.noScale) {
56+
// handles both the trace case where the dflt is listed in attributes and
57+
// the marker case where the dflt is determined by hasColorbar
58+
var showScaleDflt;
59+
if(prefix) showScaleDflt = hasColorbar(containerIn);
6060

61-
if(showScale) colorbarDefaults(containerIn, containerOut, layout);
61+
var showScale = coerce(prefix + 'showscale', showScaleDflt);
62+
if(showScale) colorbarDefaults(containerIn, containerOut, layout);
63+
}
6264
};

src/traces/scatter/line_defaults.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout,
1818
coerce('line.color', defaultColor);
1919

2020
if(hasColorscale(traceIn, 'line')) {
21-
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c'});
22-
}
23-
else {
21+
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c', noScale: true});
22+
} else {
2423
var lineColorDflt = (isArrayOrTypedArray(markerColor) ? false : markerColor) || defaultColor;
2524
coerce('line.color', lineColorDflt);
2625
}

src/traces/scatter3d/attributes.js

+23-14
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ var scatterLineAttrs = scatterAttrs.line;
2121
var scatterMarkerAttrs = scatterAttrs.marker;
2222
var scatterMarkerLineAttrs = scatterMarkerAttrs.line;
2323

24+
var lineAttrs = extendFlat({
25+
width: scatterLineAttrs.width,
26+
dash: {
27+
valType: 'enumerated',
28+
values: Object.keys(DASHES),
29+
dflt: 'solid',
30+
role: 'style',
31+
description: 'Sets the dash style of the lines.'
32+
}
33+
}, colorAttributes('line'));
34+
// not yet implemented
35+
delete lineAttrs.showscale;
36+
delete lineAttrs.colorbar;
37+
2438
function makeProjectionAttr(axLetter) {
2539
return {
2640
show: {
@@ -107,19 +121,10 @@ var attrs = module.exports = overrideAll({
107121
y: makeProjectionAttr('y'),
108122
z: makeProjectionAttr('z')
109123
},
124+
110125
connectgaps: scatterAttrs.connectgaps,
111-
line: extendFlat({
112-
width: scatterLineAttrs.width,
113-
dash: {
114-
valType: 'enumerated',
115-
values: Object.keys(DASHES),
116-
dflt: 'solid',
117-
role: 'style',
118-
description: 'Sets the dash style of the lines.'
119-
}
120-
},
121-
colorAttributes('line')
122-
),
126+
line: lineAttrs,
127+
123128
marker: extendFlat({ // Parity with scatter.js?
124129
symbol: {
125130
valType: 'enumerated',
@@ -155,8 +160,12 @@ var attrs = module.exports = overrideAll({
155160
colorAttributes('marker')
156161
),
157162

158-
textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center'}),
159-
textfont: scatterAttrs.textfont,
163+
textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center', arrayOk: false}),
164+
textfont: {
165+
color: scatterAttrs.textfont.color,
166+
size: scatterAttrs.textfont.size,
167+
family: extendFlat({}, scatterAttrs.textfont.family, {arrayOk: false})
168+
},
160169

161170
hoverinfo: extendFlat({}, baseAttrs.hoverinfo)
162171
}, 'calc', 'nested');

0 commit comments

Comments
 (0)