blazeplot 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -161,13 +161,16 @@ function o(e) {
161
161
  function s(e) {
162
162
  return "copyVisibleSamples" in e;
163
163
  }
164
- var c = 64;
165
- function l(e, t, n, r, i) {
164
+ function c(e) {
165
+ return "copyVisiblePoints" in e;
166
+ }
167
+ var l = 64, u = 64, d = 1024;
168
+ function f(e, t, n, r, i) {
166
169
  if (n === e) return t;
167
170
  let a = (i - e) / (n - e);
168
171
  return t + (r - t) * a;
169
172
  }
170
- var u = class {
173
+ var p = class {
171
174
  config;
172
175
  style;
173
176
  dataset;
@@ -179,7 +182,7 @@ var u = class {
179
182
  _lastBuildRangeStart = NaN;
180
183
  _visible = !0;
181
184
  constructor(e, t, i) {
182
- this.dataset = e, this.config = t, this.pyramid = (t.mode === "line" || t.mode === "bar") && t.downsample !== "none" ? new n() : null, this._useDatasetRangeMinMax = r(e), this.style = i, this.pyramid && e.length > 0 && !this._useDatasetRangeMinMax && this.pyramid.build(e), this._lastBuildLength = e.length, this._lastBuildRangeStart = e.range?.start ?? NaN;
185
+ this.dataset = e, this.config = t, this.pyramid = (t.mode === "line" || t.mode === "bar" || t.mode === "scatter") && t.downsample !== "none" ? new n() : null, this._useDatasetRangeMinMax = r(e), this.style = i, this.pyramid && e.length > 0 && !this._useDatasetRangeMinMax && this.pyramid.build(e), this._lastBuildLength = e.length, this._lastBuildRangeStart = e.range?.start ?? NaN;
183
186
  }
184
187
  get hasLOD() {
185
188
  return this.pyramid !== null;
@@ -248,13 +251,13 @@ var u = class {
248
251
  return this.sampleAt(i);
249
252
  }
250
253
  nearestSampleByPoint(e, t, n, r, i, a = Infinity) {
251
- let o = this.visibleIndexRange(n), s = n.xMax - n.xMin, l = n.yMax - n.yMin;
252
- if (o.start >= o.end || r <= 0 || i <= 0 || s <= 0 || l <= 0) return null;
253
- let u = r / s, d = i / l, f = -1, p = a < 0 ? -1 : Number.isFinite(a) ? a * a : Infinity, m = (n) => {
254
+ let o = this.visibleIndexRange(n), s = n.xMax - n.xMin, c = n.yMax - n.yMin;
255
+ if (o.start >= o.end || r <= 0 || i <= 0 || s <= 0 || c <= 0) return null;
256
+ let u = r / s, d = i / c, f = -1, p = a < 0 ? -1 : Number.isFinite(a) ? a * a : Infinity, m = (n) => {
254
257
  let r = (this.dataset.getX(n) - e) * u, i = (this.dataset.getY(n) - t) * d, a = r * r + i * i;
255
258
  (a < p || f < 0 && a <= p) && (p = a, f = n);
256
259
  }, h = this.dataset.lowerBoundX(e), g = Math.min(Math.max(h, o.start), o.end - 1);
257
- if (m(g), g > o.start && m(g - 1), g + 1 < o.end && m(g + 1), this.hasPointIntervalBounds() && o.end - o.start > c) {
260
+ if (m(g), g > o.start && m(g - 1), g + 1 < o.end && m(g + 1), this.hasPointIntervalBounds() && o.end - o.start > l) {
258
261
  let n = this.pointIntervalDistanceSq(o.start, o.end, e, t, u, d), r = n <= p ? [{
259
262
  start: o.start,
260
263
  end: o.end,
@@ -264,11 +267,11 @@ var u = class {
264
267
  let n = r.pop();
265
268
  if (n.lowerBoundSq > p) continue;
266
269
  let i = n.end - n.start;
267
- if (i <= c) {
270
+ if (i <= l) {
268
271
  for (let e = n.start; e < n.end; e++) m(e);
269
272
  continue;
270
273
  }
271
- let a = n.start + (i >> 1), o = this.pointIntervalDistanceSq(n.start, a, e, t, u, d), s = this.pointIntervalDistanceSq(a, n.end, e, t, u, d), l = {
274
+ let a = n.start + (i >> 1), o = this.pointIntervalDistanceSq(n.start, a, e, t, u, d), s = this.pointIntervalDistanceSq(a, n.end, e, t, u, d), c = {
272
275
  start: n.start,
273
276
  end: a,
274
277
  lowerBoundSq: o
@@ -277,7 +280,7 @@ var u = class {
277
280
  end: n.end,
278
281
  lowerBoundSq: s
279
282
  };
280
- o < s ? (s <= p && r.push(f), o <= p && r.push(l)) : (o <= p && r.push(l), s <= p && r.push(f));
283
+ o < s ? (s <= p && r.push(f), o <= p && r.push(c)) : (o <= p && r.push(c), s <= p && r.push(f));
281
284
  }
282
285
  } else {
283
286
  let t = Math.min(h - 1, o.end - 1), n = Math.max(h, o.start);
@@ -297,6 +300,22 @@ var u = class {
297
300
  copyRawVisible(e, t, n, r = 0) {
298
301
  return this.copyVisibleSamples(e, t, n, "points", 0, r);
299
302
  }
303
+ copyScatterVisible(e, t, n, r, i, a, o = 0) {
304
+ return this.copyVisiblePoints(e, t, n, r, i, a, o);
305
+ }
306
+ copyScatterRange(e, t, n, r, i, a = 0, o = 0, s = 0) {
307
+ if (i <= 0 || r.length < i * 2) return 0;
308
+ let c = Math.max(0, Math.floor(e)), l = Math.min(this.dataset.length, Math.ceil(t));
309
+ if (l <= c) return 0;
310
+ let u = n.yMax - n.yMin, d = Math.max(0, Math.floor(o)), f = u > 0 && d > 0 ? (Number.isFinite(s) ? Math.max(0, s) : 0) * .5 / d * u : 0, p = n.yMin - f, m = n.yMax + f, h = 0;
311
+ for (let e = c; e < l && h < i; e++) {
312
+ let t = this.dataset.getY(e);
313
+ if (t < p || t > m) continue;
314
+ let n = h * 2;
315
+ r[n] = this.dataset.getX(e) - a, r[n + 1] = t, h++;
316
+ }
317
+ return h;
318
+ }
300
319
  copyRawVisibleClipped(e, t, n, r = 0) {
301
320
  return this.copyClippedVisibleLine(e, t, n, r, "data");
302
321
  }
@@ -370,26 +389,110 @@ var u = class {
370
389
  if (i === "clip" && (a <= 0 || o <= 0)) return 0;
371
390
  let s = Math.max(0, this.dataset.lowerBoundX(e.xMin) - 1), c = Math.min(this.dataset.length, this.dataset.upperBoundX(e.xMax) + 1);
372
391
  if (c - s <= 0) return 0;
373
- let u = 0, d = NaN, f = NaN, p = (s, c) => {
374
- let l = i === "clip" ? (s - e.xMin) / a * 2 - 1 : s - r, p = i === "clip" ? (c - e.yMin) / o * 2 - 1 : c;
375
- if (u > 0 && l === d && p === f) return !0;
376
- if (u >= n) return !1;
377
- let m = u * 2;
378
- return t[m] = l, t[m + 1] = p, u++, d = l, f = p, !0;
392
+ let l = 0, u = NaN, d = NaN, p = (s, c) => {
393
+ let f = i === "clip" ? (s - e.xMin) / a * 2 - 1 : s - r, p = i === "clip" ? (c - e.yMin) / o * 2 - 1 : c;
394
+ if (l > 0 && f === u && p === d) return !0;
395
+ if (l >= n) return !1;
396
+ let m = l * 2;
397
+ return t[m] = f, t[m + 1] = p, l++, u = f, d = p, !0;
379
398
  };
380
399
  if (c - s === 1) {
381
400
  let t = this.dataset.getX(s);
382
- return t < e.xMin || t > e.xMax ? 0 : p(t, this.dataset.getY(s)) ? u : 0;
401
+ return t < e.xMin || t > e.xMax ? 0 : p(t, this.dataset.getY(s)) ? l : 0;
383
402
  }
384
403
  for (let t = s; t + 1 < c; t++) {
385
404
  let n = this.dataset.getX(t), r = this.dataset.getY(t), i = this.dataset.getX(t + 1), a = this.dataset.getY(t + 1);
386
405
  if (i < e.xMin || n > e.xMax) continue;
387
406
  let o = Math.max(n, e.xMin), s = Math.min(i, e.xMax);
388
407
  if (s < o) continue;
389
- let c = l(n, r, i, a, o), u = l(n, r, i, a, s);
390
- if (!p(o, c) || !p(s, u)) break;
408
+ let c = f(n, r, i, a, o), l = f(n, r, i, a, s);
409
+ if (!p(o, c) || !p(s, l)) break;
391
410
  }
392
- return u;
411
+ return l;
412
+ }
413
+ copyVisiblePoints(e, t, n, r, i, a, o) {
414
+ if (c(this.dataset)) return this.dataset.copyVisiblePoints(e, t, n, o, r, i, a);
415
+ if (n <= 0 || t.length < n * 2) return 0;
416
+ let s = e.xMax - e.xMin, l = e.yMax - e.yMin, u = Math.max(1, Math.floor(r)), d = Math.max(1, Math.floor(i));
417
+ if (s <= 0 || l <= 0) return 0;
418
+ let f = (Number.isFinite(a) ? Math.max(0, a) : 0) * .5, p = f / u * s, m = f / d * l, h = e.xMin - p, g = e.xMax + p, _ = e.yMin - m, v = e.yMax + m, y = this.dataset.lowerBoundX(h), b = this.dataset.upperBoundX(g);
419
+ if (b <= y) return 0;
420
+ if (b - y <= n) return this.copyVisiblePointRange(y, b, _, v, t, n, o);
421
+ let x = this.hasPointIntervalBounds(), S = x ? this.pointIntervalMinMaxY(y, b) : null;
422
+ if (S && (S.maxY < _ || S.minY > v)) return 0;
423
+ if (b - y <= n * 4) {
424
+ let e = this.copyVisiblePointsExact(y, b, _, v, t, n, o);
425
+ if (!e.overflow) return e.count;
426
+ }
427
+ let C = S !== null && S.minY >= _ && S.maxY <= v;
428
+ return this.copyVisiblePointBuckets(y, b, _, v, t, n, o, C, x);
429
+ }
430
+ copyVisiblePointRange(e, t, n, r, i, a, o) {
431
+ let s = 0;
432
+ for (let c = e; c < t && s < a; c++) {
433
+ let e = this.dataset.getY(c);
434
+ if (e < n || e > r) continue;
435
+ let t = s * 2;
436
+ i[t] = this.dataset.getX(c) - o, i[t + 1] = e, s++;
437
+ }
438
+ return s;
439
+ }
440
+ copyVisiblePointBuckets(e, t, n, r, i, a, o, s, c) {
441
+ let l = t - e, u = this.stableScatterBucketWidth(l, a), f = Math.floor(e / u) * u, p = 0, m = (e) => {
442
+ let t = p * 2;
443
+ i[t] = this.dataset.getX(e) - o, i[t + 1] = this.dataset.getY(e), p++;
444
+ };
445
+ for (let l = f; l < t && p < a; l += u) {
446
+ let a = Math.min(t, l + u), f = Math.max(e, l);
447
+ if (a <= f) continue;
448
+ let h = Math.max(f, Math.min(a - 1, l + (u >> 1)));
449
+ if (s) {
450
+ m(h);
451
+ continue;
452
+ }
453
+ let g = c && a - f >= d ? this.pointIntervalMinMaxY(f, a) : null;
454
+ if (!(g && (g.maxY < n || g.minY > r))) {
455
+ if (g && g.minY >= n && g.maxY <= r) {
456
+ m(h);
457
+ continue;
458
+ }
459
+ for (let e = f; e < a; e++) {
460
+ let t = this.dataset.getY(e);
461
+ if (t < n || t > r) continue;
462
+ let a = p * 2;
463
+ i[a] = this.dataset.getX(e) - o, i[a + 1] = t, p++;
464
+ break;
465
+ }
466
+ }
467
+ }
468
+ return p;
469
+ }
470
+ stableScatterBucketWidth(e, t) {
471
+ let n = Math.max(1, Math.ceil(e / Math.max(1, t)));
472
+ return n <= 8 ? n : Math.ceil(n / 8) * 8;
473
+ }
474
+ copyVisiblePointsExact(e, t, n, r, i, a, o) {
475
+ let s = 0, c = !1, l = this.hasPointIntervalBounds(), d = (e) => {
476
+ let t = this.dataset.getY(e);
477
+ if (t < n || t > r) return !0;
478
+ if (s >= a) return c = !0, !1;
479
+ let l = s * 2;
480
+ return i[l] = this.dataset.getX(e) - o, i[l + 1] = t, s++, !0;
481
+ }, f = (e, t) => {
482
+ for (let n = e; n < t; n++) if (!d(n)) return !1;
483
+ return !0;
484
+ }, p = (e, t) => {
485
+ if (t <= e) return !0;
486
+ let i = l ? this.pointIntervalMinMaxY(e, t) : null;
487
+ if (i && (i.maxY < n || i.minY > r)) return !0;
488
+ if (t - e <= u || !l) return f(e, t);
489
+ let a = e + (t - e >> 1);
490
+ return p(e, a) && p(a, t);
491
+ };
492
+ return p(e, t), {
493
+ count: s,
494
+ overflow: c
495
+ };
393
496
  }
394
497
  copyVisibleSamples(e, t, n, r, i, a) {
395
498
  if (s(this.dataset)) return this.dataset.copyVisibleSamples(e, t, n, r, i, a);
@@ -488,7 +591,7 @@ var u = class {
488
591
  };
489
592
  //#endregion
490
593
  //#region src/core/search.ts
491
- function d(e, t, n) {
594
+ function m(e, t, n) {
492
595
  let r = 0, i = e;
493
596
  for (; r < i;) {
494
597
  let e = r + (i - r >> 1);
@@ -496,7 +599,7 @@ function d(e, t, n) {
496
599
  }
497
600
  return r;
498
601
  }
499
- function f(e, t, n) {
602
+ function h(e, t, n) {
500
603
  let r = 0, i = e;
501
604
  for (; r < i;) {
502
605
  let e = r + (i - r >> 1);
@@ -506,7 +609,7 @@ function f(e, t, n) {
506
609
  }
507
610
  //#endregion
508
611
  //#region src/core/RingBuffer.ts
509
- var p = class e {
612
+ var g = class e {
510
613
  capacity;
511
614
  _length = 0;
512
615
  _head = 0;
@@ -568,10 +671,10 @@ var p = class e {
568
671
  return this.assertValidIndex(e), this.yData[this.logicalToPhysical(e)];
569
672
  }
570
673
  lowerBoundX(e) {
571
- return d(this._length, (e) => this.getX(e), e);
674
+ return m(this._length, (e) => this.getX(e), e);
572
675
  }
573
676
  upperBoundX(e) {
574
- return f(this._length, (e) => this.getX(e), e);
677
+ return h(this._length, (e) => this.getX(e), e);
575
678
  }
576
679
  rangeMinMaxY(e, t) {
577
680
  let n = Math.max(0, Math.floor(e)), r = Math.min(this._length, Math.ceil(t));
@@ -648,32 +751,32 @@ var p = class e {
648
751
  static nextPowerOfTwo(e) {
649
752
  return 2 ** Math.ceil(Math.log2(e));
650
753
  }
651
- }, m = "attribute vec2 position;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\n\nvoid main() {\n vec2 clipSpace = position * uScale + uOffset;\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n}\n", h = "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n", g = "attribute float aX;\nattribute float aMinY;\nattribute float aMaxY;\nattribute float aSelect;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\n\nvoid main() {\n float y = (aSelect < 0.5) ? aMinY : aMaxY;\n vec2 position = vec2(aX, y);\n vec2 clipSpace = position * uScale + uOffset;\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n}\n", _ = "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n", v = "attribute vec2 aPosition;\nattribute vec2 aCorner;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\nuniform vec2 uCanvasSize;\nuniform float uPointSize;\n\nvoid main() {\n vec2 centerClip = aPosition * uScale + uOffset;\n vec2 pointSizeClip = vec2(2.0 / uCanvasSize.x, 2.0 / uCanvasSize.y) * uPointSize * 0.5;\n vec2 clipSpace = centerClip + aCorner * pointSizeClip;\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n}\n", y = "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n", ee = "attribute vec2 aPosition;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\nuniform float uPointSize;\n\nvoid main() {\n vec2 clipSpace = aPosition * uScale + uOffset;\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n gl_PointSize = uPointSize;\n}\n", te = "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n vec2 p = gl_PointCoord * 2.0 - 1.0;\n if (dot(p, p) > 1.0) discard;\n gl_FragColor = uColor;\n}\n", ne = "attribute vec2 aPosition;\nattribute vec2 aCorner;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\nuniform float uBarWidth;\nuniform float uBaseline;\n\nvoid main() {\n float x = aPosition.x + aCorner.x * uBarWidth;\n float y = mix(uBaseline, aPosition.y, aCorner.y);\n vec2 clipSpace = vec2(x, y) * uScale + uOffset;\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n}\n", re = "attribute float aX;\nattribute float aMinY;\nattribute float aMaxY;\nattribute vec2 aCorner;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\nuniform float uBarWidth;\n\nvoid main() {\n float x = aX + aCorner.x * uBarWidth;\n float y = mix(aMinY, aMaxY, aCorner.y);\n vec2 clipSpace = vec2(x, y) * uScale + uOffset;\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n}\n", b = "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n", x = {
754
+ }, _ = "attribute vec2 position;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\n\nvoid main() {\n vec2 clipSpace = position * uScale + uOffset;\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n}\n", v = "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n", y = "attribute float aX;\nattribute float aMinY;\nattribute float aMaxY;\nattribute float aSelect;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\n\nvoid main() {\n float y = (aSelect < 0.5) ? aMinY : aMaxY;\n vec2 position = vec2(aX, y);\n vec2 clipSpace = position * uScale + uOffset;\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n}\n", b = "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n", x = "attribute vec2 aPosition;\nattribute vec2 aCorner;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\nuniform vec2 uCanvasSize;\nuniform float uPointSize;\n\nvoid main() {\n vec2 centerClip = aPosition * uScale + uOffset;\n vec2 pointSizeClip = vec2(2.0 / uCanvasSize.x, 2.0 / uCanvasSize.y) * uPointSize * 0.5;\n vec2 clipSpace = centerClip + aCorner * pointSizeClip;\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n}\n", S = "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n", C = "attribute vec2 aPosition;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\nuniform float uPointSize;\n\nvoid main() {\n vec2 clipSpace = aPosition * uScale + uOffset;\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n gl_PointSize = uPointSize;\n}\n", ee = "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n vec2 p = gl_PointCoord * 2.0 - 1.0;\n if (dot(p, p) > 1.0) discard;\n gl_FragColor = uColor;\n}\n", te = "attribute vec2 aPosition;\nattribute vec2 aCorner;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\nuniform float uBarWidth;\nuniform float uBaseline;\n\nvoid main() {\n float x = aPosition.x + aCorner.x * uBarWidth;\n float y = mix(uBaseline, aPosition.y, aCorner.y);\n vec2 clipSpace = vec2(x, y) * uScale + uOffset;\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n}\n", ne = "attribute float aX;\nattribute float aMinY;\nattribute float aMaxY;\nattribute vec2 aCorner;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\nuniform float uBarWidth;\n\nvoid main() {\n float x = aX + aCorner.x * uBarWidth;\n float y = mix(aMinY, aMaxY, aCorner.y);\n vec2 clipSpace = vec2(x, y) * uScale + uOffset;\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n}\n", w = "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n", T = {
652
755
  line: {
653
- vert: m,
654
- frag: h
756
+ vert: _,
757
+ frag: v
655
758
  },
656
759
  segment: {
657
- vert: g,
658
- frag: _
760
+ vert: y,
761
+ frag: b
659
762
  },
660
763
  point: {
661
- vert: v,
662
- frag: y
764
+ vert: x,
765
+ frag: S
663
766
  },
664
767
  pointSprite: {
665
- vert: ee,
666
- frag: te
768
+ vert: C,
769
+ frag: ee
667
770
  },
668
771
  bar: {
669
- vert: ne,
670
- frag: b
772
+ vert: te,
773
+ frag: w
671
774
  },
672
775
  barRange: {
673
- vert: re,
674
- frag: b
776
+ vert: ne,
777
+ frag: w
675
778
  }
676
- }, S = 3, C = 2, w = 4, T = 4, E = .8, D = 0, O = class {
779
+ }, E = 3, D = 2, O = 4, k = 4, A = .8, re = 0, ie = class {
677
780
  backend;
678
781
  lineProgram;
679
782
  segmentProgram;
@@ -689,7 +792,7 @@ var p = class e {
689
792
  canvasSizeUniform = new Float32Array(2);
690
793
  xOrigin = 0;
691
794
  constructor(e) {
692
- this.backend = e, this.lineProgram = this.backend.createProgram(x.line.vert, x.line.frag), this.segmentProgram = this.backend.createProgram(x.segment.vert, x.segment.frag), this.pointProgram = this.backend.createProgram(x.point.vert, x.point.frag), this.pointSpriteProgram = this.backend.createProgram(x.pointSprite.vert, x.pointSprite.frag), this.barProgram = this.backend.createProgram(x.bar.vert, x.bar.frag), this.barRangeProgram = this.backend.createProgram(x.barRange.vert, x.barRange.frag), this.segmentSelectBuffer = this.backend.createBuffer({
795
+ this.backend = e, this.lineProgram = this.backend.createProgram(T.line.vert, T.line.frag), this.segmentProgram = this.backend.createProgram(T.segment.vert, T.segment.frag), this.pointProgram = this.backend.createProgram(T.point.vert, T.point.frag), this.pointSpriteProgram = this.backend.createProgram(T.pointSprite.vert, T.pointSprite.frag), this.barProgram = this.backend.createProgram(T.bar.vert, T.bar.frag), this.barRangeProgram = this.backend.createProgram(T.barRange.vert, T.barRange.frag), this.segmentSelectBuffer = this.backend.createBuffer({
693
796
  usage: "static",
694
797
  type: "float",
695
798
  length: 2
@@ -750,6 +853,9 @@ var p = class e {
750
853
  setXOrigin(e) {
751
854
  this.xOrigin = Number.isFinite(e) ? e : 0;
752
855
  }
856
+ getWebGLContext() {
857
+ return this.backend.getContext?.() ?? null;
858
+ }
753
859
  drawLines(e, t, n, r) {
754
860
  this.drawLinePrimitive("lines", e, t, n, r);
755
861
  }
@@ -767,7 +873,7 @@ var p = class e {
767
873
  }
768
874
  drawMinMaxSegmentsInstanced(e, t, n, r) {
769
875
  this.writeCameraUniforms(r);
770
- let i = S * w, a = {
876
+ let i = E * O, a = {
771
877
  buffer: e,
772
878
  divisor: 1,
773
879
  stride: i,
@@ -776,16 +882,16 @@ var p = class e {
776
882
  buffer: e,
777
883
  divisor: 1,
778
884
  stride: i,
779
- offset: w
885
+ offset: O
780
886
  }, s = {
781
887
  buffer: e,
782
888
  divisor: 1,
783
889
  stride: i,
784
- offset: w * 2
890
+ offset: O * 2
785
891
  }, c = {
786
892
  buffer: this.segmentSelectBuffer,
787
893
  divisor: 0,
788
- stride: w,
894
+ stride: O,
789
895
  offset: 0
790
896
  };
791
897
  this.backend.draw({
@@ -814,13 +920,13 @@ var p = class e {
814
920
  let o = {
815
921
  buffer: e,
816
922
  divisor: 1,
817
- stride: C * w,
923
+ stride: D * O,
818
924
  offset: 0,
819
925
  size: 2
820
926
  }, s = {
821
927
  buffer: this.pointCornerBuffer,
822
928
  divisor: 0,
823
- stride: C * w,
929
+ stride: D * O,
824
930
  offset: 0,
825
931
  size: 2
826
932
  };
@@ -837,7 +943,7 @@ var p = class e {
837
943
  uScale: this.scaleUniform,
838
944
  uOffset: this.offsetUniform,
839
945
  uCanvasSize: this.canvasSizeUniform,
840
- uPointSize: n.pointSize ?? T,
946
+ uPointSize: n.pointSize ?? k,
841
947
  uColor: n.color
842
948
  }
843
949
  });
@@ -851,7 +957,7 @@ var p = class e {
851
957
  uniforms: {
852
958
  uScale: this.scaleUniform,
853
959
  uOffset: this.offsetUniform,
854
- uPointSize: n.pointSize ?? T,
960
+ uPointSize: n.pointSize ?? k,
855
961
  uColor: n.color
856
962
  }
857
963
  });
@@ -874,13 +980,13 @@ var p = class e {
874
980
  let i = {
875
981
  buffer: e,
876
982
  divisor: 1,
877
- stride: C * w,
983
+ stride: D * O,
878
984
  offset: 0,
879
985
  size: 2
880
986
  }, a = {
881
987
  buffer: this.barCornerBuffer,
882
988
  divisor: 0,
883
- stride: C * w,
989
+ stride: D * O,
884
990
  offset: 0,
885
991
  size: 2
886
992
  };
@@ -896,15 +1002,15 @@ var p = class e {
896
1002
  uniforms: {
897
1003
  uScale: this.scaleUniform,
898
1004
  uOffset: this.offsetUniform,
899
- uBarWidth: n.barWidth ?? E,
900
- uBaseline: n.baseline ?? D,
1005
+ uBarWidth: n.barWidth ?? A,
1006
+ uBaseline: n.baseline ?? re,
901
1007
  uColor: n.color
902
1008
  }
903
1009
  });
904
1010
  }
905
1011
  drawBarRangesInstanced(e, t, n, r) {
906
1012
  this.writeCameraUniforms(r);
907
- let i = S * w, a = {
1013
+ let i = E * O, a = {
908
1014
  buffer: e,
909
1015
  divisor: 1,
910
1016
  stride: i,
@@ -913,16 +1019,16 @@ var p = class e {
913
1019
  buffer: e,
914
1020
  divisor: 1,
915
1021
  stride: i,
916
- offset: w
1022
+ offset: O
917
1023
  }, s = {
918
1024
  buffer: e,
919
1025
  divisor: 1,
920
1026
  stride: i,
921
- offset: w * 2
1027
+ offset: O * 2
922
1028
  }, c = {
923
1029
  buffer: this.barCornerBuffer,
924
1030
  divisor: 0,
925
- stride: C * w,
1031
+ stride: D * O,
926
1032
  offset: 0,
927
1033
  size: 2
928
1034
  };
@@ -940,7 +1046,7 @@ var p = class e {
940
1046
  uniforms: {
941
1047
  uScale: this.scaleUniform,
942
1048
  uOffset: this.offsetUniform,
943
- uBarWidth: n.barWidth ?? E,
1049
+ uBarWidth: n.barWidth ?? A,
944
1050
  uColor: n.color
945
1051
  }
946
1052
  });
@@ -994,13 +1100,13 @@ var p = class e {
994
1100
  dispose() {
995
1101
  this.backend.destroy();
996
1102
  }
997
- }, k = [
1103
+ }, j = [
998
1104
  1024,
999
1105
  4096,
1000
1106
  16384,
1001
1107
  32768,
1002
1108
  131072
1003
- ], ie = class {
1109
+ ], ae = class {
1004
1110
  regl;
1005
1111
  pool = [];
1006
1112
  preAllocated = !1;
@@ -1013,7 +1119,7 @@ var p = class e {
1013
1119
  preAllocate() {
1014
1120
  if (!this.preAllocated) {
1015
1121
  this.preAllocated = !0;
1016
- for (let e of k) this.pool.push(this.createEntry(e, "stream"));
1122
+ for (let e of j) this.pool.push(this.createEntry(e, "stream"));
1017
1123
  }
1018
1124
  }
1019
1125
  acquire(e, t = "stream") {
@@ -1053,17 +1159,17 @@ var p = class e {
1053
1159
  return this.pool.find((t) => !t.inUse && t.floatCapacity >= e);
1054
1160
  }
1055
1161
  roundUp(e) {
1056
- for (let t of k) if (t >= e) return t;
1057
- let t = k[k.length - 1], n = 1 << 32 - Math.clz32(e - 1);
1162
+ for (let t of j) if (t >= e) return t;
1163
+ let t = j[j.length - 1], n = 1 << 32 - Math.clz32(e - 1);
1058
1164
  return Math.max(t * 2, n);
1059
1165
  }
1060
1166
  };
1061
1167
  //#endregion
1062
1168
  //#region src/render/ReglBackend.ts
1063
- function ae(e) {
1169
+ function oe(e) {
1064
1170
  return e;
1065
1171
  }
1066
- var oe = class {
1172
+ var se = class {
1067
1173
  gl;
1068
1174
  regl;
1069
1175
  resources;
@@ -1083,10 +1189,10 @@ var oe = class {
1083
1189
  });
1084
1190
  if (!n) throw Error("BlazePlot requires WebGL2, but this browser/context does not support it.");
1085
1191
  this.gl = n, this.regl = e({
1086
- gl: ae(this.gl),
1192
+ gl: oe(this.gl),
1087
1193
  extensions: [],
1088
1194
  optionalExtensions: ["angle_instanced_arrays", "ext_disjoint_timer_query_webgl2"]
1089
- }), this.capabilities = { instancing: this.regl.hasExtension("angle_instanced_arrays") }, this.resources = new ie(this.regl), this.resources.preAllocate();
1195
+ }), this.capabilities = { instancing: this.regl.hasExtension("angle_instanced_arrays") }, this.resources = new ae(this.regl), this.resources.preAllocate();
1090
1196
  }
1091
1197
  createBuffer(e) {
1092
1198
  let { buffer: t } = this.resources.acquire(e.length, e.usage);
@@ -1152,6 +1258,9 @@ var oe = class {
1152
1258
  h: r
1153
1259
  };
1154
1260
  }
1261
+ getContext() {
1262
+ return this.gl;
1263
+ }
1155
1264
  destroy() {
1156
1265
  this.resources.destroy(), this.regl.destroy();
1157
1266
  }
@@ -1205,7 +1314,7 @@ var oe = class {
1205
1314
  default: return e;
1206
1315
  }
1207
1316
  }
1208
- }, A = class e {
1317
+ }, M = class e {
1209
1318
  _xMin = 0;
1210
1319
  _xMax = 1;
1211
1320
  _yMin = 0;
@@ -1290,7 +1399,7 @@ var oe = class {
1290
1399
  static assertFinite(e, t) {
1291
1400
  if (!Number.isFinite(t)) throw RangeError(`Camera2D ${e} must be finite.`);
1292
1401
  }
1293
- }, j = class {
1402
+ }, N = class {
1294
1403
  camera;
1295
1404
  constructor(e) {
1296
1405
  this.camera = e;
@@ -1322,7 +1431,7 @@ var oe = class {
1322
1431
  let n = Math.max(0, -Math.floor(Math.log10(t)) + 2), r = Number(e.toFixed(n));
1323
1432
  return Object.is(r, -0) ? 0 : r;
1324
1433
  }
1325
- }, M = class {
1434
+ }, P = class {
1326
1435
  layout;
1327
1436
  config;
1328
1437
  options;
@@ -1375,7 +1484,7 @@ var oe = class {
1375
1484
  }
1376
1485
  }
1377
1486
  }
1378
- }, se = class {
1487
+ }, ce = class {
1379
1488
  root;
1380
1489
  plot;
1381
1490
  canvas;
@@ -1404,21 +1513,21 @@ var oe = class {
1404
1513
  applyBaseStyles() {
1405
1514
  this.root.style.position = "relative", this.root.style.display = "grid", this.root.style.width = "100%", this.root.style.height = "100%", this.root.style.minWidth = "0", this.root.style.minHeight = "0", this.root.style.overflow = "hidden", this.plot.style.position = "relative", this.plot.style.gridColumn = "2", this.plot.style.gridRow = "1", this.plot.style.minWidth = "0", this.plot.style.minHeight = "0", this.plot.style.overflow = "hidden", this.canvas.style.position = "absolute", this.canvas.style.inset = "0", this.canvas.style.display = "block", this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.touchAction = "none", this.yAxis.style.position = "relative", this.yAxis.style.gridColumn = "1", this.yAxis.style.gridRow = "1", this.yAxis.style.minWidth = "0", this.yAxis.style.minHeight = "0", this.yAxis.style.overflow = "hidden", this.yAxis.style.pointerEvents = "none", this.y2Axis.style.position = "relative", this.y2Axis.style.gridColumn = "3", this.y2Axis.style.gridRow = "1", this.y2Axis.style.minWidth = "0", this.y2Axis.style.minHeight = "0", this.y2Axis.style.overflow = "hidden", this.y2Axis.style.pointerEvents = "none", this.xAxis.style.position = "relative", this.xAxis.style.gridColumn = "2", this.xAxis.style.gridRow = "2", this.xAxis.style.minWidth = "0", this.xAxis.style.minHeight = "0", this.xAxis.style.overflow = "hidden", this.xAxis.style.pointerEvents = "none", this.corner.style.gridColumn = "1", this.corner.style.gridRow = "2", this.corner.style.minWidth = "0", this.corner.style.minHeight = "0", this.corner.style.pointerEvents = "none", this.cornerRight.style.gridColumn = "3", this.cornerRight.style.gridRow = "2", this.cornerRight.style.minWidth = "0", this.cornerRight.style.minHeight = "0", this.cornerRight.style.pointerEvents = "none";
1406
1515
  }
1407
- }, N = {
1516
+ }, F = {
1408
1517
  backgroundColor: [
1409
- .08,
1410
- .1,
1411
- .16,
1518
+ .02,
1519
+ .02,
1520
+ .02,
1412
1521
  1
1413
1522
  ],
1414
- backgroundCssColor: "rgba(20, 26, 41, 1)",
1523
+ backgroundCssColor: "rgba(5, 5, 5, 1)",
1415
1524
  gridColor: [
1416
1525
  .22,
1417
- .3,
1418
- .44,
1526
+ .22,
1527
+ .22,
1419
1528
  .45
1420
1529
  ],
1421
- axisColor: "#bfd6ff",
1530
+ axisColor: "#d4d4d4",
1422
1531
  axisFont: "11px ui-monospace, monospace, sans-serif",
1423
1532
  seriesColors: [
1424
1533
  [
@@ -1458,48 +1567,48 @@ var oe = class {
1458
1567
  1
1459
1568
  ]
1460
1569
  ],
1461
- tooltipBackgroundColor: "rgba(4, 8, 16, 0.85)",
1462
- tooltipTextColor: "#bfd6ff",
1570
+ tooltipBackgroundColor: "rgba(10, 10, 10, 0.88)",
1571
+ tooltipTextColor: "#e5e5e5",
1463
1572
  tooltipFont: "11px/1.35 ui-monospace, monospace",
1464
- legendBackgroundColor: "rgba(4, 8, 16, 0.85)",
1573
+ legendBackgroundColor: "rgba(10, 10, 10, 0.88)",
1465
1574
  legendBorderColor: "transparent",
1466
- legendTextColor: "#bfd6ff",
1467
- legendMutedTextColor: "#789",
1575
+ legendTextColor: "#e5e5e5",
1576
+ legendMutedTextColor: "#888",
1468
1577
  legendFont: "11px/1.35 ui-monospace, monospace"
1469
1578
  };
1470
- function P(e, t) {
1471
- if (!e) return N;
1472
- let n = F(e.backgroundColor, N.backgroundColor, t), r = e.seriesColors?.length ? e.seriesColors.map((e, n) => F(e, N.seriesColors[n % N.seriesColors.length], t)) : N.seriesColors;
1579
+ function I(e, t) {
1580
+ if (!e) return F;
1581
+ let n = L(e.backgroundColor, F.backgroundColor, t), r = e.seriesColors?.length ? e.seriesColors.map((e, n) => L(e, F.seriesColors[n % F.seriesColors.length], t)) : F.seriesColors;
1473
1582
  return {
1474
1583
  backgroundColor: n,
1475
- backgroundCssColor: ce(e.backgroundColor, N.backgroundCssColor),
1476
- gridColor: F(e.gridColor, N.gridColor, t),
1477
- axisColor: e.axisColor ?? N.axisColor,
1478
- axisFont: e.axisFont ?? N.axisFont,
1584
+ backgroundCssColor: le(e.backgroundColor, F.backgroundCssColor),
1585
+ gridColor: L(e.gridColor, F.gridColor, t),
1586
+ axisColor: e.axisColor ?? F.axisColor,
1587
+ axisFont: e.axisFont ?? F.axisFont,
1479
1588
  seriesColors: r,
1480
- tooltipBackgroundColor: e.tooltipBackgroundColor ?? N.tooltipBackgroundColor,
1481
- tooltipTextColor: e.tooltipTextColor ?? N.tooltipTextColor,
1482
- tooltipFont: e.tooltipFont ?? N.tooltipFont,
1483
- legendBackgroundColor: e.legendBackgroundColor ?? N.legendBackgroundColor,
1484
- legendBorderColor: e.legendBorderColor ?? N.legendBorderColor,
1485
- legendTextColor: e.legendTextColor ?? N.legendTextColor,
1486
- legendMutedTextColor: e.legendMutedTextColor ?? N.legendMutedTextColor,
1487
- legendFont: e.legendFont ?? N.legendFont
1589
+ tooltipBackgroundColor: e.tooltipBackgroundColor ?? F.tooltipBackgroundColor,
1590
+ tooltipTextColor: e.tooltipTextColor ?? F.tooltipTextColor,
1591
+ tooltipFont: e.tooltipFont ?? F.tooltipFont,
1592
+ legendBackgroundColor: e.legendBackgroundColor ?? F.legendBackgroundColor,
1593
+ legendBorderColor: e.legendBorderColor ?? F.legendBorderColor,
1594
+ legendTextColor: e.legendTextColor ?? F.legendTextColor,
1595
+ legendMutedTextColor: e.legendMutedTextColor ?? F.legendMutedTextColor,
1596
+ legendFont: e.legendFont ?? F.legendFont
1488
1597
  };
1489
1598
  }
1490
- function F(e, t, n) {
1599
+ function L(e, t, n) {
1491
1600
  if (!e) return t;
1492
1601
  if (typeof e != "string") return e;
1493
- let r = le(e, n), i = ue(r ?? e, n);
1494
- return L(r ?? e) ?? L(i ?? "") ?? t;
1602
+ let r = ue(e, n), i = de(r ?? e, n);
1603
+ return z(r ?? e) ?? z(i ?? "") ?? t;
1495
1604
  }
1496
- function ce(e, t) {
1497
- return e ? typeof e == "string" ? e : I(e) : t;
1605
+ function le(e, t) {
1606
+ return e ? typeof e == "string" ? e : R(e) : t;
1498
1607
  }
1499
- function I(e) {
1608
+ function R(e) {
1500
1609
  return `rgba(${Math.round(e[0] * 255)}, ${Math.round(e[1] * 255)}, ${Math.round(e[2] * 255)}, ${e[3]})`;
1501
1610
  }
1502
- function le(e, t) {
1611
+ function ue(e, t) {
1503
1612
  let n = t?.ownerDocument ?? globalThis.document;
1504
1613
  if (!n?.documentElement || typeof getComputedStyle > "u") return null;
1505
1614
  let r = t instanceof HTMLElement ? t : n.documentElement, i = n.createElement("span");
@@ -1507,11 +1616,11 @@ function le(e, t) {
1507
1616
  let a = getComputedStyle(i).color;
1508
1617
  return i.remove(), a || null;
1509
1618
  }
1510
- function L(e) {
1619
+ function z(e) {
1511
1620
  let t = e.trim();
1512
- return de(t) ?? R(t) ?? z(t);
1621
+ return fe(t) ?? pe(t) ?? me(t);
1513
1622
  }
1514
- function ue(e, t) {
1623
+ function de(e, t) {
1515
1624
  let n = t?.ownerDocument ?? globalThis.document;
1516
1625
  if (!n?.createElement) return null;
1517
1626
  let r = n.createElement("canvas").getContext("2d");
@@ -1521,7 +1630,7 @@ function ue(e, t) {
1521
1630
  let a = String(r.fillStyle);
1522
1631
  return a === i ? null : a;
1523
1632
  }
1524
- function de(e) {
1633
+ function fe(e) {
1525
1634
  let t = e.match(/^rgba?\((.*)\)$/i);
1526
1635
  if (!t) return null;
1527
1636
  let n = t[1].trim().split("/").map((e) => e.trim()), r = n[0], i = n[1], a = r.includes(",") ? r.split(",").map((e) => e.trim()).filter(Boolean) : r.split(/\s+/).filter(Boolean);
@@ -1534,7 +1643,7 @@ function de(e) {
1534
1643
  l
1535
1644
  ];
1536
1645
  }
1537
- function R(e) {
1646
+ function pe(e) {
1538
1647
  let t = e.match(/^color\(\s*srgb\s+(.+)\)$/i);
1539
1648
  if (!t) return null;
1540
1649
  let n = t[1].split("/").map((e) => e.trim()), r = n[0].split(/\s+/).filter(Boolean);
@@ -1547,7 +1656,7 @@ function R(e) {
1547
1656
  s
1548
1657
  ];
1549
1658
  }
1550
- function z(e) {
1659
+ function me(e) {
1551
1660
  let t = e.startsWith("#") ? e.slice(1) : "";
1552
1661
  if (![
1553
1662
  3,
@@ -1577,7 +1686,7 @@ function U(e) {
1577
1686
  }
1578
1687
  //#endregion
1579
1688
  //#region src/ui/Chart.ts
1580
- var W = 16384, G = W >> 1, K = W >> 1, q = 3, J = 4096, Y = 12, fe = 12, X = 5, Z = 64;
1689
+ var W = 16384, G = W >> 1, K = W >> 1, q = 3, J = 4096, Y = 12, he = 12, X = 5, Z = 64, ge = 4, _e = W * 4;
1581
1690
  function Q(e) {
1582
1691
  return e === !1 ? {
1583
1692
  visible: !1,
@@ -1623,7 +1732,7 @@ function $(e) {
1623
1732
  y2: Q(e.y2 ?? !1)
1624
1733
  };
1625
1734
  }
1626
- var pe = class {
1735
+ var ve = class {
1627
1736
  options;
1628
1737
  series = [];
1629
1738
  camera;
@@ -1660,6 +1769,7 @@ var pe = class {
1660
1769
  hoverSubscribers = /* @__PURE__ */ new Set();
1661
1770
  seriesSubscribers = /* @__PURE__ */ new Set();
1662
1771
  themeSubscribers = /* @__PURE__ */ new Set();
1772
+ renderSubscribers = /* @__PURE__ */ new Set();
1663
1773
  currentHover = null;
1664
1774
  lastPointerClientX = 0;
1665
1775
  lastPointerClientY = 0;
@@ -1674,10 +1784,10 @@ var pe = class {
1674
1784
  this.pointerInPlot = !1, this.emitHover(null);
1675
1785
  };
1676
1786
  constructor(e, t = {}) {
1677
- this.options = t, this.resolvedTheme = P(t.theme, e), this.normalizedAxes = $(t.axes), this._gridVisible = t.grid !== !1, this.layout = new se(e, this.normalizedAxes), this.layout.root.style.background = this.resolvedTheme.backgroundCssColor, this.applyCanvasSize(), this.camera = new A(), this.rightCamera = new A(), this.axis = new j(this.camera), this.rightAxis = new j(this.rightCamera), this.renderer = new O(new oe(this.layout.canvas)), this.rawLineData = new Float32Array(W * 2), this.rawLineBuffer = this.renderer.createFloatBuffer(this.rawLineData.length), this.minMaxInstanceData = new Float32Array(K * q), this.minMaxInstanceBuffer = this.renderer.createFloatBuffer(this.minMaxInstanceData.length), this.barTriangleData = new Float32Array(J * Y), this.barTriangleBuffer = this.renderer.createFloatBuffer(this.barTriangleData.length), this.gridData = new Float32Array(Z * 2), this.gridBuffer = this.renderer.createFloatBuffer(this.gridData.length), this.gridStyle = {
1787
+ this.options = t, this.resolvedTheme = I(t.theme, e), this.normalizedAxes = $(t.axes), this._gridVisible = t.grid !== !1, this.layout = new ce(e, this.normalizedAxes), this.layout.root.style.background = this.resolvedTheme.backgroundCssColor, this.applyCanvasSize(), this.camera = new M(), this.rightCamera = new M(), this.axis = new N(this.camera), this.rightAxis = new N(this.rightCamera), this.renderer = new ie(new se(this.layout.canvas)), this.rawLineData = new Float32Array(W * 2), this.rawLineBuffer = this.renderer.createFloatBuffer(this.rawLineData.length), this.minMaxInstanceData = new Float32Array(K * q), this.minMaxInstanceBuffer = this.renderer.createFloatBuffer(this.minMaxInstanceData.length), this.barTriangleData = new Float32Array(J * Y), this.barTriangleBuffer = this.renderer.createFloatBuffer(this.barTriangleData.length), this.gridData = new Float32Array(Z * 2), this.gridBuffer = this.renderer.createFloatBuffer(this.gridData.length), this.gridStyle = {
1678
1788
  color: t.gridStyle?.color ?? this.resolvedTheme.gridColor,
1679
1789
  lineWidth: t.gridStyle?.lineWidth ?? 1
1680
- }, (this.normalizedAxes.x.visible || this.normalizedAxes.y.visible || this.normalizedAxes.y2.visible) && (this.axisOverlay = new M(this.layout, this.normalizedAxes, {
1790
+ }, (this.normalizedAxes.x.visible || this.normalizedAxes.y.visible || this.normalizedAxes.y2.visible) && (this.axisOverlay = new P(this.layout, this.normalizedAxes, {
1681
1791
  color: this.resolvedTheme.axisColor,
1682
1792
  font: this.resolvedTheme.axisFont
1683
1793
  })), this.canvas.addEventListener("pointermove", this.handlePointerMove), this.canvas.addEventListener("pointerleave", this.handlePointerLeave), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(this.layout.plot));
@@ -1707,6 +1817,9 @@ var pe = class {
1707
1817
  get theme() {
1708
1818
  return this.resolvedTheme;
1709
1819
  }
1820
+ getWebGLContext() {
1821
+ return this.renderer.getWebGLContext();
1822
+ }
1710
1823
  getCamera(e = "left") {
1711
1824
  return e === "right" ? this.rightCamera : this.camera;
1712
1825
  }
@@ -1733,7 +1846,7 @@ var pe = class {
1733
1846
  }
1734
1847
  addSeries(e, t) {
1735
1848
  if ((e.mode === "ohlc" || e.mode === "candlestick") && !e.dataset) throw TypeError("OHLC and candlestick series require an OhlcDataset.");
1736
- let n = e.dataset ?? new p(e.capacity, { overflow: e.overflow }), r = this.resolvedTheme.seriesColors, i = r[this.series.length % r.length] ?? this.resolvedTheme.seriesColors[0], a = t?.color ?? i, o = new u(n, e, {
1849
+ let n = e.dataset ?? new g(e.capacity, { overflow: e.overflow }), r = this.resolvedTheme.seriesColors, i = r[this.series.length % r.length] ?? this.resolvedTheme.seriesColors[0], a = t?.color ?? i, o = new p(n, e, {
1737
1850
  color: a,
1738
1851
  lineWidth: t?.lineWidth ?? 1,
1739
1852
  pointSize: t?.pointSize ?? 4,
@@ -1844,11 +1957,15 @@ var pe = class {
1844
1957
  let e = t;
1845
1958
  return this.themeSubscribers.add(e), () => this.themeSubscribers.delete(e);
1846
1959
  }
1960
+ if (e === "render") {
1961
+ let e = t;
1962
+ return this.renderSubscribers.add(e), () => this.renderSubscribers.delete(e);
1963
+ }
1847
1964
  let n = t;
1848
1965
  return this.seriesSubscribers.add(n), () => this.seriesSubscribers.delete(n);
1849
1966
  }
1850
1967
  setTheme(e) {
1851
- this.resolvedTheme = P(e, this.layout.root), this.applyTheme(), this.emitThemeChange(), this.refreshHover();
1968
+ this.resolvedTheme = I(e, this.layout.root), this.applyTheme(), this.emitThemeChange(), this.refreshHover();
1852
1969
  }
1853
1970
  setGridVisible(e) {
1854
1971
  this._gridVisible = e;
@@ -1857,7 +1974,7 @@ var pe = class {
1857
1974
  return this._gridVisible;
1858
1975
  }
1859
1976
  setAxes(e) {
1860
- this.normalizedAxes = $(e), this.layout.update(this.normalizedAxes), this.axisOverlay?.dispose(), this.axisOverlay = null, (this.normalizedAxes.x.visible || this.normalizedAxes.y.visible || this.normalizedAxes.y2.visible) && (this.axisOverlay = new M(this.layout, this.normalizedAxes, {
1977
+ this.normalizedAxes = $(e), this.layout.update(this.normalizedAxes), this.axisOverlay?.dispose(), this.axisOverlay = null, (this.normalizedAxes.x.visible || this.normalizedAxes.y.visible || this.normalizedAxes.y2.visible) && (this.axisOverlay = new P(this.layout, this.normalizedAxes, {
1861
1978
  color: this.resolvedTheme.axisColor,
1862
1979
  font: this.resolvedTheme.axisFont
1863
1980
  })), this.resize(), this.refreshHover();
@@ -1890,7 +2007,7 @@ var pe = class {
1890
2007
  o.width = i, o.height = a;
1891
2008
  let s = o.getContext("2d");
1892
2009
  if (!s) throw Error("Unable to create a 2D canvas context for screenshot export.");
1893
- return s.fillStyle = e.background ?? I(this.resolvedTheme.backgroundColor), s.fillRect(0, 0, i, a), s.drawImage(this.canvas, (n.left - t.left) * r, (n.top - t.top) * r, n.width * r, n.height * r), this.drawDomTextForScreenshot(s, t, r), new Promise((t, n) => {
2010
+ return s.fillStyle = e.background ?? R(this.resolvedTheme.backgroundColor), s.fillRect(0, 0, i, a), s.drawImage(this.canvas, (n.left - t.left) * r, (n.top - t.top) * r, n.width * r, n.height * r), this.drawDomTextForScreenshot(s, t, r), new Promise((t, n) => {
1894
2011
  o.toBlob((e) => e ? t(e) : n(/* @__PURE__ */ Error("Unable to encode chart screenshot.")), e.type ?? "image/png", e.quality);
1895
2012
  });
1896
2013
  }
@@ -1914,7 +2031,7 @@ var pe = class {
1914
2031
  e > 0 && (this.uploadGridData(e), this.renderer.drawClipLines(this.gridBuffer, e, this.gridStyle), this.stats.drawCalls++);
1915
2032
  }
1916
2033
  for (let e of this.series) e.visible && (e.rebuildPyramid(), this.drawSeries(e));
1917
- this.axisOverlay?.update(this.camera, this.axis, this.rightCamera, this.rightAxis), this.stats.frameMs = performance.now() - e, this.refreshHover();
2034
+ this.axisOverlay?.update(this.camera, this.axis, this.rightCamera, this.rightAxis), this.emitRender(), this.stats.frameMs = performance.now() - e, this.refreshHover();
1918
2035
  }
1919
2036
  dispose() {
1920
2037
  this.stop(), this.resizeObserver?.disconnect(), this.canvas.removeEventListener("pointermove", this.handlePointerMove), this.canvas.removeEventListener("pointerleave", this.handlePointerLeave);
@@ -2004,7 +2121,7 @@ var pe = class {
2004
2121
  }
2005
2122
  }
2006
2123
  drawOhlcSeries(e, t, n) {
2007
- let r = e.visibleIndexRange(t), i = Math.floor(this.rawLineData.length / fe);
2124
+ let r = e.visibleIndexRange(t), i = Math.floor(this.rawLineData.length / he);
2008
2125
  for (let t = r.start; t < r.end;) {
2009
2126
  let a = e.copyOhlcRange(t, r.end, this.rawLineData, i, e.style.tickWidth ?? e.style.barWidth ?? .8, this.currentXOrigin);
2010
2127
  if (a <= 0) break;
@@ -2033,18 +2150,17 @@ var pe = class {
2033
2150
  }
2034
2151
  }
2035
2152
  drawScatterSeries(e, t, n) {
2036
- if (e.visibleSampleCount(t) > W) {
2037
- let r = e.copyRawVisible(t, this.rawLineData, W, this.currentXOrigin);
2038
- if (r <= 0) return;
2039
- this.uploadRawLineData(r), this.renderer.drawPoints(this.rawLineBuffer, r, e.style, n, this.canvas.width, this.canvas.height), this.recordDraw("points", r);
2153
+ let r = e.style.pointSize ?? ge, i = e.visibleSampleCount(t);
2154
+ if (e.config.downsample === "none" && i <= _e) {
2155
+ let i = e.visibleIndexRange(t);
2156
+ for (let a = i.start; a < i.end; a += W) {
2157
+ let o = e.copyScatterRange(a, Math.min(i.end, a + W), t, this.rawLineData, W, this.currentXOrigin, this.canvas.height, r);
2158
+ o <= 0 || (this.uploadRawLineData(o), this.renderer.drawPoints(this.rawLineBuffer, o, e.style, n, this.canvas.width, this.canvas.height), this.recordDraw("points", o));
2159
+ }
2040
2160
  return;
2041
2161
  }
2042
- let r = e.visibleIndexRange(t);
2043
- for (let t = r.start; t < r.end;) {
2044
- let i = e.copyRawRange(t, r.end, this.rawLineData, W, this.currentXOrigin);
2045
- if (i <= 0) break;
2046
- this.uploadRawLineData(i), this.renderer.drawPoints(this.rawLineBuffer, i, e.style, n, this.canvas.width, this.canvas.height), this.recordDraw("points", i), t += i;
2047
- }
2162
+ let a = e.copyScatterVisible(t, this.rawLineData, W, this.canvas.width, this.canvas.height, r, this.currentXOrigin);
2163
+ a <= 0 || (this.uploadRawLineData(a), this.renderer.drawPoints(this.rawLineBuffer, a, e.style, n, this.canvas.width, this.canvas.height), this.recordDraw("points", a));
2048
2164
  }
2049
2165
  drawBarSeries(e, t, n) {
2050
2166
  let r = e.visibleSampleCount(t), i = this.maxRawBarInstances();
@@ -2211,6 +2327,9 @@ var pe = class {
2211
2327
  emitThemeChange() {
2212
2328
  for (let e of this.themeSubscribers) e();
2213
2329
  }
2330
+ emitRender() {
2331
+ for (let e of this.renderSubscribers) e(this);
2332
+ }
2214
2333
  drawDomTextForScreenshot(e, t, n) {
2215
2334
  let r = this.layout.root.querySelectorAll("div");
2216
2335
  for (let i of r) {
@@ -2254,7 +2373,7 @@ var pe = class {
2254
2373
  recordRenderMode(e) {
2255
2374
  this.stats.renderMode === "none" ? this.stats.renderMode = e : this.stats.renderMode !== e && (this.stats.renderMode = "mixed");
2256
2375
  }
2257
- }, me = class {
2376
+ }, ye = class {
2258
2377
  xData;
2259
2378
  yData;
2260
2379
  constructor(e, t) {
@@ -2276,15 +2395,15 @@ var pe = class {
2276
2395
  return this.assertValidIndex(e), this.yData[e];
2277
2396
  }
2278
2397
  lowerBoundX(e) {
2279
- return d(this.length, (e) => this.xData[e], e);
2398
+ return m(this.length, (e) => this.xData[e], e);
2280
2399
  }
2281
2400
  upperBoundX(e) {
2282
- return f(this.length, (e) => this.xData[e], e);
2401
+ return h(this.length, (e) => this.xData[e], e);
2283
2402
  }
2284
2403
  assertValidIndex(e) {
2285
2404
  if (!Number.isInteger(e) || e < 0 || e >= this.length) throw RangeError(`StaticDataset index out of range: ${e}`);
2286
2405
  }
2287
- }, he = class {
2406
+ }, be = class {
2288
2407
  length;
2289
2408
  xs;
2290
2409
  opens;
@@ -2319,15 +2438,15 @@ var pe = class {
2319
2438
  return this.assertValidIndex(e), this.closes[e];
2320
2439
  }
2321
2440
  lowerBoundX(e) {
2322
- return d(this.length, (e) => this.xs[e], e);
2441
+ return m(this.length, (e) => this.xs[e], e);
2323
2442
  }
2324
2443
  upperBoundX(e) {
2325
- return f(this.length, (e) => this.xs[e], e);
2444
+ return h(this.length, (e) => this.xs[e], e);
2326
2445
  }
2327
2446
  assertValidIndex(e) {
2328
2447
  if (!Number.isInteger(e) || e < 0 || e >= this.length) throw RangeError(`StaticOhlcDataset index out of range: ${e}`);
2329
2448
  }
2330
- }, ge = class {
2449
+ }, xe = class {
2331
2450
  capacity;
2332
2451
  overflow;
2333
2452
  xData;
@@ -2392,10 +2511,10 @@ var pe = class {
2392
2511
  return this.assertValidIndex(e), this.closeData[this.logicalToPhysical(e)];
2393
2512
  }
2394
2513
  lowerBoundX(e) {
2395
- return d(this._length, (e) => this.getX(e), e);
2514
+ return m(this._length, (e) => this.getX(e), e);
2396
2515
  }
2397
2516
  upperBoundX(e) {
2398
- return f(this._length, (e) => this.getX(e), e);
2517
+ return h(this._length, (e) => this.getX(e), e);
2399
2518
  }
2400
2519
  logicalToPhysical(e) {
2401
2520
  return (this._head - this._length + e + this.capacity) % this.capacity;
@@ -2405,6 +2524,6 @@ var pe = class {
2405
2524
  }
2406
2525
  };
2407
2526
  //#endregion
2408
- export { j as AxisController, A as Camera2D, pe as Chart, N as DEFAULT_CHART_THEME, n as MinMaxPyramid, ge as OhlcRingBuffer, p as RingBuffer, u as SeriesStore, me as StaticDataset, he as StaticOhlcDataset };
2527
+ export { N as AxisController, M as Camera2D, ve as Chart, F as DEFAULT_CHART_THEME, n as MinMaxPyramid, xe as OhlcRingBuffer, g as RingBuffer, p as SeriesStore, ye as StaticDataset, be as StaticOhlcDataset };
2409
2528
 
2410
2529
  //# sourceMappingURL=index.js.map