chartgpu-angular 0.0.0-stage → 19.0.0
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/LICENSE +21 -0
- package/README.md +123 -2
- package/fesm2022/chartgpu-angular.mjs +435 -0
- package/fesm2022/chartgpu-angular.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/chartgpu-angular.component.d.ts +94 -0
- package/lib/chartgpu-angular.types.d.ts +89 -0
- package/lib/connect-charts.directive.d.ts +16 -0
- package/lib/gpu-context.provider.d.ts +1 -0
- package/lib/gpu-context.service.d.ts +20 -0
- package/package.json +42 -3
- package/public-api.d.ts +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Naren
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,124 @@
|
|
|
1
|
-
#
|
|
1
|
+
# chartgpu-angular
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An Angular wrapper for ChartGPU, a chart rendering runtime for building responsive, interactive charts in Angular templates.
|
|
4
|
+
|
|
5
|
+
This is an unofficial wrapper library. It is not affiliated with, endorsed by, or sponsored by ChartGPU or any other upstream vendor unless explicitly stated otherwise.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/chartgpu-angular)
|
|
8
|
+
[](https://www.npmjs.com/package/chartgpu-angular)
|
|
9
|
+
[](https://github.com/kai1992cool/chartgpu-angular)
|
|
10
|
+
[](https://github.com/kai1992cool/chartgpu-angular/blob/master/LICENSE)
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- Uses ChartGPU rendering through Angular components and directives.
|
|
15
|
+
- Configure charts with standard options and theme updates.
|
|
16
|
+
- Define chart content with Angular templates.
|
|
17
|
+
- Bind chart events as Angular outputs.
|
|
18
|
+
- Use shared GPU context handling for dashboards and multiple charts.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
### 1. Install the package
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install chartgpu-angular
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Key Implementation Notes:
|
|
29
|
+
|
|
30
|
+
* **This project is an unofficial wrapper library.**
|
|
31
|
+
* **WebGPU is required for rendering.**
|
|
32
|
+
* **The shared GPU context service is intended for dashboard-style reuse.**
|
|
33
|
+
|
|
34
|
+
## Angular version examples & Documentation
|
|
35
|
+
|
|
36
|
+
StackBlitz examples will be added as each Angular version's rollout is published.
|
|
37
|
+
|
|
38
|
+
> If you click the link for Standalone and NgModule examples are stuck in clone step, please refresh the screen, the stackblitz will initialize
|
|
39
|
+
|
|
40
|
+
| Angular version | Standalone example | NgModule example | Documentation |
|
|
41
|
+
| --------------- | ------------------ | ---------------- | ------------- |
|
|
42
|
+
| Angular 14 | [Modular Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/14/modular) | [Standalone Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/14/standalone) | [Storybook](https://kai1992cool.github.io/chartgpu-angular/demos?version=14) |
|
|
43
|
+
| Angular 15 | [Modular Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/15/modular) | [Standalone Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/15/standalone) | [Storybook](https://kai1992cool.github.io/chartgpu-angular/demos?version=15) |
|
|
44
|
+
| Angular 16 | [Modular Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/16/modular) | [Standalone Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/16/standalone) | [Storybook](https://kai1992cool.github.io/chartgpu-angular/demos?version=16) |
|
|
45
|
+
| Angular 17 | [Modular Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/17/modular) | [Standalone Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/17/standalone) | [Storybook](https://kai1992cool.github.io/chartgpu-angular/demos?version=17) |
|
|
46
|
+
| Angular 18 | [Modular Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/18/modular) | [Standalone Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/18/standalone) | [Storybook](https://kai1992cool.github.io/chartgpu-angular/demos?version=18) |
|
|
47
|
+
| Angular 19 | [Modular Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/19/modular) | [Standalone Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/19/standalone) | [Storybook](https://kai1992cool.github.io/chartgpu-angular/demos?version=19) |
|
|
48
|
+
| Angular 20 | [Modular Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/20/modular) | [Standalone Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/20/standalone) | [Storybook](https://kai1992cool.github.io/chartgpu-angular/demos?version=20) |
|
|
49
|
+
| Angular 21 | [Modular Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/21/modular) | [Standalone Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/21/standalone) | [Storybook](https://kai1992cool.github.io/chartgpu-angular/demos?version=21) |
|
|
50
|
+
| Angular 22 | [Modular Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/22/modular) | [Standalone Demo](https://stackblitz.com/github/kai1992cool/chartgpu-angular/tree/main/demos/22/standalone) | [Storybook](https://kai1992cool.github.io/chartgpu-angular/demos?version=22) |
|
|
51
|
+
|
|
52
|
+
Example usage:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { Component } from '@angular/core';
|
|
56
|
+
import { ChartGPUComponent, provideChartGpuContext } from 'chartgpu-angular';
|
|
57
|
+
|
|
58
|
+
@Component({
|
|
59
|
+
standalone: true,
|
|
60
|
+
imports: [ChartGPUComponent],
|
|
61
|
+
providers: [provideChartGpuContext()],
|
|
62
|
+
template: `<lib-chartgpu-angular />`,
|
|
63
|
+
})
|
|
64
|
+
export class ExampleComponent {}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Configuring Styling
|
|
68
|
+
|
|
69
|
+
### 1. Simplest way
|
|
70
|
+
|
|
71
|
+
The default setup should include the required chart styles for the component, so no separate CSS setup is usually needed.
|
|
72
|
+
|
|
73
|
+
### 2. Configure chart CSS (when needed)
|
|
74
|
+
If you need additional styles for chart modules or custom visual effects, serve the CSS files as assets in your application configuration.
|
|
75
|
+
|
|
76
|
+
Then pass the asset URL in the appropriate style injection option used by the component.
|
|
77
|
+
|
|
78
|
+
## Setup
|
|
79
|
+
|
|
80
|
+
Choose the setup that matches your Angular application.
|
|
81
|
+
|
|
82
|
+
### Standalone application
|
|
83
|
+
|
|
84
|
+
Import `ChartGPUComponent` from `chartgpu-angular` and add it to the `imports` array of each standalone component that uses it. Add `provideChartGpuContext()` to the component or application providers when you want a shared GPU context service:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { Component } from '@angular/core';
|
|
88
|
+
import { ChartGPUComponent, provideChartGpuContext } from 'chartgpu-angular';
|
|
89
|
+
|
|
90
|
+
@Component({
|
|
91
|
+
standalone: true,
|
|
92
|
+
imports: [ChartGPUComponent],
|
|
93
|
+
providers: [provideChartGpuContext()],
|
|
94
|
+
template: `<lib-chartgpu-angular />`,
|
|
95
|
+
})
|
|
96
|
+
export class ExampleComponent {}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### NgModule application
|
|
100
|
+
|
|
101
|
+
Import `ChartGPUComponent` in the `imports` array of the module that declares the component using it. If you need the shared GPU context service, provide it from the module providers with `provideChartGpuContext()`:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { NgModule } from '@angular/core';
|
|
105
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
106
|
+
import { AppComponent } from './app.component';
|
|
107
|
+
import { ChartGPUComponent, provideChartGpuContext } from 'chartgpu-angular';
|
|
108
|
+
|
|
109
|
+
@NgModule({
|
|
110
|
+
declarations: [AppComponent],
|
|
111
|
+
imports: [BrowserModule, ChartGPUComponent],
|
|
112
|
+
providers: [provideChartGpuContext()],
|
|
113
|
+
bootstrap: [AppComponent],
|
|
114
|
+
})
|
|
115
|
+
export class AppModule {}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Documentation and demos
|
|
119
|
+
|
|
120
|
+
- [ChartGPU documentation](https://chartgpu.io/docs/)
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { NgStyle } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { input, output, viewChild, signal, afterNextRender, effect, untracked, ChangeDetectionStrategy, Component, Directive, computed, Injectable, makeEnvironmentProviders } from '@angular/core';
|
|
4
|
+
import { ChartGPU, connectCharts, createPipelineCache } from 'chartgpu';
|
|
5
|
+
|
|
6
|
+
class ChartGpuAngularComponent {
|
|
7
|
+
destroyRef;
|
|
8
|
+
options = input.required();
|
|
9
|
+
gpuContext = input(null);
|
|
10
|
+
theme = input(undefined);
|
|
11
|
+
className = input();
|
|
12
|
+
style = input();
|
|
13
|
+
ready = output();
|
|
14
|
+
chartReady = output();
|
|
15
|
+
chartDispose = output();
|
|
16
|
+
resize = output();
|
|
17
|
+
click = output();
|
|
18
|
+
chartClick = output();
|
|
19
|
+
mouseOver = output();
|
|
20
|
+
mouseOut = output();
|
|
21
|
+
crosshairMove = output();
|
|
22
|
+
dataAppend = output();
|
|
23
|
+
zoomChange = output();
|
|
24
|
+
zoomRangeChange = output();
|
|
25
|
+
deviceLost = output();
|
|
26
|
+
chartError = output();
|
|
27
|
+
host = viewChild('host');
|
|
28
|
+
canvasHost = viewChild('canvasHost');
|
|
29
|
+
chartInstance = signal(null);
|
|
30
|
+
initializationError = signal(null);
|
|
31
|
+
chartContainer;
|
|
32
|
+
createdWithOptions;
|
|
33
|
+
resizeTimeout;
|
|
34
|
+
resizeObserver;
|
|
35
|
+
removeChartListeners;
|
|
36
|
+
destroying = false;
|
|
37
|
+
constructor(destroyRef) {
|
|
38
|
+
this.destroyRef = destroyRef;
|
|
39
|
+
this.destroyRef.onDestroy(() => {
|
|
40
|
+
this.resizeObserver?.disconnect();
|
|
41
|
+
if (this.resizeTimeout !== undefined) {
|
|
42
|
+
clearTimeout(this.resizeTimeout);
|
|
43
|
+
}
|
|
44
|
+
this.disposeChart();
|
|
45
|
+
});
|
|
46
|
+
afterNextRender(() => {
|
|
47
|
+
const container = this.host()?.nativeElement;
|
|
48
|
+
if (container) {
|
|
49
|
+
this.observeResize(container);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
effect(onCleanup => {
|
|
53
|
+
const container = this.canvasHost()?.nativeElement;
|
|
54
|
+
const options = this.options();
|
|
55
|
+
const gpuContext = this.gpuContext();
|
|
56
|
+
const theme = this.theme();
|
|
57
|
+
this.initializationError.set(null);
|
|
58
|
+
if (!container) {
|
|
59
|
+
this.disposeChart();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (typeof navigator === 'undefined' || !('gpu' in navigator)) {
|
|
63
|
+
this.reportError(new Error('WebGPU not supported in this browser'));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (untracked(() => this.chartInstance()) && this.chartContainer === container) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
let cancelled = false;
|
|
70
|
+
let createdInstance;
|
|
71
|
+
const initialOptions = this.getEffectiveOptions(options, theme);
|
|
72
|
+
void (gpuContext
|
|
73
|
+
? ChartGPU.create(container, initialOptions, gpuContext)
|
|
74
|
+
: ChartGPU.create(container, initialOptions)).then(instance => {
|
|
75
|
+
createdInstance = instance;
|
|
76
|
+
if (cancelled) {
|
|
77
|
+
instance.dispose();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const latest = untracked(() => ({
|
|
82
|
+
options: this.options(),
|
|
83
|
+
theme: this.theme(),
|
|
84
|
+
}));
|
|
85
|
+
if (latest.options !== options || latest.theme !== theme) {
|
|
86
|
+
instance.setOption(this.getEffectiveOptions(latest.options, latest.theme));
|
|
87
|
+
}
|
|
88
|
+
this.createdWithOptions = latest;
|
|
89
|
+
this.chartContainer = container;
|
|
90
|
+
this.chartInstance.set(instance);
|
|
91
|
+
this.removeChartListeners = this.listenToChart(instance);
|
|
92
|
+
this.ready.emit({ container });
|
|
93
|
+
this.chartReady.emit(instance);
|
|
94
|
+
const range = instance.getZoomRange();
|
|
95
|
+
if (range) {
|
|
96
|
+
this.emitZoomRange(range);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (cause) {
|
|
100
|
+
instance.dispose();
|
|
101
|
+
throw cause;
|
|
102
|
+
}
|
|
103
|
+
}).catch((cause) => {
|
|
104
|
+
if (cancelled) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (createdInstance && this.chartInstance() !== createdInstance && !createdInstance.disposed) {
|
|
108
|
+
createdInstance.dispose();
|
|
109
|
+
}
|
|
110
|
+
this.reportError(cause);
|
|
111
|
+
});
|
|
112
|
+
onCleanup(() => {
|
|
113
|
+
cancelled = true;
|
|
114
|
+
if (this.chartContainer === container) {
|
|
115
|
+
this.disposeChart();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}, { allowSignalWrites: true });
|
|
119
|
+
effect(() => {
|
|
120
|
+
const options = this.options();
|
|
121
|
+
const theme = this.theme();
|
|
122
|
+
const instance = this.chartInstance();
|
|
123
|
+
if (!instance || instance.disposed) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (this.createdWithOptions?.options === options && this.createdWithOptions.theme === theme) {
|
|
127
|
+
this.createdWithOptions = undefined;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
instance.setOption(this.getEffectiveOptions(options, theme));
|
|
132
|
+
}
|
|
133
|
+
catch (cause) {
|
|
134
|
+
this.reportError(cause);
|
|
135
|
+
}
|
|
136
|
+
}, { allowSignalWrites: true });
|
|
137
|
+
}
|
|
138
|
+
emitClick(event) {
|
|
139
|
+
this.click.emit({ x: event.offsetX, y: event.offsetY });
|
|
140
|
+
}
|
|
141
|
+
ngOnDestroy() {
|
|
142
|
+
this.destroying = true;
|
|
143
|
+
}
|
|
144
|
+
getChart() {
|
|
145
|
+
const instance = this.chartInstance();
|
|
146
|
+
return instance && !instance.disposed ? instance : null;
|
|
147
|
+
}
|
|
148
|
+
getContainer() {
|
|
149
|
+
return this.canvasHost()?.nativeElement ?? null;
|
|
150
|
+
}
|
|
151
|
+
appendData(seriesIndex, newPoints, options) {
|
|
152
|
+
this.getChart()?.appendData(seriesIndex, newPoints, options);
|
|
153
|
+
}
|
|
154
|
+
renderFrame() {
|
|
155
|
+
return this.getChart()?.renderFrame() ?? false;
|
|
156
|
+
}
|
|
157
|
+
needsRender() {
|
|
158
|
+
return this.getChart()?.needsRender() ?? false;
|
|
159
|
+
}
|
|
160
|
+
getRenderMode() {
|
|
161
|
+
return this.getChart()?.getRenderMode() ?? 'auto';
|
|
162
|
+
}
|
|
163
|
+
setRenderMode(mode) {
|
|
164
|
+
this.getChart()?.setRenderMode(mode);
|
|
165
|
+
}
|
|
166
|
+
setOption(options) {
|
|
167
|
+
this.getChart()?.setOption(options);
|
|
168
|
+
}
|
|
169
|
+
setZoomRange(start, end, source) {
|
|
170
|
+
this.getChart()?.setZoomRange(start, end, source);
|
|
171
|
+
}
|
|
172
|
+
setInteractionX(x, source) {
|
|
173
|
+
this.getChart()?.setInteractionX(x, source);
|
|
174
|
+
}
|
|
175
|
+
getInteractionX() {
|
|
176
|
+
return this.getChart()?.getInteractionX() ?? null;
|
|
177
|
+
}
|
|
178
|
+
hitTest(event) {
|
|
179
|
+
return this.getChart()?.hitTest(event) ?? null;
|
|
180
|
+
}
|
|
181
|
+
getEffectiveOptions(options, theme) {
|
|
182
|
+
return theme !== undefined ? { ...options, theme } : options;
|
|
183
|
+
}
|
|
184
|
+
listenToChart(instance) {
|
|
185
|
+
const click = (payload) => this.chartClick.emit(payload);
|
|
186
|
+
const mouseOver = (payload) => this.mouseOver.emit(payload);
|
|
187
|
+
const mouseOut = (payload) => this.mouseOut.emit(payload);
|
|
188
|
+
const crosshairMove = (payload) => this.crosshairMove.emit(payload);
|
|
189
|
+
const dataAppend = (payload) => this.dataAppend.emit(payload);
|
|
190
|
+
const zoomChange = (payload) => this.emitZoomRange(payload);
|
|
191
|
+
const deviceLost = (payload) => this.deviceLost.emit(payload);
|
|
192
|
+
instance.on('click', click);
|
|
193
|
+
instance.on('mouseover', mouseOver);
|
|
194
|
+
instance.on('mouseout', mouseOut);
|
|
195
|
+
instance.on('crosshairMove', crosshairMove);
|
|
196
|
+
instance.on('dataAppend', dataAppend);
|
|
197
|
+
instance.on('zoomRangeChange', zoomChange);
|
|
198
|
+
instance.on('deviceLost', deviceLost);
|
|
199
|
+
return () => {
|
|
200
|
+
if (instance.disposed) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
instance.off('click', click);
|
|
204
|
+
instance.off('mouseover', mouseOver);
|
|
205
|
+
instance.off('mouseout', mouseOut);
|
|
206
|
+
instance.off('crosshairMove', crosshairMove);
|
|
207
|
+
instance.off('dataAppend', dataAppend);
|
|
208
|
+
instance.off('zoomRangeChange', zoomChange);
|
|
209
|
+
instance.off('deviceLost', deviceLost);
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
emitZoomRange(range) {
|
|
213
|
+
this.zoomChange.emit({ range: { start: range.start, end: range.end } });
|
|
214
|
+
this.zoomRangeChange.emit({ start: range.start, end: range.end });
|
|
215
|
+
}
|
|
216
|
+
observeResize(container) {
|
|
217
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
221
|
+
const entry = entries[0];
|
|
222
|
+
if (!entry) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const { width, height } = entry.contentRect;
|
|
226
|
+
this.resize.emit({ width, height, container });
|
|
227
|
+
if (this.resizeTimeout !== undefined) {
|
|
228
|
+
clearTimeout(this.resizeTimeout);
|
|
229
|
+
}
|
|
230
|
+
this.resizeTimeout = setTimeout(() => {
|
|
231
|
+
this.chartInstance()?.resize();
|
|
232
|
+
this.resizeTimeout = undefined;
|
|
233
|
+
}, 100);
|
|
234
|
+
});
|
|
235
|
+
this.resizeObserver.observe(container);
|
|
236
|
+
}
|
|
237
|
+
reportError(cause) {
|
|
238
|
+
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
239
|
+
this.initializationError.set(error);
|
|
240
|
+
this.chartError.emit(error);
|
|
241
|
+
}
|
|
242
|
+
disposeChart() {
|
|
243
|
+
const instance = this.chartInstance();
|
|
244
|
+
this.removeChartListeners?.();
|
|
245
|
+
this.removeChartListeners = undefined;
|
|
246
|
+
if (instance && !instance.disposed) {
|
|
247
|
+
instance.dispose();
|
|
248
|
+
if (!this.destroying) {
|
|
249
|
+
this.chartDispose.emit();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
this.chartInstance.set(null);
|
|
253
|
+
this.chartContainer = undefined;
|
|
254
|
+
this.createdWithOptions = undefined;
|
|
255
|
+
}
|
|
256
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ChartGpuAngularComponent, deps: [{ token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
257
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: ChartGpuAngularComponent, isStandalone: true, selector: "lib-chartgpu-angular", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null }, gpuContext: { classPropertyName: "gpuContext", publicName: "gpuContext", isSignal: true, isRequired: false, transformFunction: null }, theme: { classPropertyName: "theme", publicName: "theme", isSignal: true, isRequired: false, transformFunction: null }, className: { classPropertyName: "className", publicName: "className", isSignal: true, isRequired: false, transformFunction: null }, style: { classPropertyName: "style", publicName: "style", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ready: "ready", chartReady: "chartReady", chartDispose: "chartDispose", resize: "resize", click: "click", chartClick: "chartClick", mouseOver: "mouseOver", mouseOut: "mouseOut", crosshairMove: "crosshairMove", dataAppend: "dataAppend", zoomChange: "zoomChange", zoomRangeChange: "zoomRangeChange", deviceLost: "deviceLost", chartError: "chartError" }, host: { classAttribute: "chartgpu-angular" }, viewQueries: [{ propertyName: "host", first: true, predicate: ["host"], descendants: true, isSignal: true }, { propertyName: "canvasHost", first: true, predicate: ["canvasHost"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
258
|
+
<div
|
|
259
|
+
#host
|
|
260
|
+
class="chartgpu-host"
|
|
261
|
+
[class]="className() ?? ''"
|
|
262
|
+
[ngStyle]="style()"
|
|
263
|
+
(click)="emitClick($event)"
|
|
264
|
+
>
|
|
265
|
+
<div #canvasHost class="chartgpu-canvas-host"></div>
|
|
266
|
+
@if (initializationError(); as error) {
|
|
267
|
+
<div class="chartgpu-error" role="alert">{{ error.message }}</div>
|
|
268
|
+
}
|
|
269
|
+
</div>
|
|
270
|
+
`, isInline: true, styles: [":host{display:block;width:100%;height:100%}.chartgpu-host{position:relative;width:100%;height:100%}.chartgpu-canvas-host{position:absolute;inset:0}.chartgpu-error{position:absolute;inset:0;display:grid;place-items:center;padding:1rem;text-align:center}\n"], dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
271
|
+
}
|
|
272
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ChartGpuAngularComponent, decorators: [{
|
|
273
|
+
type: Component,
|
|
274
|
+
args: [{ selector: 'lib-chartgpu-angular', standalone: true, imports: [NgStyle], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'chartgpu-angular' }, template: `
|
|
275
|
+
<div
|
|
276
|
+
#host
|
|
277
|
+
class="chartgpu-host"
|
|
278
|
+
[class]="className() ?? ''"
|
|
279
|
+
[ngStyle]="style()"
|
|
280
|
+
(click)="emitClick($event)"
|
|
281
|
+
>
|
|
282
|
+
<div #canvasHost class="chartgpu-canvas-host"></div>
|
|
283
|
+
@if (initializationError(); as error) {
|
|
284
|
+
<div class="chartgpu-error" role="alert">{{ error.message }}</div>
|
|
285
|
+
}
|
|
286
|
+
</div>
|
|
287
|
+
`, styles: [":host{display:block;width:100%;height:100%}.chartgpu-host{position:relative;width:100%;height:100%}.chartgpu-canvas-host{position:absolute;inset:0}.chartgpu-error{position:absolute;inset:0;display:grid;place-items:center;padding:1rem;text-align:center}\n"] }]
|
|
288
|
+
}], ctorParameters: () => [{ type: i0.DestroyRef }] });
|
|
289
|
+
|
|
290
|
+
class ChartgpuConnectChartsDirective {
|
|
291
|
+
charts = input([], {
|
|
292
|
+
alias: 'libChartgpuConnectCharts',
|
|
293
|
+
});
|
|
294
|
+
syncOptions = input();
|
|
295
|
+
connectionError = output();
|
|
296
|
+
ids = new WeakMap();
|
|
297
|
+
nextId = 1;
|
|
298
|
+
signature;
|
|
299
|
+
constructor() {
|
|
300
|
+
effect(onCleanup => {
|
|
301
|
+
const charts = this.charts();
|
|
302
|
+
const options = this.syncOptions();
|
|
303
|
+
const optionsSignature = options
|
|
304
|
+
? `crosshair=${options.syncCrosshair ?? ''},zoom=${options.syncZoom ?? ''}`
|
|
305
|
+
: '';
|
|
306
|
+
const signature = `${charts.map(chart => {
|
|
307
|
+
if (!chart) {
|
|
308
|
+
return 'null';
|
|
309
|
+
}
|
|
310
|
+
let id = this.ids.get(chart);
|
|
311
|
+
if (id === undefined) {
|
|
312
|
+
id = this.nextId++;
|
|
313
|
+
this.ids.set(chart, id);
|
|
314
|
+
}
|
|
315
|
+
return `${id}:${chart.disposed ? 1 : 0}`;
|
|
316
|
+
}).join('|')}|${optionsSignature}`;
|
|
317
|
+
if (signature === this.signature) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
this.signature = signature;
|
|
321
|
+
if (charts.length === 0 || charts.some(chart => !chart || chart.disposed)) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const resolved = [];
|
|
325
|
+
for (const chart of charts) {
|
|
326
|
+
if (!chart || chart.disposed) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
resolved.push(chart);
|
|
330
|
+
}
|
|
331
|
+
try {
|
|
332
|
+
const disconnect = connectCharts(resolved, options);
|
|
333
|
+
onCleanup(disconnect);
|
|
334
|
+
}
|
|
335
|
+
catch (cause) {
|
|
336
|
+
this.connectionError.emit(cause instanceof Error ? cause : new Error(String(cause)));
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ChartgpuConnectChartsDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
341
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.25", type: ChartgpuConnectChartsDirective, isStandalone: true, selector: "[libChartgpuConnectCharts]", inputs: { charts: { classPropertyName: "charts", publicName: "libChartgpuConnectCharts", isSignal: true, isRequired: false, transformFunction: null }, syncOptions: { classPropertyName: "syncOptions", publicName: "syncOptions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { connectionError: "connectionError" }, ngImport: i0 });
|
|
342
|
+
}
|
|
343
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ChartgpuConnectChartsDirective, decorators: [{
|
|
344
|
+
type: Directive,
|
|
345
|
+
args: [{
|
|
346
|
+
selector: '[libChartgpuConnectCharts]',
|
|
347
|
+
standalone: true,
|
|
348
|
+
}]
|
|
349
|
+
}], ctorParameters: () => [] });
|
|
350
|
+
|
|
351
|
+
const INITIAL_STATE = {
|
|
352
|
+
adapter: null,
|
|
353
|
+
device: null,
|
|
354
|
+
pipelineCache: null,
|
|
355
|
+
error: null,
|
|
356
|
+
isReady: false,
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Creates one shared WebGPU context and pipeline cache for charts in a dashboard.
|
|
360
|
+
* The device is intentionally not destroyed with the service so charts can share it
|
|
361
|
+
* for the lifetime of the application.
|
|
362
|
+
*/
|
|
363
|
+
class ChartgpuGPUContextService {
|
|
364
|
+
state = signal(INITIAL_STATE);
|
|
365
|
+
context = computed(() => {
|
|
366
|
+
const state = this.state();
|
|
367
|
+
if (!state.adapter || !state.device || !state.pipelineCache) {
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
adapter: state.adapter,
|
|
372
|
+
device: state.device,
|
|
373
|
+
pipelineCache: state.pipelineCache,
|
|
374
|
+
};
|
|
375
|
+
});
|
|
376
|
+
initialization;
|
|
377
|
+
initialize() {
|
|
378
|
+
if (!this.initialization) {
|
|
379
|
+
this.initialization = this.createContext();
|
|
380
|
+
}
|
|
381
|
+
return this.initialization;
|
|
382
|
+
}
|
|
383
|
+
async createContext() {
|
|
384
|
+
try {
|
|
385
|
+
if (typeof navigator === 'undefined' || !('gpu' in navigator)) {
|
|
386
|
+
throw new Error('WebGPU not supported in this browser');
|
|
387
|
+
}
|
|
388
|
+
const gpu = navigator.gpu;
|
|
389
|
+
if (!gpu) {
|
|
390
|
+
throw new Error('WebGPU not supported in this browser');
|
|
391
|
+
}
|
|
392
|
+
const adapter = await gpu.requestAdapter({ powerPreference: 'high-performance' });
|
|
393
|
+
if (!adapter) {
|
|
394
|
+
const error = new Error('WebGPU is not available. No compatible GPUAdapter was found.');
|
|
395
|
+
const state = { ...INITIAL_STATE, error };
|
|
396
|
+
this.state.set(state);
|
|
397
|
+
return state;
|
|
398
|
+
}
|
|
399
|
+
const device = await adapter.requestDevice();
|
|
400
|
+
const pipelineCache = createPipelineCache(device);
|
|
401
|
+
const state = {
|
|
402
|
+
adapter,
|
|
403
|
+
device,
|
|
404
|
+
pipelineCache,
|
|
405
|
+
error: null,
|
|
406
|
+
isReady: true,
|
|
407
|
+
};
|
|
408
|
+
this.state.set(state);
|
|
409
|
+
return state;
|
|
410
|
+
}
|
|
411
|
+
catch (cause) {
|
|
412
|
+
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
413
|
+
const state = { ...INITIAL_STATE, error };
|
|
414
|
+
this.state.set(state);
|
|
415
|
+
return state;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ChartgpuGPUContextService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
419
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ChartgpuGPUContextService, providedIn: 'root' });
|
|
420
|
+
}
|
|
421
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ChartgpuGPUContextService, decorators: [{
|
|
422
|
+
type: Injectable,
|
|
423
|
+
args: [{ providedIn: 'root' }]
|
|
424
|
+
}] });
|
|
425
|
+
|
|
426
|
+
function provideChartGpuContext() {
|
|
427
|
+
return makeEnvironmentProviders([ChartgpuGPUContextService]);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Generated bundle index. Do not edit.
|
|
432
|
+
*/
|
|
433
|
+
|
|
434
|
+
export { ChartGpuAngularComponent, ChartgpuConnectChartsDirective, ChartgpuGPUContextService, provideChartGpuContext };
|
|
435
|
+
//# sourceMappingURL=chartgpu-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartgpu-angular.mjs","sources":["../../../projects/chartgpu-angular/src/lib/chartgpu-angular.component.ts","../../../projects/chartgpu-angular/src/lib/connect-charts.directive.ts","../../../projects/chartgpu-angular/src/lib/gpu-context.service.ts","../../../projects/chartgpu-angular/src/lib/gpu-context.provider.ts","../../../projects/chartgpu-angular/src/chartgpu-angular.ts"],"sourcesContent":["import { NgStyle } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n OnDestroy,\n afterNextRender,\n effect,\n input,\n output,\n signal,\n untracked,\n viewChild,\n} from '@angular/core';\nimport {\n ChartGPU,\n type ChartGPUCrosshairMovePayload,\n type ChartGPUDeviceLostPayload,\n type ChartGPUEventPayload,\n type ChartGPUInstance,\n type ChartGPUZoomRangeChangePayload,\n type OHLCDataPoint,\n} from 'chartgpu';\nimport type {\n ChartgpuAppendDataOptions,\n ChartgpuCartesianSeriesData,\n ChartgpuChartHandle,\n ChartgpuClickEvent,\n ChartgpuDataAppendEvent,\n ChartgpuGPUContext,\n ChartgpuOptions,\n ChartgpuReadyEvent,\n ChartgpuResizeEvent,\n ChartgpuStyle,\n ChartgpuZoomChangeEvent,\n ChartgpuZoomRangeChangeEvent,\n} from './chartgpu-angular.types';\n\n@Component({\n selector: 'lib-chartgpu-angular',\n standalone: true,\n imports: [NgStyle],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { class: 'chartgpu-angular' },\n template: `\n <div\n #host\n class=\"chartgpu-host\"\n [class]=\"className() ?? ''\"\n [ngStyle]=\"style()\"\n (click)=\"emitClick($event)\"\n >\n <div #canvasHost class=\"chartgpu-canvas-host\"></div>\n @if (initializationError(); as error) {\n <div class=\"chartgpu-error\" role=\"alert\">{{ error.message }}</div>\n }\n </div>\n `,\n styles: [`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .chartgpu-host {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n .chartgpu-canvas-host {\n position: absolute;\n inset: 0;\n }\n\n .chartgpu-error {\n position: absolute;\n inset: 0;\n display: grid;\n place-items: center;\n padding: 1rem;\n text-align: center;\n }\n `],\n})\nexport class ChartGpuAngularComponent implements ChartgpuChartHandle, OnDestroy {\n readonly options = input.required<ChartgpuOptions>();\n readonly gpuContext = input<ChartgpuGPUContext | null>(null);\n readonly theme = input<ChartgpuOptions['theme'] | undefined>(undefined);\n readonly className = input<string | undefined>();\n readonly style = input<ChartgpuStyle | undefined>();\n\n readonly ready = output<ChartgpuReadyEvent>();\n readonly chartReady = output<ChartGPUInstance>();\n readonly chartDispose = output<void>();\n readonly resize = output<ChartgpuResizeEvent>();\n readonly click = output<ChartgpuClickEvent>();\n readonly chartClick = output<ChartGPUEventPayload>();\n readonly mouseOver = output<ChartGPUEventPayload>();\n readonly mouseOut = output<ChartGPUEventPayload>();\n readonly crosshairMove = output<ChartGPUCrosshairMovePayload>();\n readonly dataAppend = output<ChartgpuDataAppendEvent>();\n readonly zoomChange = output<ChartgpuZoomChangeEvent>();\n readonly zoomRangeChange = output<ChartgpuZoomRangeChangeEvent>();\n readonly deviceLost = output<ChartGPUDeviceLostPayload>();\n readonly chartError = output<Error>();\n\n readonly host = viewChild<ElementRef<HTMLDivElement>>('host');\n readonly canvasHost = viewChild<ElementRef<HTMLDivElement>>('canvasHost');\n\n private readonly chartInstance = signal<ChartGPUInstance | null>(null);\n readonly initializationError = signal<Error | null>(null);\n private chartContainer?: HTMLDivElement;\n private createdWithOptions?: {\n options: ChartgpuOptions;\n theme: ChartgpuOptions['theme'] | undefined;\n };\n private resizeTimeout?: ReturnType<typeof setTimeout>;\n private resizeObserver?: ResizeObserver;\n private removeChartListeners?: () => void;\n private destroying = false;\n\n constructor(private readonly destroyRef: DestroyRef) {\n this.destroyRef.onDestroy(() => {\n this.resizeObserver?.disconnect();\n if (this.resizeTimeout !== undefined) {\n clearTimeout(this.resizeTimeout);\n }\n this.disposeChart();\n });\n\n afterNextRender(() => {\n const container = this.host()?.nativeElement;\n if (container) {\n this.observeResize(container);\n }\n });\n\n effect(onCleanup => {\n const container = this.canvasHost()?.nativeElement;\n const options = this.options();\n const gpuContext = this.gpuContext();\n const theme = this.theme();\n\n this.initializationError.set(null);\n if (!container) {\n this.disposeChart();\n return;\n }\n if (typeof navigator === 'undefined' || !('gpu' in navigator)) {\n this.reportError(new Error('WebGPU not supported in this browser'));\n return;\n }\n\n if (untracked(() => this.chartInstance()) && this.chartContainer === container) {\n return;\n }\n\n let cancelled = false;\n let createdInstance: ChartGPUInstance | undefined;\n const initialOptions = this.getEffectiveOptions(options, theme);\n\n void (gpuContext\n ? ChartGPU.create(container, initialOptions, gpuContext)\n : ChartGPU.create(container, initialOptions)\n ).then(instance => {\n createdInstance = instance;\n if (cancelled) {\n instance.dispose();\n return;\n }\n\n try {\n const latest = untracked(() => ({\n options: this.options(),\n theme: this.theme(),\n }));\n if (latest.options !== options || latest.theme !== theme) {\n instance.setOption(this.getEffectiveOptions(latest.options, latest.theme));\n }\n\n this.createdWithOptions = latest;\n this.chartContainer = container;\n this.chartInstance.set(instance);\n this.removeChartListeners = this.listenToChart(instance);\n this.ready.emit({ container });\n this.chartReady.emit(instance);\n\n const range = instance.getZoomRange();\n if (range) {\n this.emitZoomRange(range);\n }\n } catch (cause: unknown) {\n instance.dispose();\n throw cause;\n }\n }).catch((cause: unknown) => {\n if (cancelled) {\n return;\n }\n if (createdInstance && this.chartInstance() !== createdInstance && !createdInstance.disposed) {\n createdInstance.dispose();\n }\n this.reportError(cause);\n });\n\n onCleanup(() => {\n cancelled = true;\n if (this.chartContainer === container) {\n this.disposeChart();\n }\n });\n }, { allowSignalWrites: true });\n\n effect(() => {\n const options = this.options();\n const theme = this.theme();\n const instance = this.chartInstance();\n if (!instance || instance.disposed) {\n return;\n }\n\n if (this.createdWithOptions?.options === options && this.createdWithOptions.theme === theme) {\n this.createdWithOptions = undefined;\n return;\n }\n\n try {\n instance.setOption(this.getEffectiveOptions(options, theme));\n } catch (cause: unknown) {\n this.reportError(cause);\n }\n }, { allowSignalWrites: true });\n }\n\n protected emitClick(event: MouseEvent): void {\n this.click.emit({ x: event.offsetX, y: event.offsetY });\n }\n\n ngOnDestroy(): void {\n this.destroying = true;\n }\n\n getChart(): ChartGPUInstance | null {\n const instance = this.chartInstance();\n return instance && !instance.disposed ? instance : null;\n }\n\n getContainer(): HTMLDivElement | null {\n return this.canvasHost()?.nativeElement ?? null;\n }\n\n appendData(\n seriesIndex: number,\n newPoints: ChartgpuCartesianSeriesData | OHLCDataPoint[],\n options?: ChartgpuAppendDataOptions,\n ): void {\n this.getChart()?.appendData(seriesIndex, newPoints, options);\n }\n\n renderFrame(): boolean {\n return this.getChart()?.renderFrame() ?? false;\n }\n\n needsRender(): boolean {\n return this.getChart()?.needsRender() ?? false;\n }\n\n getRenderMode(): 'auto' | 'external' {\n return this.getChart()?.getRenderMode() ?? 'auto';\n }\n\n setRenderMode(mode: 'auto' | 'external'): void {\n this.getChart()?.setRenderMode(mode);\n }\n\n setOption(options: ChartgpuOptions): void {\n this.getChart()?.setOption(options);\n }\n\n setZoomRange(start: number, end: number, source?: unknown): void {\n this.getChart()?.setZoomRange(start, end, source);\n }\n\n setInteractionX(x: number | null, source?: unknown): void {\n this.getChart()?.setInteractionX(x, source);\n }\n\n getInteractionX(): number | null {\n return this.getChart()?.getInteractionX() ?? null;\n }\n\n hitTest(event: PointerEvent | MouseEvent) {\n return this.getChart()?.hitTest(event) ?? null;\n }\n\n private getEffectiveOptions(\n options: ChartgpuOptions,\n theme: ChartgpuOptions['theme'] | undefined,\n ): ChartgpuOptions {\n return theme !== undefined ? { ...options, theme } : options;\n }\n\n private listenToChart(instance: ChartGPUInstance): () => void {\n const click = (payload: ChartGPUEventPayload) => this.chartClick.emit(payload);\n const mouseOver = (payload: ChartGPUEventPayload) => this.mouseOver.emit(payload);\n const mouseOut = (payload: ChartGPUEventPayload) => this.mouseOut.emit(payload);\n const crosshairMove = (payload: ChartGPUCrosshairMovePayload) => this.crosshairMove.emit(payload);\n const dataAppend = (payload: ChartgpuDataAppendEvent) => this.dataAppend.emit(payload);\n const zoomChange = (payload: ChartGPUZoomRangeChangePayload) => this.emitZoomRange(payload);\n const deviceLost = (payload: ChartGPUDeviceLostPayload) => this.deviceLost.emit(payload);\n\n instance.on('click', click);\n instance.on('mouseover', mouseOver);\n instance.on('mouseout', mouseOut);\n instance.on('crosshairMove', crosshairMove);\n instance.on('dataAppend', dataAppend);\n instance.on('zoomRangeChange', zoomChange);\n instance.on('deviceLost', deviceLost);\n\n return () => {\n if (instance.disposed) {\n return;\n }\n instance.off('click', click);\n instance.off('mouseover', mouseOver);\n instance.off('mouseout', mouseOut);\n instance.off('crosshairMove', crosshairMove);\n instance.off('dataAppend', dataAppend);\n instance.off('zoomRangeChange', zoomChange);\n instance.off('deviceLost', deviceLost);\n };\n }\n\n private emitZoomRange(range: { start: number; end: number }): void {\n this.zoomChange.emit({ range: { start: range.start, end: range.end } });\n this.zoomRangeChange.emit({ start: range.start, end: range.end });\n }\n\n private observeResize(container: HTMLDivElement): void {\n if (typeof ResizeObserver === 'undefined') {\n return;\n }\n\n this.resizeObserver = new ResizeObserver(entries => {\n const entry = entries[0];\n if (!entry) {\n return;\n }\n const { width, height } = entry.contentRect;\n this.resize.emit({ width, height, container });\n if (this.resizeTimeout !== undefined) {\n clearTimeout(this.resizeTimeout);\n }\n this.resizeTimeout = setTimeout(() => {\n this.chartInstance()?.resize();\n this.resizeTimeout = undefined;\n }, 100);\n });\n this.resizeObserver.observe(container);\n }\n\n private reportError(cause: unknown): void {\n const error = cause instanceof Error ? cause : new Error(String(cause));\n this.initializationError.set(error);\n this.chartError.emit(error);\n }\n\n private disposeChart(): void {\n const instance = this.chartInstance();\n this.removeChartListeners?.();\n this.removeChartListeners = undefined;\n if (instance && !instance.disposed) {\n instance.dispose();\n if (!this.destroying) {\n this.chartDispose.emit();\n }\n }\n this.chartInstance.set(null);\n this.chartContainer = undefined;\n this.createdWithOptions = undefined;\n }\n}\n","import { Directive, effect, input, output } from '@angular/core';\nimport { connectCharts } from 'chartgpu';\nimport type { ChartGPUInstance, ChartSyncOptions } from 'chartgpu';\n\n@Directive({\n selector: '[libChartgpuConnectCharts]',\n standalone: true,\n})\nexport class ChartgpuConnectChartsDirective {\n readonly charts = input<ReadonlyArray<ChartGPUInstance | null | undefined>>([], {\n alias: 'libChartgpuConnectCharts',\n });\n readonly syncOptions = input<ChartSyncOptions | undefined>();\n readonly connectionError = output<Error>();\n\n private readonly ids = new WeakMap<object, number>();\n private nextId = 1;\n private signature: string | undefined;\n\n constructor() {\n effect(onCleanup => {\n const charts = this.charts();\n const options = this.syncOptions();\n const optionsSignature = options\n ? `crosshair=${options.syncCrosshair ?? ''},zoom=${options.syncZoom ?? ''}`\n : '';\n const signature = `${charts.map(chart => {\n if (!chart) {\n return 'null';\n }\n\n let id = this.ids.get(chart);\n if (id === undefined) {\n id = this.nextId++;\n this.ids.set(chart, id);\n }\n return `${id}:${chart.disposed ? 1 : 0}`;\n }).join('|')}|${optionsSignature}`;\n\n if (signature === this.signature) {\n return;\n }\n this.signature = signature;\n\n if (charts.length === 0 || charts.some(chart => !chart || chart.disposed)) {\n return;\n }\n\n const resolved: ChartGPUInstance[] = [];\n for (const chart of charts) {\n if (!chart || chart.disposed) {\n return;\n }\n resolved.push(chart);\n }\n\n try {\n const disconnect = connectCharts(resolved, options);\n onCleanup(disconnect);\n } catch (cause: unknown) {\n this.connectionError.emit(cause instanceof Error ? cause : new Error(String(cause)));\n }\n });\n }\n}\n","import { Injectable, computed, signal } from '@angular/core';\nimport { createPipelineCache } from 'chartgpu';\nimport type { ChartGPUCreateContext } from 'chartgpu';\nimport type { ChartgpuGPUContextState } from './chartgpu-angular.types';\n\nconst INITIAL_STATE: ChartgpuGPUContextState = {\n adapter: null,\n device: null,\n pipelineCache: null,\n error: null,\n isReady: false,\n};\n\n/**\n * Creates one shared WebGPU context and pipeline cache for charts in a dashboard.\n * The device is intentionally not destroyed with the service so charts can share it\n * for the lifetime of the application.\n */\n@Injectable({ providedIn: 'root' })\nexport class ChartgpuGPUContextService {\n readonly state = signal<ChartgpuGPUContextState>(INITIAL_STATE);\n readonly context = computed<ChartGPUCreateContext | null>(() => {\n const state = this.state();\n if (!state.adapter || !state.device || !state.pipelineCache) {\n return null;\n }\n\n return {\n adapter: state.adapter,\n device: state.device,\n pipelineCache: state.pipelineCache,\n };\n });\n\n private initialization?: Promise<ChartgpuGPUContextState>;\n\n initialize(): Promise<ChartgpuGPUContextState> {\n if (!this.initialization) {\n this.initialization = this.createContext();\n }\n return this.initialization;\n }\n\n private async createContext(): Promise<ChartgpuGPUContextState> {\n try {\n if (typeof navigator === 'undefined' || !('gpu' in navigator)) {\n throw new Error('WebGPU not supported in this browser');\n }\n\n const gpu = (navigator as Navigator & {\n gpu?: {\n requestAdapter(options: {\n powerPreference: 'high-performance';\n }): Promise<ChartGPUCreateContext['adapter'] | null>;\n };\n }).gpu;\n if (!gpu) {\n throw new Error('WebGPU not supported in this browser');\n }\n\n const adapter = await gpu.requestAdapter({ powerPreference: 'high-performance' });\n if (!adapter) {\n const error = new Error('WebGPU is not available. No compatible GPUAdapter was found.');\n const state: ChartgpuGPUContextState = { ...INITIAL_STATE, error };\n this.state.set(state);\n return state;\n }\n\n const device = await adapter.requestDevice();\n const pipelineCache = createPipelineCache(device);\n const state: ChartgpuGPUContextState = {\n adapter,\n device,\n pipelineCache,\n error: null,\n isReady: true,\n };\n this.state.set(state);\n return state;\n } catch (cause: unknown) {\n const error = cause instanceof Error ? cause : new Error(String(cause));\n const state: ChartgpuGPUContextState = { ...INITIAL_STATE, error };\n this.state.set(state);\n return state;\n }\n }\n}\n","import { makeEnvironmentProviders } from '@angular/core';\nimport { ChartgpuGPUContextService } from './gpu-context.service';\n\nexport function provideChartGpuContext() {\n return makeEnvironmentProviders([ChartgpuGPUContextService]);\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAuFa,wBAAwB,CAAA;AAqCN,IAAA,UAAA;AApCpB,IAAA,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAmB;AAC3C,IAAA,UAAU,GAAG,KAAK,CAA4B,IAAI,CAAC;AACnD,IAAA,KAAK,GAAG,KAAK,CAAuC,SAAS,CAAC;IAC9D,SAAS,GAAG,KAAK,EAAsB;IACvC,KAAK,GAAG,KAAK,EAA6B;IAE1C,KAAK,GAAG,MAAM,EAAsB;IACpC,UAAU,GAAG,MAAM,EAAoB;IACvC,YAAY,GAAG,MAAM,EAAQ;IAC7B,MAAM,GAAG,MAAM,EAAuB;IACtC,KAAK,GAAG,MAAM,EAAsB;IACpC,UAAU,GAAG,MAAM,EAAwB;IAC3C,SAAS,GAAG,MAAM,EAAwB;IAC1C,QAAQ,GAAG,MA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AA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,yBAAyB,cADZ,MAAM,EAAA,CAAA;;4FACnB,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBADrC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;SCflB,sBAAsB,GAAA;AACpC,IAAA,OAAO,wBAAwB,CAAC,CAAC,yBAAyB,CAAC,CAAC;AAC9D;;ACLA;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { DestroyRef, ElementRef, OnDestroy } from '@angular/core';
|
|
2
|
+
import { type ChartGPUInstance, type OHLCDataPoint } from 'chartgpu';
|
|
3
|
+
import type { ChartgpuAppendDataOptions, ChartgpuCartesianSeriesData, ChartgpuChartHandle, ChartgpuClickEvent, ChartgpuDataAppendEvent, ChartgpuOptions, ChartgpuReadyEvent, ChartgpuResizeEvent, ChartgpuStyle, ChartgpuZoomChangeEvent, ChartgpuZoomRangeChangeEvent } from './chartgpu-angular.types';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class ChartGpuAngularComponent implements ChartgpuChartHandle, OnDestroy {
|
|
6
|
+
private readonly destroyRef;
|
|
7
|
+
readonly options: import("@angular/core").InputSignal<import("chartgpu").ChartGPUOptions>;
|
|
8
|
+
readonly gpuContext: import("@angular/core").InputSignal<Readonly<{
|
|
9
|
+
readonly device: GPUDevice;
|
|
10
|
+
readonly adapter: GPUAdapter;
|
|
11
|
+
readonly pipelineCache?: import("chartgpu").PipelineCache;
|
|
12
|
+
}>>;
|
|
13
|
+
readonly theme: import("@angular/core").InputSignal<import("chartgpu").ThemeConfig | "light" | "dark">;
|
|
14
|
+
readonly className: import("@angular/core").InputSignal<string>;
|
|
15
|
+
readonly style: import("@angular/core").InputSignal<ChartgpuStyle>;
|
|
16
|
+
readonly ready: import("@angular/core").OutputEmitterRef<ChartgpuReadyEvent>;
|
|
17
|
+
readonly chartReady: import("@angular/core").OutputEmitterRef<ChartGPUInstance>;
|
|
18
|
+
readonly chartDispose: import("@angular/core").OutputEmitterRef<void>;
|
|
19
|
+
readonly resize: import("@angular/core").OutputEmitterRef<ChartgpuResizeEvent>;
|
|
20
|
+
readonly click: import("@angular/core").OutputEmitterRef<ChartgpuClickEvent>;
|
|
21
|
+
readonly chartClick: import("@angular/core").OutputEmitterRef<Readonly<{
|
|
22
|
+
readonly seriesIndex: number | null;
|
|
23
|
+
readonly dataIndex: number | null;
|
|
24
|
+
readonly value: readonly [number, number] | null;
|
|
25
|
+
readonly seriesName: string | null;
|
|
26
|
+
readonly event: PointerEvent;
|
|
27
|
+
}>>;
|
|
28
|
+
readonly mouseOver: import("@angular/core").OutputEmitterRef<Readonly<{
|
|
29
|
+
readonly seriesIndex: number | null;
|
|
30
|
+
readonly dataIndex: number | null;
|
|
31
|
+
readonly value: readonly [number, number] | null;
|
|
32
|
+
readonly seriesName: string | null;
|
|
33
|
+
readonly event: PointerEvent;
|
|
34
|
+
}>>;
|
|
35
|
+
readonly mouseOut: import("@angular/core").OutputEmitterRef<Readonly<{
|
|
36
|
+
readonly seriesIndex: number | null;
|
|
37
|
+
readonly dataIndex: number | null;
|
|
38
|
+
readonly value: readonly [number, number] | null;
|
|
39
|
+
readonly seriesName: string | null;
|
|
40
|
+
readonly event: PointerEvent;
|
|
41
|
+
}>>;
|
|
42
|
+
readonly crosshairMove: import("@angular/core").OutputEmitterRef<Readonly<{
|
|
43
|
+
readonly x: number | null;
|
|
44
|
+
readonly source?: unknown;
|
|
45
|
+
}>>;
|
|
46
|
+
readonly dataAppend: import("@angular/core").OutputEmitterRef<ChartgpuDataAppendEvent>;
|
|
47
|
+
readonly zoomChange: import("@angular/core").OutputEmitterRef<ChartgpuZoomChangeEvent>;
|
|
48
|
+
readonly zoomRangeChange: import("@angular/core").OutputEmitterRef<ChartgpuZoomRangeChangeEvent>;
|
|
49
|
+
readonly deviceLost: import("@angular/core").OutputEmitterRef<Readonly<{
|
|
50
|
+
readonly reason: GPUDeviceLostReason;
|
|
51
|
+
readonly message: string;
|
|
52
|
+
}>>;
|
|
53
|
+
readonly chartError: import("@angular/core").OutputEmitterRef<Error>;
|
|
54
|
+
readonly host: import("@angular/core").Signal<ElementRef<HTMLDivElement>>;
|
|
55
|
+
readonly canvasHost: import("@angular/core").Signal<ElementRef<HTMLDivElement>>;
|
|
56
|
+
private readonly chartInstance;
|
|
57
|
+
readonly initializationError: import("@angular/core").WritableSignal<Error>;
|
|
58
|
+
private chartContainer?;
|
|
59
|
+
private createdWithOptions?;
|
|
60
|
+
private resizeTimeout?;
|
|
61
|
+
private resizeObserver?;
|
|
62
|
+
private removeChartListeners?;
|
|
63
|
+
private destroying;
|
|
64
|
+
constructor(destroyRef: DestroyRef);
|
|
65
|
+
protected emitClick(event: MouseEvent): void;
|
|
66
|
+
ngOnDestroy(): void;
|
|
67
|
+
getChart(): ChartGPUInstance | null;
|
|
68
|
+
getContainer(): HTMLDivElement | null;
|
|
69
|
+
appendData(seriesIndex: number, newPoints: ChartgpuCartesianSeriesData | OHLCDataPoint[], options?: ChartgpuAppendDataOptions): void;
|
|
70
|
+
renderFrame(): boolean;
|
|
71
|
+
needsRender(): boolean;
|
|
72
|
+
getRenderMode(): 'auto' | 'external';
|
|
73
|
+
setRenderMode(mode: 'auto' | 'external'): void;
|
|
74
|
+
setOption(options: ChartgpuOptions): void;
|
|
75
|
+
setZoomRange(start: number, end: number, source?: unknown): void;
|
|
76
|
+
setInteractionX(x: number | null, source?: unknown): void;
|
|
77
|
+
getInteractionX(): number | null;
|
|
78
|
+
hitTest(event: PointerEvent | MouseEvent): Readonly<{
|
|
79
|
+
readonly isInGrid: boolean;
|
|
80
|
+
readonly canvasX: number;
|
|
81
|
+
readonly canvasY: number;
|
|
82
|
+
readonly gridX: number;
|
|
83
|
+
readonly gridY: number;
|
|
84
|
+
readonly match: import("chartgpu").ChartGPUHitTestMatch | null;
|
|
85
|
+
}>;
|
|
86
|
+
private getEffectiveOptions;
|
|
87
|
+
private listenToChart;
|
|
88
|
+
private emitZoomRange;
|
|
89
|
+
private observeResize;
|
|
90
|
+
private reportError;
|
|
91
|
+
private disposeChart;
|
|
92
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ChartGpuAngularComponent, never>;
|
|
93
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ChartGpuAngularComponent, "lib-chartgpu-angular", never, { "options": { "alias": "options"; "required": true; "isSignal": true; }; "gpuContext": { "alias": "gpuContext"; "required": false; "isSignal": true; }; "theme": { "alias": "theme"; "required": false; "isSignal": true; }; "className": { "alias": "className"; "required": false; "isSignal": true; }; "style": { "alias": "style"; "required": false; "isSignal": true; }; }, { "ready": "ready"; "chartReady": "chartReady"; "chartDispose": "chartDispose"; "resize": "resize"; "click": "click"; "chartClick": "chartClick"; "mouseOver": "mouseOver"; "mouseOut": "mouseOut"; "crosshairMove": "crosshairMove"; "dataAppend": "dataAppend"; "zoomChange": "zoomChange"; "zoomRangeChange": "zoomRangeChange"; "deviceLost": "deviceLost"; "chartError": "chartError"; }, never, never, true, never>;
|
|
94
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ChartGPUOptions } from 'chartgpu';
|
|
2
|
+
import type { AnimationConfig, AnnotationConfig, AxisConfig, ChartGPUCreateContext, ChartGPUCrosshairMovePayload, ChartGPUEventPayload, ChartGPUHitTestResult, ChartGPUInstance, ChartGPUDeviceLostPayload, ChartSyncOptions, DataZoomConfig, DataPoint, OHLCDataPoint, PipelineCache, RenderMode, SeriesConfig, SeriesType, ThemeConfig, TooltipConfig } from 'chartgpu';
|
|
3
|
+
export type ChartgpuOptions = ChartGPUOptions;
|
|
4
|
+
export type ChartgpuSeriesType = SeriesType;
|
|
5
|
+
export type ChartgpuSeriesData = Extract<SeriesConfig, {
|
|
6
|
+
type: 'line';
|
|
7
|
+
}>['data'];
|
|
8
|
+
export type ChartgpuSeriesOptions = SeriesConfig;
|
|
9
|
+
export type ChartgpuAxisOptions = AxisConfig;
|
|
10
|
+
export type ChartgpuZoomOptions = DataZoomConfig;
|
|
11
|
+
export type ChartgpuTooltipOptions = TooltipConfig;
|
|
12
|
+
export type ChartgpuAnimationOptions = AnimationConfig | boolean;
|
|
13
|
+
export type ChartgpuThemeOptions = ThemeConfig | 'light' | 'dark';
|
|
14
|
+
export type ChartgpuAnnotationOptions = AnnotationConfig;
|
|
15
|
+
export type ChartgpuThreeDOptions = Pick<ChartGPUOptions, 'coordinateSystem' | 'camera' | 'interaction3d' | 'axes3d'>;
|
|
16
|
+
export type ChartgpuStreamingOptions = Pick<ChartGPUOptions, 'autoScroll'>;
|
|
17
|
+
export type ChartgpuInteractionOptions = Pick<ChartGPUOptions, 'dataZoom' | 'tooltip'>;
|
|
18
|
+
export type ChartgpuChartInstance = ChartGPUInstance;
|
|
19
|
+
export type ChartgpuGPUContext = ChartGPUCreateContext;
|
|
20
|
+
export type ChartgpuStyle = Record<string, string | number | null | undefined>;
|
|
21
|
+
export type ChartgpuZoomRange = NonNullable<ReturnType<ChartGPUInstance['getZoomRange']>>;
|
|
22
|
+
export type ChartgpuClickParams = ChartGPUEventPayload;
|
|
23
|
+
export type ChartgpuMouseOverParams = ChartGPUEventPayload;
|
|
24
|
+
export type ChartgpuCrosshairMoveParams = ChartGPUCrosshairMovePayload;
|
|
25
|
+
export type ChartgpuHitTestResult = ChartGPUHitTestResult;
|
|
26
|
+
export type ChartgpuRenderMode = RenderMode;
|
|
27
|
+
export type ChartgpuSyncOptions = ChartSyncOptions;
|
|
28
|
+
export type ChartgpuXYArraysData = Readonly<{
|
|
29
|
+
x: ArrayLike<number>;
|
|
30
|
+
y: ArrayLike<number>;
|
|
31
|
+
size?: ArrayLike<number>;
|
|
32
|
+
}>;
|
|
33
|
+
export type ChartgpuInterleavedXYData = ArrayBufferView;
|
|
34
|
+
export type ChartgpuCartesianSeriesData = ReadonlyArray<DataPoint | null> | ChartgpuXYArraysData | ChartgpuInterleavedXYData;
|
|
35
|
+
export type ChartgpuAppendDataOptions = Readonly<{
|
|
36
|
+
maxPoints?: number;
|
|
37
|
+
}>;
|
|
38
|
+
export interface ChartgpuDataAppendEvent {
|
|
39
|
+
seriesIndex: number;
|
|
40
|
+
count: number;
|
|
41
|
+
xExtent: {
|
|
42
|
+
min: number;
|
|
43
|
+
max: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface ChartgpuReadyEvent {
|
|
47
|
+
container: HTMLDivElement;
|
|
48
|
+
}
|
|
49
|
+
export interface ChartgpuResizeEvent {
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
container: HTMLDivElement;
|
|
53
|
+
}
|
|
54
|
+
export interface ChartgpuClickEvent {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
}
|
|
58
|
+
export interface ChartgpuZoomChangeEvent {
|
|
59
|
+
range: {
|
|
60
|
+
start: number;
|
|
61
|
+
end: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export interface ChartgpuZoomRangeChangeEvent {
|
|
65
|
+
start: number;
|
|
66
|
+
end: number;
|
|
67
|
+
}
|
|
68
|
+
export interface ChartgpuGPUContextState {
|
|
69
|
+
adapter: ChartGPUCreateContext['adapter'] | null;
|
|
70
|
+
device: ChartGPUCreateContext['device'] | null;
|
|
71
|
+
pipelineCache: PipelineCache | null;
|
|
72
|
+
error: Error | null;
|
|
73
|
+
isReady: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface ChartgpuChartHandle {
|
|
76
|
+
getChart(): ChartGPUInstance | null;
|
|
77
|
+
getContainer(): HTMLDivElement | null;
|
|
78
|
+
appendData(seriesIndex: number, newPoints: ChartgpuCartesianSeriesData | OHLCDataPoint[], options?: ChartgpuAppendDataOptions): void;
|
|
79
|
+
renderFrame(): boolean;
|
|
80
|
+
needsRender(): boolean;
|
|
81
|
+
getRenderMode(): RenderMode;
|
|
82
|
+
setRenderMode(mode: RenderMode): void;
|
|
83
|
+
setOption(options: ChartgpuOptions): void;
|
|
84
|
+
setZoomRange(start: number, end: number, source?: unknown): void;
|
|
85
|
+
setInteractionX(x: number | null, source?: unknown): void;
|
|
86
|
+
getInteractionX(): number | null;
|
|
87
|
+
hitTest(event: PointerEvent | MouseEvent): ChartGPUHitTestResult | null;
|
|
88
|
+
}
|
|
89
|
+
export type { ChartGPUCreateContext, ChartGPUCrosshairMovePayload, ChartGPUDeviceLostPayload, ChartGPUEventPayload, ChartGPUHitTestResult, ChartGPUInstance, ChartSyncOptions, DataPoint, OHLCDataPoint, PipelineCache, RenderMode, };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ChartGPUInstance } from 'chartgpu';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class ChartgpuConnectChartsDirective {
|
|
4
|
+
readonly charts: import("@angular/core").InputSignal<readonly ChartGPUInstance[]>;
|
|
5
|
+
readonly syncOptions: import("@angular/core").InputSignal<Readonly<{
|
|
6
|
+
readonly syncCrosshair?: boolean;
|
|
7
|
+
readonly syncZoom?: boolean;
|
|
8
|
+
}>>;
|
|
9
|
+
readonly connectionError: import("@angular/core").OutputEmitterRef<Error>;
|
|
10
|
+
private readonly ids;
|
|
11
|
+
private nextId;
|
|
12
|
+
private signature;
|
|
13
|
+
constructor();
|
|
14
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ChartgpuConnectChartsDirective, never>;
|
|
15
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ChartgpuConnectChartsDirective, "[libChartgpuConnectCharts]", never, { "charts": { "alias": "libChartgpuConnectCharts"; "required": false; "isSignal": true; }; "syncOptions": { "alias": "syncOptions"; "required": false; "isSignal": true; }; }, { "connectionError": "connectionError"; }, never, never, true, never>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function provideChartGpuContext(): import("@angular/core").EnvironmentProviders;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ChartgpuGPUContextState } from './chartgpu-angular.types';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Creates one shared WebGPU context and pipeline cache for charts in a dashboard.
|
|
5
|
+
* The device is intentionally not destroyed with the service so charts can share it
|
|
6
|
+
* for the lifetime of the application.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ChartgpuGPUContextService {
|
|
9
|
+
readonly state: import("@angular/core").WritableSignal<ChartgpuGPUContextState>;
|
|
10
|
+
readonly context: import("@angular/core").Signal<Readonly<{
|
|
11
|
+
readonly device: GPUDevice;
|
|
12
|
+
readonly adapter: GPUAdapter;
|
|
13
|
+
readonly pipelineCache?: import("chartgpu").PipelineCache;
|
|
14
|
+
}>>;
|
|
15
|
+
private initialization?;
|
|
16
|
+
initialize(): Promise<ChartgpuGPUContextState>;
|
|
17
|
+
private createContext;
|
|
18
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ChartgpuGPUContextService, never>;
|
|
19
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ChartgpuGPUContextService>;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chartgpu-angular",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "19.0.0",
|
|
4
|
+
"description": "Unnofficial Angular bindings for ChartGPU — WebGPU-powered high-performance charts",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"angular",
|
|
7
|
+
"chartgpu",
|
|
8
|
+
"react",
|
|
9
|
+
"chart",
|
|
10
|
+
"webgpu",
|
|
11
|
+
"visualization",
|
|
12
|
+
"streaming",
|
|
13
|
+
"typescript"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://kai1992cool.github.io/chartgpu-angular/",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/kai1992cool/chartgpu-angular"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/kai1992cool/chartgpu-angular/issues"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": "Naren",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@angular/common": "^19.0.0",
|
|
27
|
+
"@angular/core": "^19.0.0",
|
|
28
|
+
"chartgpu": "^0.4.0"
|
|
29
|
+
},
|
|
30
|
+
"module": "fesm2022/chartgpu-angular.mjs",
|
|
31
|
+
"typings": "index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
"./package.json": {
|
|
34
|
+
"default": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./index.d.ts",
|
|
38
|
+
"default": "./fesm2022/chartgpu-angular.mjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"sideEffects": false,
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"tslib": "^2.3.0"
|
|
44
|
+
}
|
|
6
45
|
}
|