@asanchez-sa/abby 0.4.0 → 0.6.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.
Files changed (32) hide show
  1. package/dist/components/chart/chart.d.ts +5 -74
  2. package/dist/components/chart/chart.js +5 -563
  3. package/dist/components/chart/parts/bar.d.ts +32 -0
  4. package/dist/components/chart/parts/bar.js +348 -0
  5. package/dist/components/chart/parts/{frame.d.ts → categories.d.ts} +5 -4
  6. package/dist/components/chart/parts/categories.js +212 -0
  7. package/dist/components/chart/parts/line.d.ts +43 -0
  8. package/dist/components/chart/parts/line.js +266 -0
  9. package/dist/components/chart/parts/scale.js +1 -44
  10. package/dist/components/chart/parts/scatter.d.ts +67 -0
  11. package/dist/components/chart/parts/scatter.js +157 -0
  12. package/dist/components/chart/parts/surface.d.ts +26 -0
  13. package/dist/components/chart/parts/surface.js +76 -0
  14. package/dist/components/chart/parts/types.js +5 -1
  15. package/dist/components/dialog/dialog.d.ts +21 -3
  16. package/dist/components/dialog/dialog.js +60 -12
  17. package/dist/components/sidebar/sidebar.d.ts +1 -1
  18. package/dist/components/sidebar/sidebar.js +50 -49
  19. package/dist/styles/components.css +80 -0
  20. package/package.json +2 -1
  21. package/skills/agent-ready-ui/SKILL.md +1 -1
  22. package/skills/blocks/SKILL.md +1 -1
  23. package/skills/compose-screens/SKILL.md +10 -7
  24. package/skills/compose-screens/references/charts-and-maps.md +119 -4
  25. package/skills/note-editor/SKILL.md +1 -1
  26. package/skills/note-status/SKILL.md +1 -1
  27. package/skills/setup/SKILL.md +1 -1
  28. package/skills/theming/SKILL.md +1 -1
  29. package/dist/components/chart/parts/axes.js +0 -126
  30. package/dist/components/chart/parts/frame.js +0 -278
  31. package/dist/components/chart/parts/points.d.ts +0 -1
  32. package/dist/components/chart/parts/points.js +0 -139
@@ -1,76 +1,7 @@
1
- import { ChartFrameProps } from "./parts/frame.js";
2
1
  import { ChartColor, ChartRow, ChartSeries, ChartToken } from "./parts/types.js";
3
2
  import { ChartLegend } from "./parts/legend.js";
