@crysound/crychart 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -2
- package/README.zh-CN.md +24 -2
- package/dist/crychart.cjs +479 -38
- package/dist/crychart.global.js +479 -38
- package/dist/crychart.js +479 -38
- package/dist/types/adapters/opentest.d.ts +3 -1
- package/dist/types/chart.d.ts +9 -0
- package/dist/types/index.d.ts +13 -2
- package/dist/types/mesh3d.d.ts +1 -0
- package/dist/types/render-heatmap.d.ts +2 -0
- package/dist/types/render.d.ts +4 -0
- package/dist/types/shared-webgl-context.d.ts +83 -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.7` adds an opt-in `SharedWebGLContext` mode so multiple 2D charts (`ChartXY` and `Polar`) share a single WebGL2 context without hitting browser WebGL context limits, while keeping the default per-chart mode unchanged.
|
|
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.7 --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.
|
|
@@ -49,6 +49,28 @@ line.appendSamples({ y: new Float32Array([1, 2, 3]) }, { start: 0, step: 0.001 }
|
|
|
49
49
|
context.dispose()
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
### Shared WebGL2 context (opt-in for many 2D charts)
|
|
53
|
+
|
|
54
|
+
When rendering many `ChartXY` / `Polar` instances on one page, create a page-level `SharedWebGLContext` singleton and pass it to `cryChart({ sharedContext })`:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { cryChart, SharedWebGLContext } from '@crysound/crychart'
|
|
58
|
+
|
|
59
|
+
let shared: SharedWebGLContext | undefined
|
|
60
|
+
export function getAppSharedWebGLContext() {
|
|
61
|
+
return shared && !shared.isDisposed()
|
|
62
|
+
? shared
|
|
63
|
+
: (shared = new SharedWebGLContext({ cullOffscreen: true }))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const context = cryChart({ sharedContext: getAppSharedWebGLContext() })
|
|
67
|
+
const chart = context.ChartXY({ container: document.getElementById('chart')! })
|
|
68
|
+
// Dispose charts/contexts before disposing an externally created SharedWebGLContext.
|
|
69
|
+
context.dispose()
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Notes: `SharedWebGLContext` applies to `ChartXY` and `Polar` only (`Chart3D` keeps its own WebGL2 context and throws `UnsupportedFeatureError` if passed `sharedContext` explicitly); `chart.canvas` uses a 2D presentation context in shared mode; MSAA is controlled by `SharedContextOptions.antialias`; offscreen charts pause scheduled redraws/animations until visible again. See [CHANGELOG.md](CHANGELOG.md) for full details.
|
|
73
|
+
|
|
52
74
|
The package provides ES modules, CommonJS, a browser script, and TypeScript declarations. The browser script exposes the `CRYChart` global. Themes are available through `@crysound/crychart/themes`.
|
|
53
75
|
|
|
54
76
|
## Validation
|
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.7` 新增可选的共享 WebGL2 上下文模式(`SharedWebGLContext`),允许同一页面的多张二维图表(`ChartXY` / `Polar`)共用单个 WebGL2 上下文以突破浏览器上下文数量限制,默认独立上下文行为保持不变。
|
|
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.7 --registry=https://registry.npmjs.org/
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
提交应用的锁文件,后续执行 `pnpm install --frozen-lockfile`。包入口和旧 `crychart` 包名的迁移方式见 [npm 使用说明](docs/npm-usage.md)。
|
|
@@ -47,6 +47,28 @@ line.appendSamples({ y: new Float32Array([1, 2, 3]) }, { start: 0, step: 0.001 }
|
|
|
47
47
|
context.dispose()
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
### 共享 WebGL2 上下文(多张二维图可选启用)
|
|
51
|
+
|
|
52
|
+
同屏渲染大量 `ChartXY` / `Polar` 图表时,可维护页面级 `SharedWebGLContext` 单例并传给 `cryChart({ sharedContext })`:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { cryChart, SharedWebGLContext } from '@crysound/crychart'
|
|
56
|
+
|
|
57
|
+
let shared: SharedWebGLContext | undefined
|
|
58
|
+
export function getAppSharedWebGLContext() {
|
|
59
|
+
return shared && !shared.isDisposed()
|
|
60
|
+
? shared
|
|
61
|
+
: (shared = new SharedWebGLContext({ cullOffscreen: true }))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const context = cryChart({ sharedContext: getAppSharedWebGLContext() })
|
|
65
|
+
const chart = context.ChartXY({ container: document.getElementById('chart')! })
|
|
66
|
+
// 请先销毁图表/上下文,再销毁外部创建的 SharedWebGLContext。
|
|
67
|
+
context.dispose()
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
说明:仅支持 `ChartXY` 和 `Polar`(`Chart3D` 保持独立上下文,显式传入 `sharedContext` 会抛出 `UnsupportedFeatureError`);共享模式下 `chart.canvas` 为 2D 展示画布;抗锯齿由共享上下文的 `antialias` 控制;离屏图表会暂停排帧及动画,回到视口后自动恢复。完整说明见 [CHANGELOG.md](CHANGELOG.md)。
|
|
71
|
+
|
|
50
72
|
包提供 ES 模块、CommonJS、浏览器脚本和 TypeScript 类型声明。浏览器脚本的全局对象为 `CRYChart`。主题入口为 `@crysound/crychart/themes`。
|
|
51
73
|
|
|
52
74
|
## 验证
|