|
228 | 228 | } |
229 | 229 |
|
230 | 230 | // update the position |
231 | | - this.position = (this.position + tle) % this.size; |
| 231 | + this.position = (this.position + tle); |
| 232 | + // after we get one full buffer of data we can initialize maxhold and |
| 233 | + // no longer rescale on first push |
| 234 | + if ((this.position >= this.size) && (this.firstpush === false)) { |
| 235 | + this.firstpush = true; |
| 236 | + if (this.mhpoint) { |
| 237 | + this.mhpoint.fill(-Infinity); |
| 238 | + } |
| 239 | + } |
| 240 | + this.position = this.position % this.size; |
232 | 241 |
|
233 | 242 | if (this.tle === undefined) { |
234 | 243 | tle = Math.floor(m.pavail(this.hcb)) / this.hcb.spa; |
|
325 | 334 | this.maxhold.decay = 0; |
326 | 335 | } |
327 | 336 | if (this.mhpoint) { |
328 | | - // clear the maxhold buffer by setting to the current ypoint |
329 | | - this.mhpoint.set(this.ypoint); |
| 337 | + // clear the maxhold buffer by setting to negative Infinity |
| 338 | + this.mhpoint.fill(-Infinity); |
330 | 339 | } else { |
331 | 340 | this.mhptr = new ArrayBuffer(this.pointbufsize); |
332 | 341 | this.mhpoint = new m.PointArray(this.mhptr); |
333 | | - this.mhpoint.set(this.ypoint); |
| 342 | + this.mhpoint.fill(-Infinity); |
334 | 343 | } |
335 | 344 | } else if (settings.maxhold === null) { |
336 | 345 | this.maxhold = undefined; |
|
349 | 358 | if (this.maxhold) { |
350 | 359 | this.mhptr = new ArrayBuffer(this.pointbufsize); |
351 | 360 | this.mhpoint = new m.PointArray(this.mhptr); |
| 361 | + this.mhpoint.fill(-Infinity); |
352 | 362 | } |
353 | 363 | } |
354 | 364 |
|
|
420 | 430 | this.ymin = null; |
421 | 431 | this.ymax = null; |
422 | 432 | } |
| 433 | + this.firstpush = false; |
423 | 434 | } |
424 | 435 |
|
425 | 436 | this.xdelta = this.hcb.xdelta; |
|
436 | 447 |
|
437 | 448 | // if this is the first push of data, request a rescale |
438 | 449 | if (this.firstpush === false) { |
439 | | - this.firstpush = true; |
440 | 450 | hdrmod = true; |
441 | 451 | } |
442 | 452 | return hdrmod ? true : false; |
|
470 | 480 | this.yptr = new ArrayBuffer(this.pointbufsize); |
471 | 481 | this.xpoint = new m.PointArray(this.xptr); |
472 | 482 | this.ypoint = new m.PointArray(this.yptr); |
| 483 | + // invalidate max hold buffers |
| 484 | + this.mhptr = null; |
| 485 | + this.mhpoint = null; |
473 | 486 | if (this.maxhold) { |
474 | 487 | this.mhptr = new ArrayBuffer(this.pointbufsize); |
475 | 488 | this.mhpoint = new m.PointArray(this.mhptr); |
| 489 | + this.mhpoint.fill(-Infinity); |
476 | 490 | } |
477 | 491 | } |
478 | 492 |
|
|
0 commit comments