Skip to content

Commit

Permalink
Merge pull request #2879 from plotly/scatter3d-attributes
Browse files Browse the repository at this point in the history
Scatter3d attributes fixups
  • Loading branch information
etpinard authored Aug 8, 2018
2 parents 41d870b + 07a2d3b commit def6aa5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
20 changes: 11 additions & 9 deletions src/components/colorscale/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce,

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

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

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

if(showScale) colorbarDefaults(containerIn, containerOut, layout);
var showScale = coerce(prefix + 'showscale', showScaleDflt);
if(showScale) colorbarDefaults(containerIn, containerOut, layout);
}
};
5 changes: 2 additions & 3 deletions src/traces/scatter/line_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout,
coerce('line.color', defaultColor);

if(hasColorscale(traceIn, 'line')) {
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c'});
}
else {
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c', noScale: true});
} else {
var lineColorDflt = (isArrayOrTypedArray(markerColor) ? false : markerColor) || defaultColor;
coerce('line.color', lineColorDflt);
}
Expand Down
37 changes: 23 additions & 14 deletions src/traces/scatter3d/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ var scatterLineAttrs = scatterAttrs.line;
var scatterMarkerAttrs = scatterAttrs.marker;
var scatterMarkerLineAttrs = scatterMarkerAttrs.line;

var lineAttrs = extendFlat({
width: scatterLineAttrs.width,
dash: {
valType: 'enumerated',
values: Object.keys(DASHES),
dflt: 'solid',
role: 'style',
description: 'Sets the dash style of the lines.'
}
}, colorAttributes('line'));
// not yet implemented
delete lineAttrs.showscale;
delete lineAttrs.colorbar;

function makeProjectionAttr(axLetter) {
return {
show: {
Expand Down Expand Up @@ -107,19 +121,10 @@ var attrs = module.exports = overrideAll({
y: makeProjectionAttr('y'),
z: makeProjectionAttr('z')
},

connectgaps: scatterAttrs.connectgaps,
line: extendFlat({
width: scatterLineAttrs.width,
dash: {
valType: 'enumerated',
values: Object.keys(DASHES),
dflt: 'solid',
role: 'style',
description: 'Sets the dash style of the lines.'
}
},
colorAttributes('line')
),
line: lineAttrs,

marker: extendFlat({ // Parity with scatter.js?
symbol: {
valType: 'enumerated',
Expand Down Expand Up @@ -155,8 +160,12 @@ var attrs = module.exports = overrideAll({
colorAttributes('marker')
),

textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center'}),
textfont: scatterAttrs.textfont,
textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center', arrayOk: false}),
textfont: {
color: scatterAttrs.textfont.color,
size: scatterAttrs.textfont.size,
family: extendFlat({}, scatterAttrs.textfont.family, {arrayOk: false})
},

hoverinfo: extendFlat({}, baseAttrs.hoverinfo)
}, 'calc', 'nested');
Expand Down

0 comments on commit def6aa5

Please sign in to comment.