plotagents 0.0.0-stage → 0.7.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/AGENTS.md +98 -0
- package/LICENSE +21 -0
- package/README.md +217 -2
- package/bin/plotagents.js +73 -0
- package/dist/plotagents-geo.js +79 -0
- package/dist/plotagents.js +11611 -0
- package/docs/api.md +172 -0
- package/docs/charts.md +352 -0
- package/docs/colorscales.md +46 -0
- package/docs/dashboards.md +79 -0
- package/docs/getting-started.md +142 -0
- package/docs/rendering.md +47 -0
- package/docs/themes.md +116 -0
- package/index.d.ts +384 -0
- package/package.json +80 -4
- package/schema.json +1874 -0
- package/src/axes.js +152 -0
- package/src/charts/bar.js +350 -0
- package/src/charts/categorical.js +495 -0
- package/src/charts/chord.js +218 -0
- package/src/charts/choropleth.js +807 -0
- package/src/charts/dist.js +530 -0
- package/src/charts/donut.js +232 -0
- package/src/charts/flowchart.js +407 -0
- package/src/charts/gantt.js +460 -0
- package/src/charts/heatmap.js +76 -0
- package/src/charts/kpi.js +100 -0
- package/src/charts/line.js +551 -0
- package/src/charts/network.js +707 -0
- package/src/charts/pointmap.js +599 -0
- package/src/charts/pyramid.js +177 -0
- package/src/charts/radar.js +158 -0
- package/src/charts/regplot.js +370 -0
- package/src/charts/sankey.js +169 -0
- package/src/charts/scatter.js +214 -0
- package/src/charts/sunburst.js +136 -0
- package/src/charts/treemap.js +197 -0
- package/src/charts/wordcloud.js +163 -0
- package/src/colorscales.js +182 -0
- package/src/context.js +10 -0
- package/src/dashboard.js +438 -0
- package/src/dashed.js +90 -0
- package/src/data.js +137 -0
- package/src/facet.js +84 -0
- package/src/format.js +203 -0
- package/src/frame.js +226 -0
- package/src/geo/chile.js +7 -0
- package/src/geo/data/chile-regiones.js +12 -0
- package/src/geo/data/usa-estados.js +12 -0
- package/src/geo/data/world.js +12 -0
- package/src/geo/projection.js +217 -0
- package/src/geo/registry.js +110 -0
- package/src/geo/usa.js +8 -0
- package/src/geo/world.js +7 -0
- package/src/hierarchy.js +139 -0
- package/src/index.js +336 -0
- package/src/infer.js +58 -0
- package/src/interact.js +483 -0
- package/src/lint.js +417 -0
- package/src/palette.js +59 -0
- package/src/runtime.js +416 -0
- package/src/scale.js +241 -0
- package/src/schema.js +337 -0
- package/src/stats.js +303 -0
- package/src/svg.js +85 -0
- package/src/text.js +61 -0
- package/src/theme.js +311 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
// plotagents type declarations.
|
|
2
|
+
|
|
3
|
+
export type ChartType =
|
|
4
|
+
| 'auto' | 'bar' | 'column' | 'count' | 'line' | 'area' | 'scatter' | 'bubble'
|
|
5
|
+
| 'regplot' | 'residplot' | 'jointplot' | 'hist' | 'kde' | 'ecdf'
|
|
6
|
+
| 'box' | 'violin' | 'strip' | 'swarm' | 'point' | 'radar'
|
|
7
|
+
| 'treemap' | 'sunburst' | 'donut' | 'pie' | 'heatmap' | 'sankey' | 'kpi'
|
|
8
|
+
| 'network' | 'chord' | 'pyramid' | 'flowchart' | 'gantt' | 'wordcloud' | 'choropleth' | 'symbolmap' | 'pointmap'
|
|
9
|
+
// Aliases (seaborn and others)
|
|
10
|
+
| 'barplot' | 'countplot' | 'lineplot' | 'scatterplot' | 'histplot' | 'kdeplot' | 'ecdfplot'
|
|
11
|
+
| 'lmplot' | 'boxplot' | 'violinplot' | 'stripplot' | 'swarmplot' | 'beeswarm' | 'pointplot' | 'spider'
|
|
12
|
+
| 'timeline' | 'roadmap' | 'schedule' | 'cronograma' | 'map' | 'mapa';
|
|
13
|
+
|
|
14
|
+
export type Row = Record<string, string | number | Date | null | undefined>;
|
|
15
|
+
|
|
16
|
+
export type Format =
|
|
17
|
+
| 'number' | 'compact' | 'percent' | 'currency' | 'integer'
|
|
18
|
+
| { type?: 'number' | 'compact' | 'percent' | 'currency' | 'integer'; prefix?: string; suffix?: string; /** 0–20. */ decimals?: number; currency?: string; scale?: number };
|
|
19
|
+
|
|
20
|
+
export interface KpiItem {
|
|
21
|
+
label: string;
|
|
22
|
+
value: number;
|
|
23
|
+
/** Relative change as a fraction (0.12 = +12%). */
|
|
24
|
+
delta?: number;
|
|
25
|
+
previous?: number;
|
|
26
|
+
period?: string;
|
|
27
|
+
good?: 'up' | 'down';
|
|
28
|
+
trend?: number[];
|
|
29
|
+
target?: number;
|
|
30
|
+
format?: Format;
|
|
31
|
+
display?: string;
|
|
32
|
+
note?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface RefLine { y?: number; x?: number; value?: number; label?: string; color?: string }
|
|
36
|
+
export interface Annotation { x: string | number | Date; label?: string }
|
|
37
|
+
|
|
38
|
+
export interface Theme {
|
|
39
|
+
name: string;
|
|
40
|
+
mode: 'light' | 'dark';
|
|
41
|
+
surface: string; ink: string; lede: string; muted: string;
|
|
42
|
+
grid: string; axis: string; tint: string; tint2: string; dim: string; other: string;
|
|
43
|
+
link: number;
|
|
44
|
+
categorical: string[]; sequential: string[]; diverging: string[];
|
|
45
|
+
status: { good: string; warning: string; critical: string };
|
|
46
|
+
font: { family: string; mono: string; import: string };
|
|
47
|
+
type: { title: number; subtitle: number; label: number; axis: number; legend: number; source: number; titleWeight: number };
|
|
48
|
+
marks: { barRadius: number; barMax: number; barMaxH: number; lineWidth: number; pointRadius: number; gap: number; ring: number; areaOpacity: number; bandOpacity: number; dotOpacity: number };
|
|
49
|
+
axes: { inside: boolean; grid: boolean };
|
|
50
|
+
layout: { padding: number; paddingSmall: number };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type DeepPartial<T> = { [K in keyof T]?: T[K] extends object ? (T[K] extends any[] ? T[K] | string : DeepPartial<T[K]>) : T[K] };
|
|
54
|
+
/** Simple theme tokens, mapped onto the full theme. */
|
|
55
|
+
export interface ThemeTokens {
|
|
56
|
+
/** Alias of surface. */
|
|
57
|
+
background?: string;
|
|
58
|
+
/** Alias of ink. */
|
|
59
|
+
text?: string;
|
|
60
|
+
/** First series color. */
|
|
61
|
+
accent?: string;
|
|
62
|
+
/** Grid color, or { color, dash, width }. */
|
|
63
|
+
grid?: string | { color?: string; dash?: string; width?: number };
|
|
64
|
+
axis?: string;
|
|
65
|
+
tooltip?: { bg?: string; ink?: string };
|
|
66
|
+
/** Corner radius of bars and tiles. */
|
|
67
|
+
radius?: number;
|
|
68
|
+
barRadius?: number;
|
|
69
|
+
font?: string | { family?: string; mono?: string; import?: string };
|
|
70
|
+
}
|
|
71
|
+
/** JSON theme: deep-merged over `extends` (default "papel"). Strings: built-in or registerTheme() names. */
|
|
72
|
+
export type ThemeInput = 'papel' | 'noche' | 'light' | 'dark' | (string & {}) | (Omit<DeepPartial<Theme>, 'grid' | 'font'> & ThemeTokens & { extends?: 'papel' | 'noche' | (string & {}) })
|
|
73
|
+
|
|
74
|
+
/** matplotlib colormap name (case-insensitive, `_r` reverses), a list of hex colors, or { name | colors, reverse, mid }. */
|
|
75
|
+
export type ColorScale = string | string[] | { name?: string; colors?: string[]; reverse?: boolean; mid?: number };
|
|
76
|
+
export type LegendPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
77
|
+
export type TileProvider = 'osm' | 'esri-gray' | 'esri-dark' | 'carto-light' | 'carto-dark' | 'mapbox-light' | 'mapbox-dark';
|
|
78
|
+
export type NetworkLayout = 'force' | 'circular' | 'radial' | 'concentric' | 'clusters' | 'tree' | 'grid' | 'circle';
|
|
79
|
+
|
|
80
|
+
export interface Spec {
|
|
81
|
+
type?: ChartType;
|
|
82
|
+
data?: Row[] | Record<string, number>;
|
|
83
|
+
title?: string;
|
|
84
|
+
subtitle?: string;
|
|
85
|
+
source?: string;
|
|
86
|
+
x?: string;
|
|
87
|
+
y?: string | string[];
|
|
88
|
+
series?: string;
|
|
89
|
+
color?: string;
|
|
90
|
+
value?: string;
|
|
91
|
+
label?: string;
|
|
92
|
+
group?: string;
|
|
93
|
+
path?: string[];
|
|
94
|
+
size?: string;
|
|
95
|
+
from?: string;
|
|
96
|
+
to?: string;
|
|
97
|
+
items?: KpiItem[];
|
|
98
|
+
format?: Format;
|
|
99
|
+
xFormat?: Format;
|
|
100
|
+
yFormat?: Format;
|
|
101
|
+
stack?: boolean | 'percent';
|
|
102
|
+
horizontal?: boolean;
|
|
103
|
+
sort?: 'desc' | 'asc' | 'none' | 'alpha' | 'start';
|
|
104
|
+
top?: number;
|
|
105
|
+
highlight?: string | string[];
|
|
106
|
+
/** Dashed shapes (hatched fill + dashed outline): names, a data field, { field, equals } or true. */
|
|
107
|
+
dashed?: string | string[] | boolean | { field: string; equals?: unknown };
|
|
108
|
+
/** line/area/bar on a time axis: dashed from this x on (a projection). */
|
|
109
|
+
dashedFrom?: string | number;
|
|
110
|
+
/** Meaning of the dashed shapes: legend, band label and tooltip. */
|
|
111
|
+
dashedLabel?: string | false;
|
|
112
|
+
labels?: boolean | 'auto' | number | string[];
|
|
113
|
+
labelsFor?: Record<string, string>;
|
|
114
|
+
refLines?: RefLine[] | RefLine;
|
|
115
|
+
annotations?: Annotation[];
|
|
116
|
+
index?: boolean;
|
|
117
|
+
curve?: 'linear' | 'smooth' | 'step';
|
|
118
|
+
zero?: boolean;
|
|
119
|
+
points?: boolean;
|
|
120
|
+
xScale?: 'linear' | 'log';
|
|
121
|
+
yScale?: 'linear' | 'log';
|
|
122
|
+
trend?: boolean;
|
|
123
|
+
xLabel?: string;
|
|
124
|
+
yLabel?: string;
|
|
125
|
+
aggregate?: 'sum' | 'mean' | 'max' | 'min' | 'count' | 'last' | 'first';
|
|
126
|
+
colors?: Record<string, string>;
|
|
127
|
+
theme?: ThemeInput;
|
|
128
|
+
/** Palette name ("okabe-ito", "tab10", "Set2"…, or any colormap, sampled) or a list of colors. */
|
|
129
|
+
palette?: string | string[];
|
|
130
|
+
ramp?: string | string[];
|
|
131
|
+
hue?: string;
|
|
132
|
+
facet?: string;
|
|
133
|
+
col?: string;
|
|
134
|
+
sharey?: boolean;
|
|
135
|
+
sharex?: boolean;
|
|
136
|
+
panelHeight?: number;
|
|
137
|
+
time?: string;
|
|
138
|
+
timeValue?: string | number;
|
|
139
|
+
compare?: 'previous' | 'first' | string | number | false;
|
|
140
|
+
compareData?: Row[];
|
|
141
|
+
colorBy?: 'group' | 'change' | 'label';
|
|
142
|
+
shade?: boolean;
|
|
143
|
+
change?: boolean;
|
|
144
|
+
playInterval?: number;
|
|
145
|
+
xRange?: [string | number, string | number];
|
|
146
|
+
xDomain?: [number, number];
|
|
147
|
+
yDomain?: [number, number];
|
|
148
|
+
ci?: boolean | number;
|
|
149
|
+
errorbar?: 'ci' | 'sd' | 'se' | 'pi' | 'none' | false;
|
|
150
|
+
estimator?: 'mean' | 'median' | 'sum' | 'count';
|
|
151
|
+
focus?: string | string[];
|
|
152
|
+
font?: string | { family: string; import?: string };
|
|
153
|
+
textScale?: number;
|
|
154
|
+
fontScale?: number;
|
|
155
|
+
labelScale?: number;
|
|
156
|
+
depth?: number;
|
|
157
|
+
half?: boolean;
|
|
158
|
+
bins?: number;
|
|
159
|
+
binWidth?: number;
|
|
160
|
+
stat?: 'count' | 'percent' | 'density' | 'probability';
|
|
161
|
+
kde?: boolean;
|
|
162
|
+
multiple?: 'layer' | 'stack' | 'dodge' | 'fill';
|
|
163
|
+
fill?: boolean;
|
|
164
|
+
order?: number | string[];
|
|
165
|
+
lowess?: boolean;
|
|
166
|
+
logx?: boolean;
|
|
167
|
+
annotate?: boolean;
|
|
168
|
+
kind?: 'scatter' | 'reg';
|
|
169
|
+
marginal?: 'hist' | 'kde';
|
|
170
|
+
inner?: 'box' | 'quartiles' | 'points' | 'stick' | 'none';
|
|
171
|
+
split?: boolean;
|
|
172
|
+
axis?: string;
|
|
173
|
+
axes?: string[];
|
|
174
|
+
normalize?: boolean;
|
|
175
|
+
/** Legend on/off or position (default top; left/right fall back to bottom under 520px). */
|
|
176
|
+
legend?: boolean | LegendPosition | { position?: LegendPosition };
|
|
177
|
+
legendTitle?: string;
|
|
178
|
+
/** Drop legend entries (series, first level, group); colors stay fixed and the entries stay in the legend, faded. */
|
|
179
|
+
exclude?: string | string[];
|
|
180
|
+
/** Continuous color scale. Aliases: cmap, colormap. */
|
|
181
|
+
colorScale?: ColorScale;
|
|
182
|
+
cmap?: ColorScale;
|
|
183
|
+
colormap?: ColorScale;
|
|
184
|
+
locale?: 'es' | 'en';
|
|
185
|
+
width?: number;
|
|
186
|
+
height?: number;
|
|
187
|
+
padding?: number;
|
|
188
|
+
fontFamily?: string;
|
|
189
|
+
fontImport?: boolean;
|
|
190
|
+
background?: boolean;
|
|
191
|
+
maxSlices?: number;
|
|
192
|
+
centerValue?: string;
|
|
193
|
+
centerLabel?: string;
|
|
194
|
+
midpoint?: number;
|
|
195
|
+
diverging?: boolean;
|
|
196
|
+
/** choropleth/symbolmap: "chile" (default), "usa", "world", a registered name, your own GeoJSON (FeatureCollection, Feature, Feature[] or geometry) or TopoJSON. In the browser, render() also accepts a URL. */
|
|
197
|
+
geo?: 'chile' | 'usa' | 'world' | string | object | object[];
|
|
198
|
+
/** TopoJSON: object to draw (default: the first). */
|
|
199
|
+
geoObject?: string;
|
|
200
|
+
key?: string;
|
|
201
|
+
/** Feature property matched against `key` (auto-detected when omitted). */
|
|
202
|
+
featureKey?: string;
|
|
203
|
+
/** Feature property with the display name. */
|
|
204
|
+
nameKey?: string;
|
|
205
|
+
projection?: 'mercator' | 'equalEarth' | 'albersUsa' | 'equirectangular' | 'conic' | 'identity' | 'planar' | { type: string; parallels?: [number, number]; rotate?: number; center?: [number, number] };
|
|
206
|
+
/** Zoom to regions, a [lonMin, latMin, lonMax, latMax] box, or "markers". */
|
|
207
|
+
fitTo?: string | string[] | [number, number, number, number];
|
|
208
|
+
markers?: Array<{ lon: number; lat: number; label?: string; value?: number; color?: string }> | { data: Row[]; lon?: string; lat?: string; label?: string; size?: string; color?: string; legend?: string; maxRadius?: number; radius?: number; labels?: boolean };
|
|
209
|
+
layers?: Array<{ geo: object | string; label?: string; stroke?: string; width?: number; fill?: string; dash?: boolean | string; opacity?: number; below?: boolean; object?: string }>;
|
|
210
|
+
borderColor?: string;
|
|
211
|
+
borderWidth?: number;
|
|
212
|
+
pointRadius?: number;
|
|
213
|
+
/** network: node rows (id, group, size). flowchart: steps (id, label, type, lane). */
|
|
214
|
+
nodes?: Row[];
|
|
215
|
+
/** flowchart: connections (from, to, label). Same as `data`. */
|
|
216
|
+
edges?: Row[];
|
|
217
|
+
layout?: NetworkLayout;
|
|
218
|
+
/** network: edge curvature, 0 straight (default 0.3). */
|
|
219
|
+
curveness?: number;
|
|
220
|
+
nodeId?: string;
|
|
221
|
+
nodeLabel?: string;
|
|
222
|
+
/** Largest node / circle radius in px. */
|
|
223
|
+
maxRadius?: number;
|
|
224
|
+
/** network: force-layout iterations. */
|
|
225
|
+
iterations?: number;
|
|
226
|
+
/** chord: square flow matrix with `names`. */
|
|
227
|
+
matrix?: number[][];
|
|
228
|
+
names?: string[];
|
|
229
|
+
directed?: boolean;
|
|
230
|
+
ribbonColor?: 'source' | 'smaller' | 'larger';
|
|
231
|
+
labelOrientation?: 'horizontal' | 'radial';
|
|
232
|
+
direction?: 'TB' | 'LR';
|
|
233
|
+
/** pyramid */
|
|
234
|
+
age?: string;
|
|
235
|
+
sex?: string;
|
|
236
|
+
percent?: boolean;
|
|
237
|
+
/** pointmap: tile basemap with lat/lon dots. */
|
|
238
|
+
lat?: string;
|
|
239
|
+
lon?: string;
|
|
240
|
+
tiles?: TileProvider | { url: string; attribution?: string; subdomains?: string; maxZoom?: number; retina?: boolean } | false;
|
|
241
|
+
/** Public token / API key for the tile provider (a secret Mapbox "sk." token is rejected). */
|
|
242
|
+
tilesKey?: string;
|
|
243
|
+
tileStyle?: 'muted' | 'original';
|
|
244
|
+
tileOpacity?: number;
|
|
245
|
+
zoom?: number;
|
|
246
|
+
/** [lon, lat] */
|
|
247
|
+
center?: [number, number];
|
|
248
|
+
/** choropleth */
|
|
249
|
+
missing?: 'hatch' | 'plain';
|
|
250
|
+
thresholds?: number[];
|
|
251
|
+
classes?: number;
|
|
252
|
+
scale?: 'quantile' | 'equal' | 'continuous' | 'categorical' | number[] | string;
|
|
253
|
+
values?: boolean;
|
|
254
|
+
tall?: boolean;
|
|
255
|
+
/** Seaborn-style options */
|
|
256
|
+
orient?: 'v' | 'h';
|
|
257
|
+
valueDomain?: [number, number];
|
|
258
|
+
bandwidth?: number;
|
|
259
|
+
bwAdjust?: number;
|
|
260
|
+
cut?: number;
|
|
261
|
+
jitter?: number | boolean;
|
|
262
|
+
dodge?: boolean;
|
|
263
|
+
hueOrder?: string[];
|
|
264
|
+
showMeans?: boolean;
|
|
265
|
+
cumulative?: boolean;
|
|
266
|
+
rug?: boolean;
|
|
267
|
+
complementary?: boolean;
|
|
268
|
+
radius?: number;
|
|
269
|
+
endLabels?: boolean;
|
|
270
|
+
/** treemap/sunburst */
|
|
271
|
+
showValues?: boolean;
|
|
272
|
+
hole?: number;
|
|
273
|
+
thickness?: number;
|
|
274
|
+
cellHeight?: number;
|
|
275
|
+
facetOrder?: string[];
|
|
276
|
+
/** gantt */
|
|
277
|
+
task?: string;
|
|
278
|
+
start?: string;
|
|
279
|
+
end?: string;
|
|
280
|
+
duration?: string;
|
|
281
|
+
progress?: string;
|
|
282
|
+
dependsOn?: string;
|
|
283
|
+
milestone?: string;
|
|
284
|
+
today?: string | number | boolean;
|
|
285
|
+
groupHeaders?: boolean | 'compact';
|
|
286
|
+
rowHeight?: number;
|
|
287
|
+
/** gantt: phases drawn collapsed into a summary row; true for all. Click toggles in the browser. */
|
|
288
|
+
collapsed?: boolean | string | string[];
|
|
289
|
+
collapsible?: boolean;
|
|
290
|
+
/** gantt: highlight the zero-slack chain along dependsOn. */
|
|
291
|
+
critical?: boolean;
|
|
292
|
+
criticalColor?: string;
|
|
293
|
+
/** gantt: shade weekends on day plans of up to 120 days (default true). */
|
|
294
|
+
weekends?: boolean;
|
|
295
|
+
todayColor?: string;
|
|
296
|
+
/** Browser time controls, off by default: true (buttons or slider), "buttons" or "slider". */
|
|
297
|
+
slider?: boolean | 'buttons' | 'slider';
|
|
298
|
+
play?: boolean;
|
|
299
|
+
/** wordcloud: words field, or raw text to count. */
|
|
300
|
+
text?: string | string[];
|
|
301
|
+
textField?: string;
|
|
302
|
+
columns?: number;
|
|
303
|
+
[key: string]: unknown;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface Issue { code: string; message: string; fix?: string }
|
|
307
|
+
export interface LintReport { ok: boolean; type: ChartType; errors: Issue[]; warnings: Issue[]; suggestions: Issue[] }
|
|
308
|
+
export interface SafeResult extends Omit<LintReport, 'ok'> { ok: boolean; svg: string | null; description: string }
|
|
309
|
+
|
|
310
|
+
export declare class PlotError extends Error { hint?: string }
|
|
311
|
+
|
|
312
|
+
/** Draws and returns an SVG string. Throws PlotError with a fix hint when the spec cannot be drawn. */
|
|
313
|
+
export declare function plot(spec: Spec): string;
|
|
314
|
+
/** Never throws: returns the SVG plus errors, warnings and design suggestions. */
|
|
315
|
+
export declare function safePlot(spec: Spec): SafeResult;
|
|
316
|
+
/** Reviews a spec and suggests improvements without drawing. */
|
|
317
|
+
export declare function lint(spec: Spec): LintReport;
|
|
318
|
+
/** Text description of the chart (also in the SVG <desc>). */
|
|
319
|
+
export declare function describe(spec: Spec): string;
|
|
320
|
+
/** Browser: draws into an element with tooltips, responsive width, time sliders and drill-down. */
|
|
321
|
+
export declare function render(target: string | Element, spec: Spec, opts?: { controls?: boolean }): { readonly svg: SVGSVGElement | null; readonly spec: Spec; update(spec: Spec): unknown; destroy(): void };
|
|
322
|
+
/** Self-contained HTML page with one or more interactive charts. */
|
|
323
|
+
export declare function toHTML(specs: Spec | Spec[], opts?: { title?: string; lang?: string; columns?: number }): string;
|
|
324
|
+
/** Adds tooltips to a container that already holds a plotagents SVG. */
|
|
325
|
+
export declare function attach(root: Element): void;
|
|
326
|
+
export declare function resolve(spec: Spec): Spec;
|
|
327
|
+
|
|
328
|
+
export declare const schema: Record<string, unknown>;
|
|
329
|
+
/** Library-wide defaults (font, textScale, locale, theme, palette…). The spec always wins. `configure(null)` resets. */
|
|
330
|
+
export declare function configure(options?: Partial<Spec> | null): Partial<Spec>;
|
|
331
|
+
export interface DashboardSpec {
|
|
332
|
+
title?: string; subtitle?: string; source?: string; updated?: string; note?: string;
|
|
333
|
+
locale?: 'es' | 'en'; theme?: Spec['theme']; font?: Spec['font']; palette?: string | string[];
|
|
334
|
+
data?: Row[];
|
|
335
|
+
kpis?: Array<{ label: string; value?: number; delta?: number; period?: string; trend?: number[]; good?: 'up' | 'down'; format?: Format;
|
|
336
|
+
field?: string; agg?: 'sum' | 'mean' | 'median' | 'min' | 'max' | 'count' | 'distinct' | 'ratio'; over?: string; scale?: number;
|
|
337
|
+
compare?: { field: string; current: string | number; previous: string | number }; trendBy?: string }>;
|
|
338
|
+
charts: Array<Spec & { primary?: boolean; size?: 'full' | 'large' | 'medium' | 'small'; span?: number }>;
|
|
339
|
+
filters?: Array<string | { field: string; label?: string; control?: 'buttons' | 'select'; value?: string }>;
|
|
340
|
+
layout?: 'auto' | 'executive' | 'grid';
|
|
341
|
+
colors?: Record<string, string>;
|
|
342
|
+
}
|
|
343
|
+
/** Self-contained HTML dashboard with best-practice layout, shared colors, KPIs and filters. */
|
|
344
|
+
export declare function dashboard(spec: DashboardSpec): string;
|
|
345
|
+
/** Never throws: { ok, html, plan, errors, warnings, suggestions }. */
|
|
346
|
+
export declare function safeDashboard(spec: DashboardSpec): { ok: boolean; html: string | null; plan: object | null; errors: Issue[]; warnings: Issue[]; suggestions: Issue[] };
|
|
347
|
+
export declare function lintDashboard(spec: DashboardSpec): { ok: boolean; errors: Issue[]; warnings: Issue[]; suggestions: Issue[] };
|
|
348
|
+
export declare function planDashboard(spec: DashboardSpec): object;
|
|
349
|
+
/** Browser: draws a dashboard into an element. */
|
|
350
|
+
export declare function renderDashboard(target: string | Element, spec: DashboardSpec): { update(): void; destroy(): void };
|
|
351
|
+
export declare const dashboardSchema: Record<string, unknown>;
|
|
352
|
+
/** Raw text → [{ text, value }] word counts without stopwords. */
|
|
353
|
+
export declare function countWords(text: string | string[], opts?: { minLength?: number; stopwords?: string[] }): { text: string; value: number }[];
|
|
354
|
+
export declare function registerGeo(name: string, geo: object, aliases?: string[]): object;
|
|
355
|
+
/** Any GeoJSON / TopoJSON shape → FeatureCollection. */
|
|
356
|
+
export declare function toFeatureCollection(geo: object | object[], objectName?: string): object;
|
|
357
|
+
/** Browser: downloads (once per URL) a GeoJSON or TopoJSON. */
|
|
358
|
+
export declare function loadGeo(url: string): Promise<object>;
|
|
359
|
+
export declare const palettes: Record<string, string[]>;
|
|
360
|
+
export declare const ramps: Record<string, string[]>;
|
|
361
|
+
export declare function themeFor(spec: Spec): Theme;
|
|
362
|
+
export declare function timeValues(spec: Spec): (string | number)[];
|
|
363
|
+
export declare function validatePalette(colors: string[], opts?: { mode?: 'light' | 'dark'; surface?: string; pairs?: 'adjacent' | 'all' }): { ok: boolean; checks: { name: string; status: 'pass' | 'warn' | 'fail'; detail: string }[] };
|
|
364
|
+
export declare function bundleSource(): string | null;
|
|
365
|
+
export declare function toolDefinition(opts?: { name?: string; flavor?: 'anthropic' | 'openai'; kind?: 'chart' | 'dashboard' }): Record<string, unknown>;
|
|
366
|
+
export declare const themes: Record<'papel' | 'noche' | 'light' | 'dark', Theme> & Record<string, Theme>;
|
|
367
|
+
export declare function getTheme(t?: Spec['theme']): Theme;
|
|
368
|
+
/** Registers a named theme (merged over `extends`, default papel); use it as theme: "name" or configure({ theme: "name" }). */
|
|
369
|
+
export declare function registerTheme(name: string, theme: ThemeInput): Theme;
|
|
370
|
+
/** Resolves a color scale to its stops, or null when the name is unknown. */
|
|
371
|
+
export declare function resolveColorScale(v: ColorScale): { name: string; stops: string[]; kind: 'sequential' | 'diverging' | 'cyclic' | 'qualitative' } | null;
|
|
372
|
+
/** Available colormap and palette names by kind. */
|
|
373
|
+
export declare function colorScaleNames(): { sequential: string[]; diverging: string[]; cyclic: string[]; qualitative: string[] };
|
|
374
|
+
/** Color at t ∈ [0, 1] along `stops` (OKLab). */
|
|
375
|
+
export declare function interpolateColor(stops: string[], t: number): string;
|
|
376
|
+
export declare const COLORMAPS: Record<string, string>;
|
|
377
|
+
export declare const QUALITATIVE: Record<string, string>;
|
|
378
|
+
export declare const TYPES: ChartType[];
|
|
379
|
+
export declare function squarify<T extends { value: number }>(items: T[], x: number, y: number, w: number, h: number): (T & { x: number; y: number; w: number; h: number })[];
|
|
380
|
+
export declare function makeFormat(fmt?: Format, locale?: string, values?: number[]): ((v: number) => string) & { type: string };
|
|
381
|
+
export declare function formatNumber(v: number, decimals?: number, locale?: string, trim?: boolean): string;
|
|
382
|
+
export declare function formatCompact(v: number, locale?: string, decimals?: number): string;
|
|
383
|
+
|
|
384
|
+
export default plot;
|
package/package.json
CHANGED
|
@@ -1,6 +1,82 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plotagents",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "The chart protocol for AI agents: one JSON spec in, a finished accessible SVG out. Bars, lines, Gantt charts, treemaps, sankeys, maps from any GeoJSON/TopoJSON, networks and seaborn-style plots. Zero dependencies.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"module": "./src/index.js",
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"default": "./src/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./schema.json": "./schema.json",
|
|
15
|
+
"./browser": "./dist/plotagents.js",
|
|
16
|
+
"./browser/geo": "./dist/plotagents-geo.js",
|
|
17
|
+
"./geo/chile": "./src/geo/chile.js",
|
|
18
|
+
"./geo/world": "./src/geo/world.js",
|
|
19
|
+
"./geo/usa": "./src/geo/usa.js"
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"plotagents": "bin/plotagents.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"src",
|
|
26
|
+
"dist",
|
|
27
|
+
"docs",
|
|
28
|
+
"bin",
|
|
29
|
+
"index.d.ts",
|
|
30
|
+
"schema.json",
|
|
31
|
+
"README.md",
|
|
32
|
+
"AGENTS.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"test": "node --test test/*.test.js",
|
|
37
|
+
"build": "node scripts/bundle.js",
|
|
38
|
+
"bench": "node scripts/bench.js",
|
|
39
|
+
"prepublishOnly": "node scripts/bundle.js && node --test test/*.test.js",
|
|
40
|
+
"examples": "node examples/build.js",
|
|
41
|
+
"site": "node scripts/build-site.js",
|
|
42
|
+
"schema": "node -e \"import('./src/index.js').then(m=>process.stdout.write(JSON.stringify(m.schema,null,2)))\" > schema.json"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"chart",
|
|
46
|
+
"plot",
|
|
47
|
+
"svg",
|
|
48
|
+
"dataviz",
|
|
49
|
+
"visualization",
|
|
50
|
+
"treemap",
|
|
51
|
+
"sankey",
|
|
52
|
+
"seaborn",
|
|
53
|
+
"regplot",
|
|
54
|
+
"violin",
|
|
55
|
+
"radar",
|
|
56
|
+
"sunburst",
|
|
57
|
+
"ai",
|
|
58
|
+
"agents",
|
|
59
|
+
"llm",
|
|
60
|
+
"tool-use",
|
|
61
|
+
"gantt",
|
|
62
|
+
"timeline",
|
|
63
|
+
"geojson",
|
|
64
|
+
"topojson",
|
|
65
|
+
"choropleth",
|
|
66
|
+
"map"
|
|
67
|
+
],
|
|
68
|
+
"author": "Carlos Navarrete <cnavarreteliz@gmail.com>",
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"repository": {
|
|
71
|
+
"type": "git",
|
|
72
|
+
"url": "git+https://github.com/carlosnavarreteliz/plotagents.git"
|
|
73
|
+
},
|
|
74
|
+
"homepage": "https://carlosnavarrete.cl/plotagents/",
|
|
75
|
+
"bugs": {
|
|
76
|
+
"url": "https://github.com/carlosnavarreteliz/plotagents/issues"
|
|
77
|
+
},
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=18"
|
|
80
|
+
},
|
|
81
|
+
"sideEffects": false
|
|
82
|
+
}
|