@@ -5,6 +5,7 @@ var Lib = require('../../lib');
55
66var Drawing = require ( '../../components/drawing' ) ;
77var Colorscale = require ( '../../components/colorscale' ) ;
8+ const Color = require ( '../../components/color' ) ;
89var DESELECTDIM = require ( '../../constants/interactions' ) . DESELECTDIM ;
910
1011// Stroke each arrow path according to the trace colorscale, using marker.color
@@ -33,6 +34,29 @@ function colorscaleStroke(paths, trace) {
3334 } ) ;
3435}
3536
37+ // A color-string array is not a colorscale. Apply each string here, because
38+ // `lineGroupStyle` paints an array as black.
39+ const strokeArrowColors = ( paths , trace ) => {
40+ if ( trace . _hasColorscale ) {
41+ colorscaleStroke ( paths , trace ) ;
42+ return ;
43+ }
44+
45+ const markerColor = ( trace . marker || { } ) . color ;
46+ if ( ! Lib . isArrayOrTypedArray ( markerColor ) ) return ;
47+
48+ paths . style ( 'stroke' , function ( cdi ) {
49+ if ( markerColor . length > cdi . i ) {
50+ const color = markerColor [ cdi . i ] ;
51+ if ( Color . isValid ( color ) ) {
52+ cdi . mcc = color ;
53+ return color ;
54+ }
55+ }
56+ return this . style . stroke ;
57+ } ) ;
58+ } ;
59+
3660function style ( gd ) {
3761 var s = d3 . select ( gd ) . selectAll ( 'g.trace.quiver' ) ;
3862 s . each ( function ( d ) {
@@ -49,7 +73,6 @@ function styleArrows(gd, cd, sel) {
4973 var marker = trace . marker || { } ;
5074 var markerLine = marker . line || { } ;
5175 var lineColor = Lib . isArrayOrTypedArray ( marker . color ) ? undefined : marker . color ;
52- var hasColorscale = trace . _hasColorscale ;
5376
5477 if ( ! sel ) return ;
5578
@@ -78,7 +101,7 @@ function styleArrows(gd, cd, sel) {
78101 // color, so we keep each arrow's color and dim unselected arrows
79102 // via stroke-opacity instead.
80103 Drawing . lineGroupStyle ( path , lineWidth , lineColor , markerLine . dash ) ;
81- if ( hasColorscale ) colorscaleStroke ( path , trace ) ;
104+ strokeArrowColors ( path , trace ) ;
82105 path . style ( 'stroke-opacity' , dim ? DESELECTDIM : 1 ) ;
83106 }
84107 } ) ;
@@ -87,14 +110,15 @@ function styleArrows(gd, cd, sel) {
87110 } else {
88111 var paths = sel . selectAll ( 'path.js-line' ) ;
89112 paths . call ( Drawing . lineGroupStyle , markerLine . width , lineColor , markerLine . dash ) ;
90- if ( hasColorscale ) colorscaleStroke ( paths , trace ) ;
113+ strokeArrowColors ( paths , trace ) ;
91114 paths . style ( 'stroke-opacity' , 1 ) ;
92115 Drawing . textPointStyle ( sel . selectAll ( 'text' ) , trace , gd ) ;
93116 }
94117}
95118
96119module . exports = {
97- style : style ,
98- styleOnSelect : styleOnSelect ,
99- colorscaleStroke : colorscaleStroke
120+ style,
121+ styleOnSelect,
122+ colorscaleStroke,
123+ strokeArrowColors
100124} ;
0 commit comments