4
- type BarChartProps = ChartFrameProps & {
5
- /**
6
- * Stacks the series in one bar per category, the first at the bottom. With a
7
- * single series it draws the same as without it.
8
- */
9
- stacked?: boolean;
10
- /** Shows each category's sum over its bar, and in the table when stacked. */
11
- totals?: boolean;
12
- /** A short text beside one bar, like "7 por cerrar". */
13
- note?: {
14
- /** The category it belongs to: its `id` or `label`. */
15
- category: string;
16
- text: string;
17
- /** Defaults to `muted-foreground`. */
18
- color?: ChartColor;
19
- };
20
- };
21
- /**
22
- * Bars by day or by week: one column per category, one bar per series in it,
23
- * in the order of `series`. `highlight` names the current category (today, this
24
- * week): its bars take the full color and the rest their faint tint. A series
25
- * with `variant: "forecast"` is drawn as an outline in the column of the first
26
- * series.
27
- *
28
- * Each bar is an image named "category: value" that shows the same text in a
29
- * tooltip on hover and focus; the chart is one tab stop and the arrows move
30
- * between bars. A table for a screen reader holds all the values. The chart's
31
- * name (`aria-label` or `aria-labelledby`) is required.
32
- */
33
- declare function BarChart({ series, data, highlight, stacked, totals, note, ...props }: BarChartProps): import("react").JSX.Element;
34
- type LineReference = {
35
- /** Where the line goes, in the chart's own unit. */
36
- value: number;
37
- /** The text at the line's start. Defaults to the value, formatted. */
38
- label?: string;
39
- /** Defaults to `border`, a hairline. */
40
- color?: ChartColor;
41
- };
42
- type LineChartProps = ChartFrameProps & {
43
- /**
44
- * Which points get a dot and their value: `ends` the first and the last,
45
- * `last` only the last. A small chart always marks only the last.
46
- */
47
- mark?: "ends" | "last";
48
- /** Horizontal lines to compare against, each with its label at the start. */
49
- references?: LineReference[];
50
- /**
51
- * `sm` is a chart to put side by side with others: no axes and no grid, only
52
- * the line with its last point and its value to the right.
53
- */
54
- size?: "default" | "sm";
55
- /**
56
- * The scale's minimum and maximum, used exactly. Charts that get the same
57
- * `domain` (and `height`) draw the same value at the same height. Without it
58
- * the scale runs from 0 to a round number above the largest value.
59
- */
60
- domain?: [number, number];
61
- };
62
- /**
63
- * A trend by day or by week: one line over one series, one point per
64
- * category. `mark` dots the first and last points and writes their values;
65
- * `references` draws lines to compare against; `size="sm"` is the small chart
66
- * for a grid of them, which get the same scale from `domain`. A missing value
67
- * breaks the line.
68
- *
69
- * Like `BarChart`, each point is an image named "category: value" with the
70
- * same text in a tooltip on hover and focus, the chart is one tab stop and the
71
- * arrows move between points, and a table holds all the values. The chart's
72
- * name (`aria-label` or `aria-labelledby`) is required. Only the first series
73
- * is drawn: a chart has one line.
74
- */
75
- declare function LineChart({ series, data, highlight, mark, references, size, domain, height, ...props }: LineChartProps): import("react").JSX.Element;
76
- export { BarChart, type BarChartProps, type ChartColor, ChartLegend, type ChartRow, type ChartSeries, type ChartToken, LineChart, type LineChartProps, type LineReference };
3
+ import { Chart, ChartProps } from "./parts/surface.js";
4
+ import { BarChart, BarChartProps } from "./parts/bar.js";
5
+ import { LineChart, LineChartProps, LineReference } from "./parts/line.js";
6
+ import { ScatterChart, ScatterChartProps, sqrtRadius } from "./parts/scatter.js";
7
+ export { BarChart, type BarChartProps, Chart, type ChartColor, ChartLegend, type ChartProps, type ChartRow, type ChartSeries, type ChartToken, LineChart, type LineChartProps, type LineReference, ScatterChart, type ScatterChartProps, sqrtRadius };
@@ -1,565 +1,7 @@
1
1
  "use client";
2
- import { cn } from "../../utilities/cn/index.js";
3
- import { ChartPoint, useRovingPoints } from "./parts/points.js";
4
- import { ChartFrame } from "./parts/frame.js";
5
- import { rowId, seriesColor, stackTotal, tintOf } from "./parts/scale.js";
6
- import { defaultTexts } from "./parts/types.js";
7
2
  import { ChartLegend } from "./parts/legend.js";
