@@ -17,14 +17,20 @@ var handleDomainDefaults = require('../../plots/domain').defaults;
17
17
18
18
function handleLineDefaults ( traceIn , traceOut , defaultColor , layout , coerce ) {
19
19
20
- coerce ( 'line.color' , defaultColor ) ;
21
-
22
- if ( hasColorscale ( traceIn , 'line' ) && Lib . isArray ( traceIn . line . color ) ) {
23
- coerce ( 'line.colorscale' ) ;
24
- colorscaleDefaults ( traceIn , traceOut , layout , coerce , { prefix : 'line.' , cLetter : 'c' } ) ;
25
- }
26
- else {
27
- coerce ( 'line.color' , defaultColor ) ;
20
+ var lineColor = coerce ( 'line.color' , defaultColor ) ;
21
+
22
+ if ( hasColorscale ( traceIn , 'line' ) && Lib . isArray ( lineColor ) ) {
23
+ if ( lineColor . length ) {
24
+ coerce ( 'line.colorscale' ) ;
25
+ colorscaleDefaults ( traceIn , traceOut , layout , coerce , { prefix : 'line.' , cLetter : 'c' } ) ;
26
+ // TODO: I think it would be better to keep showing lines beyond the last line color
27
+ // but I'm not sure what color to give these lines - probably black or white
28
+ // depending on the background color?
29
+ traceOut . _commonLength = Math . min ( traceOut . _commonLength , lineColor . length ) ;
30
+ }
31
+ else {
32
+ traceOut . line . color = defaultColor ;
33
+ }
28
34
}
29
35
}
30
36
@@ -53,7 +59,10 @@ function dimensionsDefaults(traceIn, traceOut) {
53
59
}
54
60
55
61
var values = coerce ( 'values' ) ;
56
- var visible = coerce ( 'visible' , values . length > 0 ) ;
62
+ var visible = coerce ( 'visible' ) ;
63
+ if ( ! ( values && values . length ) ) {
64
+ visible = dimensionOut . visible = false ;
65
+ }
57
66
58
67
if ( visible ) {
59
68
coerce ( 'label' ) ;
@@ -63,21 +72,14 @@ function dimensionsDefaults(traceIn, traceOut) {
63
72
coerce ( 'range' ) ;
64
73
coerce ( 'constraintrange' ) ;
65
74
66
- commonLength = Math . min ( commonLength , dimensionOut . values . length ) ;
75
+ commonLength = Math . min ( commonLength , values . length ) ;
67
76
}
68
77
69
78
dimensionOut . _index = i ;
70
79
dimensionsOut . push ( dimensionOut ) ;
71
80
}
72
81
73
- if ( isFinite ( commonLength ) ) {
74
- for ( i = 0 ; i < dimensionsOut . length ; i ++ ) {
75
- dimensionOut = dimensionsOut [ i ] ;
76
- if ( dimensionOut . visible && dimensionOut . values . length > commonLength ) {
77
- dimensionOut . values = dimensionOut . values . slice ( 0 , commonLength ) ;
78
- }
79
- }
80
- }
82
+ traceOut . _commonLength = commonLength ;
81
83
82
84
return dimensionsOut ;
83
85
}
@@ -97,11 +99,18 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
97
99
traceOut . visible = false ;
98
100
}
99
101
100
- // make default font size 10px,
102
+ // since we're not slicing uneven arrays anymore, stash the length in each dimension
103
+ // but we can't do this in dimensionsDefaults (yet?) because line.color can also
104
+ // truncate
105
+ for ( var i = 0 ; i < dimensions . length ; i ++ ) {
106
+ if ( dimensions [ i ] . visible ) dimensions [ i ] . _length = traceOut . _commonLength ;
107
+ }
108
+
109
+ // make default font size 10px (default is 12),
101
110
// scale linearly with global font size
102
111
var fontDflt = {
103
112
family : layout . font . family ,
104
- size : Math . round ( layout . font . size * ( 10 / 12 ) ) ,
113
+ size : Math . round ( layout . font . size / 1.2 ) ,
105
114
color : layout . font . color
106
115
} ;
107
116
0 commit comments