@crysound/crychart 1.0.3 → 1.0.4

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 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.3` keeps live charts visible while their container is resized.
9
+ Version `1.0.4` keeps long Canvas2D waveform lines visible by drawing them in bounded batches.
10
10
 
11
11
  ## Install in an application
12
12
 
13
13
  ```powershell
14
- pnpm add --save-exact @crysound/crychart@1.0.3 --registry=https://registry.npmjs.org/
14
+ pnpm add --save-exact @crysound/crychart@1.0.4 --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.3` 修复了连续调整容器大小时实时图表变空白的问题。
9
+ `1.0.4` 修复了 Canvas2D 绘制长波形时曲线消失的问题。
10
10
 
11
11
  ## 在应用中安装
12
12
 
13
13
  ```powershell
14
- pnpm add --save-exact @crysound/crychart@1.0.3 --registry=https://registry.npmjs.org/
14
+ pnpm add --save-exact @crysound/crychart@1.0.4 --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
@@ -16529,6 +16529,7 @@ void main(){
16529
16529
  if(u_dashCount>0){float phase=mod(mix(v_dashPhase.x,v_dashPhase.y,rawT),u_dashPeriod);for(int i=0;i<16;i++){if(i>=u_dashCount)break;if(phase<u_dash[i]){if(i%2==1)discard;break;}phase-=u_dash[i];}}
16530
16530
  }
16531
16531
  }`;
16532
+ var canvasStrokePointLimit = 8192;
16532
16533
  var DataRenderer = class {
16533
16534
  constructor(canvas, options = {}) {
16534
16535
  this.canvas = canvas;
@@ -17178,6 +17179,7 @@ var DataRenderer = class {
17178
17179
  ctx.lineWidth = p.thickness;
17179
17180
  ctx.setLineDash(p.mode === "line" ? [...p.dashPattern ?? []] : []);
17180
17181
  const first = p.drawFirst ?? 0, end = first + (p.drawCount ?? p.count);
17182
+ const batchSolidLine = p.mode === "line" && !p.colors && !p.dashPattern?.length && a === 1 && Number.isFinite(p.thickness) && p.thickness > 0 && end - first > canvasStrokePointLimit;
17181
17183
  if (pointOutline) for (let i = first; i < end; i++) {
17182
17184
  const x = rect.left + (p.positions[2 * i] + p.origin.x - p.domain.x.start) / (p.domain.x.end - p.domain.x.start) * rect.width;
17183
17185
  const y = rect.top + rect.height - (p.positions[2 * i + 1] + p.origin.y - p.domain.y.start) / (p.domain.y.end - p.domain.y.start) * rect.height;
@@ -17200,6 +17202,7 @@ var DataRenderer = class {
17200
17202
  }
17201
17203
  ctx.beginPath();
17202
17204
  let pen = false;
17205
+ let pathPoints = 0;
17203
17206
  let previousX = 0, previousY = 0, arcLength = 0;
17204
17207
  for (let i = first; i < end; i++) {
17205
17208
  const x = rect.left + (p.positions[2 * i] + p.origin.x - p.domain.x.start) / (p.domain.x.end - p.domain.x.start) * rect.width, y = rect.top + rect.height - (p.positions[2 * i + 1] + p.origin.y - p.domain.y.start) / (p.domain.y.end - p.domain.y.start) * rect.height;
@@ -17258,10 +17261,27 @@ var DataRenderer = class {
17258
17261
  previousX = x;
17259
17262
  previousY = y;
17260
17263
  pen = true;
17261
- } else if (pen) ctx.lineTo(x, y);
17262
- else {
17263
- ctx.moveTo(x, y);
17264
- pen = true;
17264
+ } else {
17265
+ if (batchSolidLine && pathPoints === canvasStrokePointLimit - 1) {
17266
+ const midX = previousX / 2 + x / 2;
17267
+ const midY = previousY / 2 + y / 2;
17268
+ if (pen) ctx.lineTo(midX, midY);
17269
+ ctx.stroke();
17270
+ this.stats.drawCalls++;
17271
+ ctx.beginPath();
17272
+ if (pen) ctx.moveTo(midX, midY);
17273
+ pathPoints = pen ? 1 : 0;
17274
+ }
17275
+ if (pen) ctx.lineTo(x, y);
17276
+ else {
17277
+ ctx.moveTo(x, y);
17278
+ pen = true;
17279
+ }
17280
+ if (batchSolidLine) {
17281
+ previousX = x;
17282
+ previousY = y;
17283
+ pathPoints++;
17284
+ }
17265
17285
  }
17266
17286
  }
17267
17287
  if (!p.colors) {
@@ -25142,7 +25162,7 @@ function cryChart(_options = {}) {
25142
25162
  getChartCount: () => owned2.size
25143
25163
  };
25144
25164
  }
25145
- var version = "1.0.3";
25165
+ var version = "1.0.4";
25146
25166
  var Dashboard = class {
25147
25167
  root;
25148
25168
  cells = /* @__PURE__ */ new Map();
@@ -16529,6 +16529,7 @@ void main(){
16529
16529
  if(u_dashCount>0){float phase=mod(mix(v_dashPhase.x,v_dashPhase.y,rawT),u_dashPeriod);for(int i=0;i<16;i++){if(i>=u_dashCount)break;if(phase<u_dash[i]){if(i%2==1)discard;break;}phase-=u_dash[i];}}
16530
16530
  }
16531
16531
  }`;
