@crysound/crychart 1.0.4 → 1.0.6
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 +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/crychart.cjs +124 -48
- package/dist/crychart.global.js +124 -48
- package/dist/crychart.js +124 -48
- package/dist/types/axis-canvas.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/mesh3d.d.ts +1 -0
- package/docs/npm-usage.md +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,12 +6,12 @@ CRYChart is a **frontend rendering library built by CRYSOUND for OpenTest**, wri
|
|
|
6
6
|
|
|
7
7
|
Designed for OpenTest's data visualization needs, CRYChart provides streaming data rendering, interactive axes, cursors, and 2D and 3D charts. It uses WebGL2 for rendering, with a Canvas fallback.
|
|
8
8
|
|
|
9
|
-
Version `1.0.
|
|
9
|
+
Version `1.0.6` reduces 3D mesh and wireframe allocations by reusing unchanged topology while preserving sample values and ordered geometry.
|
|
10
10
|
|
|
11
11
|
## Install in an application
|
|
12
12
|
|
|
13
13
|
```powershell
|
|
14
|
-
pnpm add --save-exact @crysound/crychart@1.0.
|
|
14
|
+
pnpm add --save-exact @crysound/crychart@1.0.6 --registry=https://registry.npmjs.org/
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
Commit the application's lockfile and use `pnpm install --frozen-lockfile` for repeatable installs. See the [npm usage guide](docs/npm-usage.md) for package entry points and migration from the old `crychart` name.
|
package/README.zh-CN.md
CHANGED
|
@@ -6,12 +6,12 @@ CRYChart 是 **CRYSOUND 为 OpenTest 定制的前端渲染库**,基于 TypeScr
|
|
|
6
6
|
|
|
7
7
|
CRYChart 面向 OpenTest 的数据可视化场景,提供流式数据绘制、交互坐标轴、游标、二维和三维图表。绘图使用 WebGL2,并提供 Canvas 回退。
|
|
8
8
|
|
|
9
|
-
`1.0.
|
|
9
|
+
`1.0.6` 通过复用未变化的拓扑,减少三维网格和线框绘制的内存分配,保留原始采样值及几何遍历顺序。
|
|
10
10
|
|
|
11
11
|
## 在应用中安装
|
|
12
12
|
|
|
13
13
|
```powershell
|
|
14
|
-
pnpm add --save-exact @crysound/crychart@1.0.
|
|
14
|
+
pnpm add --save-exact @crysound/crychart@1.0.6 --registry=https://registry.npmjs.org/
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
提交应用的锁文件,后续执行 `pnpm install --frozen-lockfile`。包入口和旧 `crychart` 包名的迁移方式见 [npm 使用说明](docs/npm-usage.md)。
|
package/dist/crychart.cjs
CHANGED
|
@@ -19035,6 +19035,35 @@ var integer = (value, minimum = 0) => {
|
|
|
19035
19035
|
var rgba = (color2) => [color2.r, color2.g, color2.b, color2.a];
|
|
19036
19036
|
var meshFillColor = (fill, fallback) => fill.kind === "empty" ? ColorRGBA(0, 0, 0, 0) : fill.getColor?.() ?? fallback;
|
|
19037
19037
|
var finiteVertex2 = (values, index) => Number.isFinite(values[index * 3]) && Number.isFinite(values[index * 3 + 1]) && Number.isFinite(values[index * 3 + 2]);
|
|
19038
|
+
function structuredWireEdges(indices, count) {
|
|
19039
|
+
const columns = indices[1], rows = count / columns;
|
|
19040
|
+
if (!Number.isInteger(columns) || columns < 2 || !Number.isInteger(rows) || rows < 2 || indices.length !== (rows - 1) * (columns - 1) * 6) return void 0;
|
|
19041
|
+
let offset = 0;
|
|
19042
|
+
for (let row = 0; row + 1 < rows; row++) for (let col = 0; col + 1 < columns; col++, offset += 6) {
|
|
19043
|
+
const i = row * columns + col, below = i + columns;
|
|
19044
|
+
if (indices[offset] !== i || indices[offset + 1] !== below || indices[offset + 2] !== i + 1 || indices[offset + 3] !== i + 1 || indices[offset + 4] !== below || indices[offset + 5] !== below + 1) return void 0;
|
|
19045
|
+
}
|
|
19046
|
+
const pairs = new Uint32Array((rows * (columns - 1) + (rows - 1) * columns + (rows - 1) * (columns - 1)) * 2);
|
|
19047
|
+
let length = 0;
|
|
19048
|
+
for (let row = 0; row + 1 < rows; row++) for (let col = 0; col + 1 < columns; col++) {
|
|
19049
|
+
const i = row * columns + col, below = i + columns;
|
|
19050
|
+
if (col === 0) {
|
|
19051
|
+
pairs[length++] = i;
|
|
19052
|
+
pairs[length++] = below;
|
|
19053
|
+
}
|
|
19054
|
+
pairs[length++] = below;
|
|
19055
|
+
pairs[length++] = i + 1;
|
|
19056
|
+
if (row === 0) {
|
|
19057
|
+
pairs[length++] = i + 1;
|
|
19058
|
+
pairs[length++] = i;
|
|
19059
|
+
}
|
|
19060
|
+
pairs[length++] = below;
|
|
19061
|
+
pairs[length++] = below + 1;
|
|
19062
|
+
pairs[length++] = below + 1;
|
|
19063
|
+
pairs[length++] = i + 1;
|
|
19064
|
+
}
|
|
19065
|
+
return pairs;
|
|
19066
|
+
}
|
|
19038
19067
|
function mergedRanges(ranges, width = 1) {
|
|
19039
19068
|
const sorted = ranges.filter((range) => range.count > 0).map((range) => ({ start: range.start, count: range.count })).sort((a, b) => a.start - b.start), out = [];
|
|
19040
19069
|
for (const range of sorted) {
|
|
@@ -19261,28 +19290,34 @@ var MeshSeries3D = class extends Series3DBase {
|
|
|
19261
19290
|
dirty = [];
|
|
19262
19291
|
styleDirty = true;
|
|
19263
19292
|
compiled;
|
|
19293
|
+
wireTopology;
|
|
19264
19294
|
boundsCache;
|
|
19265
19295
|
setGeometry(input) {
|
|
19266
19296
|
this.assertAlive();
|
|
19267
19297
|
if (!input?.positions || input.positions.length % 3) throw new RangeError("Mesh positions require complete XYZ vertices");
|
|
19268
19298
|
const positions = Float64Array.from(input.positions), count = positions.length / 3;
|
|
19269
|
-
const
|
|
19270
|
-
|
|
19271
|
-
|
|
19272
|
-
|
|
19299
|
+
const unsignedIndices = input.indices instanceof Uint32Array;
|
|
19300
|
+
if (input.indices) for (let i = 0; i < input.indices.length; i++) {
|
|
19301
|
+
const index = input.indices[i];
|
|
19302
|
+
if (index >= count || !unsignedIndices && (!Number.isSafeInteger(index) || index < 0)) throw new RangeError("Mesh index outside vertex range");
|
|
19303
|
+
}
|
|
19304
|
+
const indices = input.indices ? Uint32Array.from(input.indices) : Uint32Array.from({ length: Math.floor(count / 3) * 3 }, (_, index) => index);
|
|
19273
19305
|
if (indices.length % 3) throw new RangeError("Mesh indices require complete triangles");
|
|
19274
19306
|
if (input.values && input.values.length !== count || input.colors && input.colors.length !== count * 4) throw new RangeError("Mesh values/colors do not match vertex count");
|
|
19275
19307
|
const colors = input.colors ? Float32Array.from(input.colors) : void 0;
|
|
19276
19308
|
if (colors && !colors.every((value) => Number.isFinite(value) && value >= 0 && value <= 1)) throw new RangeError("Mesh colors require normalized finite RGBA");
|
|
19309
|
+
const sameTopology = positions.length === this.vertices.length && indices.length === this.indices.length && indices.every((value, index) => value === this.indices[index]);
|
|
19277
19310
|
this.vertices = positions;
|
|
19278
|
-
|
|
19311
|
+
if (!sameTopology) {
|
|
19312
|
+
this.indices = indices;
|
|
19313
|
+
this.topologyRevision++;
|
|
19314
|
+
this.compiled = void 0;
|
|
19315
|
+
}
|
|
19279
19316
|
this.scalarValues = input.values ? Float32Array.from(input.values) : void 0;
|
|
19280
19317
|
this.vertexColors = colors;
|
|
19281
|
-
this.topologyRevision++;
|
|
19282
19318
|
this.geometryRevision++;
|
|
19283
19319
|
this.dirty = [{ start: 0, count }];
|
|
19284
19320
|
this.styleDirty = true;
|
|
19285
|
-
this.compiled = void 0;
|
|
19286
19321
|
this.changed();
|
|
19287
19322
|
return this;
|
|
19288
19323
|
}
|
|
@@ -19371,28 +19406,62 @@ var MeshSeries3D = class extends Series3DBase {
|
|
|
19371
19406
|
for (const range of ranges) for (let i = range.start; i < range.start + range.count; i++) {
|
|
19372
19407
|
if (!all && !finiteVertex2(positions, i)) invalidVertices--;
|
|
19373
19408
|
const point = this.normalizedVertex(i, normalize);
|
|
19374
|
-
positions
|
|
19409
|
+
positions[i * 3] = point.x;
|
|
19410
|
+
positions[i * 3 + 1] = point.y;
|
|
19411
|
+
positions[i * 3 + 2] = point.z;
|
|
19375
19412
|
if (!finiteVertex2(positions, i)) invalidVertices++;
|
|
19376
19413
|
}
|
|
19377
19414
|
const colorRanges = all || this.styleDirty ? [{ start: 0, count }] : ranges;
|
|
19378
|
-
for (const range of colorRanges) for (let i = range.start; i < range.start + range.count; i++)
|
|
19415
|
+
for (const range of colorRanges) for (let i = range.start; i < range.start + range.count; i++) {
|
|
19416
|
+
const color2 = this.colorAt(i);
|
|
19417
|
+
colors[i * 4] = color2.r;
|
|
19418
|
+
colors[i * 4 + 1] = color2.g;
|
|
19419
|
+
colors[i * 4 + 2] = color2.b;
|
|
19420
|
+
colors[i * 4 + 3] = color2.a;
|
|
19421
|
+
}
|
|
19379
19422
|
const normal = ranges.length ? this.updateNormals(positions, all ? void 0 : previous?.packet.normals, ranges) : { values: previous?.packet.normals ?? meshNormals(positions, this.indices), ranges: [] };
|
|
19380
19423
|
const packet = { id: this.id, revision: ++this.packetRevision, previousRevision: previous?.packet.revision, count, mode: "triangles", positions, colors, normals: normal.values, indices: this.indices, indexRevision: this.topologyRevision, allFinite: invalidVertices === 0, lighting: this.lighting, ...this.renderingState(), color: [1, 1, 1, 1], thickness: 0, pointSize: 0, positionUpdateRanges: all ? void 0 : mergedRanges(ranges, 3), colorUpdateRanges: all ? void 0 : mergedRanges(colorRanges, 4), normalUpdateRanges: all ? void 0 : normal.ranges };
|
|
19381
19424
|
const packets = [packet];
|
|
19382
19425
|
let wire;
|
|
19383
19426
|
if (this.wireframe.getThickness() > 0 && meshFillColor(this.wireframe.getFillStyle(), ColorRGBA(0, 0, 0)).a > 0) {
|
|
19384
|
-
const
|
|
19385
|
-
|
|
19386
|
-
|
|
19387
|
-
|
|
19388
|
-
|
|
19389
|
-
|
|
19390
|
-
|
|
19391
|
-
|
|
19392
|
-
|
|
19427
|
+
const valid2 = new Uint8Array(this.indices.length / 3);
|
|
19428
|
+
if (invalidVertices === 0) valid2.fill(1);
|
|
19429
|
+
else for (let i = 0; i < this.indices.length; i += 3) valid2[i / 3] = finiteVertex2(positions, this.indices[i]) && finiteVertex2(positions, this.indices[i + 1]) && finiteVertex2(positions, this.indices[i + 2]) ? 1 : 0;
|
|
19430
|
+
let topology = this.wireTopology;
|
|
19431
|
+
if (!topology || topology.indices.length !== this.indices.length || !this.indices.every((value, index) => value === topology.indices[index]) || !valid2.every((value, index) => value === topology.valid[index])) {
|
|
19432
|
+
const gridPairs = invalidVertices === 0 ? structuredWireEdges(this.indices, count) : void 0;
|
|
19433
|
+
if (gridPairs) topology = this.wireTopology = { indices: this.indices.slice(), valid: valid2, pairs: gridPairs };
|
|
19434
|
+
else {
|
|
19435
|
+
const edges = /* @__PURE__ */ new Set(), pairs = new Uint32Array(this.indices.length * 2);
|
|
19436
|
+
const numericKeys = Number.isSafeInteger(count * count);
|
|
19437
|
+
let length = 0;
|
|
19438
|
+
for (let i = 0; i < this.indices.length; i += 3) {
|
|
19439
|
+
if (!valid2[i / 3]) continue;
|
|
19440
|
+
for (let j = 0; j < 3; j++) {
|
|
19441
|
+
const a = this.indices[i + j], b = this.indices[i + (j + 1) % 3];
|
|
19442
|
+
const low = Math.min(a, b), high = Math.max(a, b);
|
|
19443
|
+
const key = numericKeys ? low * count + high : `${low}:${high}`;
|
|
19444
|
+
if (edges.has(key)) continue;
|
|
19445
|
+
edges.add(key);
|
|
19446
|
+
pairs[length++] = a;
|
|
19447
|
+
pairs[length++] = b;
|
|
19448
|
+
}
|
|
19449
|
+
}
|
|
19450
|
+
topology = this.wireTopology = { indices: this.indices.slice(), valid: valid2, pairs: pairs.subarray(0, length) };
|
|
19393
19451
|
}
|
|
19394
19452
|
}
|
|
19395
|
-
|
|
19453
|
+
const values = new Float32Array(topology.pairs.length / 2 * 9);
|
|
19454
|
+
for (let i = 0, out = 0; i < topology.pairs.length; i += 2, out += 9) {
|
|
19455
|
+
const a = topology.pairs[i] * 3, b = topology.pairs[i + 1] * 3;
|
|
19456
|
+
values[out] = positions[a];
|
|
19457
|
+
values[out + 1] = positions[a + 1];
|
|
19458
|
+
values[out + 2] = positions[a + 2];
|
|
19459
|
+
values[out + 3] = positions[b];
|
|
19460
|
+
values[out + 4] = positions[b + 1];
|
|
19461
|
+
values[out + 5] = positions[b + 2];
|
|
19462
|
+
values[out + 6] = values[out + 7] = values[out + 8] = NaN;
|
|
19463
|
+
}
|
|
19464
|
+
wire = { id: -this.id, revision: packet.revision, count: values.length / 3, mode: "line", positions: values, ...this.renderingState(), color: rgba(meshFillColor(this.wireframe.getFillStyle(), ColorRGBA(0, 0, 0))), thickness: this.wireframe.getThickness(), pointSize: 0 };
|
|
19396
19465
|
packets.push(wire);
|
|
19397
19466
|
}
|
|
19398
19467
|
this.compiled = { key: axisKey, revision: this.revision, packet, wire, packets, invalidVertices };
|
|
@@ -19402,6 +19471,7 @@ var MeshSeries3D = class extends Series3DBase {
|
|
|
19402
19471
|
}
|
|
19403
19472
|
dispose() {
|
|
19404
19473
|
this.compiled = void 0;
|
|
19474
|
+
this.wireTopology = void 0;
|
|
19405
19475
|
this.vertices = new Float64Array(0);
|
|
19406
19476
|
this.indices = new Uint32Array(0);
|
|
19407
19477
|
this.scalarValues = void 0;
|
|
@@ -19934,7 +20004,6 @@ function fitEllipsoid3D(input, options = {}) {
|
|
|
19934
20004
|
// src/axis-canvas.ts
|
|
19935
20005
|
var color = (fill, fallback) => fill?.kind === "empty" ? ColorRGBA(0, 0, 0, 0) : fill?.getColor?.() ?? fallback;
|
|
19936
20006
|
var validFont = (font2) => font2.toCSS?.() ?? `${font2.getSize()}px sans-serif`;
|
|
19937
|
-
var isDefaultFont = (font2) => font2.getSize() === 12 && font2.family === "sans-serif" && font2.weight === "normal" && font2.style === "normal" && font2.variant === "normal";
|
|
19938
20007
|
var lineBoxHeight = (font2) => font2.getSize() * 0.8;
|
|
19939
20008
|
function lineBoxBaseline(metrics2, font2) {
|
|
19940
20009
|
const size = font2.getSize();
|
|
@@ -19950,7 +20019,7 @@ function textMetrics(ctx, text, font2, cache) {
|
|
|
19950
20019
|
}
|
|
19951
20020
|
let measured;
|
|
19952
20021
|
try {
|
|
19953
|
-
measured = ctx?.measureText(text);
|
|
20022
|
+
measured = ctx?.measureText?.(text);
|
|
19954
20023
|
} finally {
|
|
19955
20024
|
if (ctx) {
|
|
19956
20025
|
if (previous !== void 0) ctx.font = previous;
|
|
@@ -19995,10 +20064,13 @@ function measuredTickLayout(axis, ctx, axisSizePixels = axis.getPixelLength(), c
|
|
|
19995
20064
|
return axis.direction === "x" ? measured.width : measured.ascent + measured.descent;
|
|
19996
20065
|
});
|
|
19997
20066
|
}
|
|
19998
|
-
function metrics(axis, ctx, cache, theme, resolveFont
|
|
20067
|
+
function metrics(axis, ctx, cache, theme, resolveFont) {
|
|
19999
20068
|
const horizontal = axis.direction === "x", strategy = axis.tickStrategy, tick = strategy.getMajorTickStyle();
|
|
20000
20069
|
const titleText = axis.getDisplayTitle(), titleVisible = titleText.length > 0 && color(axis.titleFill, ColorRGBA(190, 200, 215)).a > 0;
|
|
20001
|
-
const
|
|
20070
|
+
const liveCustomTicks = axis.annotations.filter((annotation) => annotation.kind === "tick" && annotation.visible && !annotation.disposed);
|
|
20071
|
+
const hasCustomTicks = liveCustomTicks.length > 0;
|
|
20072
|
+
const strokeThickness = (axis.stroke?.getThickness?.() ?? 0) > 0 && color(axis.stroke?.getFillStyle?.(), ColorRGBA(0, 0, 0, 0)).a > 0 ? axis.stroke.getThickness() : 0;
|
|
20073
|
+
const titleOnly = !strategy.visible && titleVisible && !hasCustomTicks;
|
|
20002
20074
|
const baseFont = tick.hasLabelFontOverride() ? tick.getLabelFont() : theme?.font ?? tick.getLabelFont();
|
|
20003
20075
|
const labelFont = resolveFont?.(baseFont) ?? baseFont, titleFont = resolveFont?.(axis.titleFont) ?? axis.titleFont;
|
|
20004
20076
|
const visibleLevels = ["major", "minor", "great"].flatMap((level) => {
|
|
@@ -20008,36 +20080,39 @@ function metrics(axis, ctx, cache, theme, resolveFont, contentLayout = false) {
|
|
|
20008
20080
|
const fill = resolvedTickFill(axis, level, style, theme);
|
|
20009
20081
|
return [{ level, style, font: font2, visible: color(fill, ColorRGBA(0, 0, 0, 0)).a > 0 }];
|
|
20010
20082
|
});
|
|
20011
|
-
const margin2 = axis.getMarginAfterTicks(), tickLength = titleOnly ? 0 : Math.max(0, ...visibleLevels.map(({ style }) => style.getTickStyle()?.getThickness?.() > 0 ? style.getTickLength() : 0));
|
|
20083
|
+
const margin2 = axis.getMarginAfterTicks(), tickLength = titleOnly || !strategy.visible && !hasCustomTicks ? 0 : Math.max(0, ...visibleLevels.map(({ style }) => style.getTickStyle()?.getThickness?.() > 0 ? style.getTickLength() : 0));
|
|
20012
20084
|
const rotation = (axis.titleRotation ?? (horizontal ? 0 : -90)) * Math.PI / 180;
|
|
20013
|
-
const customLabels = visibleLevels.some(({ level, style, visible }) => visible && (typeof style.formatter === "function" || typeof (level === "major" ? strategy.getMajorFormattingFunction() : strategy.getMinorFormattingFunction()) === "function")) || strategy.getFormattingOffset() !== void 0 || strategy.customMajor !== void 0 || strategy.customMinor !== void 0 || strategy.hasDateTimeFormatting?.() === true;
|
|
20014
|
-
const interval = axis.getInterval(), longDefault = !horizontal && strategy.kind === "numeric" && !customLabels && [interval.start, interval.end].some((value) => formatNumeric(value, interval).length * labelFont.getSize() * 0.6 + 17 > 54);
|
|
20015
|
-
const changedLayout = contentLayout || titleOnly || margin2 > 0 || visibleLevels.some(({ font: font2, visible }) => visible && !isDefaultFont(font2)) || !isDefaultFont(titleFont) || axis.titleRotation !== void 0 || tickLength > 7 || customLabels || longDefault || strategy.kind === "datetime";
|
|
20016
|
-
if (!changedLayout) return { measured: false, labelFont, titleFont, lane: 0, laneOffset: 0, laneSize: horizontal ? 44 : 54, labelOffset: horizontal ? axis.opposite ? 10 : 20 : 9, titleOffset: horizontal ? axis.opposite ? 32 : 43 : 48, tickLength, labelWidth: 0, labelAscent: 9, labelDescent: 3, titleWidth: 0, titleAscent: 9, titleDescent: 3, rotation };
|
|
20017
20085
|
const layout = measuredTickLayout(axis, ctx, void 0, cache, theme, resolveFont), labels = visibleLevels.flatMap(({ level, font: font2, visible }) => visible ? (layout[level] ?? []).filter((t) => t.label.length).map((t) => textMetrics(ctx, t.label, font2, cache)) : []);
|
|
20018
|
-
const
|
|
20019
|
-
|
|
20020
|
-
|
|
20021
|
-
|
|
20022
|
-
|
|
20023
|
-
|
|
20024
|
-
|
|
20086
|
+
const customTickLabels = liveCustomTicks.map((annotation) => {
|
|
20087
|
+
const formatted = typeof annotation.textFormatter === "function" ? String(annotation.textFormatter(annotation.value)) : String(annotation.text ?? "");
|
|
20088
|
+
return formatted.length > 0 ? textMetrics(ctx, formatted, labelFont, cache) : void 0;
|
|
20089
|
+
}).filter((m) => !!m);
|
|
20090
|
+
const allLabels = [...labels, ...customTickLabels], hasLabels = allLabels.length > 0;
|
|
20091
|
+
const labelWidth = Math.max(0, ...allLabels.map((m) => m.width)), labelAscent = Math.max(labelFont.getSize() * 0.75, ...allLabels.map((m) => m.ascent)), labelDescent = Math.max(labelFont.getSize() * 0.25, ...allLabels.map((m) => m.descent));
|
|
20092
|
+
const title = titleVisible ? textMetrics(ctx, titleText, titleFont, cache) : { width: 0, ascent: titleFont.getSize() * 0.75, descent: titleFont.getSize() * 0.25, baseline: lineBoxBaseline(void 0, titleFont) };
|
|
20093
|
+
if (axis.titleRotation === void 0) {
|
|
20094
|
+
const gutter = 7, labelOffset2 = hasLabels || hasCustomTicks ? tickLength + gutter : 0;
|
|
20095
|
+
const labelBand = horizontal ? Math.max(customTickLabels.length > 0 ? lineBoxHeight(labelFont) : 0, ...visibleLevels.filter((level) => level.visible).map((level) => lineBoxHeight(level.font))) : labelWidth;
|
|
20096
|
+
const labelOuter2 = hasLabels ? labelOffset2 + labelBand : hasCustomTicks ? labelOffset2 : tickLength;
|
|
20097
|
+
const titleHalf = lineBoxHeight(titleFont) / 2;
|
|
20098
|
+
const titleBase = labelOuter2 > 0 ? labelOuter2 + (hasLabels ? margin2 : 0) : (strokeThickness > 0 ? strokeThickness / 2 : 0) + gutter;
|
|
20099
|
+
const titleOffset2 = titleBase + titleHalf;
|
|
20025
20100
|
const extent2 = Math.max(labelOuter2, titleVisible ? titleOffset2 + titleHalf : 0);
|
|
20026
|
-
|
|
20101
|
+
const laneSize2 = extent2 > 0 ? extent2 + gutter : strokeThickness > 0 ? Math.ceil(strokeThickness) : 0;
|
|
20102
|
+
return { measured: true, labelFont, titleFont, lane: 0, laneOffset: 0, laneSize: laneSize2, labelOffset: labelOffset2, titleOffset: titleOffset2, tickLength, labelWidth, labelAscent, labelDescent, titleWidth: title.width, titleAscent: title.ascent, titleDescent: title.descent, rotation, lineBoxTitleBaseline: title.baseline };
|
|
20027
20103
|
}
|
|
20028
20104
|
const titleBox = rotatedBounds(title.width, title.ascent, title.descent, rotation);
|
|
20029
|
-
const labelOffset = titleOnly ? 0 : horizontal ? axis.opposite ? Math.max(10, tickLength + labelDescent + 3) : Math.max(20, tickLength + labelAscent + 3) : Math.max(9, tickLength +
|
|
20030
|
-
const labelOuter = titleOnly ? 0 : horizontal ? labelOffset + (axis.opposite ? labelAscent : labelDescent) : labelOffset + labelWidth;
|
|
20105
|
+
const labelOffset = titleOnly || !hasLabels && !hasCustomTicks ? 0 : horizontal ? axis.opposite ? Math.max(10, tickLength + labelDescent + 3) : Math.max(20, tickLength + labelAscent + 3) : Math.max(9, tickLength + 5);
|
|
20106
|
+
const labelOuter = titleOnly || !hasLabels && !hasCustomTicks ? 0 : horizontal ? labelOffset + (axis.opposite ? labelAscent : labelDescent) : labelOffset + labelWidth;
|
|
20031
20107
|
const titleInner = horizontal ? axis.opposite ? titleBox.bottom : -titleBox.top : axis.opposite ? -titleBox.left : titleBox.right;
|
|
20032
20108
|
const titleOuter = horizontal ? axis.opposite ? -titleBox.top : titleBox.bottom : axis.opposite ? titleBox.right : -titleBox.left;
|
|
20033
|
-
const
|
|
20034
|
-
const
|
|
20035
|
-
const
|
|
20036
|
-
const baseline = horizontal ? 44 : 54, laneSize = contentLayout ? Math.ceil(extent + (horizontal ? 2 : 0)) : changedLayout ? Math.max(baseline, Math.ceil(extent + 8)) : baseline;
|
|
20109
|
+
const titleOffset = labelOuter + (hasLabels ? margin2 : 0) + titleInner + (labelOuter > 0 ? 2 : 5);
|
|
20110
|
+
const extent = Math.max(labelOuter, titleVisible ? titleOffset + titleOuter : 0, tickLength, strokeThickness);
|
|
20111
|
+
const laneSize = extent > 0 ? Math.ceil(extent + (horizontal ? 2 : 4)) : 0;
|
|
20037
20112
|
return { measured: true, labelFont, titleFont, lane: 0, laneOffset: 0, laneSize, labelOffset, titleOffset, tickLength, labelWidth, labelAscent, labelDescent, titleWidth: title.width, titleAscent: title.ascent, titleDescent: title.descent, rotation };
|
|
20038
20113
|
}
|
|
20039
|
-
function measureAxisCanvasLayout(ctx, axesX, axesY, theme, resolveFont
|
|
20040
|
-
const result2 = {
|
|
20114
|
+
function measureAxisCanvasLayout(ctx, axesX, axesY, theme, resolveFont) {
|
|
20115
|
+
const result2 = { contentMargins: { left: 0, right: 0, top: 0, bottom: 0 }, extraMargins: { left: 0, right: 0, top: 0, bottom: 0 }, axes: /* @__PURE__ */ new Map() };
|
|
20041
20116
|
const textCache = /* @__PURE__ */ new Map();
|
|
20042
20117
|
for (const [horizontal, list] of [[true, axesX], [false, axesY]]) for (const opposite of [false, true]) {
|
|
20043
20118
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -20048,14 +20123,14 @@ function measureAxisCanvasLayout(ctx, axesX, axesY, theme, resolveFont, contentL
|
|
|
20048
20123
|
}
|
|
20049
20124
|
let offset = 0, lane = 0;
|
|
20050
20125
|
for (const [, axes] of [...groups].sort((a, b) => a[0] - b[0])) {
|
|
20051
|
-
const values = axes.map((axis) => [axis, metrics(axis, ctx, textCache, theme, resolveFont
|
|
20126
|
+
const values = axes.map((axis) => [axis, metrics(axis, ctx, textCache, theme, resolveFont)]), size = Math.max(0, ...values.map(([, m]) => m.laneSize));
|
|
20052
20127
|
for (const [axis, value] of values) result2.axes.set(axis, { ...value, lane, laneOffset: offset, laneSize: size });
|
|
20053
20128
|
offset += size;
|
|
20054
20129
|
lane++;
|
|
20055
20130
|
}
|
|
20056
20131
|
const side = horizontal ? opposite ? "top" : "bottom" : opposite ? "right" : "left";
|
|
20057
20132
|
result2.extraMargins[side] = Math.max(0, offset - lane * (horizontal ? 44 : 54));
|
|
20058
|
-
|
|
20133
|
+
result2.contentMargins[side] = offset;
|
|
20059
20134
|
}
|
|
20060
20135
|
return result2;
|
|
20061
20136
|
}
|
|
@@ -21421,7 +21496,7 @@ var ChartXY = class {
|
|
|
21421
21496
|
this.prepareCustomTickPlacementLengths(axesX, axesY);
|
|
21422
21497
|
const layoutAxesX = axesX.filter((axis) => this.hasAxisLaneContent(axis));
|
|
21423
21498
|
const layoutAxesY = axesY.filter((axis) => this.hasAxisLaneContent(axis));
|
|
21424
|
-
this.axisCanvasLayout = this.kind === "xy" ? measureAxisCanvasLayout(this.overlayContext ?? void 0, layoutAxesX, layoutAxesY, this.theme, this.resolveTextFont
|
|
21499
|
+
this.axisCanvasLayout = this.kind === "xy" ? measureAxisCanvasLayout(this.overlayContext ?? void 0, layoutAxesX, layoutAxesY, this.theme, this.resolveTextFont) : void 0;
|
|
21425
21500
|
const axisExtra = this.axisCanvasLayout?.extraMargins ?? { left: 0, right: 0, top: 0, bottom: 0 };
|
|
21426
21501
|
const legendMargin = this.overlayContext ? this.legend.getLayout(this.overlayContext, this.legendArea()).margin : { left: 0, right: 0, top: 0, bottom: 0 };
|
|
21427
21502
|
if (this.kind === "polar") {
|
|
@@ -23374,6 +23449,7 @@ var Chart3D = class extends ChartXY {
|
|
|
23374
23449
|
this.coordsAxis.z = this.axesZ[0];
|
|
23375
23450
|
if (this.renderer?.gl && this.canvas)
|
|
23376
23451
|
this.gpu3d = new DataRenderer3D(this.renderer.gl, this.canvas);
|
|
23452
|
+
this.layout();
|
|
23377
23453
|
this.invalidate();
|
|
23378
23454
|
}
|
|
23379
23455
|
/** Project full XYZ axis coordinates with the existing original GPU camera
|
|
@@ -25162,7 +25238,7 @@ function cryChart(_options = {}) {
|
|
|
25162
25238
|
getChartCount: () => owned2.size
|
|
25163
25239
|
};
|
|
25164
25240
|
}
|
|
25165
|
-
var version = "1.0.
|
|
25241
|
+
var version = "1.0.6";
|
|
25166
25242
|
var Dashboard = class {
|
|
25167
25243
|
root;
|
|
25168
25244
|
cells = /* @__PURE__ */ new Map();
|
package/dist/crychart.global.js
CHANGED
|
@@ -19035,6 +19035,35 @@ void main() {
|
|
|
19035
19035
|
var rgba = (color2) => [color2.r, color2.g, color2.b, color2.a];
|
|
19036
19036
|
var meshFillColor = (fill, fallback) => fill.kind === "empty" ? ColorRGBA(0, 0, 0, 0) : fill.getColor?.() ?? fallback;
|
|
19037
19037
|
var finiteVertex2 = (values, index) => Number.isFinite(values[index * 3]) && Number.isFinite(values[index * 3 + 1]) && Number.isFinite(values[index * 3 + 2]);
|
|
19038
|
+
function structuredWireEdges(indices, count) {
|
|
19039
|
+
const columns = indices[1], rows = count / columns;
|
|
19040
|
+
if (!Number.isInteger(columns) || columns < 2 || !Number.isInteger(rows) || rows < 2 || indices.length !== (rows - 1) * (columns - 1) * 6) return void 0;
|
|
19041
|
+
let offset = 0;
|
|
19042
|
+
for (let row = 0; row + 1 < rows; row++) for (let col = 0; col + 1 < columns; col++, offset += 6) {
|
|
19043
|
+
const i = row * columns + col, below = i + columns;
|
|
19044
|
+
if (indices[offset] !== i || indices[offset + 1] !== below || indices[offset + 2] !== i + 1 || indices[offset + 3] !== i + 1 || indices[offset + 4] !== below || indices[offset + 5] !== below + 1) return void 0;
|
|
19045
|
+
}
|
|
19046
|
+
const pairs = new Uint32Array((rows * (columns - 1) + (rows - 1) * columns + (rows - 1) * (columns - 1)) * 2);
|
|
19047
|
+
let length = 0;
|
|
19048
|
+
for (let row = 0; row + 1 < rows; row++) for (let col = 0; col + 1 < columns; col++) {
|
|
19049
|
+
const i = row * columns + col, below = i + columns;
|
|
19050
|
+
if (col === 0) {
|
|
19051
|
+
pairs[length++] = i;
|
|
19052
|
+
pairs[length++] = below;
|
|
19053
|
+
}
|
|
19054
|
+
pairs[length++] = below;
|
|
19055
|
+
pairs[length++] = i + 1;
|
|
19056
|
+
if (row === 0) {
|
|
19057
|
+
pairs[length++] = i + 1;
|
|
19058
|
+
pairs[length++] = i;
|
|
19059
|
+
}
|
|
19060
|
+
pairs[length++] = below;
|
|
19061
|
+
pairs[length++] = below + 1;
|
|
19062
|
+
pairs[length++] = below + 1;
|
|
19063
|
+
pairs[length++] = i + 1;
|
|
19064
|
+
}
|
|
19065
|
+
return pairs;
|
|
19066
|
+
}
|
|
19038
19067
|
function mergedRanges(ranges, width = 1) {
|
|
19039
19068
|
const sorted = ranges.filter((range) => range.count > 0).map((range) => ({ start: range.start, count: range.count })).sort((a, b) => a.start - b.start), out = [];
|
|
19040
19069
|
for (const range of sorted) {
|
|
@@ -19261,28 +19290,34 @@ void main() {
|
|
|
19261
19290
|
dirty = [];
|
|
19262
19291
|
styleDirty = true;
|
|
19263
19292
|
compiled;
|
|
19293
|
+
wireTopology;
|
|
19264
19294
|
boundsCache;
|
|
19265
19295
|
setGeometry(input) {
|
|
19266
19296
|
this.assertAlive();
|
|
19267
19297
|
if (!input?.positions || input.positions.length % 3) throw new RangeError("Mesh positions require complete XYZ vertices");
|
|
19268
19298
|
const positions = Float64Array.from(input.positions), count = positions.length / 3;
|
|
19269
|
-
const
|
|
19270
|
-
|
|
19271
|
-
|
|
19272
|
-
|
|
19299
|
+
const unsignedIndices = input.indices instanceof Uint32Array;
|
|
19300
|
+
if (input.indices) for (let i = 0; i < input.indices.length; i++) {
|
|
19301
|
+
const index = input.indices[i];
|
|
19302
|
+
if (index >= count || !unsignedIndices && (!Number.isSafeInteger(index) || index < 0)) throw new RangeError("Mesh index outside vertex range");
|
|
19303
|
+
}
|
|
19304
|
+
const indices = input.indices ? Uint32Array.from(input.indices) : Uint32Array.from({ length: Math.floor(count / 3) * 3 }, (_, index) => index);
|
|
19273
19305
|
if (indices.length % 3) throw new RangeError("Mesh indices require complete triangles");
|
|
19274
19306
|
if (input.values && input.values.length !== count || input.colors && input.colors.length !== count * 4) throw new RangeError("Mesh values/colors do not match vertex count");
|
|
19275
19307
|
const colors = input.colors ? Float32Array.from(input.colors) : void 0;
|
|
19276
19308
|
if (colors && !colors.every((value) => Number.isFinite(value) && value >= 0 && value <= 1)) throw new RangeError("Mesh colors require normalized finite RGBA");
|
|
19309
|
+
const sameTopology = positions.length === this.vertices.length && indices.length === this.indices.length && indices.every((value, index) => value === this.indices[index]);
|
|
19277
19310
|
this.vertices = positions;
|
|
19278
|
-
|
|
19311
|
+
if (!sameTopology) {
|
|
19312
|
+
this.indices = indices;
|
|
19313
|
+
this.topologyRevision++;
|
|
19314
|
+
this.compiled = void 0;
|
|
19315
|
+
}
|
|
19279
19316
|
this.scalarValues = input.values ? Float32Array.from(input.values) : void 0;
|
|
19280
19317
|
this.vertexColors = colors;
|
|
19281
|
-
this.topologyRevision++;
|
|
19282
19318
|
this.geometryRevision++;
|
|
19283
19319
|
this.dirty = [{ start: 0, count }];
|
|
19284
19320
|
this.styleDirty = true;
|
|
19285
|
-
this.compiled = void 0;
|
|
19286
19321
|
this.changed();
|
|
19287
19322
|
return this;
|
|
19288
19323
|
}
|
|
@@ -19371,28 +19406,62 @@ void main() {
|
|
|
19371
19406
|
for (const range of ranges) for (let i = range.start; i < range.start + range.count; i++) {
|
|
19372
19407
|
if (!all && !finiteVertex2(positions, i)) invalidVertices--;
|
|
19373
19408
|
const point = this.normalizedVertex(i, normalize);
|
|
19374
|
-
positions
|
|
19409
|
+
positions[i * 3] = point.x;
|
|
19410
|
+
positions[i * 3 + 1] = point.y;
|
|
19411
|
+
positions[i * 3 + 2] = point.z;
|
|
19375
19412
|
if (!finiteVertex2(positions, i)) invalidVertices++;
|
|
19376
19413
|
}
|
|
19377
19414
|
const colorRanges = all || this.styleDirty ? [{ start: 0, count }] : ranges;
|
|
19378
|
-
for (const range of colorRanges) for (let i = range.start; i < range.start + range.count; i++)
|
|
19415
|
+
for (const range of colorRanges) for (let i = range.start; i < range.start + range.count; i++) {
|
|
19416
|
+
const color2 = this.colorAt(i);
|
|
19417
|
+
colors[i * 4] = color2.r;
|
|
19418
|
+
colors[i * 4 + 1] = color2.g;
|
|
19419
|
+
colors[i * 4 + 2] = color2.b;
|
|
19420
|
+
colors[i * 4 + 3] = color2.a;
|
|
19421
|
+
}
|
|
19379
19422
|
const normal = ranges.length ? this.updateNormals(positions, all ? void 0 : previous?.packet.normals, ranges) : { values: previous?.packet.normals ?? meshNormals(positions, this.indices), ranges: [] };
|
|
19380
19423
|
const packet = { id: this.id, revision: ++this.packetRevision, previousRevision: previous?.packet.revision, count, mode: "triangles", positions, colors, normals: normal.values, indices: this.indices, indexRevision: this.topologyRevision, allFinite: invalidVertices === 0, lighting: this.lighting, ...this.renderingState(), color: [1, 1, 1, 1], thickness: 0, pointSize: 0, positionUpdateRanges: all ? void 0 : mergedRanges(ranges, 3), colorUpdateRanges: all ? void 0 : mergedRanges(colorRanges, 4), normalUpdateRanges: all ? void 0 : normal.ranges };
|
|
19381
19424
|
const packets = [packet];
|
|
19382
19425
|
let wire;
|
|
19383
19426
|
if (this.wireframe.getThickness() > 0 && meshFillColor(this.wireframe.getFillStyle(), ColorRGBA(0, 0, 0)).a > 0) {
|
|
19384
|
-
const
|
|
19385
|
-
|
|
19386
|
-
|
|
19387
|
-
|
|
19388
|
-
|
|
19389
|
-
|
|
19390
|
-
|
|
19391
|
-
|
|
19392
|
-
|
|
19427
|
+
const valid2 = new Uint8Array(this.indices.length / 3);
|
|
19428
|
+
if (invalidVertices === 0) valid2.fill(1);
|
|
19429
|
+
else for (let i = 0; i < this.indices.length; i += 3) valid2[i / 3] = finiteVertex2(positions, this.indices[i]) && finiteVertex2(positions, this.indices[i + 1]) && finiteVertex2(positions, this.indices[i + 2]) ? 1 : 0;
|
|
19430
|
+
let topology = this.wireTopology;
|
|
19431
|
+
if (!topology || topology.indices.length !== this.indices.length || !this.indices.every((value, index) => value === topology.indices[index]) || !valid2.every((value, index) => value === topology.valid[index])) {
|
|
19432
|
+
const gridPairs = invalidVertices === 0 ? structuredWireEdges(this.indices, count) : void 0;
|
|
19433
|
+
if (gridPairs) topology = this.wireTopology = { indices: this.indices.slice(), valid: valid2, pairs: gridPairs };
|
|
19434
|
+
else {
|
|
19435
|
+
const edges = /* @__PURE__ */ new Set(), pairs = new Uint32Array(this.indices.length * 2);
|
|
19436
|
+
const numericKeys = Number.isSafeInteger(count * count);
|
|
19437
|
+
let length = 0;
|
|
19438
|
+
for (let i = 0; i < this.indices.length; i += 3) {
|
|
19439
|
+
if (!valid2[i / 3]) continue;
|
|
19440
|
+
for (let j = 0; j < 3; j++) {
|
|
19441
|
+
const a = this.indices[i + j], b = this.indices[i + (j + 1) % 3];
|
|
19442
|
+
const low = Math.min(a, b), high = Math.max(a, b);
|
|
19443
|
+
const key = numericKeys ? low * count + high : `${low}:${high}`;
|
|
19444
|
+
if (edges.has(key)) continue;
|
|
19445
|
+
edges.add(key);
|
|
19446
|
+
pairs[length++] = a;
|
|
19447
|
+
pairs[length++] = b;
|
|
19448
|
+
}
|
|
19449
|
+
}
|
|
19450
|
+
topology = this.wireTopology = { indices: this.indices.slice(), valid: valid2, pairs: pairs.subarray(0, length) };
|
|
19393
19451
|
}
|
|
19394
19452
|
}
|
|
19395
|
-
|
|
19453
|
+
const values = new Float32Array(topology.pairs.length / 2 * 9);
|
|
19454
|
+
for (let i = 0, out = 0; i < topology.pairs.length; i += 2, out += 9) {
|
|
19455
|
+
const a = topology.pairs[i] * 3, b = topology.pairs[i + 1] * 3;
|
|
19456
|
+
values[out] = positions[a];
|
|
19457
|
+
values[out + 1] = positions[a + 1];
|
|
19458
|
+
values[out + 2] = positions[a + 2];
|
|
19459
|
+
values[out + 3] = positions[b];
|
|
19460
|
+
values[out + 4] = positions[b + 1];
|
|
19461
|
+
values[out + 5] = positions[b + 2];
|
|
19462
|
+
values[out + 6] = values[out + 7] = values[out + 8] = NaN;
|
|
19463
|
+
}
|
|
19464
|
+
wire = { id: -this.id, revision: packet.revision, count: values.length / 3, mode: "line", positions: values, ...this.renderingState(), color: rgba(meshFillColor(this.wireframe.getFillStyle(), ColorRGBA(0, 0, 0))), thickness: this.wireframe.getThickness(), pointSize: 0 };
|
|
19396
19465
|
packets.push(wire);
|
|
19397
19466
|
}
|
|
19398
19467
|
this.compiled = { key: axisKey, revision: this.revision, packet, wire, packets, invalidVertices };
|
|
@@ -19402,6 +19471,7 @@ void main() {
|
|
|
19402
19471
|
}
|
|
19403
19472
|
dispose() {
|
|
19404
19473
|
this.compiled = void 0;
|
|
19474
|
+
this.wireTopology = void 0;
|
|
19405
19475
|
this.vertices = new Float64Array(0);
|
|
19406
19476
|
this.indices = new Uint32Array(0);
|
|
19407
19477
|
this.scalarValues = void 0;
|
|
@@ -19934,7 +20004,6 @@ void main() {
|
|
|
19934
20004
|
// src/axis-canvas.ts
|
|
19935
20005
|
var color = (fill, fallback) => fill?.kind === "empty" ? ColorRGBA(0, 0, 0, 0) : fill?.getColor?.() ?? fallback;
|
|
19936
20006
|
var validFont = (font2) => font2.toCSS?.() ?? `${font2.getSize()}px sans-serif`;
|
|
19937
|
-
var isDefaultFont = (font2) => font2.getSize() === 12 && font2.family === "sans-serif" && font2.weight === "normal" && font2.style === "normal" && font2.variant === "normal";
|
|
19938
20007
|
var lineBoxHeight = (font2) => font2.getSize() * 0.8;
|
|
19939
20008
|
function lineBoxBaseline(metrics2, font2) {
|
|
19940
20009
|
const size = font2.getSize();
|
|
@@ -19950,7 +20019,7 @@ void main() {
|
|
|
19950
20019
|
}
|
|
19951
20020
|
let measured;
|
|
19952
20021
|
try {
|
|
19953
|
-
measured = ctx?.measureText(text);
|
|
20022
|
+
measured = ctx?.measureText?.(text);
|
|
19954
20023
|
} finally {
|
|
19955
20024
|
if (ctx) {
|
|
19956
20025
|
if (previous !== void 0) ctx.font = previous;
|
|
@@ -19995,10 +20064,13 @@ void main() {
|
|
|
19995
20064
|
return axis.direction === "x" ? measured.width : measured.ascent + measured.descent;
|
|
19996
20065
|
});
|
|
19997
20066
|
}
|
|
19998
|
-
function metrics(axis, ctx, cache, theme, resolveFont
|
|
20067
|
+
function metrics(axis, ctx, cache, theme, resolveFont) {
|
|
19999
20068
|
const horizontal = axis.direction === "x", strategy = axis.tickStrategy, tick = strategy.getMajorTickStyle();
|
|
20000
20069
|
const titleText = axis.getDisplayTitle(), titleVisible = titleText.length > 0 && color(axis.titleFill, ColorRGBA(190, 200, 215)).a > 0;
|
|
20001
|
-
const
|
|
20070
|
+
const liveCustomTicks = axis.annotations.filter((annotation) => annotation.kind === "tick" && annotation.visible && !annotation.disposed);
|
|
20071
|
+
const hasCustomTicks = liveCustomTicks.length > 0;
|
|
20072
|
+
const strokeThickness = (axis.stroke?.getThickness?.() ?? 0) > 0 && color(axis.stroke?.getFillStyle?.(), ColorRGBA(0, 0, 0, 0)).a > 0 ? axis.stroke.getThickness() : 0;
|
|
20073
|
+
const titleOnly = !strategy.visible && titleVisible && !hasCustomTicks;
|
|
20002
20074
|
const baseFont = tick.hasLabelFontOverride() ? tick.getLabelFont() : theme?.font ?? tick.getLabelFont();
|
|
20003
20075
|
const labelFont = resolveFont?.(baseFont) ?? baseFont, titleFont = resolveFont?.(axis.titleFont) ?? axis.titleFont;
|
|
20004
20076
|
const visibleLevels = ["major", "minor", "great"].flatMap((level) => {
|
|
@@ -20008,36 +20080,39 @@ void main() {
|
|
|
20008
20080
|
const fill = resolvedTickFill(axis, level, style, theme);
|
|
20009
20081
|
return [{ level, style, font: font2, visible: color(fill, ColorRGBA(0, 0, 0, 0)).a > 0 }];
|
|
20010
20082
|
});
|
|
20011
|
-
const margin2 = axis.getMarginAfterTicks(), tickLength = titleOnly ? 0 : Math.max(0, ...visibleLevels.map(({ style }) => style.getTickStyle()?.getThickness?.() > 0 ? style.getTickLength() : 0));
|
|
20083
|
+
const margin2 = axis.getMarginAfterTicks(), tickLength = titleOnly || !strategy.visible && !hasCustomTicks ? 0 : Math.max(0, ...visibleLevels.map(({ style }) => style.getTickStyle()?.getThickness?.() > 0 ? style.getTickLength() : 0));
|
|
20012
20084
|
const rotation = (axis.titleRotation ?? (horizontal ? 0 : -90)) * Math.PI / 180;
|
|
20013
|
-
const customLabels = visibleLevels.some(({ level, style, visible }) => visible && (typeof style.formatter === "function" || typeof (level === "major" ? strategy.getMajorFormattingFunction() : strategy.getMinorFormattingFunction()) === "function")) || strategy.getFormattingOffset() !== void 0 || strategy.customMajor !== void 0 || strategy.customMinor !== void 0 || strategy.hasDateTimeFormatting?.() === true;
|
|
20014
|
-
const interval = axis.getInterval(), longDefault = !horizontal && strategy.kind === "numeric" && !customLabels && [interval.start, interval.end].some((value) => formatNumeric(value, interval).length * labelFont.getSize() * 0.6 + 17 > 54);
|
|
20015
|
-
const changedLayout = contentLayout || titleOnly || margin2 > 0 || visibleLevels.some(({ font: font2, visible }) => visible && !isDefaultFont(font2)) || !isDefaultFont(titleFont) || axis.titleRotation !== void 0 || tickLength > 7 || customLabels || longDefault || strategy.kind === "datetime";
|
|
20016
|
-
if (!changedLayout) return { measured: false, labelFont, titleFont, lane: 0, laneOffset: 0, laneSize: horizontal ? 44 : 54, labelOffset: horizontal ? axis.opposite ? 10 : 20 : 9, titleOffset: horizontal ? axis.opposite ? 32 : 43 : 48, tickLength, labelWidth: 0, labelAscent: 9, labelDescent: 3, titleWidth: 0, titleAscent: 9, titleDescent: 3, rotation };
|
|
20017
20085
|
const layout = measuredTickLayout(axis, ctx, void 0, cache, theme, resolveFont), labels = visibleLevels.flatMap(({ level, font: font2, visible }) => visible ? (layout[level] ?? []).filter((t) => t.label.length).map((t) => textMetrics(ctx, t.label, font2, cache)) : []);
|
|
20018
|
-
const
|
|
20019
|
-
|
|
20020
|
-
|
|
20021
|
-
|
|
20022
|
-
|
|
20023
|
-
|
|
20024
|
-
|
|
20086
|
+
const customTickLabels = liveCustomTicks.map((annotation) => {
|
|
20087
|
+
const formatted = typeof annotation.textFormatter === "function" ? String(annotation.textFormatter(annotation.value)) : String(annotation.text ?? "");
|
|
20088
|
+
return formatted.length > 0 ? textMetrics(ctx, formatted, labelFont, cache) : void 0;
|
|
20089
|
+
}).filter((m) => !!m);
|
|
20090
|
+
const allLabels = [...labels, ...customTickLabels], hasLabels = allLabels.length > 0;
|
|
20091
|
+
const labelWidth = Math.max(0, ...allLabels.map((m) => m.width)), labelAscent = Math.max(labelFont.getSize() * 0.75, ...allLabels.map((m) => m.ascent)), labelDescent = Math.max(labelFont.getSize() * 0.25, ...allLabels.map((m) => m.descent));
|
|
20092
|
+
const title = titleVisible ? textMetrics(ctx, titleText, titleFont, cache) : { width: 0, ascent: titleFont.getSize() * 0.75, descent: titleFont.getSize() * 0.25, baseline: lineBoxBaseline(void 0, titleFont) };
|
|
20093
|
+
if (axis.titleRotation === void 0) {
|
|
20094
|
+
const gutter = 7, labelOffset2 = hasLabels || hasCustomTicks ? tickLength + gutter : 0;
|
|
20095
|
+
const labelBand = horizontal ? Math.max(customTickLabels.length > 0 ? lineBoxHeight(labelFont) : 0, ...visibleLevels.filter((level) => level.visible).map((level) => lineBoxHeight(level.font))) : labelWidth;
|
|
20096
|
+
const labelOuter2 = hasLabels ? labelOffset2 + labelBand : hasCustomTicks ? labelOffset2 : tickLength;
|
|
20097
|
+
const titleHalf = lineBoxHeight(titleFont) / 2;
|
|
20098
|
+
const titleBase = labelOuter2 > 0 ? labelOuter2 + (hasLabels ? margin2 : 0) : (strokeThickness > 0 ? strokeThickness / 2 : 0) + gutter;
|
|
20099
|
+
const titleOffset2 = titleBase + titleHalf;
|
|
20025
20100
|
const extent2 = Math.max(labelOuter2, titleVisible ? titleOffset2 + titleHalf : 0);
|
|
20026
|
-
|
|
20101
|
+
const laneSize2 = extent2 > 0 ? extent2 + gutter : strokeThickness > 0 ? Math.ceil(strokeThickness) : 0;
|
|
20102
|
+
return { measured: true, labelFont, titleFont, lane: 0, laneOffset: 0, laneSize: laneSize2, labelOffset: labelOffset2, titleOffset: titleOffset2, tickLength, labelWidth, labelAscent, labelDescent, titleWidth: title.width, titleAscent: title.ascent, titleDescent: title.descent, rotation, lineBoxTitleBaseline: title.baseline };
|
|
20027
20103
|
}
|
|
20028
20104
|
const titleBox = rotatedBounds(title.width, title.ascent, title.descent, rotation);
|
|
20029
|
-
const labelOffset = titleOnly ? 0 : horizontal ? axis.opposite ? Math.max(10, tickLength + labelDescent + 3) : Math.max(20, tickLength + labelAscent + 3) : Math.max(9, tickLength +
|
|
20030
|
-
const labelOuter = titleOnly ? 0 : horizontal ? labelOffset + (axis.opposite ? labelAscent : labelDescent) : labelOffset + labelWidth;
|
|
20105
|
+
const labelOffset = titleOnly || !hasLabels && !hasCustomTicks ? 0 : horizontal ? axis.opposite ? Math.max(10, tickLength + labelDescent + 3) : Math.max(20, tickLength + labelAscent + 3) : Math.max(9, tickLength + 5);
|
|
20106
|
+
const labelOuter = titleOnly || !hasLabels && !hasCustomTicks ? 0 : horizontal ? labelOffset + (axis.opposite ? labelAscent : labelDescent) : labelOffset + labelWidth;
|
|
20031
20107
|
const titleInner = horizontal ? axis.opposite ? titleBox.bottom : -titleBox.top : axis.opposite ? -titleBox.left : titleBox.right;
|
|
20032
20108
|
const titleOuter = horizontal ? axis.opposite ? -titleBox.top : titleBox.bottom : axis.opposite ? titleBox.right : -titleBox.left;
|
|
20033
|
-
const
|
|
20034
|
-
const
|
|
20035
|
-
const
|
|
20036
|
-
const baseline = horizontal ? 44 : 54, laneSize = contentLayout ? Math.ceil(extent + (horizontal ? 2 : 0)) : changedLayout ? Math.max(baseline, Math.ceil(extent + 8)) : baseline;
|
|
20109
|
+
const titleOffset = labelOuter + (hasLabels ? margin2 : 0) + titleInner + (labelOuter > 0 ? 2 : 5);
|
|
20110
|
+
const extent = Math.max(labelOuter, titleVisible ? titleOffset + titleOuter : 0, tickLength, strokeThickness);
|
|
20111
|
+
const laneSize = extent > 0 ? Math.ceil(extent + (horizontal ? 2 : 4)) : 0;
|
|
20037
20112
|
return { measured: true, labelFont, titleFont, lane: 0, laneOffset: 0, laneSize, labelOffset, titleOffset, tickLength, labelWidth, labelAscent, labelDescent, titleWidth: title.width, titleAscent: title.ascent, titleDescent: title.descent, rotation };
|
|
20038
20113
|
}
|
|
20039
|
-
function measureAxisCanvasLayout(ctx, axesX, axesY, theme, resolveFont
|
|
20040
|
-
const result2 = {
|
|
20114
|
+
function measureAxisCanvasLayout(ctx, axesX, axesY, theme, resolveFont) {
|
|
20115
|
+
const result2 = { contentMargins: { left: 0, right: 0, top: 0, bottom: 0 }, extraMargins: { left: 0, right: 0, top: 0, bottom: 0 }, axes: /* @__PURE__ */ new Map() };
|
|
20041
20116
|
const textCache = /* @__PURE__ */ new Map();
|
|
20042
20117
|
for (const [horizontal, list] of [[true, axesX], [false, axesY]]) for (const opposite of [false, true]) {
|
|
20043
20118
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -20048,14 +20123,14 @@ void main() {
|
|
|
20048
20123
|
}
|
|
20049
20124
|
let offset = 0, lane = 0;
|
|
20050
20125
|
for (const [, axes] of [...groups].sort((a, b) => a[0] - b[0])) {
|
|
20051
|
-
const values = axes.map((axis) => [axis, metrics(axis, ctx, textCache, theme, resolveFont
|
|
20126
|
+
const values = axes.map((axis) => [axis, metrics(axis, ctx, textCache, theme, resolveFont)]), size = Math.max(0, ...values.map(([, m]) => m.laneSize));
|
|
20052
20127
|
for (const [axis, value] of values) result2.axes.set(axis, { ...value, lane, laneOffset: offset, laneSize: size });
|
|
20053
20128
|
offset += size;
|
|
20054
20129
|
lane++;
|
|
20055
20130
|
}
|
|
20056
20131
|
const side = horizontal ? opposite ? "top" : "bottom" : opposite ? "right" : "left";
|
|
20057
20132
|
result2.extraMargins[side] = Math.max(0, offset - lane * (horizontal ? 44 : 54));
|
|
20058
|
-
|
|
20133
|
+
result2.contentMargins[side] = offset;
|
|
20059
20134
|
}
|
|
20060
20135
|
return result2;
|
|
20061
20136
|
}
|
|
@@ -21421,7 +21496,7 @@ void main() {
|
|
|
21421
21496
|
this.prepareCustomTickPlacementLengths(axesX, axesY);
|
|
21422
21497
|
const layoutAxesX = axesX.filter((axis) => this.hasAxisLaneContent(axis));
|
|
21423
21498
|
const layoutAxesY = axesY.filter((axis) => this.hasAxisLaneContent(axis));
|
|
21424
|
-
this.axisCanvasLayout = this.kind === "xy" ? measureAxisCanvasLayout(this.overlayContext ?? void 0, layoutAxesX, layoutAxesY, this.theme, this.resolveTextFont
|
|
21499
|
+
this.axisCanvasLayout = this.kind === "xy" ? measureAxisCanvasLayout(this.overlayContext ?? void 0, layoutAxesX, layoutAxesY, this.theme, this.resolveTextFont) : void 0;
|
|
21425
21500
|
const axisExtra = this.axisCanvasLayout?.extraMargins ?? { left: 0, right: 0, top: 0, bottom: 0 };
|
|
21426
21501
|
const legendMargin = this.overlayContext ? this.legend.getLayout(this.overlayContext, this.legendArea()).margin : { left: 0, right: 0, top: 0, bottom: 0 };
|
|
21427
21502
|
if (this.kind === "polar") {
|
|
@@ -23374,6 +23449,7 @@ void main() {
|
|
|
23374
23449
|
this.coordsAxis.z = this.axesZ[0];
|
|
23375
23450
|
if (this.renderer?.gl && this.canvas)
|
|
23376
23451
|
this.gpu3d = new DataRenderer3D(this.renderer.gl, this.canvas);
|
|
23452
|
+
this.layout();
|
|
23377
23453
|
this.invalidate();
|
|
23378
23454
|
}
|
|
23379
23455
|
/** Project full XYZ axis coordinates with the existing original GPU camera
|
|
@@ -25162,7 +25238,7 @@ ${sample.position[0].toFixed(4)}, ${sample.position[1].toFixed(4)}`, contains: (
|
|
|
25162
25238
|
getChartCount: () => owned2.size
|
|
25163
25239
|
};
|
|
25164
25240
|
}
|
|
25165
|
-
var version = "1.0.
|
|
25241
|
+
var version = "1.0.6";
|
|
25166
25242
|
var Dashboard = class {
|
|
25167
25243
|
root;
|
|
25168
25244
|
cells = /* @__PURE__ */ new Map();
|
package/dist/crychart.js
CHANGED
|
@@ -18851,6 +18851,35 @@ var integer = (value, minimum = 0) => {
|
|
|
18851
18851
|
var rgba = (color2) => [color2.r, color2.g, color2.b, color2.a];
|
|
18852
18852
|
var meshFillColor = (fill, fallback) => fill.kind === "empty" ? ColorRGBA(0, 0, 0, 0) : fill.getColor?.() ?? fallback;
|
|
18853
18853
|
var finiteVertex2 = (values, index) => Number.isFinite(values[index * 3]) && Number.isFinite(values[index * 3 + 1]) && Number.isFinite(values[index * 3 + 2]);
|
|
18854
|
+
function structuredWireEdges(indices, count) {
|
|
18855
|
+
const columns = indices[1], rows = count / columns;
|
|
18856
|
+
if (!Number.isInteger(columns) || columns < 2 || !Number.isInteger(rows) || rows < 2 || indices.length !== (rows - 1) * (columns - 1) * 6) return void 0;
|
|
18857
|
+
let offset = 0;
|
|
18858
|
+
for (let row = 0; row + 1 < rows; row++) for (let col = 0; col + 1 < columns; col++, offset += 6) {
|
|
18859
|
+
const i = row * columns + col, below = i + columns;
|
|
18860
|
+
if (indices[offset] !== i || indices[offset + 1] !== below || indices[offset + 2] !== i + 1 || indices[offset + 3] !== i + 1 || indices[offset + 4] !== below || indices[offset + 5] !== below + 1) return void 0;
|
|
18861
|
+
}
|
|
18862
|
+
const pairs = new Uint32Array((rows * (columns - 1) + (rows - 1) * columns + (rows - 1) * (columns - 1)) * 2);
|
|
18863
|
+
let length = 0;
|
|
18864
|
+
for (let row = 0; row + 1 < rows; row++) for (let col = 0; col + 1 < columns; col++) {
|
|
18865
|
+
const i = row * columns + col, below = i + columns;
|
|
18866
|
+
if (col === 0) {
|
|
18867
|
+
pairs[length++] = i;
|
|
18868
|
+
pairs[length++] = below;
|
|
18869
|
+
}
|
|
18870
|
+
pairs[length++] = below;
|
|
18871
|
+
pairs[length++] = i + 1;
|
|
18872
|
+
if (row === 0) {
|
|
18873
|
+
pairs[length++] = i + 1;
|
|
18874
|
+
pairs[length++] = i;
|
|
18875
|
+
}
|
|
18876
|
+
pairs[length++] = below;
|
|
18877
|
+
pairs[length++] = below + 1;
|
|
18878
|
+
pairs[length++] = below + 1;
|
|
18879
|
+
pairs[length++] = i + 1;
|
|
18880
|
+
}
|
|
18881
|
+
return pairs;
|
|
18882
|
+
}
|
|
18854
18883
|
function mergedRanges(ranges, width = 1) {
|
|
18855
18884
|
const sorted = ranges.filter((range) => range.count > 0).map((range) => ({ start: range.start, count: range.count })).sort((a, b) => a.start - b.start), out = [];
|
|
18856
18885
|
for (const range of sorted) {
|
|
@@ -19077,28 +19106,34 @@ var MeshSeries3D = class extends Series3DBase {
|
|
|
19077
19106
|
dirty = [];
|
|
19078
19107
|
styleDirty = true;
|
|
19079
19108
|
compiled;
|
|
19109
|
+
wireTopology;
|
|
19080
19110
|
boundsCache;
|
|
19081
19111
|
setGeometry(input) {
|
|
19082
19112
|
this.assertAlive();
|
|
19083
19113
|
if (!input?.positions || input.positions.length % 3) throw new RangeError("Mesh positions require complete XYZ vertices");
|
|
19084
19114
|
const positions = Float64Array.from(input.positions), count = positions.length / 3;
|
|
19085
|
-
const
|
|
19086
|
-
|
|
19087
|
-
|
|
19088
|
-
|
|
19115
|
+
const unsignedIndices = input.indices instanceof Uint32Array;
|
|
19116
|
+
if (input.indices) for (let i = 0; i < input.indices.length; i++) {
|
|
19117
|
+
const index = input.indices[i];
|
|
19118
|
+
if (index >= count || !unsignedIndices && (!Number.isSafeInteger(index) || index < 0)) throw new RangeError("Mesh index outside vertex range");
|
|
19119
|
+
}
|
|
19120
|
+
const indices = input.indices ? Uint32Array.from(input.indices) : Uint32Array.from({ length: Math.floor(count / 3) * 3 }, (_, index) => index);
|
|
19089
19121
|
if (indices.length % 3) throw new RangeError("Mesh indices require complete triangles");
|
|
19090
19122
|
if (input.values && input.values.length !== count || input.colors && input.colors.length !== count * 4) throw new RangeError("Mesh values/colors do not match vertex count");
|
|
19091
19123
|
const colors = input.colors ? Float32Array.from(input.colors) : void 0;
|
|
19092
19124
|
if (colors && !colors.every((value) => Number.isFinite(value) && value >= 0 && value <= 1)) throw new RangeError("Mesh colors require normalized finite RGBA");
|
|
19125
|
+
const sameTopology = positions.length === this.vertices.length && indices.length === this.indices.length && indices.every((value, index) => value === this.indices[index]);
|
|
19093
19126
|
this.vertices = positions;
|
|
19094
|
-
|
|
19127
|
+
if (!sameTopology) {
|
|
19128
|
+
this.indices = indices;
|
|
19129
|
+
this.topologyRevision++;
|
|
19130
|
+
this.compiled = void 0;
|
|
19131
|
+
}
|
|
19095
19132
|
this.scalarValues = input.values ? Float32Array.from(input.values) : void 0;
|
|
19096
19133
|
this.vertexColors = colors;
|
|
19097
|
-
this.topologyRevision++;
|
|
19098
19134
|
this.geometryRevision++;
|
|
19099
19135
|
this.dirty = [{ start: 0, count }];
|
|
19100
19136
|
this.styleDirty = true;
|
|
19101
|
-
this.compiled = void 0;
|
|
19102
19137
|
this.changed();
|
|
19103
19138
|
return this;
|
|
19104
19139
|
}
|
|
@@ -19187,28 +19222,62 @@ var MeshSeries3D = class extends Series3DBase {
|
|
|
19187
19222
|
for (const range of ranges) for (let i = range.start; i < range.start + range.count; i++) {
|
|
19188
19223
|
if (!all && !finiteVertex2(positions, i)) invalidVertices--;
|
|
19189
19224
|
const point = this.normalizedVertex(i, normalize);
|
|
19190
|
-
positions
|
|
19225
|
+
positions[i * 3] = point.x;
|
|
19226
|
+
positions[i * 3 + 1] = point.y;
|
|
19227
|
+
positions[i * 3 + 2] = point.z;
|
|
19191
19228
|
if (!finiteVertex2(positions, i)) invalidVertices++;
|
|
19192
19229
|
}
|
|
19193
19230
|
const colorRanges = all || this.styleDirty ? [{ start: 0, count }] : ranges;
|
|
19194
|
-
for (const range of colorRanges) for (let i = range.start; i < range.start + range.count; i++)
|
|
19231
|
+
for (const range of colorRanges) for (let i = range.start; i < range.start + range.count; i++) {
|
|
19232
|
+
const color2 = this.colorAt(i);
|
|
19233
|
+
colors[i * 4] = color2.r;
|
|
19234
|
+
colors[i * 4 + 1] = color2.g;
|
|
19235
|
+
colors[i * 4 + 2] = color2.b;
|
|
19236
|
+
colors[i * 4 + 3] = color2.a;
|
|
19237
|
+
}
|
|
19195
19238
|
const normal = ranges.length ? this.updateNormals(positions, all ? void 0 : previous?.packet.normals, ranges) : { values: previous?.packet.normals ?? meshNormals(positions, this.indices), ranges: [] };
|
|
19196
19239
|
const packet = { id: this.id, revision: ++this.packetRevision, previousRevision: previous?.packet.revision, count, mode: "triangles", positions, colors, normals: normal.values, indices: this.indices, indexRevision: this.topologyRevision, allFinite: invalidVertices === 0, lighting: this.lighting, ...this.renderingState(), color: [1, 1, 1, 1], thickness: 0, pointSize: 0, positionUpdateRanges: all ? void 0 : mergedRanges(ranges, 3), colorUpdateRanges: all ? void 0 : mergedRanges(colorRanges, 4), normalUpdateRanges: all ? void 0 : normal.ranges };
|
|
19197
19240
|
const packets = [packet];
|
|
19198
19241
|
let wire;
|
|
19199
19242
|
if (this.wireframe.getThickness() > 0 && meshFillColor(this.wireframe.getFillStyle(), ColorRGBA(0, 0, 0)).a > 0) {
|
|
19200
|
-
const
|
|
19201
|
-
|
|
19202
|
-
|
|
19203
|
-
|
|
19204
|
-
|
|
19205
|
-
|
|
19206
|
-
|
|
19207
|
-
|
|
19208
|
-
|
|
19243
|
+
const valid2 = new Uint8Array(this.indices.length / 3);
|
|
19244
|
+
if (invalidVertices === 0) valid2.fill(1);
|
|
19245
|
+
else for (let i = 0; i < this.indices.length; i += 3) valid2[i / 3] = finiteVertex2(positions, this.indices[i]) && finiteVertex2(positions, this.indices[i + 1]) && finiteVertex2(positions, this.indices[i + 2]) ? 1 : 0;
|
|
19246
|
+
let topology = this.wireTopology;
|
|
19247
|
+
if (!topology || topology.indices.length !== this.indices.length || !this.indices.every((value, index) => value === topology.indices[index]) || !valid2.every((value, index) => value === topology.valid[index])) {
|
|
19248
|
+
const gridPairs = invalidVertices === 0 ? structuredWireEdges(this.indices, count) : void 0;
|
|
19249
|
+
if (gridPairs) topology = this.wireTopology = { indices: this.indices.slice(), valid: valid2, pairs: gridPairs };
|
|
19250
|
+
else {
|
|
19251
|
+
const edges = /* @__PURE__ */ new Set(), pairs = new Uint32Array(this.indices.length * 2);
|
|
19252
|
+
const numericKeys = Number.isSafeInteger(count * count);
|
|
19253
|
+
let length = 0;
|
|
19254
|
+
for (let i = 0; i < this.indices.length; i += 3) {
|
|
19255
|
+
if (!valid2[i / 3]) continue;
|
|
19256
|
+
for (let j = 0; j < 3; j++) {
|
|
19257
|
+
const a = this.indices[i + j], b = this.indices[i + (j + 1) % 3];
|
|
19258
|
+
const low = Math.min(a, b), high = Math.max(a, b);
|
|
19259
|
+
const key = numericKeys ? low * count + high : `${low}:${high}`;
|
|
19260
|
+
if (edges.has(key)) continue;
|
|
19261
|
+
edges.add(key);
|
|
19262
|
+
pairs[length++] = a;
|
|
19263
|
+
pairs[length++] = b;
|
|
19264
|
+
}
|
|
19265
|
+
}
|
|
19266
|
+
topology = this.wireTopology = { indices: this.indices.slice(), valid: valid2, pairs: pairs.subarray(0, length) };
|
|
19209
19267
|
}
|
|
19210
19268
|
}
|
|
19211
|
-
|
|
19269
|
+
const values = new Float32Array(topology.pairs.length / 2 * 9);
|
|
19270
|
+
for (let i = 0, out = 0; i < topology.pairs.length; i += 2, out += 9) {
|
|
19271
|
+
const a = topology.pairs[i] * 3, b = topology.pairs[i + 1] * 3;
|
|
19272
|
+
values[out] = positions[a];
|
|
19273
|
+
values[out + 1] = positions[a + 1];
|
|
19274
|
+
values[out + 2] = positions[a + 2];
|
|
19275
|
+
values[out + 3] = positions[b];
|
|
19276
|
+
values[out + 4] = positions[b + 1];
|
|
19277
|
+
values[out + 5] = positions[b + 2];
|
|
19278
|
+
values[out + 6] = values[out + 7] = values[out + 8] = NaN;
|
|
19279
|
+
}
|
|
19280
|
+
wire = { id: -this.id, revision: packet.revision, count: values.length / 3, mode: "line", positions: values, ...this.renderingState(), color: rgba(meshFillColor(this.wireframe.getFillStyle(), ColorRGBA(0, 0, 0))), thickness: this.wireframe.getThickness(), pointSize: 0 };
|
|
19212
19281
|
packets.push(wire);
|
|
19213
19282
|
}
|
|
19214
19283
|
this.compiled = { key: axisKey, revision: this.revision, packet, wire, packets, invalidVertices };
|
|
@@ -19218,6 +19287,7 @@ var MeshSeries3D = class extends Series3DBase {
|
|
|
19218
19287
|
}
|
|
19219
19288
|
dispose() {
|
|
19220
19289
|
this.compiled = void 0;
|
|
19290
|
+
this.wireTopology = void 0;
|
|
19221
19291
|
this.vertices = new Float64Array(0);
|
|
19222
19292
|
this.indices = new Uint32Array(0);
|
|
19223
19293
|
this.scalarValues = void 0;
|
|
@@ -19750,7 +19820,6 @@ function fitEllipsoid3D(input, options = {}) {
|
|
|
19750
19820
|
// src/axis-canvas.ts
|
|
19751
19821
|
var color = (fill, fallback) => fill?.kind === "empty" ? ColorRGBA(0, 0, 0, 0) : fill?.getColor?.() ?? fallback;
|
|
19752
19822
|
var validFont = (font2) => font2.toCSS?.() ?? `${font2.getSize()}px sans-serif`;
|
|
19753
|
-
var isDefaultFont = (font2) => font2.getSize() === 12 && font2.family === "sans-serif" && font2.weight === "normal" && font2.style === "normal" && font2.variant === "normal";
|
|
19754
19823
|
var lineBoxHeight = (font2) => font2.getSize() * 0.8;
|
|
19755
19824
|
function lineBoxBaseline(metrics2, font2) {
|
|
19756
19825
|
const size = font2.getSize();
|
|
@@ -19766,7 +19835,7 @@ function textMetrics(ctx, text, font2, cache) {
|
|
|
19766
19835
|
}
|
|
19767
19836
|
let measured;
|
|
19768
19837
|
try {
|
|
19769
|
-
measured = ctx?.measureText(text);
|
|
19838
|
+
measured = ctx?.measureText?.(text);
|
|
19770
19839
|
} finally {
|
|
19771
19840
|
if (ctx) {
|
|
19772
19841
|
if (previous !== void 0) ctx.font = previous;
|
|
@@ -19811,10 +19880,13 @@ function measuredTickLayout(axis, ctx, axisSizePixels = axis.getPixelLength(), c
|
|
|
19811
19880
|
return axis.direction === "x" ? measured.width : measured.ascent + measured.descent;
|
|
19812
19881
|
});
|
|
19813
19882
|
}
|
|
19814
|
-
function metrics(axis, ctx, cache, theme, resolveFont
|
|
19883
|
+
function metrics(axis, ctx, cache, theme, resolveFont) {
|
|
19815
19884
|
const horizontal = axis.direction === "x", strategy = axis.tickStrategy, tick = strategy.getMajorTickStyle();
|
|
19816
19885
|
const titleText = axis.getDisplayTitle(), titleVisible = titleText.length > 0 && color(axis.titleFill, ColorRGBA(190, 200, 215)).a > 0;
|
|
19817
|
-
const
|
|
19886
|
+
const liveCustomTicks = axis.annotations.filter((annotation) => annotation.kind === "tick" && annotation.visible && !annotation.disposed);
|
|
19887
|
+
const hasCustomTicks = liveCustomTicks.length > 0;
|
|
19888
|
+
const strokeThickness = (axis.stroke?.getThickness?.() ?? 0) > 0 && color(axis.stroke?.getFillStyle?.(), ColorRGBA(0, 0, 0, 0)).a > 0 ? axis.stroke.getThickness() : 0;
|
|
19889
|
+
const titleOnly = !strategy.visible && titleVisible && !hasCustomTicks;
|
|
19818
19890
|
const baseFont = tick.hasLabelFontOverride() ? tick.getLabelFont() : theme?.font ?? tick.getLabelFont();
|
|
19819
19891
|
const labelFont = resolveFont?.(baseFont) ?? baseFont, titleFont = resolveFont?.(axis.titleFont) ?? axis.titleFont;
|
|
19820
19892
|
const visibleLevels = ["major", "minor", "great"].flatMap((level) => {
|
|
@@ -19824,36 +19896,39 @@ function metrics(axis, ctx, cache, theme, resolveFont, contentLayout = false) {
|
|
|
19824
19896
|
const fill = resolvedTickFill(axis, level, style, theme);
|
|
19825
19897
|
return [{ level, style, font: font2, visible: color(fill, ColorRGBA(0, 0, 0, 0)).a > 0 }];
|
|
19826
19898
|
});
|
|
19827
|
-
const margin2 = axis.getMarginAfterTicks(), tickLength = titleOnly ? 0 : Math.max(0, ...visibleLevels.map(({ style }) => style.getTickStyle()?.getThickness?.() > 0 ? style.getTickLength() : 0));
|
|
19899
|
+
const margin2 = axis.getMarginAfterTicks(), tickLength = titleOnly || !strategy.visible && !hasCustomTicks ? 0 : Math.max(0, ...visibleLevels.map(({ style }) => style.getTickStyle()?.getThickness?.() > 0 ? style.getTickLength() : 0));
|
|
19828
19900
|
const rotation = (axis.titleRotation ?? (horizontal ? 0 : -90)) * Math.PI / 180;
|
|
19829
|
-
const customLabels = visibleLevels.some(({ level, style, visible }) => visible && (typeof style.formatter === "function" || typeof (level === "major" ? strategy.getMajorFormattingFunction() : strategy.getMinorFormattingFunction()) === "function")) || strategy.getFormattingOffset() !== void 0 || strategy.customMajor !== void 0 || strategy.customMinor !== void 0 || strategy.hasDateTimeFormatting?.() === true;
|
|
19830
|
-
const interval = axis.getInterval(), longDefault = !horizontal && strategy.kind === "numeric" && !customLabels && [interval.start, interval.end].some((value) => formatNumeric(value, interval).length * labelFont.getSize() * 0.6 + 17 > 54);
|
|
19831
|
-
const changedLayout = contentLayout || titleOnly || margin2 > 0 || visibleLevels.some(({ font: font2, visible }) => visible && !isDefaultFont(font2)) || !isDefaultFont(titleFont) || axis.titleRotation !== void 0 || tickLength > 7 || customLabels || longDefault || strategy.kind === "datetime";
|
|
19832
|
-
if (!changedLayout) return { measured: false, labelFont, titleFont, lane: 0, laneOffset: 0, laneSize: horizontal ? 44 : 54, labelOffset: horizontal ? axis.opposite ? 10 : 20 : 9, titleOffset: horizontal ? axis.opposite ? 32 : 43 : 48, tickLength, labelWidth: 0, labelAscent: 9, labelDescent: 3, titleWidth: 0, titleAscent: 9, titleDescent: 3, rotation };
|
|
19833
19901
|
const layout = measuredTickLayout(axis, ctx, void 0, cache, theme, resolveFont), labels = visibleLevels.flatMap(({ level, font: font2, visible }) => visible ? (layout[level] ?? []).filter((t) => t.label.length).map((t) => textMetrics(ctx, t.label, font2, cache)) : []);
|
|
19834
|
-
const
|
|
19835
|
-
|
|
19836
|
-
|
|
19837
|
-
|
|
19838
|
-
|
|
19839
|
-
|
|
19840
|
-
|
|
19902
|
+
const customTickLabels = liveCustomTicks.map((annotation) => {
|
|
19903
|
+
const formatted = typeof annotation.textFormatter === "function" ? String(annotation.textFormatter(annotation.value)) : String(annotation.text ?? "");
|
|
19904
|
+
return formatted.length > 0 ? textMetrics(ctx, formatted, labelFont, cache) : void 0;
|
|
19905
|
+
}).filter((m) => !!m);
|
|
19906
|
+
const allLabels = [...labels, ...customTickLabels], hasLabels = allLabels.length > 0;
|
|
19907
|
+
const labelWidth = Math.max(0, ...allLabels.map((m) => m.width)), labelAscent = Math.max(labelFont.getSize() * 0.75, ...allLabels.map((m) => m.ascent)), labelDescent = Math.max(labelFont.getSize() * 0.25, ...allLabels.map((m) => m.descent));
|
|
19908
|
+
const title = titleVisible ? textMetrics(ctx, titleText, titleFont, cache) : { width: 0, ascent: titleFont.getSize() * 0.75, descent: titleFont.getSize() * 0.25, baseline: lineBoxBaseline(void 0, titleFont) };
|
|
19909
|
+
if (axis.titleRotation === void 0) {
|
|
19910
|
+
const gutter = 7, labelOffset2 = hasLabels || hasCustomTicks ? tickLength + gutter : 0;
|
|
19911
|
+
const labelBand = horizontal ? Math.max(customTickLabels.length > 0 ? lineBoxHeight(labelFont) : 0, ...visibleLevels.filter((level) => level.visible).map((level) => lineBoxHeight(level.font))) : labelWidth;
|
|
19912
|
+
const labelOuter2 = hasLabels ? labelOffset2 + labelBand : hasCustomTicks ? labelOffset2 : tickLength;
|
|
19913
|
+
const titleHalf = lineBoxHeight(titleFont) / 2;
|
|
19914
|
+
const titleBase = labelOuter2 > 0 ? labelOuter2 + (hasLabels ? margin2 : 0) : (strokeThickness > 0 ? strokeThickness / 2 : 0) + gutter;
|
|
19915
|
+
const titleOffset2 = titleBase + titleHalf;
|
|
19841
19916
|
const extent2 = Math.max(labelOuter2, titleVisible ? titleOffset2 + titleHalf : 0);
|
|
19842
|
-
|
|
19917
|
+
const laneSize2 = extent2 > 0 ? extent2 + gutter : strokeThickness > 0 ? Math.ceil(strokeThickness) : 0;
|
|
19918
|
+
return { measured: true, labelFont, titleFont, lane: 0, laneOffset: 0, laneSize: laneSize2, labelOffset: labelOffset2, titleOffset: titleOffset2, tickLength, labelWidth, labelAscent, labelDescent, titleWidth: title.width, titleAscent: title.ascent, titleDescent: title.descent, rotation, lineBoxTitleBaseline: title.baseline };
|
|
19843
19919
|
}
|
|
19844
19920
|
const titleBox = rotatedBounds(title.width, title.ascent, title.descent, rotation);
|
|
19845
|
-
const labelOffset = titleOnly ? 0 : horizontal ? axis.opposite ? Math.max(10, tickLength + labelDescent + 3) : Math.max(20, tickLength + labelAscent + 3) : Math.max(9, tickLength +
|
|
19846
|
-
const labelOuter = titleOnly ? 0 : horizontal ? labelOffset + (axis.opposite ? labelAscent : labelDescent) : labelOffset + labelWidth;
|
|
19921
|
+
const labelOffset = titleOnly || !hasLabels && !hasCustomTicks ? 0 : horizontal ? axis.opposite ? Math.max(10, tickLength + labelDescent + 3) : Math.max(20, tickLength + labelAscent + 3) : Math.max(9, tickLength + 5);
|
|
19922
|
+
const labelOuter = titleOnly || !hasLabels && !hasCustomTicks ? 0 : horizontal ? labelOffset + (axis.opposite ? labelAscent : labelDescent) : labelOffset + labelWidth;
|
|
19847
19923
|
const titleInner = horizontal ? axis.opposite ? titleBox.bottom : -titleBox.top : axis.opposite ? -titleBox.left : titleBox.right;
|
|
19848
19924
|
const titleOuter = horizontal ? axis.opposite ? -titleBox.top : titleBox.bottom : axis.opposite ? titleBox.right : -titleBox.left;
|
|
19849
|
-
const
|
|
19850
|
-
const
|
|
19851
|
-
const
|
|
19852
|
-
const baseline = horizontal ? 44 : 54, laneSize = contentLayout ? Math.ceil(extent + (horizontal ? 2 : 0)) : changedLayout ? Math.max(baseline, Math.ceil(extent + 8)) : baseline;
|
|
19925
|
+
const titleOffset = labelOuter + (hasLabels ? margin2 : 0) + titleInner + (labelOuter > 0 ? 2 : 5);
|
|
19926
|
+
const extent = Math.max(labelOuter, titleVisible ? titleOffset + titleOuter : 0, tickLength, strokeThickness);
|
|
19927
|
+
const laneSize = extent > 0 ? Math.ceil(extent + (horizontal ? 2 : 4)) : 0;
|
|
19853
19928
|
return { measured: true, labelFont, titleFont, lane: 0, laneOffset: 0, laneSize, labelOffset, titleOffset, tickLength, labelWidth, labelAscent, labelDescent, titleWidth: title.width, titleAscent: title.ascent, titleDescent: title.descent, rotation };
|
|
19854
19929
|
}
|
|
19855
|
-
function measureAxisCanvasLayout(ctx, axesX, axesY, theme, resolveFont
|
|
19856
|
-
const result2 = {
|
|
19930
|
+
function measureAxisCanvasLayout(ctx, axesX, axesY, theme, resolveFont) {
|
|
19931
|
+
const result2 = { contentMargins: { left: 0, right: 0, top: 0, bottom: 0 }, extraMargins: { left: 0, right: 0, top: 0, bottom: 0 }, axes: /* @__PURE__ */ new Map() };
|
|
19857
19932
|
const textCache = /* @__PURE__ */ new Map();
|
|
19858
19933
|
for (const [horizontal, list] of [[true, axesX], [false, axesY]]) for (const opposite of [false, true]) {
|
|
19859
19934
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -19864,14 +19939,14 @@ function measureAxisCanvasLayout(ctx, axesX, axesY, theme, resolveFont, contentL
|
|
|
19864
19939
|
}
|
|
19865
19940
|
let offset = 0, lane = 0;
|
|
19866
19941
|
for (const [, axes] of [...groups].sort((a, b) => a[0] - b[0])) {
|
|
19867
|
-
const values = axes.map((axis) => [axis, metrics(axis, ctx, textCache, theme, resolveFont
|
|
19942
|
+
const values = axes.map((axis) => [axis, metrics(axis, ctx, textCache, theme, resolveFont)]), size = Math.max(0, ...values.map(([, m]) => m.laneSize));
|
|
19868
19943
|
for (const [axis, value] of values) result2.axes.set(axis, { ...value, lane, laneOffset: offset, laneSize: size });
|
|
19869
19944
|
offset += size;
|
|
19870
19945
|
lane++;
|
|
19871
19946
|
}
|
|
19872
19947
|
const side = horizontal ? opposite ? "top" : "bottom" : opposite ? "right" : "left";
|
|
19873
19948
|
result2.extraMargins[side] = Math.max(0, offset - lane * (horizontal ? 44 : 54));
|
|
19874
|
-
|
|
19949
|
+
result2.contentMargins[side] = offset;
|
|
19875
19950
|
}
|
|
19876
19951
|
return result2;
|
|
19877
19952
|
}
|
|
@@ -21237,7 +21312,7 @@ var ChartXY = class {
|
|
|
21237
21312
|
this.prepareCustomTickPlacementLengths(axesX, axesY);
|
|
21238
21313
|
const layoutAxesX = axesX.filter((axis) => this.hasAxisLaneContent(axis));
|
|
21239
21314
|
const layoutAxesY = axesY.filter((axis) => this.hasAxisLaneContent(axis));
|
|
21240
|
-
this.axisCanvasLayout = this.kind === "xy" ? measureAxisCanvasLayout(this.overlayContext ?? void 0, layoutAxesX, layoutAxesY, this.theme, this.resolveTextFont
|
|
21315
|
+
this.axisCanvasLayout = this.kind === "xy" ? measureAxisCanvasLayout(this.overlayContext ?? void 0, layoutAxesX, layoutAxesY, this.theme, this.resolveTextFont) : void 0;
|
|
21241
21316
|
const axisExtra = this.axisCanvasLayout?.extraMargins ?? { left: 0, right: 0, top: 0, bottom: 0 };
|
|
21242
21317
|
const legendMargin = this.overlayContext ? this.legend.getLayout(this.overlayContext, this.legendArea()).margin : { left: 0, right: 0, top: 0, bottom: 0 };
|
|
21243
21318
|
if (this.kind === "polar") {
|
|
@@ -23190,6 +23265,7 @@ var Chart3D = class extends ChartXY {
|
|
|
23190
23265
|
this.coordsAxis.z = this.axesZ[0];
|
|
23191
23266
|
if (this.renderer?.gl && this.canvas)
|
|
23192
23267
|
this.gpu3d = new DataRenderer3D(this.renderer.gl, this.canvas);
|
|
23268
|
+
this.layout();
|
|
23193
23269
|
this.invalidate();
|
|
23194
23270
|
}
|
|
23195
23271
|
/** Project full XYZ axis coordinates with the existing original GPU camera
|
|
@@ -24978,7 +25054,7 @@ function cryChart(_options = {}) {
|
|
|
24978
25054
|
getChartCount: () => owned2.size
|
|
24979
25055
|
};
|
|
24980
25056
|
}
|
|
24981
|
-
var version = "1.0.
|
|
25057
|
+
var version = "1.0.6";
|
|
24982
25058
|
var Dashboard = class {
|
|
24983
25059
|
root;
|
|
24984
25060
|
cells = /* @__PURE__ */ new Map();
|
|
@@ -65,8 +65,8 @@ export interface AxisCanvasTheme {
|
|
|
65
65
|
export declare function measureChartTitleContent(ctx: CanvasRenderingContext2D | undefined, text: string, font: FontSettings, dpr?: number): number;
|
|
66
66
|
type TickLevel = 'great' | 'major' | 'minor';
|
|
67
67
|
export declare function resolvedTickFill(axis: Axis, level: TickLevel, style: TickStyle, theme?: AxisCanvasTheme, forDrawing?: boolean): any;
|
|
68
|
-
/**
|
|
69
|
-
export declare function measureAxisCanvasLayout(ctx: CanvasRenderingContext2D | undefined, axesX: readonly Axis[], axesY: readonly Axis[], theme?: AxisCanvasTheme, resolveFont?: (font: FontSettings) => FontSettings
|
|
68
|
+
/** Measure compact content-based axis lanes for XY charts regardless of textRenderer. */
|
|
69
|
+
export declare function measureAxisCanvasLayout(ctx: CanvasRenderingContext2D | undefined, axesX: readonly Axis[], axesY: readonly Axis[], theme?: AxisCanvasTheme, resolveFont?: (font: FontSettings) => FontSettings): AxisCanvasLayout;
|
|
70
70
|
export declare function axisCanvasLaneOffset(layout: AxisCanvasLayout, axis: Axis): number;
|
|
71
71
|
/** Keep the actual ink inside the physical axis range, without changing text.
|
|
72
72
|
* A label wider than that range cannot fit: align its nearer end and retain
|
package/dist/types/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare function cryChart(_options?: Record<string, unknown>): {
|
|
|
51
51
|
/** Live charts owned by this context; disposed charts are released immediately. */
|
|
52
52
|
getChartCount: () => number;
|
|
53
53
|
};
|
|
54
|
-
export declare const version = "1.0.
|
|
54
|
+
export declare const version = "1.0.6";
|
|
55
55
|
export declare class Dashboard {
|
|
56
56
|
readonly root: HTMLDivElement;
|
|
57
57
|
private cells;
|
package/dist/types/mesh3d.d.ts
CHANGED
|
@@ -115,6 +115,7 @@ export declare class MeshSeries3D extends Series3DBase {
|
|
|
115
115
|
protected dirty: DirtyRange[];
|
|
116
116
|
protected styleDirty: boolean;
|
|
117
117
|
private compiled?;
|
|
118
|
+
private wireTopology?;
|
|
118
119
|
private boundsCache?;
|
|
119
120
|
setGeometry(input: MeshGeometry3D): this;
|
|
120
121
|
setData(input: MeshGeometry3D | readonly MeshVertex3D[]): this;
|
package/docs/npm-usage.md
CHANGED