blazeplot 0.1.6 → 0.1.7
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/README.md +8 -4
- package/dist/core/SeriesStore.d.ts +4 -0
- package/dist/core/SeriesStore.d.ts.map +1 -1
- package/dist/core/types.d.ts +5 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.js +332 -58
- package/dist/index.js.map +1 -1
- package/dist/render/ReglBackend.d.ts +2 -0
- package/dist/render/ReglBackend.d.ts.map +1 -1
- package/dist/render/Renderer.d.ts +16 -1
- package/dist/render/Renderer.d.ts.map +1 -1
- package/dist/render/ShaderPrograms.d.ts +8 -0
- package/dist/render/ShaderPrograms.d.ts.map +1 -1
- package/dist/render/index.d.ts +1 -1
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/types.d.ts +12 -1
- package/dist/render/types.d.ts.map +1 -1
- package/dist/ui/Chart.d.ts +9 -1
- package/dist/ui/Chart.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -122,7 +122,7 @@ var t = 16, n = class {
|
|
|
122
122
|
_dirty = !1;
|
|
123
123
|
_visible = !0;
|
|
124
124
|
constructor(e, t, r) {
|
|
125
|
-
this.dataset = e, this.config = t, this.pyramid = t.
|
|
125
|
+
this.dataset = e, this.config = t, this.pyramid = t.mode === "line" && t.downsample !== "none" ? new n() : null, this.style = r, this.pyramid && e.length > 0 && this.pyramid.build(e);
|
|
126
126
|
}
|
|
127
127
|
get hasLOD() {
|
|
128
128
|
return this.pyramid !== null;
|
|
@@ -168,28 +168,58 @@ var t = 16, n = class {
|
|
|
168
168
|
return Math.max(0, n - t);
|
|
169
169
|
}
|
|
170
170
|
copyRawVisible(e, t, n) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
for (let e = r; e < i && s < n; e += o) t[s * 2] = this.dataset.getX(e), t[s * 2 + 1] = this.dataset.getY(e), s++;
|
|
176
|
-
return s;
|
|
171
|
+
return this.copyVisibleSamples(e, t, n, "points", 0);
|
|
172
|
+
}
|
|
173
|
+
copyAreaVisible(e, t, n, r = 0) {
|
|
174
|
+
return this.copyVisibleSamples(e, t, n, "area", r) * 2;
|
|
177
175
|
}
|
|
178
176
|
copyMinMaxVisible(e, t, n) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
177
|
+
return this.copyMinMaxSegments(e, t, n, "line-list") * 2;
|
|
178
|
+
}
|
|
179
|
+
copyMinMaxInstanced(e, t, n) {
|
|
180
|
+
return this.copyMinMaxSegments(e, t, n, "instanced");
|
|
181
|
+
}
|
|
182
|
+
copyVisibleSamples(e, t, n, r, i) {
|
|
183
|
+
let a = r === "points" ? 2 : 4;
|
|
184
|
+
if (n <= 0 || t.length < n * a) return 0;
|
|
185
|
+
let o = this.dataset.lowerBoundX(e.xMin), s = this.dataset.upperBoundX(e.xMax), c = s - o;
|
|
186
|
+
if (c <= 0) return 0;
|
|
187
|
+
let l = Math.max(1, Math.ceil(c / n)), u = 0;
|
|
188
|
+
for (let e = o; e < s && u < n; e += l) {
|
|
189
|
+
let n = this.dataset.getX(e), a = this.dataset.getY(e);
|
|
190
|
+
if (r === "points") {
|
|
191
|
+
let e = u * 2;
|
|
192
|
+
t[e] = n, t[e + 1] = a;
|
|
193
|
+
} else {
|
|
194
|
+
let e = u * 4;
|
|
195
|
+
t[e] = n, t[e + 1] = i, t[e + 2] = n, t[e + 3] = a;
|
|
196
|
+
}
|
|
197
|
+
u++;
|
|
198
|
+
}
|
|
199
|
+
return u;
|
|
200
|
+
}
|
|
201
|
+
copyMinMaxSegments(e, t, n, r) {
|
|
202
|
+
let i = r === "line-list" ? 4 : 3;
|
|
203
|
+
if (!this.pyramid || n <= 0 || t.length < n * i) return 0;
|
|
204
|
+
let a = this.dataset.lowerBoundX(e.xMin), o = this.dataset.upperBoundX(e.xMax), s = o - a;
|
|
205
|
+
if (s <= 0) return 0;
|
|
206
|
+
let c = Math.min(n, s);
|
|
207
|
+
for (let e = 0; e < c; e++) {
|
|
208
|
+
let n = a + Math.floor(e * s / c), i = a + Math.max(Math.floor((e + 1) * s / c), Math.floor(e * s / c) + 1), l = Math.min(o, i), u = Infinity, d = -Infinity;
|
|
185
209
|
for (let e = n; e < l; e++) {
|
|
186
210
|
let t = this.dataset.getY(e);
|
|
187
211
|
t < u && (u = t), t > d && (d = t);
|
|
188
212
|
}
|
|
189
213
|
let f = this.dataset.getX(n + (l - n >> 1));
|
|
190
|
-
|
|
214
|
+
if (r === "line-list") {
|
|
215
|
+
let n = e * 4;
|
|
216
|
+
t[n] = f, t[n + 1] = u, t[n + 2] = f, t[n + 3] = d;
|
|
217
|
+
} else {
|
|
218
|
+
let n = e * 3;
|
|
219
|
+
t[n] = f, t[n + 1] = u, t[n + 2] = d;
|
|
220
|
+
}
|
|
191
221
|
}
|
|
192
|
-
return
|
|
222
|
+
return c;
|
|
193
223
|
}
|
|
194
224
|
}, i = class {
|
|
195
225
|
capacity;
|
|
@@ -260,16 +290,70 @@ var t = 16, n = class {
|
|
|
260
290
|
frag: "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n"
|
|
261
291
|
},
|
|
262
292
|
segment: {
|
|
263
|
-
vert: "attribute float aX;\nattribute float aMinY;\nattribute float aMaxY;\n\nuniform vec2 uScale;\nuniform vec2 uOffset;\n\nvoid main() {\n float y = (
|
|
293
|
+
vert: "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",
|
|
294
|
+
frag: "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n"
|
|
295
|
+
},
|
|
296
|
+
point: {
|
|
297
|
+
vert: "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",
|
|
298
|
+
frag: "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n"
|
|
299
|
+
},
|
|
300
|
+
bar: {
|
|
301
|
+
vert: "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",
|
|
264
302
|
frag: "precision mediump float;\n\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n"
|
|
265
303
|
}
|
|
266
|
-
}, o = class {
|
|
304
|
+
}, o = 3, s = 2, c = 4, l = 4, u = .8, d = 0, f = class {
|
|
267
305
|
backend;
|
|
268
306
|
lineProgram;
|
|
307
|
+
segmentProgram;
|
|
308
|
+
pointProgram;
|
|
309
|
+
barProgram;
|
|
310
|
+
segmentSelectBuffer;
|
|
311
|
+
pointCornerBuffer;
|
|
312
|
+
barCornerBuffer;
|
|
269
313
|
scaleUniform = new Float32Array(2);
|
|
270
314
|
offsetUniform = new Float32Array(2);
|
|
315
|
+
canvasSizeUniform = new Float32Array(2);
|
|
271
316
|
constructor(e) {
|
|
272
|
-
this.backend = e, this.lineProgram = this.backend.createProgram(a.line.vert, a.line.frag)
|
|
317
|
+
this.backend = e, this.lineProgram = this.backend.createProgram(a.line.vert, a.line.frag), this.segmentProgram = this.backend.createProgram(a.segment.vert, a.segment.frag), this.pointProgram = this.backend.createProgram(a.point.vert, a.point.frag), this.barProgram = this.backend.createProgram(a.bar.vert, a.bar.frag), this.segmentSelectBuffer = this.backend.createBuffer({
|
|
318
|
+
usage: "static",
|
|
319
|
+
type: "float",
|
|
320
|
+
length: 2
|
|
321
|
+
}), this.backend.updateBuffer(this.segmentSelectBuffer, new Float32Array([0, 1])), this.pointCornerBuffer = this.backend.createBuffer({
|
|
322
|
+
usage: "static",
|
|
323
|
+
type: "float",
|
|
324
|
+
length: 8
|
|
325
|
+
}), this.backend.updateBuffer(this.pointCornerBuffer, new Float32Array([
|
|
326
|
+
-1,
|
|
327
|
+
-1,
|
|
328
|
+
1,
|
|
329
|
+
-1,
|
|
330
|
+
-1,
|
|
331
|
+
1,
|
|
332
|
+
1,
|
|
333
|
+
1
|
|
334
|
+
])), this.barCornerBuffer = this.backend.createBuffer({
|
|
335
|
+
usage: "static",
|
|
336
|
+
type: "float",
|
|
337
|
+
length: 8
|
|
338
|
+
}), this.backend.updateBuffer(this.barCornerBuffer, new Float32Array([
|
|
339
|
+
-.5,
|
|
340
|
+
0,
|
|
341
|
+
.5,
|
|
342
|
+
0,
|
|
343
|
+
-.5,
|
|
344
|
+
1,
|
|
345
|
+
.5,
|
|
346
|
+
1
|
|
347
|
+
]));
|
|
348
|
+
}
|
|
349
|
+
get supportsInstancedSegments() {
|
|
350
|
+
return this.backend.capabilities.instancing;
|
|
351
|
+
}
|
|
352
|
+
get supportsInstancedPoints() {
|
|
353
|
+
return this.backend.capabilities.instancing;
|
|
354
|
+
}
|
|
355
|
+
get supportsInstancedBars() {
|
|
356
|
+
return this.backend.capabilities.instancing;
|
|
273
357
|
}
|
|
274
358
|
clear(e, t, n, r) {
|
|
275
359
|
this.backend.clear(e, t, n, r);
|
|
@@ -293,8 +377,131 @@ var t = 16, n = class {
|
|
|
293
377
|
drawLineStrip(e, t, n, r) {
|
|
294
378
|
this.drawLinePrimitive("line_strip", e, t, n, r);
|
|
295
379
|
}
|
|
380
|
+
drawMinMaxSegments(e, t, n, r) {
|
|
381
|
+
this.drawLines(e, t, n, r);
|
|
382
|
+
}
|
|
383
|
+
drawMinMaxSegmentsInstanced(e, t, n, r) {
|
|
384
|
+
this.writeCameraUniforms(r);
|
|
385
|
+
let i = o * c, a = {
|
|
386
|
+
buffer: e,
|
|
387
|
+
divisor: 1,
|
|
388
|
+
stride: i,
|
|
389
|
+
offset: 0
|
|
390
|
+
}, s = {
|
|
391
|
+
buffer: e,
|
|
392
|
+
divisor: 1,
|
|
393
|
+
stride: i,
|
|
394
|
+
offset: c
|
|
395
|
+
}, l = {
|
|
396
|
+
buffer: e,
|
|
397
|
+
divisor: 1,
|
|
398
|
+
stride: i,
|
|
399
|
+
offset: c * 2
|
|
400
|
+
}, u = {
|
|
401
|
+
buffer: this.segmentSelectBuffer,
|
|
402
|
+
divisor: 0,
|
|
403
|
+
stride: c,
|
|
404
|
+
offset: 0
|
|
405
|
+
};
|
|
406
|
+
this.backend.draw({
|
|
407
|
+
program: this.segmentProgram,
|
|
408
|
+
primitive: "lines",
|
|
409
|
+
count: 2,
|
|
410
|
+
instances: t,
|
|
411
|
+
attributes: {
|
|
412
|
+
aMaxY: l,
|
|
413
|
+
aMinY: s,
|
|
414
|
+
aSelect: u,
|
|
415
|
+
aX: a
|
|
416
|
+
},
|
|
417
|
+
uniforms: {
|
|
418
|
+
uScale: this.scaleUniform,
|
|
419
|
+
uOffset: this.offsetUniform,
|
|
420
|
+
uColor: n.color
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
drawPointsInstanced(e, t, n, r, i, a) {
|
|
425
|
+
this.writeCameraUniforms(r), this.canvasSizeUniform[0] = Math.max(1, i), this.canvasSizeUniform[1] = Math.max(1, a);
|
|
426
|
+
let o = {
|
|
427
|
+
buffer: e,
|
|
428
|
+
divisor: 1,
|
|
429
|
+
stride: s * c,
|
|
430
|
+
offset: 0,
|
|
431
|
+
size: 2
|
|
432
|
+
}, u = {
|
|
433
|
+
buffer: this.pointCornerBuffer,
|
|
434
|
+
divisor: 0,
|
|
435
|
+
stride: s * c,
|
|
436
|
+
offset: 0,
|
|
437
|
+
size: 2
|
|
438
|
+
};
|
|
439
|
+
this.backend.draw({
|
|
440
|
+
program: this.pointProgram,
|
|
441
|
+
primitive: "triangle_strip",
|
|
442
|
+
count: 4,
|
|
443
|
+
instances: t,
|
|
444
|
+
attributes: {
|
|
445
|
+
aCorner: u,
|
|
446
|
+
aPosition: o
|
|
447
|
+
},
|
|
448
|
+
uniforms: {
|
|
449
|
+
uScale: this.scaleUniform,
|
|
450
|
+
uOffset: this.offsetUniform,
|
|
451
|
+
uCanvasSize: this.canvasSizeUniform,
|
|
452
|
+
uPointSize: n.pointSize ?? l,
|
|
453
|
+
uColor: n.color
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
drawAreaStrip(e, t, n, r) {
|
|
458
|
+
this.writeCameraUniforms(r), this.backend.draw({
|
|
459
|
+
program: this.lineProgram,
|
|
460
|
+
primitive: "triangle_strip",
|
|
461
|
+
count: t,
|
|
462
|
+
attributes: { position: e },
|
|
463
|
+
uniforms: {
|
|
464
|
+
uScale: this.scaleUniform,
|
|
465
|
+
uOffset: this.offsetUniform,
|
|
466
|
+
uColor: n.fillColor ?? n.color
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
drawBarsInstanced(e, t, n, r) {
|
|
471
|
+
this.writeCameraUniforms(r);
|
|
472
|
+
let i = {
|
|
473
|
+
buffer: e,
|
|
474
|
+
divisor: 1,
|
|
475
|
+
stride: s * c,
|
|
476
|
+
offset: 0,
|
|
477
|
+
size: 2
|
|
478
|
+
}, a = {
|
|
479
|
+
buffer: this.barCornerBuffer,
|
|
480
|
+
divisor: 0,
|
|
481
|
+
stride: s * c,
|
|
482
|
+
offset: 0,
|
|
483
|
+
size: 2
|
|
484
|
+
};
|
|
485
|
+
this.backend.draw({
|
|
486
|
+
program: this.barProgram,
|
|
487
|
+
primitive: "triangle_strip",
|
|
488
|
+
count: 4,
|
|
489
|
+
instances: t,
|
|
490
|
+
attributes: {
|
|
491
|
+
aCorner: a,
|
|
492
|
+
aPosition: i
|
|
493
|
+
},
|
|
494
|
+
uniforms: {
|
|
495
|
+
uScale: this.scaleUniform,
|
|
496
|
+
uOffset: this.offsetUniform,
|
|
497
|
+
uBarWidth: n.barWidth ?? u,
|
|
498
|
+
uBaseline: n.baseline ?? d,
|
|
499
|
+
uColor: n.color
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
}
|
|
296
503
|
drawLinePrimitive(e, t, n, r, i) {
|
|
297
|
-
this.
|
|
504
|
+
this.writeCameraUniforms(i), this.backend.draw({
|
|
298
505
|
program: this.lineProgram,
|
|
299
506
|
primitive: e,
|
|
300
507
|
count: n,
|
|
@@ -306,19 +513,19 @@ var t = 16, n = class {
|
|
|
306
513
|
}
|
|
307
514
|
});
|
|
308
515
|
}
|
|
309
|
-
|
|
310
|
-
this.
|
|
516
|
+
writeCameraUniforms(e) {
|
|
517
|
+
this.scaleUniform[0] = e.xScale, this.scaleUniform[1] = e.yScale, this.offsetUniform[0] = e.xOffset, this.offsetUniform[1] = e.yOffset;
|
|
311
518
|
}
|
|
312
519
|
dispose() {
|
|
313
520
|
this.backend.destroy();
|
|
314
521
|
}
|
|
315
|
-
},
|
|
522
|
+
}, p = [
|
|
316
523
|
1024,
|
|
317
524
|
4096,
|
|
318
525
|
16384,
|
|
319
526
|
32768,
|
|
320
527
|
131072
|
|
321
|
-
],
|
|
528
|
+
], m = class {
|
|
322
529
|
regl;
|
|
323
530
|
pool = [];
|
|
324
531
|
preAllocated = !1;
|
|
@@ -331,7 +538,7 @@ var t = 16, n = class {
|
|
|
331
538
|
preAllocate() {
|
|
332
539
|
if (!this.preAllocated) {
|
|
333
540
|
this.preAllocated = !0;
|
|
334
|
-
for (let e of
|
|
541
|
+
for (let e of p) this.pool.push(this.createEntry(e, "stream"));
|
|
335
542
|
}
|
|
336
543
|
}
|
|
337
544
|
acquire(e, t = "stream") {
|
|
@@ -371,23 +578,24 @@ var t = 16, n = class {
|
|
|
371
578
|
return this.pool.find((t) => !t.inUse && t.floatCapacity >= e);
|
|
372
579
|
}
|
|
373
580
|
roundUp(e) {
|
|
374
|
-
for (let t of
|
|
375
|
-
let t =
|
|
581
|
+
for (let t of p) if (t >= e) return t;
|
|
582
|
+
let t = p[p.length - 1], n = 1 << 32 - Math.clz32(e - 1);
|
|
376
583
|
return Math.max(t * 2, n);
|
|
377
584
|
}
|
|
378
585
|
};
|
|
379
586
|
//#endregion
|
|
380
587
|
//#region src/render/ReglBackend.ts
|
|
381
|
-
function
|
|
588
|
+
function h(e) {
|
|
382
589
|
return e;
|
|
383
590
|
}
|
|
384
|
-
var
|
|
591
|
+
var g = class {
|
|
385
592
|
gl;
|
|
386
593
|
regl;
|
|
387
594
|
resources;
|
|
388
595
|
nextProgramId = 1;
|
|
389
596
|
commandCache = /* @__PURE__ */ new Map();
|
|
390
597
|
scissorBox = null;
|
|
598
|
+
capabilities;
|
|
391
599
|
constructor(t) {
|
|
392
600
|
let n = t.getContext("webgl2", {
|
|
393
601
|
alpha: !0,
|
|
@@ -400,10 +608,10 @@ var u = class {
|
|
|
400
608
|
});
|
|
401
609
|
if (!n) throw Error("BlazePlot requires WebGL2, but this browser/context does not support it.");
|
|
402
610
|
this.gl = n, this.regl = e({
|
|
403
|
-
gl:
|
|
611
|
+
gl: h(this.gl),
|
|
404
612
|
extensions: [],
|
|
405
|
-
optionalExtensions: ["ext_disjoint_timer_query_webgl2"]
|
|
406
|
-
}), this.resources = new
|
|
613
|
+
optionalExtensions: ["angle_instanced_arrays", "ext_disjoint_timer_query_webgl2"]
|
|
614
|
+
}), this.capabilities = { instancing: this.regl.hasExtension("angle_instanced_arrays") }, this.resources = new m(this.regl), this.resources.preAllocate();
|
|
407
615
|
}
|
|
408
616
|
createBuffer(e) {
|
|
409
617
|
let { buffer: t } = this.resources.acquire(e.length, e.usage);
|
|
@@ -436,7 +644,7 @@ var u = class {
|
|
|
436
644
|
].join("|"), a = this.commandCache.get(i);
|
|
437
645
|
a || (a = this.createDrawCommand(t, e.primitive, n, r, e.instances !== void 0), this.commandCache.set(i, a));
|
|
438
646
|
let o = {};
|
|
439
|
-
for (let t of n) o[t] = this.
|
|
647
|
+
for (let t of n) o[t] = this.resolveAttribute(e.attributes[t]);
|
|
440
648
|
let s = {
|
|
441
649
|
count: e.count,
|
|
442
650
|
instances: e.instances ?? 0,
|
|
@@ -497,6 +705,15 @@ var u = class {
|
|
|
497
705
|
}
|
|
498
706
|
});
|
|
499
707
|
}
|
|
708
|
+
resolveAttribute(e) {
|
|
709
|
+
return "divisor" in e ? {
|
|
710
|
+
buffer: this.asReglBuffer(e.buffer).buffer,
|
|
711
|
+
divisor: e.divisor,
|
|
712
|
+
stride: e.stride,
|
|
713
|
+
offset: e.offset,
|
|
714
|
+
size: e.size
|
|
715
|
+
} : this.asReglBuffer(e).buffer;
|
|
716
|
+
}
|
|
500
717
|
asReglBuffer(e) {
|
|
501
718
|
return e;
|
|
502
719
|
}
|
|
@@ -513,7 +730,7 @@ var u = class {
|
|
|
513
730
|
default: return e;
|
|
514
731
|
}
|
|
515
732
|
}
|
|
516
|
-
},
|
|
733
|
+
}, _ = class {
|
|
517
734
|
canvas;
|
|
518
735
|
camera;
|
|
519
736
|
policy;
|
|
@@ -567,7 +784,7 @@ var u = class {
|
|
|
567
784
|
dispose() {
|
|
568
785
|
this.canvas.removeEventListener("pointerdown", this.onPointerDown), this.canvas.removeEventListener("pointermove", this.onPointerMove), this.canvas.removeEventListener("pointerup", this.onPointerUp), this.canvas.removeEventListener("pointercancel", this.onPointerUp), this.canvas.removeEventListener("wheel", this.onWheel);
|
|
569
786
|
}
|
|
570
|
-
},
|
|
787
|
+
}, v = class e {
|
|
571
788
|
_xMin = 0;
|
|
572
789
|
_xMax = 1;
|
|
573
790
|
_yMin = 0;
|
|
@@ -652,7 +869,7 @@ var u = class {
|
|
|
652
869
|
static assertFinite(e, t) {
|
|
653
870
|
if (!Number.isFinite(t)) throw RangeError(`Camera2D ${e} must be finite.`);
|
|
654
871
|
}
|
|
655
|
-
},
|
|
872
|
+
}, y = class {
|
|
656
873
|
camera;
|
|
657
874
|
constructor(e) {
|
|
658
875
|
this.camera = e;
|
|
@@ -684,7 +901,7 @@ var u = class {
|
|
|
684
901
|
let n = Math.max(0, -Math.floor(Math.log10(t)) + 2), r = Number(e.toFixed(n));
|
|
685
902
|
return Object.is(r, -0) ? 0 : r;
|
|
686
903
|
}
|
|
687
|
-
},
|
|
904
|
+
}, b = class {
|
|
688
905
|
layout;
|
|
689
906
|
config;
|
|
690
907
|
options;
|
|
@@ -726,7 +943,7 @@ var u = class {
|
|
|
726
943
|
}
|
|
727
944
|
}
|
|
728
945
|
}
|
|
729
|
-
},
|
|
946
|
+
}, x = class {
|
|
730
947
|
root;
|
|
731
948
|
plot;
|
|
732
949
|
canvas;
|
|
@@ -753,8 +970,8 @@ var u = class {
|
|
|
753
970
|
applyBaseStyles() {
|
|
754
971
|
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.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";
|
|
755
972
|
}
|
|
756
|
-
},
|
|
757
|
-
function
|
|
973
|
+
}, S = 16384, C = S >> 1, w = S >> 1, T = 3, E = 64;
|
|
974
|
+
function D(e) {
|
|
758
975
|
return e === !1 ? {
|
|
759
976
|
visible: !1,
|
|
760
977
|
position: "inside"
|
|
@@ -766,7 +983,7 @@ function v(e) {
|
|
|
766
983
|
position: e.position ?? "inside"
|
|
767
984
|
};
|
|
768
985
|
}
|
|
769
|
-
var
|
|
986
|
+
var O = class {
|
|
770
987
|
options;
|
|
771
988
|
series = [];
|
|
772
989
|
camera;
|
|
@@ -775,6 +992,8 @@ var y = class {
|
|
|
775
992
|
input;
|
|
776
993
|
rawLineBuffer;
|
|
777
994
|
rawLineData;
|
|
995
|
+
minMaxInstanceBuffer;
|
|
996
|
+
minMaxInstanceData;
|
|
778
997
|
gridBuffer;
|
|
779
998
|
gridData;
|
|
780
999
|
gridStyle;
|
|
@@ -816,9 +1035,9 @@ var y = class {
|
|
|
816
1035
|
position: "inside"
|
|
817
1036
|
}
|
|
818
1037
|
} : this.normalizedAxes = {
|
|
819
|
-
x:
|
|
820
|
-
y:
|
|
821
|
-
}, this.layout = new
|
|
1038
|
+
x: D(n.x),
|
|
1039
|
+
y: D(n.y)
|
|
1040
|
+
}, this.layout = new x(e, this.normalizedAxes), this.applyCanvasSize(), this.camera = new v(), this.axis = new y(this.camera), this.renderer = new f(new g(this.layout.canvas)), this.input = new _(this.layout.canvas, this.camera, t.viewportPolicy), this.rawLineData = new Float32Array(S * 2), this.rawLineBuffer = this.renderer.createFloatBuffer(this.rawLineData.length), this.minMaxInstanceData = new Float32Array(w * T), this.minMaxInstanceBuffer = this.renderer.createFloatBuffer(this.minMaxInstanceData.length), this.gridData = new Float32Array(E * 2), this.gridBuffer = this.renderer.createFloatBuffer(this.gridData.length), this.gridStyle = {
|
|
822
1041
|
color: t.gridStyle?.color ?? [
|
|
823
1042
|
.22,
|
|
824
1043
|
.3,
|
|
@@ -826,22 +1045,31 @@ var y = class {
|
|
|
826
1045
|
.45
|
|
827
1046
|
],
|
|
828
1047
|
lineWidth: t.gridStyle?.lineWidth ?? 1
|
|
829
|
-
}, (this.normalizedAxes.x.visible || this.normalizedAxes.y.visible) && (this.axisOverlay = new
|
|
1048
|
+
}, (this.normalizedAxes.x.visible || this.normalizedAxes.y.visible) && (this.axisOverlay = new b(this.layout, this.normalizedAxes)), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(this.layout.plot));
|
|
830
1049
|
}
|
|
831
1050
|
get canvas() {
|
|
832
1051
|
return this.layout.canvas;
|
|
833
1052
|
}
|
|
834
1053
|
addSeries(e, t) {
|
|
835
|
-
let n =
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
lineWidth: t?.lineWidth ?? 1
|
|
1054
|
+
let n = e.dataset ?? new i(e.capacity), a = t?.color ?? [
|
|
1055
|
+
.3,
|
|
1056
|
+
.6,
|
|
1057
|
+
1,
|
|
1058
|
+
1
|
|
1059
|
+
], o = new r(n, e, {
|
|
1060
|
+
color: a,
|
|
1061
|
+
lineWidth: t?.lineWidth ?? 1,
|
|
1062
|
+
pointSize: t?.pointSize ?? 4,
|
|
1063
|
+
barWidth: t?.barWidth ?? .8,
|
|
1064
|
+
baseline: t?.baseline ?? 0,
|
|
1065
|
+
fillColor: t?.fillColor ?? [
|
|
1066
|
+
a[0],
|
|
1067
|
+
a[1],
|
|
1068
|
+
a[2],
|
|
1069
|
+
a[3] * .25
|
|
1070
|
+
]
|
|
843
1071
|
});
|
|
844
|
-
return this.series.push(
|
|
1072
|
+
return this.series.push(o), o;
|
|
845
1073
|
}
|
|
846
1074
|
removeSeries(e) {
|
|
847
1075
|
let t = this.series.indexOf(e);
|
|
@@ -882,7 +1110,26 @@ var y = class {
|
|
|
882
1110
|
}
|
|
883
1111
|
for (let e of this.series) {
|
|
884
1112
|
if (!e.visible) continue;
|
|
885
|
-
|
|
1113
|
+
if (e.config.mode === "scatter") {
|
|
1114
|
+
this.drawScatterSeries(e, t);
|
|
1115
|
+
continue;
|
|
1116
|
+
}
|
|
1117
|
+
if (e.config.mode === "bar") {
|
|
1118
|
+
this.drawBarSeries(e, t);
|
|
1119
|
+
continue;
|
|
1120
|
+
}
|
|
1121
|
+
if (e.config.mode === "area") {
|
|
1122
|
+
this.drawAreaSeries(e, t);
|
|
1123
|
+
continue;
|
|
1124
|
+
}
|
|
1125
|
+
let n = e.visibleSampleCount(t), r = e.hasLOD && n > S;
|
|
1126
|
+
if (r && this.renderer.supportsInstancedSegments) {
|
|
1127
|
+
let n = e.copyMinMaxInstanced(t, this.minMaxInstanceData, this.maxMinMaxSegments());
|
|
1128
|
+
if (n <= 0) continue;
|
|
1129
|
+
this.renderer.updateFloatBuffer(this.minMaxInstanceBuffer, this.minMaxInstanceData), this.renderer.drawMinMaxSegmentsInstanced(this.minMaxInstanceBuffer, n, e.style, this.camera), this.recordRenderMode("minmax"), this.stats.pointsRendered += n * 2, this.stats.drawCalls++, this.stats.uploadBytes += this.minMaxInstanceData.byteLength;
|
|
1130
|
+
continue;
|
|
1131
|
+
}
|
|
1132
|
+
let i = r ? e.copyMinMaxVisible(t, this.rawLineData, this.maxMinMaxSegments()) : e.copyRawVisible(t, this.rawLineData, S);
|
|
886
1133
|
i < 2 || (this.renderer.updateFloatBuffer(this.rawLineBuffer, this.rawLineData), r ? (this.renderer.drawMinMaxSegments(this.rawLineBuffer, i, e.style, this.camera), this.recordRenderMode("minmax")) : (this.renderer.drawLineStrip(this.rawLineBuffer, i, e.style, this.camera), this.recordRenderMode("raw")), this.stats.pointsRendered += i, this.stats.drawCalls++, this.stats.uploadBytes += this.rawLineData.byteLength);
|
|
887
1134
|
}
|
|
888
1135
|
this.axisOverlay?.update(this.camera, this.axis), this.stats.frameMs = performance.now() - e;
|
|
@@ -894,16 +1141,43 @@ var y = class {
|
|
|
894
1141
|
let t = Number.isFinite(e) ? Math.max(1, e) : 1, n = Math.max(1, Math.floor(this.canvas.clientWidth * t)), r = Math.max(1, Math.floor(this.canvas.clientHeight * t));
|
|
895
1142
|
return this.canvas.width === n && this.canvas.height === r ? !1 : (this.canvas.width = n, this.canvas.height = r, !0);
|
|
896
1143
|
}
|
|
1144
|
+
drawAreaSeries(e, t) {
|
|
1145
|
+
let n = e.style.baseline ?? 0, r = e.copyAreaVisible(t, this.rawLineData, C, n);
|
|
1146
|
+
if (r < 4) return;
|
|
1147
|
+
this.renderer.updateFloatBuffer(this.rawLineBuffer, this.rawLineData), this.renderer.drawAreaStrip(this.rawLineBuffer, r, e.style, this.camera), this.stats.pointsRendered += r, this.stats.drawCalls++, this.stats.uploadBytes += this.rawLineData.byteLength;
|
|
1148
|
+
let i = this.uploadRawInstances(e, t, C);
|
|
1149
|
+
i >= 2 && (this.renderer.drawLineStrip(this.rawLineBuffer, i, e.style, this.camera), this.stats.pointsRendered += i, this.stats.drawCalls++), this.recordRenderMode("area");
|
|
1150
|
+
}
|
|
1151
|
+
drawScatterSeries(e, t) {
|
|
1152
|
+
if (!this.renderer.supportsInstancedPoints) return;
|
|
1153
|
+
let n = this.uploadRawInstances(e, t, S);
|
|
1154
|
+
n <= 0 || (this.renderer.drawPointsInstanced(this.rawLineBuffer, n, e.style, this.camera, this.canvas.width, this.canvas.height), this.recordInstancedDraw("points", n));
|
|
1155
|
+
}
|
|
1156
|
+
drawBarSeries(e, t) {
|
|
1157
|
+
if (!this.renderer.supportsInstancedBars) return;
|
|
1158
|
+
let n = this.uploadRawInstances(e, t, S);
|
|
1159
|
+
n <= 0 || (this.renderer.drawBarsInstanced(this.rawLineBuffer, n, e.style, this.camera), this.recordInstancedDraw("bars", n));
|
|
1160
|
+
}
|
|
1161
|
+
uploadRawInstances(e, t, n) {
|
|
1162
|
+
let r = e.copyRawVisible(t, this.rawLineData, n);
|
|
1163
|
+
return r <= 0 ? 0 : (this.renderer.updateFloatBuffer(this.rawLineBuffer, this.rawLineData), this.stats.uploadBytes += this.rawLineData.byteLength, r);
|
|
1164
|
+
}
|
|
1165
|
+
recordInstancedDraw(e, t) {
|
|
1166
|
+
this.recordRenderMode(e), this.stats.pointsRendered += t, this.stats.drawCalls++;
|
|
1167
|
+
}
|
|
1168
|
+
maxMinMaxSegments() {
|
|
1169
|
+
return Math.min(this.canvas.width, w);
|
|
1170
|
+
}
|
|
897
1171
|
writeGridVertices(e) {
|
|
898
1172
|
let t = Math.max(1, this.canvas.clientWidth), n = Math.max(1, this.canvas.clientHeight);
|
|
899
1173
|
this.axis.getXTickValues(t, 12, this.xTicks), this.axis.getYTickValues(n, 8, this.yTicks);
|
|
900
1174
|
let r = 0;
|
|
901
1175
|
for (let t of this.xTicks) {
|
|
902
|
-
if (r + 2 >
|
|
1176
|
+
if (r + 2 > E) return r;
|
|
903
1177
|
this.gridData[r * 2] = t, this.gridData[r * 2 + 1] = e.yMin, r++, this.gridData[r * 2] = t, this.gridData[r * 2 + 1] = e.yMax, r++;
|
|
904
1178
|
}
|
|
905
1179
|
for (let t of this.yTicks) {
|
|
906
|
-
if (r + 2 >
|
|
1180
|
+
if (r + 2 > E) return r;
|
|
907
1181
|
this.gridData[r * 2] = e.xMin, this.gridData[r * 2 + 1] = t, r++, this.gridData[r * 2] = e.xMax, this.gridData[r * 2 + 1] = t, r++;
|
|
908
1182
|
}
|
|
909
1183
|
return r;
|
|
@@ -911,7 +1185,7 @@ var y = class {
|
|
|
911
1185
|
recordRenderMode(e) {
|
|
912
1186
|
this.stats.renderMode === "none" ? this.stats.renderMode = e : this.stats.renderMode !== e && (this.stats.renderMode = "mixed");
|
|
913
1187
|
}
|
|
914
|
-
},
|
|
1188
|
+
}, k = class {
|
|
915
1189
|
xData;
|
|
916
1190
|
yData;
|
|
917
1191
|
constructor(e, t) {
|
|
@@ -953,6 +1227,6 @@ var y = class {
|
|
|
953
1227
|
}
|
|
954
1228
|
};
|
|
955
1229
|
//#endregion
|
|
956
|
-
export {
|
|
1230
|
+
export { y as AxisController, v as Camera2D, O as Chart, n as MinMaxPyramid, i as RingBuffer, r as SeriesStore, k as StaticDataset };
|
|
957
1231
|
|
|
958
1232
|
//# sourceMappingURL=index.js.map
|