Skip to content

Commit 62d68bf

Browse files
committed
#581 calculating cmin/cmax for the line too; test cases
1 parent c61ffcc commit 62d68bf

8 files changed

+41
-9
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright 2012-2016, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
10+
'use strict';
11+
12+
var hasColorscale = require('../../components/colorscale/has_colorscale');
13+
var calcColorscale = require('../../components/colorscale/calc');
14+
15+
var subTypes = require('./subtypes');
16+
17+
18+
// common to 'scatter', 'scatter3d' and 'scattergeo'
19+
module.exports = function calcMarkerColorscale(trace) {
20+
if(!subTypes.hasLines(trace)) return;
21+
22+
var line = trace.line;
23+
24+
// auto-z and autocolorscale if applicable
25+
if(hasColorscale(trace, 'line')) {
26+
calcColorscale(trace, line.color, 'line', 'c');
27+
}
28+
};

src/traces/scatter/marker_defaults.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ var subTypes = require('./subtypes');
2020
module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
2121
var isBubble = subTypes.isBubble(traceIn),
2222
lineColor = (traceIn.line || {}).color,
23+
lineColorscale = (traceIn.line || {}).colorscale,
24+
defaultColorscale,
2325
defaultMLC;
2426

2527
if(lineColor) defaultColor = lineColor;
28+
if(lineColorscale) defaultColorscale = lineColorscale;
2629

2730
coerce('marker.symbol');
2831
coerce('marker.opacity', isBubble ? 0.7 : 1);
2932
coerce('marker.size');
3033

3134
coerce('marker.color', defaultColor);
35+
coerce('marker.colorscale', defaultColorscale);
3236
if(hasColorscale(traceIn, 'marker')) {
3337
colorscaleDefaults(
3438
traceIn, traceOut, layout, coerce, {prefix: 'marker.', cLetter: 'c'}

src/traces/scatter3d/calc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
'use strict';
1010

1111
var arraysToCalcdata = require('../scatter/arrays_to_calcdata');
12+
var calcLineColorscale = require('../scatter/line_colorscale_calc');
1213
var calcMarkerColorscale = require('../scatter/marker_colorscale_calc');
1314

1415

@@ -21,6 +22,7 @@ module.exports = function calc(gd, trace) {
2122
var cd = [{x: false, y: false, trace: trace, t: {}}];
2223

2324
arraysToCalcdata(cd);
25+
calcLineColorscale(trace);
2426
calcMarkerColorscale(trace);
2527

2628
return cd;

test/image/baselines/20.png

-73 KB
Loading
Loading
Loading

test/image/mocks/gl3d_scatter-color-palette-with-default-marker.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
"x":[-4,-3,-2,-1,0,1,2,3,4,5,6],
44
"y":[7,5,6,4,2,3,1,3,-1,-4,-2],
55
"z":[2,3,4,5,4,3,2,1,0,-1,-2],
6-
"mode": "lines",
6+
"mode": "lines+markers",
77
"line": {
8-
"width": 10,
8+
"width": 5,
99
"colorscale": "Viridis",
10-
"color": [1,2,3,4,5,6,7,8,9,10],
11-
"cmin": 1,
12-
"cmax": 10
10+
"color": [1,2,3,4,5,6,7,8,9,10]
11+
},
12+
"marker": {
13+
"size": 10
1314
},
1415
"type":"scatter3d"
1516
}],

test/image/mocks/gl3d_scatter-color-palette.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
"z":[2,3,4,5,4,3,2,1,0,-1,-2],
66
"mode": "lines",
77
"line": {
8-
"width": 5,
98
"colorscale": "Viridis",
10-
"color": [1,2,3,4,5,6,7,8,9,10],
11-
"cmin": 1,
12-
"cmax": 10
9+
"color": [1,2,3,4,5,6,7,8,9,10]
1310
},
1411
"type":"scatter3d"
1512
}],

0 commit comments

Comments
 (0)