@ggterm/core 0.2.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/dist/annotations.d.ts +79 -0
- package/dist/annotations.d.ts.map +1 -0
- package/dist/canvas/canvas.d.ts.map +1 -0
- package/dist/canvas/index.d.ts.map +1 -0
- package/dist/cli-plot.d.ts +14 -0
- package/dist/cli-plot.d.ts.map +1 -0
- package/dist/cli.d.ts +13 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +6485 -0
- package/dist/coords/cartesian.d.ts +96 -0
- package/dist/coords/cartesian.d.ts.map +1 -0
- package/dist/demo.d.ts +6 -0
- package/dist/demo.d.ts.map +1 -0
- package/dist/export/index.d.ts +6 -0
- package/dist/export/index.d.ts.map +1 -0
- package/dist/export/vega-lite.d.ts +87 -0
- package/dist/export/vega-lite.d.ts.map +1 -0
- package/dist/facets/index.d.ts +168 -0
- package/dist/facets/index.d.ts.map +1 -0
- package/dist/geoms/area.d.ts.map +1 -0
- package/dist/geoms/bar.d.ts +38 -0
- package/dist/geoms/bar.d.ts.map +1 -0
- package/dist/geoms/boxplot.d.ts.map +1 -0
- package/dist/geoms/contour.d.ts +33 -0
- package/dist/geoms/contour.d.ts.map +1 -0
- package/dist/geoms/errorbar.d.ts +41 -0
- package/dist/geoms/errorbar.d.ts.map +1 -0
- package/dist/geoms/histogram.d.ts +62 -0
- package/dist/geoms/histogram.d.ts.map +1 -0
- package/dist/geoms/index.d.ts +22 -0
- package/dist/geoms/index.d.ts.map +1 -0
- package/dist/geoms/line.d.ts.map +1 -0
- package/dist/geoms/path.d.ts +59 -0
- package/dist/geoms/path.d.ts.map +1 -0
- package/dist/geoms/point.d.ts +30 -0
- package/dist/geoms/point.d.ts.map +1 -0
- package/dist/geoms/qq.d.ts +75 -0
- package/dist/geoms/qq.d.ts.map +1 -0
- package/dist/geoms/rect.d.ts +37 -0
- package/dist/geoms/rect.d.ts.map +1 -0
- package/dist/geoms/rug.d.ts +65 -0
- package/dist/geoms/rug.d.ts.map +1 -0
- package/dist/geoms/segment.d.ts.map +1 -0
- package/dist/geoms/smooth.d.ts +51 -0
- package/dist/geoms/smooth.d.ts.map +1 -0
- package/dist/geoms/step.d.ts +43 -0
- package/dist/geoms/step.d.ts.map +1 -0
- package/dist/geoms/text.d.ts +23 -0
- package/dist/geoms/text.d.ts.map +1 -0
- package/dist/geoms/tile.d.ts +27 -0
- package/dist/geoms/tile.d.ts.map +1 -0
- package/dist/geoms/violin.d.ts +29 -0
- package/dist/geoms/violin.d.ts.map +1 -0
- package/dist/grammar.d.ts +81 -0
- package/dist/grammar.d.ts.map +1 -0
- package/dist/history/index.d.ts +75 -0
- package/dist/history/index.d.ts.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9168 -0
- package/dist/performance/binning.d.ts +112 -0
- package/dist/performance/binning.d.ts.map +1 -0
- package/dist/performance/canvas-diff.d.ts +107 -0
- package/dist/performance/canvas-diff.d.ts.map +1 -0
- package/dist/performance/index.d.ts +14 -0
- package/dist/performance/index.d.ts.map +1 -0
- package/dist/performance/level-of-detail.d.ts +98 -0
- package/dist/performance/level-of-detail.d.ts.map +1 -0
- package/dist/performance/sampling.d.ts +86 -0
- package/dist/performance/sampling.d.ts.map +1 -0
- package/dist/pipeline/index.d.ts +11 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/pipeline.d.ts.map +1 -0
- package/dist/pipeline/render-axes.d.ts +94 -0
- package/dist/pipeline/render-axes.d.ts.map +1 -0
- package/dist/pipeline/render-geoms.d.ts +121 -0
- package/dist/pipeline/render-geoms.d.ts.map +1 -0
- package/dist/pipeline/scales.d.ts +151 -0
- package/dist/pipeline/scales.d.ts.map +1 -0
- package/dist/positions/index.d.ts +141 -0
- package/dist/positions/index.d.ts.map +1 -0
- package/dist/repl/index.d.ts +6 -0
- package/dist/repl/index.d.ts.map +1 -0
- package/dist/repl/repl.d.ts +161 -0
- package/dist/repl/repl.d.ts.map +1 -0
- package/dist/scales/alpha.d.ts +57 -0
- package/dist/scales/alpha.d.ts.map +1 -0
- package/dist/scales/color.d.ts +260 -0
- package/dist/scales/color.d.ts.map +1 -0
- package/dist/scales/continuous.d.ts +60 -0
- package/dist/scales/continuous.d.ts.map +1 -0
- package/dist/scales/datetime.d.ts +60 -0
- package/dist/scales/datetime.d.ts.map +1 -0
- package/dist/scales/discrete.d.ts +36 -0
- package/dist/scales/discrete.d.ts.map +1 -0
- package/dist/scales/index.d.ts +11 -0
- package/dist/scales/index.d.ts.map +1 -0
- package/dist/scales/shape.d.ts +43 -0
- package/dist/scales/shape.d.ts.map +1 -0
- package/dist/scales/size.d.ts +43 -0
- package/dist/scales/size.d.ts.map +1 -0
- package/dist/stats/bin.d.ts.map +1 -0
- package/dist/stats/boxplot.d.ts.map +1 -0
- package/dist/stats/count.d.ts +21 -0
- package/dist/stats/count.d.ts.map +1 -0
- package/dist/stats/density.d.ts +36 -0
- package/dist/stats/density.d.ts.map +1 -0
- package/dist/stats/index.d.ts +18 -0
- package/dist/stats/index.d.ts.map +1 -0
- package/dist/stats/qq.d.ts +47 -0
- package/dist/stats/qq.d.ts.map +1 -0
- package/dist/stats/smooth.d.ts.map +1 -0
- package/dist/stats/summary.d.ts.map +1 -0
- package/dist/streaming/data-buffer.d.ts +121 -0
- package/dist/streaming/data-buffer.d.ts.map +1 -0
- package/dist/streaming/data-window.d.ts +133 -0
- package/dist/streaming/data-window.d.ts.map +1 -0
- package/dist/streaming/index.d.ts +14 -0
- package/dist/streaming/index.d.ts.map +1 -0
- package/dist/streaming/rolling-aggregator.d.ts +116 -0
- package/dist/streaming/rolling-aggregator.d.ts.map +1 -0
- package/dist/streaming/streaming-plot.d.ts +194 -0
- package/dist/streaming/streaming-plot.d.ts.map +1 -0
- package/dist/terminal/capabilities.d.ts +89 -0
- package/dist/terminal/capabilities.d.ts.map +1 -0
- package/dist/terminal/colors.d.ts +82 -0
- package/dist/terminal/colors.d.ts.map +1 -0
- package/dist/terminal/index.d.ts +12 -0
- package/dist/terminal/index.d.ts.map +1 -0
- package/dist/terminal/renderer-chain.d.ts +110 -0
- package/dist/terminal/renderer-chain.d.ts.map +1 -0
- package/dist/themes/default.d.ts.map +1 -0
- package/dist/types.d.ts +198 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stats/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC7C,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE3D,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAC7D,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEjE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AACvE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEjE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACrD,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAE9D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AACxD,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE7E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AACtE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* stat_qq - Compute quantiles for Q-Q plots
|
|
3
|
+
*
|
|
4
|
+
* Q-Q (quantile-quantile) plots compare sample quantiles against
|
|
5
|
+
* theoretical quantiles from a reference distribution (usually normal).
|
|
6
|
+
* Points falling on a diagonal line indicate the data follows the
|
|
7
|
+
* reference distribution.
|
|
8
|
+
*/
|
|
9
|
+
import type { DataSource, Stat } from '../types';
|
|
10
|
+
export interface StatQQParams {
|
|
11
|
+
/** Distribution to compare against (default: 'norm') */
|
|
12
|
+
distribution?: 'norm' | 'uniform' | 'exp';
|
|
13
|
+
/** Distribution parameters (mean, sd for normal) */
|
|
14
|
+
dparams?: {
|
|
15
|
+
mean?: number;
|
|
16
|
+
sd?: number;
|
|
17
|
+
rate?: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface QQResult {
|
|
21
|
+
/** Sample quantile (actual data value) */
|
|
22
|
+
sample: number;
|
|
23
|
+
/** Theoretical quantile from reference distribution */
|
|
24
|
+
theoretical: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Compute Q-Q plot data
|
|
28
|
+
*/
|
|
29
|
+
export declare function computeQQ(data: DataSource, field: string, params?: StatQQParams): QQResult[];
|
|
30
|
+
/**
|
|
31
|
+
* Compute Q-Q line parameters (slope and intercept)
|
|
32
|
+
* The line passes through the first and third quartiles
|
|
33
|
+
*/
|
|
34
|
+
export declare function computeQQLine(data: DataSource, field: string, params?: StatQQParams): {
|
|
35
|
+
slope: number;
|
|
36
|
+
intercept: number;
|
|
37
|
+
} | null;
|
|
38
|
+
/**
|
|
39
|
+
* Create stat_qq transformation
|
|
40
|
+
*/
|
|
41
|
+
export declare function stat_qq(params?: StatQQParams): Stat;
|
|
42
|
+
/**
|
|
43
|
+
* Create stat_qq_line transformation
|
|
44
|
+
* Returns two points defining the Q-Q reference line
|
|
45
|
+
*/
|
|
46
|
+
export declare function stat_qq_line(params?: StatQQParams): Stat;
|
|
47
|
+
//# sourceMappingURL=qq.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qq.d.ts","sourceRoot":"","sources":["../../src/stats/qq.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAoB,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAElE,MAAM,WAAW,YAAY;IAC3B,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,CAAA;IACzC,oDAAoD;IACpD,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CACxD;AAED,MAAM,WAAW,QAAQ;IACvB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAA;IACd,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAA;CACpB;AAsFD;;GAEG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,YAAiB,GACxB,QAAQ,EAAE,CAgDZ;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,YAAiB,GACxB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkD7C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,MAAM,GAAE,YAAiB,GAAG,IAAI,CAevD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,YAAiB,GAAG,IAAI,CA+B5D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smooth.d.ts","sourceRoot":"","sources":["../../src/stats/smooth.ts"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KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,UAAU,CAAA;IAC5D,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAA;IACzF,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAA;IACzF,qEAAqE;IACrE,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,gBAAgB,GAAG,cAAc,CAAA;CACpE;AAmED,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAClB,CAAC,EAAE,MAAM,CAAA;IACT,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,iBAAsB,GAC7B,UAAU,CA+EZ;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,iBAAsB,GAAG,IAAI,CAoCjE"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Buffer
|
|
3
|
+
*
|
|
4
|
+
* Efficient circular buffer for streaming data storage.
|
|
5
|
+
* Provides O(1) push/pop operations and automatic capacity management.
|
|
6
|
+
*/
|
|
7
|
+
import type { DataRecord } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Buffer configuration options
|
|
10
|
+
*/
|
|
11
|
+
export interface BufferOptions {
|
|
12
|
+
/** Maximum number of records to store */
|
|
13
|
+
maxSize: number;
|
|
14
|
+
/** Whether to overwrite oldest data when full (default: true) */
|
|
15
|
+
overwrite?: boolean;
|
|
16
|
+
/** Field to use for time-based operations */
|
|
17
|
+
timeField?: string;
|
|
18
|
+
/** Maximum age in milliseconds (removes old data automatically) */
|
|
19
|
+
maxAge?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Circular buffer for efficient streaming data storage
|
|
23
|
+
*/
|
|
24
|
+
export declare class DataBuffer<T extends DataRecord = DataRecord> {
|
|
25
|
+
private buffer;
|
|
26
|
+
private head;
|
|
27
|
+
private tail;
|
|
28
|
+
private _size;
|
|
29
|
+
private options;
|
|
30
|
+
private lastCleanup;
|
|
31
|
+
private cleanupInterval;
|
|
32
|
+
constructor(options: BufferOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Push a single record to the buffer
|
|
35
|
+
*/
|
|
36
|
+
push(record: T): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Push multiple records to the buffer
|
|
39
|
+
*/
|
|
40
|
+
pushMany(records: T[]): number;
|
|
41
|
+
/**
|
|
42
|
+
* Remove and return the oldest record
|
|
43
|
+
*/
|
|
44
|
+
shift(): T | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Get record at index (0 = oldest)
|
|
47
|
+
*/
|
|
48
|
+
get(index: number): T | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Get the most recent record
|
|
51
|
+
*/
|
|
52
|
+
latest(): T | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Get the oldest record
|
|
55
|
+
*/
|
|
56
|
+
oldest(): T | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Get all records as array (oldest to newest)
|
|
59
|
+
*/
|
|
60
|
+
toArray(): T[];
|
|
61
|
+
/**
|
|
62
|
+
* Get records within a time range
|
|
63
|
+
*/
|
|
64
|
+
getTimeRange(startTime: number, endTime: number): T[];
|
|
65
|
+
/**
|
|
66
|
+
* Get the last N records
|
|
67
|
+
*/
|
|
68
|
+
getLast(n: number): T[];
|
|
69
|
+
/**
|
|
70
|
+
* Clear all data
|
|
71
|
+
*/
|
|
72
|
+
clear(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Current number of records
|
|
75
|
+
*/
|
|
76
|
+
get size(): number;
|
|
77
|
+
/**
|
|
78
|
+
* Maximum capacity
|
|
79
|
+
*/
|
|
80
|
+
get capacity(): number;
|
|
81
|
+
/**
|
|
82
|
+
* Whether buffer is full
|
|
83
|
+
*/
|
|
84
|
+
get isFull(): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Whether buffer is empty
|
|
87
|
+
*/
|
|
88
|
+
get isEmpty(): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Get time range of data in buffer
|
|
91
|
+
*/
|
|
92
|
+
getTimeExtent(): {
|
|
93
|
+
min: number;
|
|
94
|
+
max: number;
|
|
95
|
+
} | null;
|
|
96
|
+
/**
|
|
97
|
+
* Remove data older than maxAge
|
|
98
|
+
*/
|
|
99
|
+
private cleanupOldData;
|
|
100
|
+
/**
|
|
101
|
+
* Iterate over all records
|
|
102
|
+
*/
|
|
103
|
+
[Symbol.iterator](): Iterator<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Map over all records
|
|
106
|
+
*/
|
|
107
|
+
map<U>(fn: (record: T, index: number) => U): U[];
|
|
108
|
+
/**
|
|
109
|
+
* Filter records
|
|
110
|
+
*/
|
|
111
|
+
filter(fn: (record: T) => boolean): T[];
|
|
112
|
+
/**
|
|
113
|
+
* Reduce records
|
|
114
|
+
*/
|
|
115
|
+
reduce<U>(fn: (acc: U, record: T) => U, initial: U): U;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create a data buffer with the given options
|
|
119
|
+
*/
|
|
120
|
+
export declare function createDataBuffer<T extends DataRecord = DataRecord>(options: BufferOptions): DataBuffer<T>;
|
|
121
|
+
//# sourceMappingURL=data-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-buffer.d.ts","sourceRoot":"","sources":["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AAI,IAAI;IAMb;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,aAAa,IAAI;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAmBpD;;OAEG;IACH,OAAO,CAAC,cAAc;IAwBtB;;OAEG;IACF,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC;IAOjC;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE;IAShD;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,GAAG,CAAC,EAAE;IAUvC;;OAEG;IACH,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC;CAOvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAChE,OAAO,EAAE,aAAa,GACrB,UAAU,CAAC,CAAC,CAAC,CAEf"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Window
|
|
3
|
+
*
|
|
4
|
+
* Manages time-windowed or count-windowed data for streaming plots.
|
|
5
|
+
* Provides sliding window views over streaming data.
|
|
6
|
+
*/
|
|
7
|
+
import type { DataRecord } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Window configuration options
|
|
10
|
+
*/
|
|
11
|
+
export interface WindowOptions {
|
|
12
|
+
/** Window type: time-based or count-based */
|
|
13
|
+
type: 'time' | 'count';
|
|
14
|
+
/** Window size (milliseconds for time, count for count) */
|
|
15
|
+
size: number;
|
|
16
|
+
/** Slide interval (how often to advance the window) */
|
|
17
|
+
slide?: number;
|
|
18
|
+
/** Field to use for time values */
|
|
19
|
+
timeField?: string;
|
|
20
|
+
/** Maximum buffer size (for memory management) */
|
|
21
|
+
maxBufferSize?: number;
|
|
22
|
+
/** Whether to emit partial windows at start */
|
|
23
|
+
emitPartial?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Statistics for the current window
|
|
27
|
+
*/
|
|
28
|
+
export interface WindowStats {
|
|
29
|
+
/** Number of records in window */
|
|
30
|
+
count: number;
|
|
31
|
+
/** Start time/index of window */
|
|
32
|
+
start: number;
|
|
33
|
+
/** End time/index of window */
|
|
34
|
+
end: number;
|
|
35
|
+
/** Duration (for time windows) */
|
|
36
|
+
duration: number;
|
|
37
|
+
/** Records per second (for time windows) */
|
|
38
|
+
rate: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Window event types
|
|
42
|
+
*/
|
|
43
|
+
export type WindowEventType = 'data' | 'slide' | 'full' | 'empty';
|
|
44
|
+
/**
|
|
45
|
+
* Window event handler
|
|
46
|
+
*/
|
|
47
|
+
export type WindowEventHandler<T extends DataRecord> = (event: WindowEventType, data: T[], stats: WindowStats) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Data Window for streaming data management
|
|
50
|
+
*/
|
|
51
|
+
export declare class DataWindow<T extends DataRecord = DataRecord> {
|
|
52
|
+
private buffer;
|
|
53
|
+
private options;
|
|
54
|
+
private windowStart;
|
|
55
|
+
private lastSlide;
|
|
56
|
+
private eventHandlers;
|
|
57
|
+
private recordCount;
|
|
58
|
+
constructor(options: WindowOptions);
|
|
59
|
+
/**
|
|
60
|
+
* Push a single record
|
|
61
|
+
*/
|
|
62
|
+
push(record: T): void;
|
|
63
|
+
/**
|
|
64
|
+
* Push multiple records
|
|
65
|
+
*/
|
|
66
|
+
pushMany(records: T[]): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get data in the current window
|
|
69
|
+
*/
|
|
70
|
+
getWindowData(): T[];
|
|
71
|
+
/**
|
|
72
|
+
* Get data for a time-based window
|
|
73
|
+
*/
|
|
74
|
+
private getTimeWindowData;
|
|
75
|
+
/**
|
|
76
|
+
* Get data for a count-based window
|
|
77
|
+
*/
|
|
78
|
+
private getCountWindowData;
|
|
79
|
+
/**
|
|
80
|
+
* Check if window should slide
|
|
81
|
+
*/
|
|
82
|
+
private checkSlide;
|
|
83
|
+
/**
|
|
84
|
+
* Get current window statistics
|
|
85
|
+
*/
|
|
86
|
+
getStats(): WindowStats;
|
|
87
|
+
/**
|
|
88
|
+
* Get all buffered data (not just window)
|
|
89
|
+
*/
|
|
90
|
+
getAllData(): T[];
|
|
91
|
+
/**
|
|
92
|
+
* Clear all data
|
|
93
|
+
*/
|
|
94
|
+
clear(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Register event handler
|
|
97
|
+
*/
|
|
98
|
+
on(event: WindowEventType, handler: WindowEventHandler<T>): void;
|
|
99
|
+
/**
|
|
100
|
+
* Remove event handler
|
|
101
|
+
*/
|
|
102
|
+
off(event: WindowEventType, handler: WindowEventHandler<T>): void;
|
|
103
|
+
/**
|
|
104
|
+
* Emit event to handlers
|
|
105
|
+
*/
|
|
106
|
+
private emit;
|
|
107
|
+
/**
|
|
108
|
+
* Get buffer size
|
|
109
|
+
*/
|
|
110
|
+
get bufferSize(): number;
|
|
111
|
+
/**
|
|
112
|
+
* Get window size configuration
|
|
113
|
+
*/
|
|
114
|
+
get windowSize(): number;
|
|
115
|
+
/**
|
|
116
|
+
* Check if window is full
|
|
117
|
+
*/
|
|
118
|
+
get isFull(): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Get field statistics for the current window
|
|
121
|
+
*/
|
|
122
|
+
getFieldStats(field: string): {
|
|
123
|
+
min: number;
|
|
124
|
+
max: number;
|
|
125
|
+
mean: number;
|
|
126
|
+
sum: number;
|
|
127
|
+
} | null;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Create a data window with the given options
|
|
131
|
+
*/
|
|
132
|
+
export declare function createDataWindow<T extends DataRecord = DataRecord>(options: WindowOptions): DataWindow<T>;
|
|
133
|
+
//# sourceMappingURL=data-window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-window.d.ts","sourceRoot":"","sources":["../../src/streaming/data-window.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG1C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,6CAA6C;IAC7C,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IACtB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAA;IACZ,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAA;AAEjE;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,UAAU,IAAI,CACrD,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,CA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AE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;CAwB7F;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAChE,OAAO,EAAE,aAAa,GACrB,UAAU,CAAC,CAAC,CAAC,CAEf"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming Data Support
|
|
3
|
+
*
|
|
4
|
+
* Provides real-time data streaming capabilities for ggterm plots:
|
|
5
|
+
* - Incremental data updates with .push()
|
|
6
|
+
* - Time-windowed rendering (sliding window)
|
|
7
|
+
* - Rolling aggregations (mean, sum, min, max)
|
|
8
|
+
* - Efficient buffer management
|
|
9
|
+
*/
|
|
10
|
+
export { StreamingPlot, createStreamingPlot, createTimeSeriesPlot, type StreamingPlotOptions, type StreamingPlotState, } from './streaming-plot';
|
|
11
|
+
export { DataWindow, createDataWindow, type WindowOptions, type WindowStats, } from './data-window';
|
|
12
|
+
export { RollingAggregator, createRollingAggregator, createMultiAggregator, ExponentialMovingAverage, type AggregationType, type RollingOptions, } from './rolling-aggregator';
|
|
13
|
+
export { DataBuffer, createDataBuffer, type BufferOptions, } from './data-buffer';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/streaming/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GACxB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,WAAW,GACjB,MAAM,eAAe,CAAA;AAEtB,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rolling Aggregator
|
|
3
|
+
*
|
|
4
|
+
* Computes rolling/sliding window aggregations efficiently.
|
|
5
|
+
* Supports mean, sum, min, max, count, variance, and custom aggregations.
|
|
6
|
+
*/
|
|
7
|
+
import type { DataRecord } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Built-in aggregation types
|
|
10
|
+
*/
|
|
11
|
+
export type AggregationType = 'mean' | 'sum' | 'min' | 'max' | 'count' | 'first' | 'last' | 'variance' | 'stddev' | 'median';
|
|
12
|
+
/**
|
|
13
|
+
* Rolling aggregation options
|
|
14
|
+
*/
|
|
15
|
+
export interface RollingOptions {
|
|
16
|
+
/** Window size for aggregation */
|
|
17
|
+
windowSize: number;
|
|
18
|
+
/** Field to aggregate */
|
|
19
|
+
field: string;
|
|
20
|
+
/** Aggregation type */
|
|
21
|
+
type: AggregationType;
|
|
22
|
+
/** Output field name (defaults to field_type) */
|
|
23
|
+
outputField?: string;
|
|
24
|
+
/** Minimum number of values required to compute (default: 1) */
|
|
25
|
+
minPeriods?: number;
|
|
26
|
+
/** Center the window (default: false = trailing) */
|
|
27
|
+
center?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Rolling Aggregator class
|
|
31
|
+
*/
|
|
32
|
+
export declare class RollingAggregator<T extends DataRecord = DataRecord> {
|
|
33
|
+
private options;
|
|
34
|
+
private state;
|
|
35
|
+
constructor(options: RollingOptions);
|
|
36
|
+
/**
|
|
37
|
+
* Add a value and get the current aggregation
|
|
38
|
+
*/
|
|
39
|
+
push(value: number): number | null;
|
|
40
|
+
/**
|
|
41
|
+
* Process a record and return it with the aggregated field added
|
|
42
|
+
*/
|
|
43
|
+
process(record: T): T & {
|
|
44
|
+
[key: string]: number | null;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Process multiple records
|
|
48
|
+
*/
|
|
49
|
+
processMany(records: T[]): Array<T & {
|
|
50
|
+
[key: string]: number | null;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Compute the current aggregation value
|
|
54
|
+
*/
|
|
55
|
+
private compute;
|
|
56
|
+
/**
|
|
57
|
+
* Get value at position in window (0 = oldest)
|
|
58
|
+
*/
|
|
59
|
+
private getValueAt;
|
|
60
|
+
/**
|
|
61
|
+
* Compute median (requires sorting, O(n log n))
|
|
62
|
+
*/
|
|
63
|
+
private computeMedian;
|
|
64
|
+
/**
|
|
65
|
+
* Get all values in the current window
|
|
66
|
+
*/
|
|
67
|
+
private getWindowValues;
|
|
68
|
+
/**
|
|
69
|
+
* Recalculate min/max from scratch (needed when oldest value leaves window)
|
|
70
|
+
*/
|
|
71
|
+
private recalculateMinMax;
|
|
72
|
+
/**
|
|
73
|
+
* Reset the aggregator state
|
|
74
|
+
*/
|
|
75
|
+
reset(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Get current window size (number of values)
|
|
78
|
+
*/
|
|
79
|
+
get currentSize(): number;
|
|
80
|
+
/**
|
|
81
|
+
* Get configured window size
|
|
82
|
+
*/
|
|
83
|
+
get windowSize(): number;
|
|
84
|
+
/**
|
|
85
|
+
* Get the output field name
|
|
86
|
+
*/
|
|
87
|
+
get outputField(): string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Create a rolling aggregator
|
|
91
|
+
*/
|
|
92
|
+
export declare function createRollingAggregator<T extends DataRecord = DataRecord>(options: RollingOptions): RollingAggregator<T>;
|
|
93
|
+
/**
|
|
94
|
+
* Create multiple rolling aggregators and combine their output
|
|
95
|
+
*/
|
|
96
|
+
export declare function createMultiAggregator<T extends DataRecord = DataRecord>(configs: RollingOptions[]): {
|
|
97
|
+
process: (record: T) => T & {
|
|
98
|
+
[key: string]: number | null;
|
|
99
|
+
};
|
|
100
|
+
processMany: (records: T[]) => Array<T & {
|
|
101
|
+
[key: string]: number | null;
|
|
102
|
+
}>;
|
|
103
|
+
reset: () => void;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Exponential Moving Average (EMA) calculator
|
|
107
|
+
*/
|
|
108
|
+
export declare class ExponentialMovingAverage {
|
|
109
|
+
private alpha;
|
|
110
|
+
private value;
|
|
111
|
+
constructor(span: number);
|
|
112
|
+
push(value: number): number;
|
|
113
|
+
get current(): number | null;
|
|
114
|
+
reset(): void;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=rolling-aggregator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rolling-aggregator.d.ts","sourceRoot":"","sources":["../../src/streaming/rolling-aggregator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,KAAK,GACL,KAAK,GACL,KAAK,GACL,OAAO,GACP,OAAO,GACP,MAAM,GACN,UAAU,GACV,QAAQ,GACR,QAAQ,CAAA;AAEZ;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAA;IAClB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,uBAAuB;IACvB,IAAI,EAAE,eAAe,CAAA;IACrB,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oDAAoD;IACpD,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAeD;;GAEG;AACH,qBAAa,iBAAiB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU;IAC9D,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,KAAK,CA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AG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAA;IAC1E,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB,CA2BA;AAED;;GAEG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,KAAK,CAAsB;gBAEvB,IAAI,EAAE,MAAM;IAKxB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAS3B,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming Plot
|
|
3
|
+
*
|
|
4
|
+
* High-level API for creating streaming/real-time plots.
|
|
5
|
+
* Combines data buffering, windowing, aggregation, and rendering.
|
|
6
|
+
*/
|
|
7
|
+
import type { DataRecord, AestheticMapping, Geom, Scale, Theme, Labels } from '../types';
|
|
8
|
+
import { type RollingOptions } from './rolling-aggregator';
|
|
9
|
+
/**
|
|
10
|
+
* Streaming plot configuration
|
|
11
|
+
*/
|
|
12
|
+
export interface StreamingPlotOptions {
|
|
13
|
+
/** Maximum number of points to display */
|
|
14
|
+
maxPoints?: number;
|
|
15
|
+
/** Time window in milliseconds (alternative to maxPoints) */
|
|
16
|
+
timeWindow?: number;
|
|
17
|
+
/** Field to use for time-based operations */
|
|
18
|
+
timeField?: string;
|
|
19
|
+
/** Update throttle in milliseconds */
|
|
20
|
+
throttleMs?: number;
|
|
21
|
+
/** Auto-rescale axes on new data */
|
|
22
|
+
autoScale?: boolean;
|
|
23
|
+
/** Rolling aggregations to compute */
|
|
24
|
+
aggregations?: RollingOptions[];
|
|
25
|
+
/** Initial aesthetic mapping */
|
|
26
|
+
aes?: AestheticMapping;
|
|
27
|
+
/** Initial geometries */
|
|
28
|
+
geoms?: Geom[];
|
|
29
|
+
/** Initial scales */
|
|
30
|
+
scales?: Scale[];
|
|
31
|
+
/** Theme */
|
|
32
|
+
theme?: Partial<Theme>;
|
|
33
|
+
/** Labels */
|
|
34
|
+
labels?: Labels;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Current state of the streaming plot
|
|
38
|
+
*/
|
|
39
|
+
export interface StreamingPlotState {
|
|
40
|
+
/** Total points received */
|
|
41
|
+
totalPoints: number;
|
|
42
|
+
/** Points currently displayed */
|
|
43
|
+
displayedPoints: number;
|
|
44
|
+
/** Points per second (recent) */
|
|
45
|
+
pointsPerSecond: number;
|
|
46
|
+
/** Last update timestamp */
|
|
47
|
+
lastUpdate: number;
|
|
48
|
+
/** Is currently rendering */
|
|
49
|
+
isRendering: boolean;
|
|
50
|
+
/** Last render duration in ms */
|
|
51
|
+
lastRenderMs: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Render output
|
|
55
|
+
*/
|
|
56
|
+
export interface RenderOutput {
|
|
57
|
+
/** Rendered string */
|
|
58
|
+
output: string;
|
|
59
|
+
/** Render duration in ms */
|
|
60
|
+
renderMs: number;
|
|
61
|
+
/** Number of points rendered */
|
|
62
|
+
pointCount: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Event types for streaming plot
|
|
66
|
+
*/
|
|
67
|
+
export type StreamingEventType = 'data' | 'render' | 'resize' | 'error';
|
|
68
|
+
export declare class StreamingPlot<T extends DataRecord = DataRecord> {
|
|
69
|
+
private options;
|
|
70
|
+
private buffer;
|
|
71
|
+
private window;
|
|
72
|
+
private aggregators;
|
|
73
|
+
private plot;
|
|
74
|
+
private state;
|
|
75
|
+
private lastRenderTime;
|
|
76
|
+
private recentPoints;
|
|
77
|
+
private eventHandlers;
|
|
78
|
+
private pendingRender;
|
|
79
|
+
private renderWidth;
|
|
80
|
+
private renderHeight;
|
|
81
|
+
constructor(options?: StreamingPlotOptions);
|
|
82
|
+
/**
|
|
83
|
+
* Push a single data point
|
|
84
|
+
*/
|
|
85
|
+
push(record: T): this;
|
|
86
|
+
/**
|
|
87
|
+
* Push multiple data points
|
|
88
|
+
*/
|
|
89
|
+
pushMany(records: T[]): this;
|
|
90
|
+
/**
|
|
91
|
+
* Get current data for rendering
|
|
92
|
+
*/
|
|
93
|
+
getData(): T[];
|
|
94
|
+
/**
|
|
95
|
+
* Render the plot to a string
|
|
96
|
+
*/
|
|
97
|
+
render(options?: {
|
|
98
|
+
width?: number;
|
|
99
|
+
height?: number;
|
|
100
|
+
}): RenderOutput;
|
|
101
|
+
/**
|
|
102
|
+
* Schedule a throttled render
|
|
103
|
+
*/
|
|
104
|
+
private scheduleRender;
|
|
105
|
+
/**
|
|
106
|
+
* Clean up old timestamps from rate tracking
|
|
107
|
+
*/
|
|
108
|
+
private cleanupRateTracking;
|
|
109
|
+
/**
|
|
110
|
+
* Get current state
|
|
111
|
+
*/
|
|
112
|
+
getState(): StreamingPlotState;
|
|
113
|
+
/**
|
|
114
|
+
* Set render dimensions
|
|
115
|
+
*/
|
|
116
|
+
setSize(width: number, height: number): this;
|
|
117
|
+
/**
|
|
118
|
+
* Update aesthetic mapping
|
|
119
|
+
*/
|
|
120
|
+
setAes(aes: AestheticMapping): this;
|
|
121
|
+
/**
|
|
122
|
+
* Add a geometry
|
|
123
|
+
*/
|
|
124
|
+
addGeom(geom: Geom): this;
|
|
125
|
+
/**
|
|
126
|
+
* Set geometries (replaces existing)
|
|
127
|
+
*/
|
|
128
|
+
setGeoms(geoms: Geom[]): this;
|
|
129
|
+
/**
|
|
130
|
+
* Add a scale
|
|
131
|
+
*/
|
|
132
|
+
addScale(scale: Scale): this;
|
|
133
|
+
/**
|
|
134
|
+
* Set labels
|
|
135
|
+
*/
|
|
136
|
+
setLabels(labels: Labels): this;
|
|
137
|
+
/**
|
|
138
|
+
* Add a rolling aggregation
|
|
139
|
+
*/
|
|
140
|
+
addAggregation(options: RollingOptions): this;
|
|
141
|
+
/**
|
|
142
|
+
* Clear all data
|
|
143
|
+
*/
|
|
144
|
+
clear(): this;
|
|
145
|
+
/**
|
|
146
|
+
* Get buffer statistics
|
|
147
|
+
*/
|
|
148
|
+
getBufferStats(): {
|
|
149
|
+
size: number;
|
|
150
|
+
capacity: number;
|
|
151
|
+
utilization: number;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Register event handler
|
|
155
|
+
*/
|
|
156
|
+
on(event: StreamingEventType, handler: (data: unknown) => void): this;
|
|
157
|
+
/**
|
|
158
|
+
* Remove event handler
|
|
159
|
+
*/
|
|
160
|
+
off(event: StreamingEventType, handler: (data: unknown) => void): this;
|
|
161
|
+
/**
|
|
162
|
+
* Emit event
|
|
163
|
+
*/
|
|
164
|
+
private emit;
|
|
165
|
+
/**
|
|
166
|
+
* Get time extent of current data
|
|
167
|
+
*/
|
|
168
|
+
getTimeExtent(): {
|
|
169
|
+
min: number;
|
|
170
|
+
max: number;
|
|
171
|
+
} | null;
|
|
172
|
+
/**
|
|
173
|
+
* Get value extent for a field
|
|
174
|
+
*/
|
|
175
|
+
getFieldExtent(field: string): {
|
|
176
|
+
min: number;
|
|
177
|
+
max: number;
|
|
178
|
+
} | null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Create a streaming plot with the given options
|
|
182
|
+
*/
|
|
183
|
+
export declare function createStreamingPlot<T extends DataRecord = DataRecord>(options?: StreamingPlotOptions): StreamingPlot<T>;
|
|
184
|
+
/**
|
|
185
|
+
* Create a time-series streaming plot
|
|
186
|
+
*/
|
|
187
|
+
export declare function createTimeSeriesPlot<T extends DataRecord = DataRecord>(options: {
|
|
188
|
+
timeField?: string;
|
|
189
|
+
valueField?: string;
|
|
190
|
+
timeWindow?: number;
|
|
191
|
+
maxPoints?: number;
|
|
192
|
+
title?: string;
|
|
193
|
+
}): StreamingPlot<T>;
|
|
194
|
+
//# sourceMappingURL=streaming-plot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming-plot.d.ts","sourceRoot":"","sources":["../../src/streaming/streaming-plot.ts"],"names":[],"mappings":"A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