@@ -14,6 +14,8 @@ var customAssertions = require('../assets/custom_assertions');
14
14
var assertHoverLabelStyle = customAssertions . assertHoverLabelStyle ;
15
15
var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
16
16
17
+ var SLICES_SELECTOR = '.slice path' ;
18
+ var LEGEND_ENTRIES_SELECTOR = '.legendpoints path' ;
17
19
18
20
describe ( 'Pie defaults' , function ( ) {
19
21
function _supply ( trace ) {
@@ -100,11 +102,11 @@ describe('Pie traces:', function() {
100
102
expect ( this . style . stroke . replace ( / \s / g, '' ) ) . toBe ( 'rgb(100,100,100)' ) ;
101
103
expect ( this . style . strokeOpacity ) . toBe ( '0.7' ) ;
102
104
}
103
- var slices = d3 . selectAll ( '.slice path' ) ;
105
+ var slices = d3 . selectAll ( SLICES_SELECTOR ) ;
104
106
slices . each ( checkPath ) ;
105
107
expect ( slices . size ( ) ) . toBe ( 5 ) ;
106
108
107
- var legendEntries = d3 . selectAll ( '.legendpoints path' ) ;
109
+ var legendEntries = d3 . selectAll ( LEGEND_ENTRIES_SELECTOR ) ;
108
110
legendEntries . each ( checkPath ) ;
109
111
expect ( legendEntries . size ( ) ) . toBe ( 5 ) ;
110
112
} )
@@ -141,7 +143,7 @@ describe('Pie traces:', function() {
141
143
142
144
function _checkSliceColors ( colors ) {
143
145
return function ( ) {
144
- d3 . select ( gd ) . selectAll ( '.slice path' ) . each ( function ( d , i ) {
146
+ d3 . select ( gd ) . selectAll ( SLICES_SELECTOR ) . each ( function ( d , i ) {
145
147
expect ( this . style . fill . replace ( / ( \s | r g b \( | \) ) / g, '' ) ) . toBe ( colors [ i ] , i ) ;
146
148
} ) ;
147
149
} ;
@@ -182,6 +184,40 @@ describe('Pie traces:', function() {
182
184
. catch ( failTest )
183
185
. then ( done ) ;
184
186
} ) ;
187
+
188
+ it ( 'supports separate stroke width values per slice' , function ( done ) {
189
+ var data = [
190
+ {
191
+ values : [ 20 , 26 , 55 ] ,
192
+ labels : [ 'Residential' , 'Non-Residential' , 'Utility' ] ,
193
+ type : 'pie' ,
194
+ pull : [ 0.1 , 0 , 0 ] ,
195
+ marker : {
196
+ colors : [ 'rebeccapurple' , 'purple' , 'mediumpurple' ] ,
197
+ line : {
198
+ width : [ 3 , 0 , 0 ]
199
+ }
200
+ }
201
+ }
202
+ ] ;
203
+ var layout = {
204
+ showlegend : true
205
+ } ;
206
+
207
+ Plotly . plot ( gd , data , layout )
208
+ . then ( function ( ) {
209
+ var expWidths = [ '3' , '0' , '0' ] ;
210
+
211
+ d3 . selectAll ( SLICES_SELECTOR ) . each ( function ( d ) {
212
+ expect ( this . style . strokeWidth ) . toBe ( expWidths [ d . pointNumber ] ) ;
213
+ } ) ;
214
+ d3 . selectAll ( LEGEND_ENTRIES_SELECTOR ) . each ( function ( d ) {
215
+ expect ( this . style . strokeWidth ) . toBe ( expWidths [ d [ 0 ] . i ] ) ;
216
+ } ) ;
217
+ } )
218
+ . catch ( failTest )
219
+ . then ( done ) ;
220
+ } ) ;
185
221
} ) ;
186
222
187
223
describe ( 'pie hovering' , function ( ) {
@@ -677,7 +713,7 @@ describe('pie relayout', function() {
677
713
return Plotly . relayout ( gd , 'colorway' , relayoutColors ) ;
678
714
} )
679
715
. then ( function ( ) {
680
- var slices = d3 . selectAll ( '.slice path' ) ;
716
+ var slices = d3 . selectAll ( SLICES_SELECTOR ) ;
681
717
slices . each ( checkRelayoutColor ) ;
682
718
} )
683
719
. then ( done ) ;
0 commit comments