File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,9 @@ define(
159
159
160
160
// Update dimensions and origin based on extrema of plots
161
161
PlotUpdater . prototype . updateBounds = function ( ) {
162
- var bufferArray = this . bufferArray ,
162
+ var bufferArray = this . bufferArray . filter ( function ( lineBuffer ) {
163
+ return lineBuffer . getLength ( ) > 0 ; // Ignore empty lines
164
+ } ) ,
163
165
priorDomainOrigin = this . origin [ 0 ] ,
164
166
priorDomainDimensions = this . dimensions [ 0 ] ;
165
167
Original file line number Diff line number Diff line change @@ -202,6 +202,38 @@ define(
202
202
expect ( updater . getDimensions ( ) [ 1 ] ) . toBeGreaterThan ( 20 ) ;
203
203
} ) ;
204
204
205
+ describe ( "when no data is initially available" , function ( ) {
206
+ beforeEach ( function ( ) {
207
+ testDomainValues = { } ;
208
+ testRangeValues = { } ;
209
+ updater = new PlotUpdater (
210
+ mockSubscription ,
211
+ testDomain ,
212
+ testRange ,
213
+ 1350 // Smaller max size for easier testing
214
+ ) ;
215
+ } ) ;
216
+
217
+ it ( "has no line data" , function ( ) {
218
+ // Either no lines, or empty lines are fine
219
+ expect ( updater . getLineBuffers ( ) . map ( function ( lineBuffer ) {
220
+ return lineBuffer . getLength ( ) ;
221
+ } ) . reduce ( function ( a , b ) {
222
+ return a + b ;
223
+ } , 0 ) ) . toEqual ( 0 ) ;
224
+ } ) ;
225
+
226
+ it ( "determines initial domain bounds from first available data" , function ( ) {
227
+ testDomainValues . a = 123 ;
228
+ testRangeValues . a = 456 ;
229
+ updater . update ( ) ;
230
+ expect ( updater . getOrigin ( ) [ 0 ] ) . toEqual ( jasmine . any ( Number ) ) ;
231
+ expect ( updater . getOrigin ( ) [ 1 ] ) . toEqual ( jasmine . any ( Number ) ) ;
232
+ expect ( isNaN ( updater . getOrigin ( ) [ 0 ] ) ) . toBeFalsy ( ) ;
233
+ expect ( isNaN ( updater . getOrigin ( ) [ 1 ] ) ) . toBeFalsy ( ) ;
234
+ } ) ;
235
+ } ) ;
236
+
205
237
} ) ;
206
238
}
207
239
) ;
You can’t perform that action at this time.
0 commit comments