@@ -14,6 +14,8 @@ var customAssertions = require('../assets/custom_assertions');
1414var assertHoverLabelStyle = customAssertions . assertHoverLabelStyle ;
1515var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
1616
17+ var SLICES_SELECTOR = '.slice path' ;
18+ var LEGEND_ENTRIES_SELECTOR = '.legendpoints path' ;
1719
1820describe ( 'Pie defaults' , function ( ) {
1921 function _supply ( trace ) {
@@ -100,11 +102,11 @@ describe('Pie traces:', function() {
100102 expect ( this . style . stroke . replace ( / \s / g, '' ) ) . toBe ( 'rgb(100,100,100)' ) ;
101103 expect ( this . style . strokeOpacity ) . toBe ( '0.7' ) ;
102104 }
103- var slices = d3 . selectAll ( '.slice path' ) ;
105+ var slices = d3 . selectAll ( SLICES_SELECTOR ) ;
104106 slices . each ( checkPath ) ;
105107 expect ( slices . size ( ) ) . toBe ( 5 ) ;
106108
107- var legendEntries = d3 . selectAll ( '.legendpoints path' ) ;
109+ var legendEntries = d3 . selectAll ( LEGEND_ENTRIES_SELECTOR ) ;
108110 legendEntries . each ( checkPath ) ;
109111 expect ( legendEntries . size ( ) ) . toBe ( 5 ) ;
110112 } )
@@ -141,7 +143,7 @@ describe('Pie traces:', function() {
141143
142144 function _checkSliceColors ( colors ) {
143145 return function ( ) {
144- d3 . select ( gd ) . selectAll ( '.slice path' ) . each ( function ( d , i ) {
146+ d3 . select ( gd ) . selectAll ( SLICES_SELECTOR ) . each ( function ( d , i ) {
145147 expect ( this . style . fill . replace ( / ( \s | r g b \( | \) ) / g, '' ) ) . toBe ( colors [ i ] , i ) ;
146148 } ) ;
147149 } ;
@@ -182,6 +184,40 @@ describe('Pie traces:', function() {
182184 . catch ( failTest )
183185 . then ( done ) ;
184186 } ) ;
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+ } ) ;
185221} ) ;
186222
187223describe ( 'pie hovering' , function ( ) {
@@ -677,7 +713,7 @@ describe('pie relayout', function() {
677713 return Plotly . relayout ( gd , 'colorway' , relayoutColors ) ;
678714 } )
679715 . then ( function ( ) {
680- var slices = d3 . selectAll ( '.slice path' ) ;
716+ var slices = d3 . selectAll ( SLICES_SELECTOR ) ;
681717 slices . each ( checkRelayoutColor ) ;
682718 } )
683719 . then ( done ) ;
0 commit comments