16532
+ var canvasStrokePointLimit = 8192;
16532
16533
  var DataRenderer = class {
16533
16534
  constructor(canvas, options = {}) {
16534
16535
  this.canvas = canvas;
@@ -17178,6 +17179,7 @@ void main(){
17178
17179
  ctx.lineWidth = p.thickness;
17179
17180
  ctx.setLineDash(p.mode === "line" ? [...p.dashPattern ?? []] : []);
17180
17181
  const first = p.drawFirst ?? 0, end = first + (p.drawCount ?? p.count);
17182
+ const batchSolidLine = p.mode === "line" && !p.colors && !p.dashPattern?.length && a === 1 && Number.isFinite(p.thickness) && p.thickness > 0 && end - first > canvasStrokePointLimit;
17181
17183
  if (pointOutline) for (let i = first; i < end; i++) {
17182
17184
  const x = rect.left + (p.positions[2 * i] + p.origin.x - p.domain.x.start) / (p.domain.x.end - p.domain.x.start) * rect.width;
17183
17185
  const y = rect.top + rect.height - (p.positions[2 * i + 1] + p.origin.y - p.domain.y.start) / (p.domain.y.end - p.domain.y.start) * rect.height;
@@ -17200,6 +17202,7 @@ void main(){
17200
17202
  }
17201
17203
  ctx.beginPath();
17202
17204
  let pen = false;
17205
+ let pathPoints = 0;
17203
17206
  let previousX = 0, previousY = 0, arcLength = 0;
17204
17207
  for (let i = first; i < end; i++) {
17205
17208
  const x = rect.left + (p.positions[2 * i] + p.origin.x - p.domain.x.start) / (p.domain.x.end - p.domain.x.start) * rect.width, y = rect.top + rect.height - (p.positions[2 * i + 1] + p.origin.y - p.domain.y.start) / (p.domain.y.end - p.domain.y.start) * rect.height;
@@ -17258,10 +17261,27 @@ void main(){
17258
17261
  previousX = x;
17259
17262
  previousY = y;
17260
17263
  pen = true;
17261
- } else if (pen) ctx.lineTo(x, y);
17262
- else {
17263
- ctx.moveTo(x, y);
17264
- pen = true;
17264
+ } else {
17265
+ if (batchSolidLine && pathPoints === canvasStrokePointLimit - 1) {
17266
+ const midX = previousX / 2 + x / 2;
17267
+ const midY = previousY / 2 + y / 2;
17268
+ if (pen) ctx.lineTo(midX, midY);
17269
+ ctx.stroke();
17270
+ this.stats.drawCalls++;
17271
+ ctx.beginPath();
17272
+ if (pen) ctx.moveTo(midX, midY);
17273
+ pathPoints = pen ? 1 : 0;
17274
+ }
17275
+ if (pen) ctx.lineTo(x, y);
17276
+ else {
17277
+ ctx.moveTo(x, y);
17278
+ pen = true;
17279
+ }
17280
+ if (batchSolidLine) {
17281
+ previousX = x;
17282
+ previousY = y;
17283
+ pathPoints++;
17284
+ }
17265
17285
  }
17266
17286
  }
17267
17287
  if (!p.colors) {
@@ -25142,7 +25162,7 @@ ${sample.position[0].toFixed(4)}, ${sample.position[1].toFixed(4)}`, contains: (
25142
25162
  getChartCount: () => owned2.size
25143
25163
  };
25144
25164
  }
25145
- var version = "1.0.3";
25165
+ var version = "1.0.4";
25146
25166
  var Dashboard = class {
25147
25167
  root;
25148
25168
  cells = /* @__PURE__ */ new Map();
package/dist/crychart.js CHANGED
@@ -16345,6 +16345,7 @@ void main(){
16345
16345
  if(u_dashCount>0){float phase=mod(mix(v_dashPhase.x,v_dashPhase.y,rawT),u_dashPeriod);for(int i=0;i<16;i++){if(i>=u_dashCount)break;if(phase<u_dash[i]){if(i%2==1)discard;break;}phase-=u_dash[i];}}
16346
16346
  }
16347
16347
  }`;
16348
+ var canvasStrokePointLimit = 8192;
16348
16349
  var DataRenderer = class {
16349
16350
  constructor(canvas, options = {}) {
16350
16351
  this.canvas = canvas;
@@ -16994,6 +16995,7 @@ var DataRenderer = class {
16994
16995
  ctx.lineWidth = p.thickness;
16995
16996
  ctx.setLineDash(p.mode === "line" ? [...p.dashPattern ?? []] : []);
16996
16997
  const first = p.drawFirst ?? 0, end = first + (p.drawCount ?? p.count);
16998
+ const batchSolidLine = p.mode === "line" && !p.colors && !p.dashPattern?.length && a === 1 && Number.isFinite(p.thickness) && p.thickness > 0 && end - first > canvasStrokePointLimit;
16997
16999
  if (pointOutline) for (let i = first; i < end; i++) {
16998
17000
  const x = rect.left + (p.positions[2 * i] + p.origin.x - p.domain.x.start) / (p.domain.x.end - p.domain.x.start) * rect.width;
16999
17001
  const y = rect.top + rect.height - (p.positions[2 * i + 1] + p.origin.y - p.domain.y.start) / (p.domain.y.end - p.domain.y.start) * rect.height;
@@ -17016,6 +17018,7 @@ var DataRenderer = class {
17016
17018
  }
17017
17019
  ctx.beginPath();
17018
17020
  let pen = false;
17021
+ let pathPoints = 0;
17019
17022
  let previousX = 0, previousY = 0, arcLength = 0;
17020
17023
  for (let i = first; i < end; i++) {
17021
17024
  const x = rect.left + (p.positions[2 * i] + p.origin.x - p.domain.x.start) / (p.domain.x.end - p.domain.x.start) * rect.width, y = rect.top + rect.height - (p.positions[2 * i + 1] + p.origin.y - p.domain.y.start) / (p.domain.y.end - p.domain.y.start) * rect.height;
@@ -17074,10 +17077,27 @@ var DataRenderer = class {
17074
17077
  previousX = x;
17075
17078
  previousY = y;
17076
17079
  pen = true;
17077
- } else if (pen) ctx.lineTo(x, y);
17078
- else {
17079
- ctx.moveTo(x, y);
17080
- pen = true;
17080
+ } else {
17081
+ if (batchSolidLine && pathPoints === canvasStrokePointLimit - 1) {
17082
+ const midX = previousX / 2 + x / 2;
17083
+ const midY = previousY / 2 + y / 2;
17084
+ if (pen) ctx.lineTo(midX, midY);
17085
+ ctx.stroke();
17086
+ this.stats.drawCalls++;
17087
+ ctx.beginPath();
17088
+ if (pen) ctx.moveTo(midX, midY);
17089
+ pathPoints = pen ? 1 : 0;
17090
+ }
17091
+ if (pen) ctx.lineTo(x, y);
17092
+ else {
17093
+ ctx.moveTo(x, y);
17094
+ pen = true;
17095
+ }
17096
+ if (batchSolidLine) {
17097
+ previousX = x;
17098
+ previousY = y;
17099
+ pathPoints++;
17100
+ }
17081
17101
  }
17082
17102
  }
17083
17103
  if (!p.colors) {
@@ -24958,7 +24978,7 @@ function cryChart(_options = {}) {
24958
24978
  getChartCount: () => owned2.size
24959
24979
  };
24960
24980
  }
24961
- var version = "1.0.3";
24981
+ var version = "1.0.4";
24962
24982
  var Dashboard = class {
24963
24983
  root;
24964
24984
  cells = /* @__PURE__ */ new Map();
@@ -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.3";
54
+ export declare const version = "1.0.4";
55
55
  export declare class Dashboard {
56
56
  readonly root: HTMLDivElement;
57
57
  private cells;
package/docs/npm-usage.md CHANGED
@@ -3,7 +3,7 @@
3
3
  在应用目录安装固定版本:
4
4
 
5
5
  ```powershell
6
- pnpm add --save-exact @crysound/crychart@1.0.3 --registry=https://registry.npmjs.org/
6
+ pnpm add --save-exact @crysound/crychart@1.0.4 --registry=https://registry.npmjs.org/
7
7
  ```
8
8
 
9
9
  ES 模块和 TypeScript 使用相同入口:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crysound/crychart",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "CRYChart chart engine with streaming data, interactive axes and WebGL rendering",
5
5
  "type": "module",
6
6
  "main": "./dist/crychart.cjs",