8
8
9
9
'use strict' ;
10
10
11
- var hasColorscale = require ( '../../components/colorscale/helpers' ) . hasColorscale ;
12
- var calcColorscale = require ( '../../components/colorscale/calc' ) ;
11
+ var Colorscale = require ( '../../components/colorscale' ) ;
13
12
var Lib = require ( '../../lib' ) ;
14
13
var wrap = require ( '../../lib/gup' ) . wrap ;
15
14
@@ -19,22 +18,24 @@ module.exports = function calc(gd, trace) {
19
18
}
20
19
trace . line . color = convertTypedArray ( trace . line . color ) ;
21
20
22
- var cs = ! ! trace . line . colorscale && Array . isArray ( trace . line . color ) ;
23
- var color = cs ? trace . line . color : constHalf ( trace . _length ) ;
24
- var cscale = cs ? trace . line . colorscale : [ [ 0 , trace . line . color ] , [ 1 , trace . line . color ] ] ;
21
+ var lineColor ;
22
+ var cscale ;
25
23
26
- if ( hasColorscale ( trace , 'line' ) ) {
27
- calcColorscale ( gd , trace , {
28
- vals : color ,
24
+ if ( Colorscale . hasColorscale ( trace , 'line' ) && Array . isArray ( trace . line . color ) ) {
25
+ lineColor = trace . line . color ;
26
+ cscale = Colorscale . extractOpts ( trace . line ) . colorscale ;
27
+
28
+ Colorscale . calc ( gd , trace , {
29
+ vals : lineColor ,
29
30
containerStr : 'line' ,
30
31
cLetter : 'c'
31
32
} ) ;
33
+ } else {
34
+ lineColor = constHalf ( trace . _length ) ;
35
+ cscale = [ [ 0 , trace . line . color ] , [ 1 , trace . line . color ] ] ;
32
36
}
33
37
34
- return wrap ( {
35
- lineColor : color ,
36
- cscale : cscale
37
- } ) ;
38
+ return wrap ( { lineColor : lineColor , cscale : cscale } ) ;
38
39
} ;
39
40
40
41
function constHalf ( len ) {
0 commit comments