@@ -150,6 +150,52 @@ describe('restyle', function() {
150
150
expect ( firstLine2 ) . toBe ( secondLine2 ) ;
151
151
} ) . then ( done ) ;
152
152
} ) ;
153
+
154
+ it ( 'can change scatter mode' , function ( done ) {
155
+ var mock = Lib . extendDeep ( { } , require ( '@mocks/text_chart_basic.json' ) ) ;
156
+
157
+ function assertScatterModeSizes ( lineSize , pointSize , textSize ) {
158
+ var gd3 = d3 . select ( gd ) ,
159
+ lines = gd3 . selectAll ( 'g.scatter.trace .js-line' ) ,
160
+ points = gd3 . selectAll ( 'g.scatter.trace path.point' ) ,
161
+ texts = gd3 . selectAll ( 'g.scatter.trace text' ) ;
162
+
163
+ expect ( lines . size ( ) ) . toEqual ( lineSize ) ;
164
+ expect ( points . size ( ) ) . toEqual ( pointSize ) ;
165
+ expect ( texts . size ( ) ) . toEqual ( textSize ) ;
166
+ }
167
+
168
+ Plotly . plot ( gd , mock . data , mock . layout ) . then ( function ( ) {
169
+ assertScatterModeSizes ( 2 , 6 , 9 ) ;
170
+
171
+ return Plotly . restyle ( gd , 'mode' , 'lines' ) ;
172
+ } )
173
+ . then ( function ( ) {
174
+ assertScatterModeSizes ( 3 , 0 , 0 ) ;
175
+
176
+ return Plotly . restyle ( gd , 'mode' , 'markers' ) ;
177
+ } )
178
+ . then ( function ( ) {
179
+ assertScatterModeSizes ( 0 , 9 , 0 ) ;
180
+
181
+ return Plotly . restyle ( gd , 'mode' , 'markers+text' ) ;
182
+ } )
183
+ . then ( function ( ) {
184
+ assertScatterModeSizes ( 0 , 9 , 9 ) ;
185
+
186
+ return Plotly . restyle ( gd , 'mode' , 'text' ) ;
187
+ } )
188
+ . then ( function ( ) {
189
+ assertScatterModeSizes ( 0 , 0 , 9 ) ;
190
+
191
+ return Plotly . restyle ( gd , 'mode' , 'markers+text+lines' ) ;
192
+ } )
193
+ . then ( function ( ) {
194
+ assertScatterModeSizes ( 3 , 9 , 9 ) ;
195
+ } )
196
+ . then ( done ) ;
197
+
198
+ } ) ;
153
199
} ) ;
154
200
} ) ;
155
201
0 commit comments