Skip to content

Commit e7beb41

Browse files
committed
#581 [WIP commit] making colorscale usable; initiating progress for showscale if requested; temporarily suspending color defaulting for marker / marker.line to defer on defaulting decisions and to manually test independently
1 parent 189dcd8 commit e7beb41

File tree

6 files changed

+113
-7
lines changed

6 files changed

+113
-7
lines changed

src/traces/scatter/line_defaults.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,24 @@
99

1010
'use strict';
1111

12+
var hasColorscale = require('../../components/colorscale/has_colorscale');
13+
var colorscaleDefaults = require('../../components/colorscale/defaults');
14+
1215

1316
// common to 'scatter', 'scatter3d', 'scattergeo' and 'scattergl'
14-
module.exports = function lineDefaults(traceIn, traceOut, defaultColor, coerce) {
17+
module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
1518
var markerColor = (traceIn.marker || {}).color;
1619

17-
// don't try to inherit a color array
18-
coerce('line.color', (Array.isArray(markerColor) ? false : markerColor) ||
19-
defaultColor);
20+
if(traceIn.line) defaultColor = markerColor;
21+
22+
coerce('line.color', defaultColor);
23+
if(hasColorscale(traceIn, 'line')) {
24+
colorscaleDefaults(
25+
traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c'}
26+
);
27+
}
28+
29+
2030
coerce('line.width');
2131
coerce('line.dash');
2232
};

src/traces/scatter/marker_colorscale_calc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ var subTypes = require('./subtypes');
1919
module.exports = function calcMarkerColorscale(trace) {
2020
if(!subTypes.hasMarkers(trace)) return;
2121

22+
var line = trace.line;
2223
var marker = trace.marker;
2324

2425
// auto-z and autocolorscale if applicable
26+
if(hasColorscale(trace, 'line')) {
27+
calcColorscale(trace, line.color, 'line', 'c');
28+
}
29+
2530
if(hasColorscale(trace, 'marker')) {
2631
calcColorscale(trace, marker.color, 'marker', 'c');
2732
}

src/traces/scatter/marker_defaults.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ var subTypes = require('./subtypes');
1919
// common to 'scatter', 'scatter3d', 'scattergeo' and 'scattergl'
2020
module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
2121
var isBubble = subTypes.isBubble(traceIn),
22-
lineColor = (traceIn.line || {}).color,
22+
// TEMPORARILY HOLDING OFF ON THE DEFAULTING
23+
lineColor = ({}).color, // lineColor = (traceIn.line || {}).color,
2324
defaultMLC;
2425

2526
if(lineColor) defaultColor = lineColor;

src/traces/scatter3d/attributes.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,16 @@ module.exports = {
9999
connectgaps: scatterAttrs.connectgaps,
100100
line: extendFlat({}, {
101101
width: scatterLineAttrs.width,
102-
dash: scatterLineAttrs.dash
102+
dash: scatterLineAttrs.dash,
103+
showscale: {
104+
valType: 'boolean',
105+
role: 'info',
106+
dflt: false,
107+
description: [
108+
'Has an effect only if `marker.color` is set to a numerical array.',
109+
'Determines whether or not a colorbar is displayed.'
110+
].join(' ')
111+
}
103112
},
104113
colorAttributes('line')
105114
),

src/traces/scatter3d/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3737

3838
if(subTypes.hasLines(traceOut)) {
3939
coerce('connectgaps');
40-
handleLineDefaults(traceIn, traceOut, defaultColor, coerce);
40+
handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce);
4141
}
4242

4343
if(subTypes.hasMarkers(traceOut)) {
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"data": [{
3+
"x":["-4","-3","-2","-1","0","1","2","3","4","5","6"],
4+
"y":["7","5","6","4","2","3","1","3","-1","-4","-2"],
5+
"z":["2","3","4","5","4","3","2","1","0","-1","-2"],
6+
"mode": "lines+markers",
7+
"line": {
8+
"width": 5,
9+
"color": [10,15,20,25,30,35,40,45,50,55,60],
10+
"colorscale": "Rainbow",
11+
"showscale": true
12+
},
13+
"marker": {
14+
"size": 10,
15+
"colorscale": "Viridis",
16+
"color": [9,15,20,25,30,35,40,45,50,55,61]
17+
},
18+
"name":"Col3",
19+
"type":"scatter3d",
20+
"xsrc":":c54135",
21+
"ysrc":":a7b14d",
22+
"zsrc":":7b7778",
23+
"uid":"3e38e6"
24+
}],
25+
"layout": {
26+
"yaxis":{
27+
"type":"linear",
28+
"autorange":true,
29+
"rangemode":"normal",
30+
"showline":true,
31+
"mirror":true,
32+
"showgrid":true,
33+
"zeroline":false,
34+
"zerolinecolor":"rgb(214, 39, 40)"
35+
},"xaxis":{
36+
"type":"linear",
37+
"autorange":true,
38+
"rangemode":"normal",
39+
"showline":true,
40+
"mirror":true,
41+
"showgrid":true,
42+
"zeroline":false,
43+
"zerolinecolor":"rgb(214, 39, 40)"
44+
},"scene":{
45+
"xaxis":{
46+
"type":"linear",
47+
"autorange":true,
48+
"rangemode":"normal",
49+
"showline":true,
50+
"mirror":true,
51+
"showgrid":true,
52+
"zeroline":false,
53+
"zerolinecolor":"rgb(214, 39, 40)"
54+
},"yaxis":{
55+
"type":"linear",
56+
"autorange":true,
57+
"rangemode":"normal",
58+
"showline":true,
59+
"mirror":true,
60+
"showgrid":true,
61+
"zeroline":false,
62+
"zerolinecolor":"rgb(214, 39, 40)"
63+
},"zaxis":{
64+
"type":"linear",
65+
"autorange":false,
66+
"rangemode":"normal",
67+
"showline":true,
68+
"mirror":true,
69+
"showgrid":true,
70+
"zeroline":false,
71+
"zerolinecolor":"rgb(214, 39, 40)",
72+
"range":[-3,6]
73+
}
74+
},
75+
"height":758,
76+
"width":1310,
77+
"autosize":true,
78+
"showlegend":false,
79+
"dragmode":"rotate"
80+
}
81+
}

0 commit comments

Comments
 (0)