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