8
- import { c } from "react/compiler-runtime";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
- // src/components/chart/chart.tsx
11
- /** Alma's bar: it fills 72% of its column when it's alone in it. */
12
- const lone = .72;
13
- const shared = .86;
14
- /** A stacked bar is narrower: about a third of its column, as in Paper. */
15
- const stackedFill = .32;
16
- /** The air between two segments of a stack. */
17
- const segmentGap = 2;
18
- /** Room for a total over the tallest bar: 6px of air and a 16px line. */
19
- const totalRoom = 22;
20
- /** The bar's own look: the full color, its faint tint, or a forecast's outline. */
21
- function barLook(series, color, faint, empty) {
22
- if (empty) return { fill: "var(--border)" };
23
- if (series.variant === "forecast") return {
24
- fill: tintOf(color),
25
- stroke: color,
26
- strokeDasharray: "3 3",
27
- strokeWidth: 1
28
- };
29
- return { fill: faint ? tintOf(color) : color };
30
- }
31
- /**
32
- * Bars by day or by week: one column per category, one bar per series in it,
33
- * in the order of `series`. `highlight` names the current category (today, this
34
- * week): its bars take the full color and the rest their faint tint. A series
35
- * with `variant: "forecast"` is drawn as an outline in the column of the first
36
- * series.
37
- *
38
- * Each bar is an image named "category: value" that shows the same text in a
39
- * tooltip on hover and focus; the chart is one tab stop and the arrows move
40
- * between bars. A table for a screen reader holds all the values. The chart's
41
- * name (`aria-label` or `aria-labelledby`) is required.
42
- */
43
- function BarChart(t0) {
44
- const $ = c(39);
45
- let data;
46
- let highlight;
47
- let note;
48
- let props;
49
- let series;
50
- let t1;
51
- let t2;
52
- if ($[0] !== t0) {
53
- ({series, data, highlight, stacked: t1, totals: t2, note, ...props} = t0);
54
- $[0] = t0;
55
- $[1] = data;
56
- $[2] = highlight;
57
- $[3] = note;
58
- $[4] = props;
59
- $[5] = series;
60
- $[6] = t1;
61
- $[7] = t2;
62
- } else {
63
- data = $[1];
64
- highlight = $[2];
65
- note = $[3];
66
- props = $[4];
67
- series = $[5];
68
- t1 = $[6];
69
- t2 = $[7];
70
- }
71
- const stacked = t1 === void 0 ? false : t1;
72
- const totals = t2 === void 0 ? false : t2;
73
- const stack = stacked && series.length > 1;
74
- let columns;
75
- let marks;
76
- let t3;
77
- if ($[8] !== data || $[9] !== series || $[10] !== stack) {
78
- const solid = series.filter(_temp);
79
- columns = stack ? 1 : Math.max(1, solid.length);
80
- marks = data.flatMap((row, category) => series.flatMap((each_0, index) => {
81
- const value = row.values[each_0.key];
82
- if (typeof value !== "number" || !Number.isFinite(value)) return [];
83
- return [{
84
- row,
85
- category,
86
- series: each_0,
87
- index,
88
- value,
89
- column: each_0.variant === "forecast" ? 0 : solid.indexOf(each_0)
90
- }];
91
- }));
92
- t3 = Array.from(new Set(marks.map(_temp2)));
93
- $[8] = data;
94
- $[9] = series;
95
- $[10] = stack;
96
- $[11] = columns;
97
- $[12] = marks;
98
- $[13] = t3;
99
- } else {
100
- columns = $[11];
101
- marks = $[12];
102
- t3 = $[13];
103
- }
104
- const stacks = t3;
105
- const roving = useRovingPoints(stack ? stacks.length : marks.length);
106
- let t4;
107
- if ($[14] !== data || $[15] !== highlight) {
108
- t4 = highlight !== void 0 && data.some((row_0) => rowId(row_0) === highlight);
109
- $[14] = data;
110
- $[15] = highlight;
111
- $[16] = t4;
112
- } else t4 = $[16];
113
- const highlighted = t4;
114
- const t5 = totals ? totalRoom : 0;
115
- let t6;
116
- if ($[17] !== columns || $[18] !== data || $[19] !== highlighted || $[20] !== marks || $[21] !== note || $[22] !== props || $[23] !== roving.active || $[24] !== roving.onKeyDown || $[25] !== roving.setChosen || $[26] !== series || $[27] !== stack || $[28] !== stacks || $[29] !== totals) {
117
- t6 = (t7) => {
118
- const { plot, tooltip, text, highlighted: current } = t7;
119
- const slot = 1 / data.length / columns;
120
- const barWidth = slot * (stack ? stackedFill : columns > 1 ? shared : lone);
121
- const inset = (slot - barWidth) / 2;
122
- const tops = /* @__PURE__ */ new Map();
123
- const reach = (category_0, top, middle) => {
124
- const left = category_0 / data.length + inset;
125
- const known = tops.get(category_0);
126
- if (!known || top > known.top) tops.set(category_0, {
127
- top,
128
- middle,
129
- left
130
- });
131
- };
132
- const drawn = stack ? stacks.map((category_1, position) => {
133
- const row_1 = data[category_1];
134
- const start = category_1 / data.length;
135
- let cumulative = 0;
136
- let shown = 0;
137
- const segments = [];
138
- const parts = [];
139
- series.forEach((each_1, index_0) => {
140
- const value_0 = row_1.values[each_1.key];
141
- if (typeof value_0 !== "number" || !Number.isFinite(value_0)) return;
142
- parts.push(`${each_1.name}: ${text(value_0)}`);
143
- if (value_0 <= 0) return;
144
- const bottom = plot.baseline - plot.rise(cumulative) - shown * segmentGap;
145
- cumulative = cumulative + value_0;
146
- const height = plot.rise(cumulative) - plot.rise(cumulative - value_0);
147
- const y = bottom - height;
148
- segments.push(/* @__PURE__ */ jsx("rect", {
149
- "aria-hidden": "true",
150
- x: `${(start + inset) * 100}%`,
151
- width: `${barWidth * 100}%`,
152
- y,
153
- height,
154
- rx: Math.min(2, height / 2),
155
- className: "pointer-events-none",
156
- style: barLook(each_1, seriesColor(each_1, index_0), false, false)
157
- }, each_1.key));
158
- reach(category_1, plot.baseline - y, plot.baseline - y - height / 2);
159
- shown = shown + 1;
160
- });
161
- const total = stackTotal(row_1, series);
162
- if (total <= 0) {
163
- segments.push(/* @__PURE__ */ jsx("rect", {
164
- "aria-hidden": "true",
165
- x: `${(start + inset) * 100}%`,
166
- width: `${barWidth * 100}%`,
167
- y: plot.baseline - 4,
168
- height: 4,
169
- rx: 2,
170
- className: "pointer-events-none",
171
- style: barLook(series[0], "", false, true)
172
- }, "empty"));
173
- reach(category_1, 4, 2);
174
- }
175
- const name = [
176
- row_1.label,
177
- ...parts,
178
- `${props.totalHeader ?? defaultTexts.totalHeader}: ${text(total)}`
179
- ];
180
- return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx(ChartPoint, {
181
- controller: tooltip,
182
- index: position,
183
- active: roving.active,
184
- onActivate: roving.setChosen,
185
- label: name.join(", "),
186
- x: `${start * 100}%`,
187
- width: `${slot * 100}%`,
188
- height: plot.height
189
- }), segments] }, category_1);
190
- }) : marks.map((mark_0, position_0) => {
191
- const start_0 = mark_0.category / data.length + mark_0.column * slot;
192
- const rise = plot.rise(mark_0.value);
193
- const height_0 = Math.max(rise, 4);
194
- const color = seriesColor(mark_0.series, mark_0.index);
195
- const name_0 = columns > 1 || series.length > 1 ? `${mark_0.row.label}, ${mark_0.series.name}: ${text(mark_0.value)}` : `${mark_0.row.label}: ${text(mark_0.value)}`;
196
- reach(mark_0.category, height_0, height_0 / 2);
197
- return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx(ChartPoint, {
198
- controller: tooltip,
199
- index: position_0,
200
- active: roving.active,
201
- onActivate: roving.setChosen,
202
- label: name_0,
203
- x: `${start_0 * 100}%`,
204
- width: `${slot * 100}%`,
205
- height: plot.height
206
- }), /* @__PURE__ */ jsx("rect", {
207
- "aria-hidden": "true",
208
- x: `${(start_0 + inset) * 100}%`,
209
- width: `${barWidth * 100}%`,
210
- y: plot.baseline - height_0,
211
- height: height_0,
212
- rx: Math.min(6, height_0 / 2),
213
- className: "pointer-events-none",
214
- style: barLook(mark_0.series, color, highlighted && mark_0.category !== current, mark_0.value <= 0)
215
- })] }, `${mark_0.category}-${mark_0.series.key}`);
216
- });
217
- const noted = note ? data.findIndex((row_2) => rowId(row_2) === note.category) : -1;
218
- const noteAt = tops.get(noted);
219
- return /* @__PURE__ */ jsxs(Fragment, { children: [
220
- /* @__PURE__ */ jsx("g", {
221
- onKeyDown: roving.onKeyDown,
222
- children: drawn
223
- }),
224
- totals ? /* @__PURE__ */ jsx("g", {
225
- "aria-hidden": "true",
226
- "data-slot": "chart-totals",
227
- children: data.map((row_3, category_2) => {
228
- const at = tops.get(category_2);
229
- if (!at) return null;
230
- return /* @__PURE__ */ jsx("text", {
231
- x: `${(category_2 + .5) / data.length * 100}%`,
232
- y: plot.baseline - at.top - 6,
233
- textAnchor: "middle",
234
- className: cn("fill-foreground text-supporting tabular-nums", category_2 === current ? "font-semibold" : "font-medium"),
235
- children: text(stackTotal(row_3, series))
236
- }, category_2);
237
- })
238
- }) : null,
239
- note && noteAt ? /* @__PURE__ */ jsx("text", {
240
- "aria-hidden": "true",
241
- "data-slot": "chart-note",
242
- x: `${noteAt.left * 100}%`,
243
- dx: -8,
244
- y: plot.baseline - noteAt.middle,
245
- dominantBaseline: "central",
246
- textAnchor: "end",
247
- className: "text-supporting font-medium",
248
- style: { fill: note.color ? seriesColor({
249
- key: "",
250
- name: "",
251
- color: note.color
252
- }, 0) : "var(--muted-foreground)" },
253
- children: note.text
254
- }) : null
255
- ] });
256
- };
257
- $[17] = columns;
258
- $[18] = data;
259
- $[19] = highlighted;
260
- $[20] = marks;
261
- $[21] = note;
262
- $[22] = props;
263
- $[23] = roving.active;
264
- $[24] = roving.onKeyDown;
265
- $[25] = roving.setChosen;
266
- $[26] = series;
267
- $[27] = stack;
268
- $[28] = stacks;
269
- $[29] = totals;
270
- $[30] = t6;
271
- } else t6 = $[30];
272
- let t7;
273
- if ($[31] !== data || $[32] !== highlight || $[33] !== props || $[34] !== series || $[35] !== stack || $[36] !== t5 || $[37] !== t6) {
274
- t7 = /* @__PURE__ */ jsx(ChartFrame, {
275
- data,
276
- series,
277
- highlight,
278
- stack,
279
- room: t5,
280
- ...props,
281
- children: t6
282
- });
283
- $[31] = data;
284
- $[32] = highlight;
285
- $[33] = props;
286
- $[34] = series;
287
- $[35] = stack;
288
- $[36] = t5;
289
- $[37] = t6;
290
- $[38] = t7;
291
- } else t7 = $[38];
292
- return t7;
293
- }
294
- function _temp2(mark) {
295
- return mark.category;
296
- }
297
- function _temp(each) {
298
- return each.variant !== "forecast";
299
- }
300
- /** The dot at the end of a line, and the first one. Alma's: 4px with a ring, 3px. */
301
- const lastDot = 4;
302
- const firstDot = 3;
303
- /** Room above the line for the value over a marked point: 4px of air and a 12px line. */
304
- const valueRoom = 18;
305
- /** A point's value sits this far over its dot. */
306
- const valueLift = 11;
307
- /** What a small chart keeps above and under its line, as in Paper's cards. */
308
- const smallInset = {
309
- room: 5,
310
- bottom: 7
311
- };
312
- /** The gap between a small chart's last dot and its value. */
313
- const valueGap = 10;
314
- /**
315
- * A trend by day or by week: one line over one series, one point per
316
- * category. `mark` dots the first and last points and writes their values;
317
- * `references` draws lines to compare against; `size="sm"` is the small chart
318
- * for a grid of them, which get the same scale from `domain`. A missing value
319
- * breaks the line.
320
- *
321
- * Like `BarChart`, each point is an image named "category: value" with the
322
- * same text in a tooltip on hover and focus, the chart is one tab stop and the
323
- * arrows move between points, and a table holds all the values. The chart's
324
- * name (`aria-label` or `aria-labelledby`) is required. Only the first series
325
- * is drawn: a chart has one line.
326
- */
327
- function LineChart(t0) {
328
- const $ = c(41);
329
- let data;
330
- let domain;
331
- let height;
332
- let highlight;
333
- let props;
334
- let series;
335
- let t1;
336
- let t2;
337
- let t3;
338
- if ($[0] !== t0) {
339
- ({series, data, highlight, mark: t1, references: t2, size: t3, domain, height, ...props} = t0);
340
- $[0] = t0;
341
- $[1] = data;
342
- $[2] = domain;
343
- $[3] = height;
344
- $[4] = highlight;
345
- $[5] = props;
346
- $[6] = series;
347
- $[7] = t1;
348
- $[8] = t2;
349
- $[9] = t3;
350
- } else {
351
- data = $[1];
352
- domain = $[2];
353
- height = $[3];
354
- highlight = $[4];
355
- props = $[5];
356
- series = $[6];
357
- t1 = $[7];
358
- t2 = $[8];
359
- t3 = $[9];
360
- }
361
- const mark = t1 === void 0 ? "ends" : t1;
362
- let t4;
363
- if ($[10] !== t2) {
364
- t4 = t2 === void 0 ? [] : t2;
365
- $[10] = t2;
366
- $[11] = t4;
367
- } else t4 = $[11];
368
- const references = t4;
369
- const small = (t3 === void 0 ? "default" : t3) === "sm";
370
- let line;
371
- let t5;
372
- if ($[12] !== series) {
373
- line = series.slice(0, 1);
374
- t5 = line[0] ? seriesColor(line[0], 0) : "var(--foreground)";
375
- $[12] = series;
376
- $[13] = line;
377
- $[14] = t5;
378
- } else {
379
- line = $[13];
380
- t5 = $[14];
381
- }
382
- const color = t5;
383
- let t6;
384
- if ($[15] !== data || $[16] !== line) {
385
- let t7;
386
- if ($[18] !== line) {
387
- t7 = (row, category) => {
388
- const value = line[0] ? row.values[line[0].key] : void 0;
389
- return typeof value === "number" && Number.isFinite(value) ? [{
390
- row,
391
- category,
392
- value
393
- }] : [];
394
- };
395
- $[18] = line;
396
- $[19] = t7;
397
- } else t7 = $[19];
398
- t6 = data.flatMap(t7);
399
- $[15] = data;
400
- $[16] = line;
401
- $[17] = t6;
402
- } else t6 = $[17];
403
- const points = t6;
404
- const roving = useRovingPoints(points.length);
405
- const t7 = highlight !== void 0 && data.some((row_0) => rowId(row_0) === highlight) ? highlight : void 0;
406
- const t8 = height ?? (small ? 96 : 120);
407
- const t9 = small ? smallInset.room : mark ? valueRoom : 0;
408
- const t10 = small ? smallInset.bottom : 7;
409
- const t11 = small ? false : props.yAxis;
410
- const t12 = small ? false : props.xAxis;
411
- const t13 = small ? false : props.grid;
412
- let t14;
413
- if ($[20] !== color || $[21] !== data.length || $[22] !== mark || $[23] !== points || $[24] !== references || $[25] !== roving || $[26] !== small) {
414
- t14 = (t15) => {
415
- const { plot, tooltip, text, width } = t15;
416
- const count = data.length;
417
- const first = points[0];
418
- const last = points[points.length - 1];
419
- const lastText = last ? text(last.value) : "";
420
- const room = small && last ? lastText.length * 7 + valueGap + 4 : 0;
421
- const span = Math.max(0, width - room);
422
- const edge = 5;
423
- const xOf = (category_0) => Math.min(Math.max(edge, span - edge), Math.max(edge, (category_0 + .5) / count * span));
424
- const yOf = (value_0) => plot.baseline - plot.rise(value_0);
425
- const slot = (category_1) => width > 0 ? `${category_1 / count * span}` : `${category_1 / count * 100}%`;
426
- const slotWidth = width > 0 ? `${span / count}` : `${100 / count}%`;
427
- const runs = [];
428
- for (const point of points) {
429
- const run = runs[runs.length - 1];
430
- const before = run?.[run.length - 1];
431
- if (run && before && before.category === point.category - 1) run.push(point);
432
- else runs.push([point]);
433
- }
434
- const marked = [...!small && mark === "ends" && first && first !== last ? [first] : [], ...last ? [last] : []];
435
- return /* @__PURE__ */ jsxs(Fragment, { children: [
436
- /* @__PURE__ */ jsx("g", {
437
- "aria-hidden": "true",
438
- "data-slot": "chart-references",
439
- children: references.map((reference, index) => {
440
- const y = yOf(reference.value);
441
- const label = reference.label ?? text(reference.value);
442
- const start = Math.max(28, label.length * 7 + 6);
443
- return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
444
- x1: start,
445
- x2: "100%",
446
- y1: y + .5,
447
- y2: y + .5,
448
- shapeRendering: "crispEdges",
449
- className: reference.color ? void 0 : "stroke-border",
450
- style: reference.color ? { stroke: seriesColor({
451
- key: "",
452
- name: "",
453
- color: reference.color
454
- }, 0) } : void 0
455
- }), /* @__PURE__ */ jsx("text", {
456
- x: 0,
457
- y: y + .5,
458
- dominantBaseline: "central",
459
- className: "fill-subtle text-supporting tabular-nums",
460
- children: label
461
- })] }, index);
462
- })
463
- }),
464
- /* @__PURE__ */ jsx("g", {
465
- onKeyDown: roving.onKeyDown,
466
- children: points.map((point_0, position) => /* @__PURE__ */ jsx(ChartPoint, {
467
- controller: tooltip,
468
- index: position,
469
- active: roving.active,
470
- onActivate: roving.setChosen,
471
- label: `${point_0.row.label}: ${text(point_0.value)}`,
472
- x: slot(point_0.category),
473
- width: slotWidth,
474
- height: plot.height
475
- }, point_0.category))
476
- }),
477
- width > 0 ? /* @__PURE__ */ jsxs("g", {
478
- "aria-hidden": "true",
479
- className: "pointer-events-none",
480
- "data-slot": "chart-line",
481
- children: [runs.map((run_0) => run_0.length > 1 ? /* @__PURE__ */ jsx("polyline", {
482
- points: run_0.map((p) => `${xOf(p.category)},${yOf(p.value)}`).join(" "),
483
- fill: "none",
484
- strokeWidth: 2,
485
- strokeLinecap: "round",
486
- strokeLinejoin: "round",
487
- style: { stroke: color }
488
- }, run_0[0]?.category) : /* @__PURE__ */ jsx("circle", {
489
- cx: xOf(run_0[0]?.category ?? 0),
490
- cy: yOf(run_0[0]?.value ?? 0),
491
- r: 1,
492
- style: { fill: color }
493
- }, run_0[0]?.category)), marked.map((point_1) => {
494
- const isLast = point_1 === last;
495
- const x = xOf(point_1.category);
496
- const y_0 = yOf(point_1.value);
497
- return /* @__PURE__ */ jsxs("g", {
498
- "data-slot": isLast ? "chart-last" : "chart-first",
499
- children: [/* @__PURE__ */ jsx("circle", {
500
- cx: x,
501
- cy: y_0,
502
- r: isLast ? lastDot : firstDot,
503
- strokeWidth: isLast ? 2 : 0,
504
- className: "stroke-background",
505
- style: { fill: color }
506
- }), small ? /* @__PURE__ */ jsx("text", {
507
- x: x + valueGap,
508
- y: y_0,
509
- dominantBaseline: "central",
510
- className: "fill-foreground text-supporting tabular-nums",
511
- children: text(point_1.value)
512
- }) : /* @__PURE__ */ jsx("text", {
513
- x,
514
- y: y_0 - valueLift,
515
- textAnchor: !isLast && x < 16 ? "start" : isLast && x > width - 16 ? "end" : "middle",
516
- className: cn("text-supporting tabular-nums", isLast ? "fill-foreground font-semibold" : "fill-muted-foreground"),
517
- children: text(point_1.value)
518
- })]
519
- }, point_1.category);
520
- })]
521
- }) : null
522
- ] });
523
- };
524
- $[20] = color;
525
- $[21] = data.length;
526
- $[22] = mark;
527
- $[23] = points;
528
- $[24] = references;
529
- $[25] = roving;
530
- $[26] = small;
531
- $[27] = t14;
532
- } else t14 = $[27];
533
- let t15;
534
- if ($[28] !== data || $[29] !== domain || $[30] !== line || $[31] !== props || $[32] !== t10 || $[33] !== t11 || $[34] !== t12 || $[35] !== t13 || $[36] !== t14 || $[37] !== t7 || $[38] !== t8 || $[39] !== t9) {
535
- t15 = /* @__PURE__ */ jsx(ChartFrame, {
536
- data,
537
- series: line,
538
- highlight: t7,
539
- height: t8,
540
- domain,
541
- room: t9,
542
- bottom: t10,
543
- ...props,
544
- yAxis: t11,
545
- xAxis: t12,
546
- grid: t13,
547
- children: t14
548
- });
549
- $[28] = data;
550
- $[29] = domain;
551
- $[30] = line;
552
- $[31] = props;
553
- $[32] = t10;
554
- $[33] = t11;
555
- $[34] = t12;
556
- $[35] = t13;
557
- $[36] = t14;
558
- $[37] = t7;
559
- $[38] = t8;
560
- $[39] = t9;
561
- $[40] = t15;
562
- } else t15 = $[40];
563
- return t15;
564
- }
565
- export { BarChart, ChartLegend, LineChart };
3
+ import { Chart } from "./parts/surface.js";
4
+ import { BarChart } from "./parts/bar.js";
5
+ import { LineChart } from "./parts/line.js";
6
+ import { ScatterChart, sqrtRadius } from "./parts/scatter.js";
7
+ export { BarChart, Chart, ChartLegend, LineChart, ScatterChart, sqrtRadius };
@@ -0,0 +1,32 @@
1
+ import { CategoryChartProps } from "./categories.js";
2
+ import { ChartColor } from "./types.js";
3
+ export type BarChartProps = CategoryChartProps & {
4
+ /**
5
+ * Stacks the series in one bar per category, the first at the bottom. With a
6
+ * single series it draws the same as without it.
7
+ */
8
+ stacked?: boolean;
9
+ /** Shows each category's sum over its bar, and in the table when stacked. */
10
+ totals?: boolean;
11
+ /** A short text beside one bar, like "7 por cerrar". */
12
+ note?: {
13
+ /** The category it belongs to: its `id` or `label`. */
14
+ category: string;
15
+ text: string;
16
+ /** Defaults to `muted-foreground`. */
17
+ color?: ChartColor;
18
+ };
19
+ };
20
+ /**
21
+ * Bars by day or by week: one column per category, one bar per series in it,
22
+ * in the order of `series`. `highlight` names the current category (today, this
23
+ * week): its bars take the full color and the rest their faint tint. A series
24
+ * with `variant: "forecast"` is drawn as an outline in the column of the first
25
+ * series. `stacked` piles the series into one bar, with `totals` over it.
26
+ *
27
+ * Drawn by TanStack Charts: the chart is one tab stop, the arrows move between
28
+ * bars (between whole stacks when stacked), and the tooltip announces each
29
+ * one. A table for a screen reader holds all the values. The chart's name
30
+ * (`aria-label` or `aria-labelledby`) is required.
31
+ */
32
+ export declare function BarChart(props: BarChartProps): import("react").JSX.Element;