blazeplot 0.1.10 → 0.1.11
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 +46 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +263 -119
- package/dist/index.js.map +1 -1
- package/dist/interaction/index.d.ts +0 -1
- package/dist/interaction/index.d.ts.map +1 -1
- package/dist/plugins/interactions.d.ts +3 -0
- package/dist/plugins/interactions.d.ts.map +1 -0
- package/dist/plugins/interactions.js +143 -0
- package/dist/plugins/interactions.js.map +1 -0
- package/dist/plugins/legend.js +22 -18
- package/dist/plugins/legend.js.map +1 -1
- package/dist/plugins/tooltip.js +1 -1
- package/dist/plugins/tooltip.js.map +1 -1
- package/dist/render/ReglBackend.d.ts.map +1 -1
- package/dist/ui/Chart.d.ts +18 -2
- package/dist/ui/Chart.d.ts.map +1 -1
- package/dist/ui/Interactions.d.ts +19 -0
- package/dist/ui/Interactions.d.ts.map +1 -0
- package/dist/ui/Legend.d.ts +5 -0
- package/dist/ui/Legend.d.ts.map +1 -1
- package/dist/ui/Tooltip.d.ts +3 -0
- package/dist/ui/Tooltip.d.ts.map +1 -1
- package/dist/ui/theme.d.ts +41 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/package.json +5 -1
- package/dist/interaction/InputController.d.ts +0 -23
- package/dist/interaction/InputController.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -799,7 +799,7 @@ var i = class {
|
|
|
799
799
|
16384,
|
|
800
800
|
32768,
|
|
801
801
|
131072
|
|
802
|
-
],
|
|
802
|
+
], ee = class {
|
|
803
803
|
regl;
|
|
804
804
|
pool = [];
|
|
805
805
|
preAllocated = !1;
|
|
@@ -859,10 +859,10 @@ var i = class {
|
|
|
859
859
|
};
|
|
860
860
|
//#endregion
|
|
861
861
|
//#region src/render/ReglBackend.ts
|
|
862
|
-
function
|
|
862
|
+
function te(e) {
|
|
863
863
|
return e;
|
|
864
864
|
}
|
|
865
|
-
var
|
|
865
|
+
var E = class {
|
|
866
866
|
gl;
|
|
867
867
|
regl;
|
|
868
868
|
resources;
|
|
@@ -882,10 +882,10 @@ var O = class {
|
|
|
882
882
|
});
|
|
883
883
|
if (!n) throw Error("BlazePlot requires WebGL2, but this browser/context does not support it.");
|
|
884
884
|
this.gl = n, this.regl = e({
|
|
885
|
-
gl:
|
|
885
|
+
gl: te(this.gl),
|
|
886
886
|
extensions: [],
|
|
887
887
|
optionalExtensions: ["angle_instanced_arrays", "ext_disjoint_timer_query_webgl2"]
|
|
888
|
-
}), this.capabilities = { instancing: this.regl.hasExtension("angle_instanced_arrays") }, this.resources = new
|
|
888
|
+
}), this.capabilities = { instancing: this.regl.hasExtension("angle_instanced_arrays") }, this.resources = new ee(this.regl), this.resources.preAllocate();
|
|
889
889
|
}
|
|
890
890
|
createBuffer(e) {
|
|
891
891
|
let { buffer: t } = this.resources.acquire(e.length, e.usage);
|
|
@@ -944,7 +944,7 @@ var O = class {
|
|
|
944
944
|
] });
|
|
945
945
|
}
|
|
946
946
|
viewport(e, t, n, r) {
|
|
947
|
-
this.scissorBox = {
|
|
947
|
+
this.regl.poll(), this.scissorBox = {
|
|
948
948
|
x: e,
|
|
949
949
|
y: t,
|
|
950
950
|
w: n,
|
|
@@ -1004,61 +1004,7 @@ var O = class {
|
|
|
1004
1004
|
default: return e;
|
|
1005
1005
|
}
|
|
1006
1006
|
}
|
|
1007
|
-
},
|
|
1008
|
-
canvas;
|
|
1009
|
-
camera;
|
|
1010
|
-
policy;
|
|
1011
|
-
_enabled = !0;
|
|
1012
|
-
activePointerId = null;
|
|
1013
|
-
lastX = 0;
|
|
1014
|
-
lastY = 0;
|
|
1015
|
-
constructor(e, t, n) {
|
|
1016
|
-
this.canvas = e, this.camera = t, this.policy = n, this.bindEvents();
|
|
1017
|
-
}
|
|
1018
|
-
get enabled() {
|
|
1019
|
-
return this._enabled;
|
|
1020
|
-
}
|
|
1021
|
-
set enabled(e) {
|
|
1022
|
-
this._enabled = e;
|
|
1023
|
-
}
|
|
1024
|
-
bindEvents() {
|
|
1025
|
-
this.canvas.addEventListener("pointerdown", this.onPointerDown), this.canvas.addEventListener("pointermove", this.onPointerMove), this.canvas.addEventListener("pointerup", this.onPointerUp), this.canvas.addEventListener("pointercancel", this.onPointerUp), this.canvas.addEventListener("wheel", this.onWheel, { passive: !1 });
|
|
1026
|
-
}
|
|
1027
|
-
onPointerDown = (e) => {
|
|
1028
|
-
!this._enabled || this.activePointerId !== null || (this.activePointerId = e.pointerId, this.lastX = e.clientX, this.lastY = e.clientY, this.canvas.setPointerCapture(e.pointerId));
|
|
1029
|
-
};
|
|
1030
|
-
onPointerMove = (e) => {
|
|
1031
|
-
if (!this._enabled || e.pointerId !== this.activePointerId) return;
|
|
1032
|
-
let t = this.canvas.getBoundingClientRect(), n = t.width > 0 ? (this.lastX - e.clientX) / t.width : 0, r = t.height > 0 ? (e.clientY - this.lastY) / t.height : 0, i = this.applyPanPolicy({
|
|
1033
|
-
dx: n,
|
|
1034
|
-
dy: r
|
|
1035
|
-
});
|
|
1036
|
-
i && this.camera.pan(i), this.lastX = e.clientX, this.lastY = e.clientY;
|
|
1037
|
-
};
|
|
1038
|
-
onPointerUp = (e) => {
|
|
1039
|
-
e.pointerId === this.activePointerId && (this.activePointerId = null, this.canvas.hasPointerCapture(e.pointerId) && this.canvas.releasePointerCapture(e.pointerId));
|
|
1040
|
-
};
|
|
1041
|
-
onWheel = (e) => {
|
|
1042
|
-
if (!this._enabled) return;
|
|
1043
|
-
e.preventDefault();
|
|
1044
|
-
let t = e.deltaY < 0 ? 1.1 : .9, n = this.canvas.getBoundingClientRect(), r = n.width > 0 ? (e.clientX - n.left) / n.width : .5, i = n.height > 0 ? 1 - (e.clientY - n.top) / n.height : .5, a = this.applyZoomPolicy({
|
|
1045
|
-
factor: t,
|
|
1046
|
-
cx: r,
|
|
1047
|
-
cy: i,
|
|
1048
|
-
axis: "xy"
|
|
1049
|
-
});
|
|
1050
|
-
a && this.camera.zoom(a);
|
|
1051
|
-
};
|
|
1052
|
-
applyPanPolicy(e) {
|
|
1053
|
-
return this.policy?.beforePan ? this.policy.beforePan(this.camera, e) : e;
|
|
1054
|
-
}
|
|
1055
|
-
applyZoomPolicy(e) {
|
|
1056
|
-
return this.policy?.beforeZoom ? this.policy.beforeZoom(this.camera, e) : e;
|
|
1057
|
-
}
|
|
1058
|
-
dispose() {
|
|
1059
|
-
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);
|
|
1060
|
-
}
|
|
1061
|
-
}, A = class e {
|
|
1007
|
+
}, D = class e {
|
|
1062
1008
|
_xMin = 0;
|
|
1063
1009
|
_xMax = 1;
|
|
1064
1010
|
_yMin = 0;
|
|
@@ -1143,7 +1089,7 @@ var O = class {
|
|
|
1143
1089
|
static assertFinite(e, t) {
|
|
1144
1090
|
if (!Number.isFinite(t)) throw RangeError(`Camera2D ${e} must be finite.`);
|
|
1145
1091
|
}
|
|
1146
|
-
},
|
|
1092
|
+
}, O = class {
|
|
1147
1093
|
camera;
|
|
1148
1094
|
constructor(e) {
|
|
1149
1095
|
this.camera = e;
|
|
@@ -1175,7 +1121,7 @@ var O = class {
|
|
|
1175
1121
|
let n = Math.max(0, -Math.floor(Math.log10(t)) + 2), r = Number(e.toFixed(n));
|
|
1176
1122
|
return Object.is(r, -0) ? 0 : r;
|
|
1177
1123
|
}
|
|
1178
|
-
},
|
|
1124
|
+
}, k = class {
|
|
1179
1125
|
layout;
|
|
1180
1126
|
config;
|
|
1181
1127
|
options;
|
|
@@ -1217,7 +1163,7 @@ var O = class {
|
|
|
1217
1163
|
}
|
|
1218
1164
|
}
|
|
1219
1165
|
}
|
|
1220
|
-
},
|
|
1166
|
+
}, A = class {
|
|
1221
1167
|
root;
|
|
1222
1168
|
plot;
|
|
1223
1169
|
canvas;
|
|
@@ -1244,8 +1190,181 @@ var O = class {
|
|
|
1244
1190
|
applyBaseStyles() {
|
|
1245
1191
|
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.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";
|
|
1246
1192
|
}
|
|
1247
|
-
},
|
|
1193
|
+
}, j = {
|
|
1194
|
+
backgroundColor: [
|
|
1195
|
+
.08,
|
|
1196
|
+
.1,
|
|
1197
|
+
.16,
|
|
1198
|
+
1
|
|
1199
|
+
],
|
|
1200
|
+
backgroundCssColor: "rgba(20, 26, 41, 1)",
|
|
1201
|
+
gridColor: [
|
|
1202
|
+
.22,
|
|
1203
|
+
.3,
|
|
1204
|
+
.44,
|
|
1205
|
+
.45
|
|
1206
|
+
],
|
|
1207
|
+
axisColor: "#bfd6ff",
|
|
1208
|
+
axisFont: "11px ui-monospace, monospace, sans-serif",
|
|
1209
|
+
seriesColors: [
|
|
1210
|
+
[
|
|
1211
|
+
.3,
|
|
1212
|
+
.6,
|
|
1213
|
+
1,
|
|
1214
|
+
1
|
|
1215
|
+
],
|
|
1216
|
+
[
|
|
1217
|
+
.95,
|
|
1218
|
+
.35,
|
|
1219
|
+
.35,
|
|
1220
|
+
1
|
|
1221
|
+
],
|
|
1222
|
+
[
|
|
1223
|
+
.2,
|
|
1224
|
+
.8,
|
|
1225
|
+
.4,
|
|
1226
|
+
.9
|
|
1227
|
+
],
|
|
1228
|
+
[
|
|
1229
|
+
.95,
|
|
1230
|
+
.72,
|
|
1231
|
+
.25,
|
|
1232
|
+
1
|
|
1233
|
+
],
|
|
1234
|
+
[
|
|
1235
|
+
.72,
|
|
1236
|
+
.45,
|
|
1237
|
+
.95,
|
|
1238
|
+
1
|
|
1239
|
+
],
|
|
1240
|
+
[
|
|
1241
|
+
.25,
|
|
1242
|
+
.85,
|
|
1243
|
+
.95,
|
|
1244
|
+
1
|
|
1245
|
+
]
|
|
1246
|
+
],
|
|
1247
|
+
tooltipBackgroundColor: "rgba(4, 8, 16, 0.85)",
|
|
1248
|
+
tooltipTextColor: "#bfd6ff",
|
|
1249
|
+
tooltipFont: "11px/1.35 ui-monospace, monospace",
|
|
1250
|
+
legendBackgroundColor: "rgba(4, 8, 16, 0.85)",
|
|
1251
|
+
legendBorderColor: "transparent",
|
|
1252
|
+
legendTextColor: "#bfd6ff",
|
|
1253
|
+
legendMutedTextColor: "#789",
|
|
1254
|
+
legendFont: "11px/1.35 ui-monospace, monospace"
|
|
1255
|
+
};
|
|
1256
|
+
function M(e, t) {
|
|
1257
|
+
if (!e) return j;
|
|
1258
|
+
let n = N(e.backgroundColor, j.backgroundColor, t), r = e.seriesColors?.length ? e.seriesColors.map((e, n) => N(e, j.seriesColors[n % j.seriesColors.length], t)) : j.seriesColors;
|
|
1259
|
+
return {
|
|
1260
|
+
backgroundColor: n,
|
|
1261
|
+
backgroundCssColor: P(e.backgroundColor, j.backgroundCssColor),
|
|
1262
|
+
gridColor: N(e.gridColor, j.gridColor, t),
|
|
1263
|
+
axisColor: e.axisColor ?? j.axisColor,
|
|
1264
|
+
axisFont: e.axisFont ?? j.axisFont,
|
|
1265
|
+
seriesColors: r,
|
|
1266
|
+
tooltipBackgroundColor: e.tooltipBackgroundColor ?? j.tooltipBackgroundColor,
|
|
1267
|
+
tooltipTextColor: e.tooltipTextColor ?? j.tooltipTextColor,
|
|
1268
|
+
tooltipFont: e.tooltipFont ?? j.tooltipFont,
|
|
1269
|
+
legendBackgroundColor: e.legendBackgroundColor ?? j.legendBackgroundColor,
|
|
1270
|
+
legendBorderColor: e.legendBorderColor ?? j.legendBorderColor,
|
|
1271
|
+
legendTextColor: e.legendTextColor ?? j.legendTextColor,
|
|
1272
|
+
legendMutedTextColor: e.legendMutedTextColor ?? j.legendMutedTextColor,
|
|
1273
|
+
legendFont: e.legendFont ?? j.legendFont
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
function N(e, t, n) {
|
|
1277
|
+
if (!e) return t;
|
|
1278
|
+
if (typeof e != "string") return e;
|
|
1279
|
+
let r = I(e, n), i = R(r ?? e, n);
|
|
1280
|
+
return L(r ?? e) ?? L(i ?? "") ?? t;
|
|
1281
|
+
}
|
|
1282
|
+
function P(e, t) {
|
|
1283
|
+
return e ? typeof e == "string" ? e : F(e) : t;
|
|
1284
|
+
}
|
|
1285
|
+
function F(e) {
|
|
1286
|
+
return `rgba(${Math.round(e[0] * 255)}, ${Math.round(e[1] * 255)}, ${Math.round(e[2] * 255)}, ${e[3]})`;
|
|
1287
|
+
}
|
|
1288
|
+
function I(e, t) {
|
|
1289
|
+
let n = t?.ownerDocument ?? globalThis.document;
|
|
1290
|
+
if (!n?.documentElement || typeof getComputedStyle > "u") return null;
|
|
1291
|
+
let r = t instanceof HTMLElement ? t : n.documentElement, i = n.createElement("span");
|
|
1292
|
+
i.style.position = "absolute", i.style.visibility = "hidden", i.style.pointerEvents = "none", i.style.color = e, r.appendChild(i);
|
|
1293
|
+
let a = getComputedStyle(i).color;
|
|
1294
|
+
return i.remove(), a || null;
|
|
1295
|
+
}
|
|
1296
|
+
function L(e) {
|
|
1297
|
+
let t = e.trim();
|
|
1298
|
+
return z(t) ?? B(t) ?? V(t);
|
|
1299
|
+
}
|
|
1300
|
+
function R(e, t) {
|
|
1301
|
+
let n = t?.ownerDocument ?? globalThis.document;
|
|
1302
|
+
if (!n?.createElement) return null;
|
|
1303
|
+
let r = n.createElement("canvas").getContext("2d");
|
|
1304
|
+
if (!r) return null;
|
|
1305
|
+
let i = "#010203";
|
|
1306
|
+
r.fillStyle = i, r.fillStyle = e;
|
|
1307
|
+
let a = String(r.fillStyle);
|
|
1308
|
+
return a === i ? null : a;
|
|
1309
|
+
}
|
|
1310
|
+
function z(e) {
|
|
1311
|
+
let t = e.match(/^rgba?\((.*)\)$/i);
|
|
1312
|
+
if (!t) return null;
|
|
1313
|
+
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);
|
|
1314
|
+
if (a.length < 3) return null;
|
|
1315
|
+
let o = H(a[0]), s = H(a[1]), c = H(a[2]), l = W(i ?? (a.length > 3 ? a[3] : void 0));
|
|
1316
|
+
return o === null || s === null || c === null || l === null ? null : [
|
|
1317
|
+
o,
|
|
1318
|
+
s,
|
|
1319
|
+
c,
|
|
1320
|
+
l
|
|
1321
|
+
];
|
|
1322
|
+
}
|
|
1323
|
+
function B(e) {
|
|
1324
|
+
let t = e.match(/^color\(\s*srgb\s+(.+)\)$/i);
|
|
1325
|
+
if (!t) return null;
|
|
1326
|
+
let n = t[1].split("/").map((e) => e.trim()), r = n[0].split(/\s+/).filter(Boolean);
|
|
1327
|
+
if (r.length < 3) return null;
|
|
1328
|
+
let i = U(r[0]), a = U(r[1]), o = U(r[2]), s = W(n[1]);
|
|
1329
|
+
return i === null || a === null || o === null || s === null ? null : [
|
|
1330
|
+
i,
|
|
1331
|
+
a,
|
|
1332
|
+
o,
|
|
1333
|
+
s
|
|
1334
|
+
];
|
|
1335
|
+
}
|
|
1248
1336
|
function V(e) {
|
|
1337
|
+
let t = e.startsWith("#") ? e.slice(1) : "";
|
|
1338
|
+
if (![
|
|
1339
|
+
3,
|
|
1340
|
+
4,
|
|
1341
|
+
6,
|
|
1342
|
+
8
|
|
1343
|
+
].includes(t.length) || !/^[\da-f]+$/i.test(t)) return null;
|
|
1344
|
+
let n = t.length <= 4 ? [...t].map((e) => e + e).join("") : t, r = Number.parseInt(n, 16);
|
|
1345
|
+
return Number.isFinite(r) ? [
|
|
1346
|
+
(r >> (n.length === 8 ? 24 : 16) & 255) / 255,
|
|
1347
|
+
(r >> (n.length === 8 ? 16 : 8) & 255) / 255,
|
|
1348
|
+
(r >> (n.length === 8 ? 8 : 0) & 255) / 255,
|
|
1349
|
+
n.length === 8 ? (r & 255) / 255 : 1
|
|
1350
|
+
] : null;
|
|
1351
|
+
}
|
|
1352
|
+
function H(e) {
|
|
1353
|
+
return e.endsWith("%") ? G(Number.parseFloat(e) / 100) : G(Number.parseFloat(e) / 255);
|
|
1354
|
+
}
|
|
1355
|
+
function U(e) {
|
|
1356
|
+
return e.endsWith("%") ? G(Number.parseFloat(e) / 100) : G(Number.parseFloat(e));
|
|
1357
|
+
}
|
|
1358
|
+
function W(e) {
|
|
1359
|
+
return e ? e.endsWith("%") ? G(Number.parseFloat(e) / 100) : G(Number.parseFloat(e)) : 1;
|
|
1360
|
+
}
|
|
1361
|
+
function G(e) {
|
|
1362
|
+
return Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : null;
|
|
1363
|
+
}
|
|
1364
|
+
//#endregion
|
|
1365
|
+
//#region src/ui/Chart.ts
|
|
1366
|
+
var K = 16384, q = K >> 1, J = K >> 1, Y = 3, X = 4096, Z = 12, Q = 64;
|
|
1367
|
+
function $(e) {
|
|
1249
1368
|
return e === !1 ? {
|
|
1250
1369
|
visible: !1,
|
|
1251
1370
|
position: "inside"
|
|
@@ -1257,13 +1376,12 @@ function V(e) {
|
|
|
1257
1376
|
position: e.position ?? "inside"
|
|
1258
1377
|
};
|
|
1259
1378
|
}
|
|
1260
|
-
var
|
|
1379
|
+
var ne = class {
|
|
1261
1380
|
options;
|
|
1262
1381
|
series = [];
|
|
1263
1382
|
camera;
|
|
1264
1383
|
axis;
|
|
1265
1384
|
renderer;
|
|
1266
|
-
input;
|
|
1267
1385
|
rawLineBuffer;
|
|
1268
1386
|
rawLineData;
|
|
1269
1387
|
minMaxInstanceBuffer;
|
|
@@ -1277,6 +1395,7 @@ var H = class {
|
|
|
1277
1395
|
yTicks = [];
|
|
1278
1396
|
axisOverlay = null;
|
|
1279
1397
|
normalizedAxes;
|
|
1398
|
+
resolvedTheme;
|
|
1280
1399
|
layout;
|
|
1281
1400
|
stats = {
|
|
1282
1401
|
fps: 0,
|
|
@@ -1303,7 +1422,7 @@ var H = class {
|
|
|
1303
1422
|
this.pointerInPlot = !1, this.emitHover(null);
|
|
1304
1423
|
};
|
|
1305
1424
|
constructor(e, t = {}) {
|
|
1306
|
-
this.options = t;
|
|
1425
|
+
this.options = t, this.resolvedTheme = M(t.theme, e);
|
|
1307
1426
|
let n = t.axes;
|
|
1308
1427
|
n === !1 ? this.normalizedAxes = {
|
|
1309
1428
|
x: {
|
|
@@ -1324,17 +1443,15 @@ var H = class {
|
|
|
1324
1443
|
position: "inside"
|
|
1325
1444
|
}
|
|
1326
1445
|
} : this.normalizedAxes = {
|
|
1327
|
-
x:
|
|
1328
|
-
y:
|
|
1329
|
-
}, this.layout = new
|
|
1330
|
-
color: t.gridStyle?.color ??
|
|
1331
|
-
.22,
|
|
1332
|
-
.3,
|
|
1333
|
-
.44,
|
|
1334
|
-
.45
|
|
1335
|
-
],
|
|
1446
|
+
x: $(n.x),
|
|
1447
|
+
y: $(n.y)
|
|
1448
|
+
}, this.layout = new A(e, this.normalizedAxes), this.layout.root.style.background = this.resolvedTheme.backgroundCssColor, this.applyCanvasSize(), this.camera = new D(), this.axis = new O(this.camera), this.renderer = new w(new E(this.layout.canvas)), this.rawLineData = new Float32Array(K * 2), this.rawLineBuffer = this.renderer.createFloatBuffer(this.rawLineData.length), this.minMaxInstanceData = new Float32Array(J * Y), this.minMaxInstanceBuffer = this.renderer.createFloatBuffer(this.minMaxInstanceData.length), this.barTriangleData = new Float32Array(X * Z), this.barTriangleBuffer = this.renderer.createFloatBuffer(this.barTriangleData.length), this.gridData = new Float32Array(Q * 2), this.gridBuffer = this.renderer.createFloatBuffer(this.gridData.length), this.gridStyle = {
|
|
1449
|
+
color: t.gridStyle?.color ?? this.resolvedTheme.gridColor,
|
|
1336
1450
|
lineWidth: t.gridStyle?.lineWidth ?? 1
|
|
1337
|
-
}, (this.normalizedAxes.x.visible || this.normalizedAxes.y.visible) && (this.axisOverlay = new
|
|
1451
|
+
}, (this.normalizedAxes.x.visible || this.normalizedAxes.y.visible) && (this.axisOverlay = new k(this.layout, this.normalizedAxes, {
|
|
1452
|
+
color: this.resolvedTheme.axisColor,
|
|
1453
|
+
font: this.resolvedTheme.axisFont
|
|
1454
|
+
})), 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));
|
|
1338
1455
|
for (let e of t.plugins ?? []) {
|
|
1339
1456
|
let t = e.install(this);
|
|
1340
1457
|
typeof t == "function" ? this.pluginDisposers.push(t) : t && this.pluginDisposers.push(() => t.dispose());
|
|
@@ -1349,30 +1466,54 @@ var H = class {
|
|
|
1349
1466
|
get plotElement() {
|
|
1350
1467
|
return this.layout.plot;
|
|
1351
1468
|
}
|
|
1469
|
+
get xAxisElement() {
|
|
1470
|
+
return this.layout.xAxis;
|
|
1471
|
+
}
|
|
1472
|
+
get yAxisElement() {
|
|
1473
|
+
return this.layout.yAxis;
|
|
1474
|
+
}
|
|
1475
|
+
get theme() {
|
|
1476
|
+
return this.resolvedTheme;
|
|
1477
|
+
}
|
|
1478
|
+
getCamera() {
|
|
1479
|
+
return this.camera;
|
|
1480
|
+
}
|
|
1352
1481
|
dataToPlot(e, t) {
|
|
1353
1482
|
let [n, r] = this.camera.toClip(e, t);
|
|
1354
1483
|
return this.camera.toScreen(n, r, this.canvas.clientWidth, this.canvas.clientHeight);
|
|
1355
1484
|
}
|
|
1485
|
+
clientToData(e, t) {
|
|
1486
|
+
let n = this.canvas.getBoundingClientRect();
|
|
1487
|
+
if (n.width <= 0 || n.height <= 0) return null;
|
|
1488
|
+
let r = e - n.left, i = t - n.top;
|
|
1489
|
+
if (r < 0 || i < 0 || r > n.width || i > n.height) return null;
|
|
1490
|
+
let a = this.camera.viewport;
|
|
1491
|
+
return [a.xMin + r / n.width * (a.xMax - a.xMin), a.yMax - i / n.height * (a.yMax - a.yMin)];
|
|
1492
|
+
}
|
|
1493
|
+
getViewport() {
|
|
1494
|
+
return this.camera.viewport;
|
|
1495
|
+
}
|
|
1496
|
+
pan(e) {
|
|
1497
|
+
this.camera.pan(e), this.refreshHover();
|
|
1498
|
+
}
|
|
1499
|
+
zoom(e) {
|
|
1500
|
+
this.camera.zoom(e), this.refreshHover();
|
|
1501
|
+
}
|
|
1356
1502
|
addSeries(e, t) {
|
|
1357
|
-
let n = e.dataset ?? new a(e.capacity), r = t?.color ??
|
|
1358
|
-
|
|
1359
|
-
.6,
|
|
1360
|
-
1,
|
|
1361
|
-
1
|
|
1362
|
-
], o = new i(n, e, {
|
|
1363
|
-
color: r,
|
|
1503
|
+
let n = e.dataset ?? new a(e.capacity), r = this.resolvedTheme.seriesColors, o = r[this.series.length % r.length] ?? this.resolvedTheme.seriesColors[0], s = t?.color ?? o, c = new i(n, e, {
|
|
1504
|
+
color: s,
|
|
1364
1505
|
lineWidth: t?.lineWidth ?? 1,
|
|
1365
1506
|
pointSize: t?.pointSize ?? 4,
|
|
1366
1507
|
barWidth: t?.barWidth ?? .8,
|
|
1367
1508
|
baseline: t?.baseline ?? 0,
|
|
1368
1509
|
fillColor: t?.fillColor ?? [
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1510
|
+
s[0],
|
|
1511
|
+
s[1],
|
|
1512
|
+
s[2],
|
|
1513
|
+
s[3] * .25
|
|
1373
1514
|
]
|
|
1374
1515
|
});
|
|
1375
|
-
return this.series.push(
|
|
1516
|
+
return this.series.push(c), this.emitSeriesChange(), c;
|
|
1376
1517
|
}
|
|
1377
1518
|
addLine(e, t) {
|
|
1378
1519
|
return this.addSeries({
|
|
@@ -1417,10 +1558,11 @@ var H = class {
|
|
|
1417
1558
|
}));
|
|
1418
1559
|
}
|
|
1419
1560
|
setViewport(e) {
|
|
1420
|
-
this.camera.setViewport(e);
|
|
1561
|
+
this.camera.setViewport(e), this.refreshHover();
|
|
1421
1562
|
}
|
|
1422
1563
|
resize(e = globalThis.devicePixelRatio) {
|
|
1423
|
-
|
|
1564
|
+
let t = this.applyCanvasSize(e);
|
|
1565
|
+
return t && this.refreshHover(), t;
|
|
1424
1566
|
}
|
|
1425
1567
|
getFrameStats(e = {
|
|
1426
1568
|
fps: 0,
|
|
@@ -1467,7 +1609,7 @@ var H = class {
|
|
|
1467
1609
|
o.width = i, o.height = a;
|
|
1468
1610
|
let s = o.getContext("2d");
|
|
1469
1611
|
if (!s) throw Error("Unable to create a 2D canvas context for screenshot export.");
|
|
1470
|
-
return
|
|
1612
|
+
return s.fillStyle = e.background ?? F(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) => {
|
|
1471
1613
|
o.toBlob((e) => e ? t(e) : n(/* @__PURE__ */ Error("Unable to encode chart screenshot.")), e.type ?? "image/png", e.quality);
|
|
1472
1614
|
});
|
|
1473
1615
|
}
|
|
@@ -1482,56 +1624,58 @@ var H = class {
|
|
|
1482
1624
|
}
|
|
1483
1625
|
render() {
|
|
1484
1626
|
let e = performance.now();
|
|
1485
|
-
this.lastFrameAt > 0 && (this.stats.fps = 1e3 / (e - this.lastFrameAt)), this.lastFrameAt = e, this.stats.pointsRendered = 0, this.stats.drawCalls = 0, this.stats.uploadBytes = 0, this.stats.renderMode = "none", this.options.viewportPolicy?.beforeRender?.(this.camera)
|
|
1486
|
-
let t = this.
|
|
1627
|
+
this.lastFrameAt > 0 && (this.stats.fps = 1e3 / (e - this.lastFrameAt)), this.lastFrameAt = e, this.stats.pointsRendered = 0, this.stats.drawCalls = 0, this.stats.uploadBytes = 0, this.stats.renderMode = "none", this.options.viewportPolicy?.beforeRender?.(this.camera);
|
|
1628
|
+
let [t, n, r, i] = this.resolvedTheme.backgroundColor;
|
|
1629
|
+
this.renderer.viewport(0, 0, this.canvas.width, this.canvas.height), this.renderer.clear(t, n, r, i);
|
|
1630
|
+
let a = this.camera.viewport;
|
|
1487
1631
|
if (this.options.grid !== !1) {
|
|
1488
|
-
let e = this.writeGridVertices(
|
|
1632
|
+
let e = this.writeGridVertices(a);
|
|
1489
1633
|
e > 0 && (this.renderer.updateFloatBuffer(this.gridBuffer, this.gridData), this.renderer.drawLines(this.gridBuffer, e, this.gridStyle, this.camera), this.stats.drawCalls++, this.stats.uploadBytes += this.gridData.byteLength);
|
|
1490
1634
|
}
|
|
1491
1635
|
for (let e of this.series) {
|
|
1492
1636
|
if (!e.visible) continue;
|
|
1493
1637
|
if (e.rebuildPyramid(), e.config.mode === "scatter") {
|
|
1494
|
-
this.drawScatterSeries(e,
|
|
1638
|
+
this.drawScatterSeries(e, a);
|
|
1495
1639
|
continue;
|
|
1496
1640
|
}
|
|
1497
1641
|
if (e.config.mode === "bar") {
|
|
1498
|
-
this.drawBarSeries(e,
|
|
1642
|
+
this.drawBarSeries(e, a);
|
|
1499
1643
|
continue;
|
|
1500
1644
|
}
|
|
1501
1645
|
if (e.config.mode === "area") {
|
|
1502
|
-
this.drawAreaSeries(e,
|
|
1646
|
+
this.drawAreaSeries(e, a);
|
|
1503
1647
|
continue;
|
|
1504
1648
|
}
|
|
1505
|
-
let
|
|
1506
|
-
if (
|
|
1507
|
-
let
|
|
1508
|
-
if (
|
|
1509
|
-
this.renderer.updateFloatBuffer(this.minMaxInstanceBuffer, this.minMaxInstanceData), this.renderer.drawMinMaxSegmentsInstanced(this.minMaxInstanceBuffer,
|
|
1649
|
+
let t = e.visibleSampleCount(a), n = e.hasLOD && t > K;
|
|
1650
|
+
if (n && this.renderer.supportsInstancedSegments) {
|
|
1651
|
+
let t = e.copyMinMaxInstanced(a, this.minMaxInstanceData, this.maxMinMaxSegments());
|
|
1652
|
+
if (t <= 0) continue;
|
|
1653
|
+
this.renderer.updateFloatBuffer(this.minMaxInstanceBuffer, this.minMaxInstanceData), this.renderer.drawMinMaxSegmentsInstanced(this.minMaxInstanceBuffer, t, e.style, this.camera), this.recordRenderMode("minmax"), this.stats.pointsRendered += t * 2, this.stats.drawCalls++, this.stats.uploadBytes += this.minMaxInstanceData.byteLength;
|
|
1510
1654
|
continue;
|
|
1511
1655
|
}
|
|
1512
|
-
let
|
|
1513
|
-
|
|
1656
|
+
let r = n ? e.copyMinMaxVisible(a, this.rawLineData, this.maxMinMaxSegments()) : e.copyRawVisible(a, this.rawLineData, K);
|
|
1657
|
+
r < 2 || (this.renderer.updateFloatBuffer(this.rawLineBuffer, this.rawLineData), n ? (this.renderer.drawMinMaxSegments(this.rawLineBuffer, r, e.style, this.camera), this.recordRenderMode("minmax")) : (this.renderer.drawLineStrip(this.rawLineBuffer, r, e.style, this.camera), this.recordRenderMode("raw")), this.stats.pointsRendered += r, this.stats.drawCalls++, this.stats.uploadBytes += this.rawLineData.byteLength);
|
|
1514
1658
|
}
|
|
1515
1659
|
this.axisOverlay?.update(this.camera, this.axis), this.stats.frameMs = performance.now() - e, this.refreshHover();
|
|
1516
1660
|
}
|
|
1517
1661
|
dispose() {
|
|
1518
1662
|
this.stop(), this.resizeObserver?.disconnect(), this.canvas.removeEventListener("pointermove", this.handlePointerMove), this.canvas.removeEventListener("pointerleave", this.handlePointerLeave);
|
|
1519
1663
|
for (let e of this.pluginDisposers.splice(0)) e();
|
|
1520
|
-
this.
|
|
1664
|
+
this.axisOverlay?.dispose(), this.renderer.dispose(), this.layout.dispose();
|
|
1521
1665
|
}
|
|
1522
1666
|
applyCanvasSize(e = globalThis.devicePixelRatio) {
|
|
1523
1667
|
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));
|
|
1524
1668
|
return this.canvas.width === n && this.canvas.height === r ? !1 : (this.canvas.width = n, this.canvas.height = r, !0);
|
|
1525
1669
|
}
|
|
1526
1670
|
drawAreaSeries(e, t) {
|
|
1527
|
-
let n = e.style.baseline ?? 0, r = e.copyAreaVisible(t, this.rawLineData,
|
|
1671
|
+
let n = e.style.baseline ?? 0, r = e.copyAreaVisible(t, this.rawLineData, q, n);
|
|
1528
1672
|
if (r < 4) return;
|
|
1529
1673
|
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;
|
|
1530
|
-
let i = this.uploadRawInstances(e, t,
|
|
1674
|
+
let i = this.uploadRawInstances(e, t, q);
|
|
1531
1675
|
i >= 2 && (this.renderer.drawLineStrip(this.rawLineBuffer, i, e.style, this.camera), this.stats.pointsRendered += i, this.stats.drawCalls++), this.recordRenderMode("area");
|
|
1532
1676
|
}
|
|
1533
1677
|
drawScatterSeries(e, t) {
|
|
1534
|
-
let n = this.uploadRawInstances(e, t,
|
|
1678
|
+
let n = this.uploadRawInstances(e, t, K);
|
|
1535
1679
|
n <= 0 || (this.renderer.supportsInstancedPoints ? this.renderer.drawPointsInstanced(this.rawLineBuffer, n, e.style, this.camera, this.canvas.width, this.canvas.height) : this.renderer.drawPointSprites(this.rawLineBuffer, n, e.style, this.camera), this.recordInstancedDraw("points", n));
|
|
1536
1680
|
}
|
|
1537
1681
|
drawBarSeries(e, t) {
|
|
@@ -1559,7 +1703,7 @@ var H = class {
|
|
|
1559
1703
|
}
|
|
1560
1704
|
includeBaselineInBarRanges(e, t) {
|
|
1561
1705
|
for (let n = 0; n < e; n++) {
|
|
1562
|
-
let e = n *
|
|
1706
|
+
let e = n * Y, r = this.minMaxInstanceData[e + 1], i = this.minMaxInstanceData[e + 2];
|
|
1563
1707
|
this.minMaxInstanceData[e + 1] = Math.min(t, r), this.minMaxInstanceData[e + 2] = Math.max(t, i);
|
|
1564
1708
|
}
|
|
1565
1709
|
}
|
|
@@ -1593,7 +1737,7 @@ var H = class {
|
|
|
1593
1737
|
return [Math.max(n.xMin, s), Math.min(n.xMax, c)];
|
|
1594
1738
|
}
|
|
1595
1739
|
writeBarTriangle(e, t, n, r, i) {
|
|
1596
|
-
let a = e *
|
|
1740
|
+
let a = e * Z;
|
|
1597
1741
|
this.barTriangleData[a] = t, this.barTriangleData[a + 1] = r, this.barTriangleData[a + 2] = n, this.barTriangleData[a + 3] = r, this.barTriangleData[a + 4] = t, this.barTriangleData[a + 5] = i, this.barTriangleData[a + 6] = t, this.barTriangleData[a + 7] = i, this.barTriangleData[a + 8] = n, this.barTriangleData[a + 9] = r, this.barTriangleData[a + 10] = n, this.barTriangleData[a + 11] = i;
|
|
1598
1742
|
}
|
|
1599
1743
|
drawBarTriangleFallback(e, t) {
|
|
@@ -1669,24 +1813,24 @@ var H = class {
|
|
|
1669
1813
|
}
|
|
1670
1814
|
}
|
|
1671
1815
|
maxMinMaxSegments() {
|
|
1672
|
-
return Math.min(this.canvas.width,
|
|
1816
|
+
return Math.min(this.canvas.width, J);
|
|
1673
1817
|
}
|
|
1674
1818
|
maxBarFallbackBars() {
|
|
1675
|
-
return Math.min(
|
|
1819
|
+
return Math.min(X, K);
|
|
1676
1820
|
}
|
|
1677
1821
|
maxRawBarInstances() {
|
|
1678
|
-
return this.renderer.supportsInstancedBars ?
|
|
1822
|
+
return this.renderer.supportsInstancedBars ? K : this.maxBarFallbackBars();
|
|
1679
1823
|
}
|
|
1680
1824
|
writeGridVertices(e) {
|
|
1681
1825
|
let t = Math.max(1, this.canvas.clientWidth), n = Math.max(1, this.canvas.clientHeight);
|
|
1682
1826
|
this.axis.getXTickValues(t, 12, this.xTicks), this.axis.getYTickValues(n, 8, this.yTicks);
|
|
1683
1827
|
let r = 0;
|
|
1684
1828
|
for (let t of this.xTicks) {
|
|
1685
|
-
if (r + 2 >
|
|
1829
|
+
if (r + 2 > Q) return r;
|
|
1686
1830
|
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++;
|
|
1687
1831
|
}
|
|
1688
1832
|
for (let t of this.yTicks) {
|
|
1689
|
-
if (r + 2 >
|
|
1833
|
+
if (r + 2 > Q) return r;
|
|
1690
1834
|
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++;
|
|
1691
1835
|
}
|
|
1692
1836
|
return r;
|
|
@@ -1694,7 +1838,7 @@ var H = class {
|
|
|
1694
1838
|
recordRenderMode(e) {
|
|
1695
1839
|
this.stats.renderMode === "none" ? this.stats.renderMode = e : this.stats.renderMode !== e && (this.stats.renderMode = "mixed");
|
|
1696
1840
|
}
|
|
1697
|
-
},
|
|
1841
|
+
}, re = class {
|
|
1698
1842
|
xData;
|
|
1699
1843
|
yData;
|
|
1700
1844
|
constructor(e, t) {
|
|
@@ -1736,6 +1880,6 @@ var H = class {
|
|
|
1736
1880
|
}
|
|
1737
1881
|
};
|
|
1738
1882
|
//#endregion
|
|
1739
|
-
export {
|
|
1883
|
+
export { O as AxisController, D as Camera2D, ne as Chart, j as DEFAULT_CHART_THEME, n as MinMaxPyramid, a as RingBuffer, i as SeriesStore, re as StaticDataset };
|
|
1740
1884
|
|
|
1741
1885
|
//# sourceMappingURL=index.js.map
|