88
99'use strict' ;
1010
11- var hasColorscale = require ( '../../components/colorscale/helpers' ) . hasColorscale ;
12- var calcColorscale = require ( '../../components/colorscale/calc' ) ;
11+ var Colorscale = require ( '../../components/colorscale' ) ;
1312var Lib = require ( '../../lib' ) ;
1413var wrap = require ( '../../lib/gup' ) . wrap ;
1514
@@ -19,22 +18,24 @@ module.exports = function calc(gd, trace) {
1918 }
2019 trace . line . color = convertTypedArray ( trace . line . color ) ;
2120
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 ;
2523
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 ,
2930 containerStr : 'line' ,
3031 cLetter : 'c'
3132 } ) ;
33+ } else {
34+ lineColor = constHalf ( trace . _length ) ;
35+ cscale = [ [ 0 , trace . line . color ] , [ 1 , trace . line . color ] ] ;
3236 }
3337
34- return wrap ( {
35- lineColor : color ,
36- cscale : cscale
37- } ) ;
38+ return wrap ( { lineColor : lineColor , cscale : cscale } ) ;
3839} ;
3940
4041function constHalf ( len ) {
0 commit comments