trackplot 0.1.0 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd833ad4b756522e2bdb9fc4e0f6191c6c08b19a201594c734b6462d39d8393a
4
- data.tar.gz: 2f2252c88ab1f1a26ba96691ba144e563c872cae9d04a9b48c50cbe1bcea7dc9
3
+ metadata.gz: f1640bf80db9c399eac8aeb2df85355ad008dec2b91c3b7e3a8c87fa1dfaaddc
4
+ data.tar.gz: 88a4e3de4b79d903085690c6dd7bcd9795f9f574fc083d1b68b03e0eba7a19bc
5
5
  SHA512:
6
- metadata.gz: d103b294082c7ac43aca2413159a41601f23629440ff4a6a5f466e3ba4b2cea68937a412189d1688da1f992c9187abaeef6fdf2ecddbf19ad4fb31fb5211919a
7
- data.tar.gz: 4281f9f68481f93be1734292a9f8a9afa2e8c6873975c41cb422a43bd97c14d8e9adad8180a2425492c81b3922cb262456123d5c7f4d36911c19973867a9930a
6
+ metadata.gz: 90143b3d120b726acf7fe579314636d8e7526de86d34d384f053663ddee6eb41497176aa6d670c28c8b2d1c52a7a6e6b516d3fd5d9d433287597b7c1360746a1
7
+ data.tar.gz: 58cb42158c1d86bf600e93a1c7ae0792e4cbb270e1d9177d6d96da84d90ae41070c686a72a0fbcad98ff026fb3d4673d61d0977095807bb6b3ee59e6f9ec433a
@@ -0,0 +1,292 @@
1
+ // ─── Theme ──────────────────────────────────────────────────────────────────
2
+
3
+ export interface ThemeConfig {
4
+ colors?: string[];
5
+ background?: string;
6
+ text_color?: string;
7
+ axis_color?: string;
8
+ grid_color?: string;
9
+ tooltip_bg?: string;
10
+ tooltip_text?: string;
11
+ tooltip_border?: string;
12
+ font?: string;
13
+ }
14
+
15
+ // ─── Component Configs ──────────────────────────────────────────────────────
16
+
17
+ export interface LineConfig {
18
+ type: "line";
19
+ data_key: string;
20
+ color?: string;
21
+ stroke_width?: number;
22
+ curve?: boolean;
23
+ dashed?: boolean;
24
+ dot?: boolean;
25
+ dot_size?: number;
26
+ y_axis?: "left" | "right";
27
+ }
28
+
29
+ export interface BarConfig {
30
+ type: "bar";
31
+ data_key: string;
32
+ color?: string;
33
+ opacity?: number;
34
+ radius?: number;
35
+ stack?: string;
36
+ y_axis?: "left" | "right";
37
+ }
38
+
39
+ export interface AreaConfig {
40
+ type: "area";
41
+ data_key: string;
42
+ color?: string;
43
+ opacity?: number;
44
+ stroke_width?: number;
45
+ curve?: boolean;
46
+ stack?: string;
47
+ y_axis?: "left" | "right";
48
+ }
49
+
50
+ export interface ScatterConfig {
51
+ type: "scatter";
52
+ data_key: string;
53
+ x_key?: string;
54
+ color?: string;
55
+ opacity?: number;
56
+ dot_size?: number;
57
+ y_axis?: "left" | "right";
58
+ }
59
+
60
+ export interface PieConfig {
61
+ type: "pie";
62
+ data_key: string;
63
+ label_key?: string;
64
+ donut?: boolean;
65
+ pad_angle?: number;
66
+ }
67
+
68
+ export interface RadarConfig {
69
+ type: "radar";
70
+ data_key: string;
71
+ color?: string;
72
+ opacity?: number;
73
+ stroke_width?: number;
74
+ dot?: boolean;
75
+ dot_size?: number;
76
+ }
77
+
78
+ export interface HorizontalBarConfig {
79
+ type: "horizontal_bar";
80
+ data_key: string;
81
+ color?: string;
82
+ opacity?: number;
83
+ radius?: number;
84
+ }
85
+
86
+ export interface CandlestickConfig {
87
+ type: "candlestick";
88
+ open: string;
89
+ high: string;
90
+ low: string;
91
+ close: string;
92
+ up_color?: string;
93
+ down_color?: string;
94
+ }
95
+
96
+ export interface FunnelConfig {
97
+ type: "funnel";
98
+ data_key: string;
99
+ label_key?: string;
100
+ }
101
+
102
+ export interface HeatmapConfig {
103
+ type: "heatmap";
104
+ x_key: string;
105
+ y_key: string;
106
+ value_key: string;
107
+ color_range?: [string, string];
108
+ radius?: number;
109
+ }
110
+
111
+ export interface TreemapConfig {
112
+ type: "treemap";
113
+ value_key: string;
114
+ label_key: string;
115
+ parent_key?: string;
116
+ }
117
+
118
+ export interface AxisConfig {
119
+ type: "axis";
120
+ direction: "x" | "y";
121
+ axis_id?: "left" | "right";
122
+ data_key?: string;
123
+ label?: string;
124
+ format?: "currency" | "percent" | "compact" | "decimal" | "integer" | string;
125
+ tick_count?: number;
126
+ tick_rotation?: number;
127
+ }
128
+
129
+ export interface TooltipConfig {
130
+ type: "tooltip";
131
+ format?: "currency" | "percent" | "compact" | "decimal" | "integer" | string;
132
+ }
133
+
134
+ export interface LegendConfig {
135
+ type: "legend";
136
+ position?: "top" | "bottom" | "left" | "right";
137
+ clickable?: boolean;
138
+ }
139
+
140
+ export interface GridConfig {
141
+ type: "grid";
142
+ horizontal?: boolean;
143
+ vertical?: boolean;
144
+ }
145
+
146
+ export interface ReferenceLineConfig {
147
+ type: "reference_line";
148
+ direction: "x" | "y";
149
+ value: number | string;
150
+ color?: string;
151
+ stroke_width?: number;
152
+ dashed?: boolean;
153
+ label?: string;
154
+ }
155
+
156
+ export interface DataLabelConfig {
157
+ type: "data_label";
158
+ position?: "top" | "center";
159
+ format?: "currency" | "percent" | "compact" | "decimal" | "integer" | string;
160
+ font_size?: number;
161
+ }
162
+
163
+ export interface BrushConfig {
164
+ type: "brush";
165
+ axis?: "x" | "y";
166
+ height?: number;
167
+ }
168
+
169
+ // ─── Discriminated Union ────────────────────────────────────────────────────
170
+
171
+ export type ComponentConfig =
172
+ | LineConfig
173
+ | BarConfig
174
+ | AreaConfig
175
+ | ScatterConfig
176
+ | PieConfig
177
+ | RadarConfig
178
+ | HorizontalBarConfig
179
+ | CandlestickConfig
180
+ | FunnelConfig
181
+ | HeatmapConfig
182
+ | TreemapConfig
183
+ | AxisConfig
184
+ | TooltipConfig
185
+ | LegendConfig
186
+ | GridConfig
187
+ | ReferenceLineConfig
188
+ | DataLabelConfig
189
+ | BrushConfig;
190
+
191
+ // ─── Chart Config ───────────────────────────────────────────────────────────
192
+
193
+ export interface ChartConfig {
194
+ data: Record<string, unknown>[];
195
+ components: ComponentConfig[];
196
+ animate?: boolean;
197
+ theme?: ThemeConfig;
198
+ title?: string;
199
+ description?: string;
200
+ empty_message?: string;
201
+ }
202
+
203
+ // ─── Sparkline Config ───────────────────────────────────────────────────────
204
+
205
+ export interface SparklineConfig {
206
+ data: Record<string, unknown>[];
207
+ key: string;
208
+ type?: "line" | "bar" | "area";
209
+ color?: string;
210
+ fill?: string;
211
+ stroke_width?: number;
212
+ dot?: boolean;
213
+ }
214
+
215
+ // ─── Custom Event Details ───────────────────────────────────────────────────
216
+
217
+ export interface TrackplotClickDetail {
218
+ chartType: string;
219
+ dataKey: string;
220
+ datum: Record<string, unknown>;
221
+ index: number;
222
+ value: unknown;
223
+ }
224
+
225
+ export interface TrackplotDataUpdateDetail {
226
+ count: number;
227
+ }
228
+
229
+ // ─── Custom Event Maps ──────────────────────────────────────────────────────
230
+
231
+ interface TrackplotEventMap {
232
+ "trackplot:click": CustomEvent<TrackplotClickDetail>;
233
+ "trackplot:data-update": CustomEvent<TrackplotDataUpdateDetail>;
234
+ "trackplot:render": CustomEvent<void>;
235
+ }
236
+
237
+ // ─── Custom Elements ────────────────────────────────────────────────────────
238
+
239
+ export declare class TrackplotElement extends HTMLElement {
240
+ /** Replace chart data and re-render without animation. */
241
+ updateData(newData: Record<string, unknown>[]): void;
242
+
243
+ /** Replace the full config object and re-render. */
244
+ updateConfig(config: ChartConfig): void;
245
+
246
+ /** Append new data points and re-render with sliding window. */
247
+ appendData(
248
+ newPoints: Record<string, unknown>[],
249
+ options?: { maxPoints?: number }
250
+ ): void;
251
+
252
+ /** Export chart as SVG file download. */
253
+ exportSVG(filename?: string): Promise<Blob | null>;
254
+
255
+ /** Export chart as PNG file download. */
256
+ exportPNG(scale?: number, filename?: string): Promise<Blob | null>;
257
+
258
+ addEventListener<K extends keyof TrackplotEventMap>(
259
+ type: K,
260
+ listener: (this: TrackplotElement, ev: TrackplotEventMap[K]) => void,
261
+ options?: boolean | AddEventListenerOptions
262
+ ): void;
263
+
264
+ addEventListener(
265
+ type: string,
266
+ listener: EventListenerOrEventListenerObject,
267
+ options?: boolean | AddEventListenerOptions
268
+ ): void;
269
+
270
+ removeEventListener<K extends keyof TrackplotEventMap>(
271
+ type: K,
272
+ listener: (this: TrackplotElement, ev: TrackplotEventMap[K]) => void,
273
+ options?: boolean | EventListenerOptions
274
+ ): void;
275
+
276
+ removeEventListener(
277
+ type: string,
278
+ listener: EventListenerOrEventListenerObject,
279
+ options?: boolean | EventListenerOptions
280
+ ): void;
281
+ }
282
+
283
+ export declare class SparklineElement extends HTMLElement {}
284
+
285
+ // ─── Global Augmentation ────────────────────────────────────────────────────
286
+
287
+ declare global {
288
+ interface HTMLElementTagNameMap {
289
+ "trackplot-chart": TrackplotElement;
290
+ "trackplot-sparkline": SparklineElement;
291
+ }
292
+ }