Skip to content

Commit f7b467e

Browse files
committed
fix scattermapbox defaults for omitted options
I had to make a mock marker.line object in _fullData to keep legends happy, but at least it doesn't respond to values in data.
1 parent a3a0a4f commit f7b467e

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

src/traces/scatter/line_defaults.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var hasColorscale = require('../../components/colorscale/has_colorscale');
1313
var colorscaleDefaults = require('../../components/colorscale/defaults');
1414

1515

16-
module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
16+
module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) {
1717
var markerColor = (traceIn.marker || {}).color;
1818

1919
coerce('line.color', defaultColor);
@@ -27,5 +27,5 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout,
2727
}
2828

2929
coerce('line.width');
30-
coerce('line.dash');
30+
if(!(opts || {}).noDash) coerce('line.dash');
3131
};

src/traces/scatter/marker_defaults.js

+18-16
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var colorscaleDefaults = require('../../components/colorscale/defaults');
1616
var subTypes = require('./subtypes');
1717

1818

19-
module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
19+
module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) {
2020
var isBubble = subTypes.isBubble(traceIn),
2121
lineColor = (traceIn.line || {}).color,
2222
defaultMLC;
@@ -33,22 +33,24 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout
3333
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'marker.', cLetter: 'c'});
3434
}
3535

36-
// if there's a line with a different color than the marker, use
37-
// that line color as the default marker line color
38-
// (except when it's an array)
39-
// mostly this is for transparent markers to behave nicely
40-
if(lineColor && !Array.isArray(lineColor) && (traceOut.marker.color !== lineColor)) {
41-
defaultMLC = lineColor;
36+
if(!(opts || {}).noLine) {
37+
// if there's a line with a different color than the marker, use
38+
// that line color as the default marker line color
39+
// (except when it's an array)
40+
// mostly this is for transparent markers to behave nicely
41+
if(lineColor && !Array.isArray(lineColor) && (traceOut.marker.color !== lineColor)) {
42+
defaultMLC = lineColor;
43+
}
44+
else if(isBubble) defaultMLC = Color.background;
45+
else defaultMLC = Color.defaultLine;
46+
47+
coerce('marker.line.color', defaultMLC);
48+
if(hasColorscale(traceIn, 'marker.line')) {
49+
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'marker.line.', cLetter: 'c'});
50+
}
51+
52+
coerce('marker.line.width', isBubble ? 1 : 0);
4253
}
43-
else if(isBubble) defaultMLC = Color.background;
44-
else defaultMLC = Color.defaultLine;
45-
46-
coerce('marker.line.color', defaultMLC);
47-
if(hasColorscale(traceIn, 'marker.line')) {
48-
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'marker.line.', cLetter: 'c'});
49-
}
50-
51-
coerce('marker.line.width', isBubble ? 1 : 0);
5254

5355
if(isBubble) {
5456
coerce('marker.sizeref');

src/traces/scattermapbox/defaults.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
2626
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
2727
}
2828

29-
function coerceMarker(attr, dflt) {
30-
var attrs = (attr.indexOf('.line') === -1) ? attributes : scatterAttrs;
29+
// function coerceMarker(attr, dflt) {
30+
// var attrs = (attr.indexOf('.line') === -1) ? attributes : scatterAttrs;
3131

32-
// use 'scatter' attributes for 'marker.line.' attr,
33-
// so that we can reuse the scatter marker defaults
32+
// // use 'scatter' attributes for 'marker.line.' attr,
33+
// // so that we can reuse the scatter marker defaults
3434

35-
return Lib.coerce(traceIn, traceOut, attrs, attr, dflt);
36-
}
35+
// return Lib.coerce(traceIn, traceOut, attrs, attr, dflt);
36+
// }
3737

3838
var len = handleLonLatDefaults(traceIn, traceOut, coerce);
3939
if(!len) {
@@ -46,16 +46,18 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
4646
coerce('mode');
4747

4848
if(subTypes.hasLines(traceOut)) {
49-
handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce);
49+
handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce, {noDash: true});
5050
coerce('connectgaps');
5151
}
5252

5353
if(subTypes.hasMarkers(traceOut)) {
54-
handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerceMarker);
54+
handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, {noLine: true});
5555

5656
// array marker.size and marker.color are only supported with circles
5757

5858
var marker = traceOut.marker;
59+
// we need mock marker.line object to make legends happy
60+
marker.line = {width: 0};
5961

6062
if(marker.symbol !== 'circle') {
6163
if(Array.isArray(marker.size)) marker.size = marker.size[0];

0 commit comments

Comments
 (0)