@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.
- package/dist/components/chart/chart.d.ts +5 -74
- package/dist/components/chart/chart.js +5 -563
- package/dist/components/chart/parts/bar.d.ts +32 -0
- package/dist/components/chart/parts/bar.js +348 -0
- package/dist/components/chart/parts/{frame.d.ts → categories.d.ts} +5 -4
- package/dist/components/chart/parts/categories.js +212 -0
- package/dist/components/chart/parts/line.d.ts +43 -0
- package/dist/components/chart/parts/line.js +266 -0
- package/dist/components/chart/parts/scale.js +1 -44
- package/dist/components/chart/parts/scatter.d.ts +67 -0
- package/dist/components/chart/parts/scatter.js +157 -0
- package/dist/components/chart/parts/surface.d.ts +26 -0
- package/dist/components/chart/parts/surface.js +76 -0
- package/dist/components/chart/parts/types.js +5 -1
- package/dist/components/dialog/dialog.d.ts +21 -3
- package/dist/components/dialog/dialog.js +60 -12
- package/dist/components/sidebar/sidebar.d.ts +1 -1
- package/dist/components/sidebar/sidebar.js +50 -49
- package/dist/styles/components.css +80 -0
- package/package.json +2 -1
- package/skills/agent-ready-ui/SKILL.md +1 -1
- package/skills/blocks/SKILL.md +1 -1
- package/skills/compose-screens/SKILL.md +10 -7
- package/skills/compose-screens/references/charts-and-maps.md +119 -4
- package/skills/note-editor/SKILL.md +1 -1
- package/skills/note-status/SKILL.md +1 -1
- package/skills/setup/SKILL.md +1 -1
- package/skills/theming/SKILL.md +1 -1
- package/dist/components/chart/parts/axes.js +0 -126
- package/dist/components/chart/parts/frame.js +0 -278
- package/dist/components/chart/parts/points.d.ts +0 -1
- package/dist/components/chart/parts/points.js +0 -139
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# Charts and maps
|
|
2
2
|
|
|
3
|
-
Read this when you build a bar chart with `BarChart`, a line chart with `LineChart` or a map of nodes with `Graph`. The main skill points here from its "Show counts or trends by day or week" and "Draw memories as a map" sections.
|
|
3
|
+
Read this when you build a bar chart with `BarChart`, a line chart with `LineChart`, a scatter chart with `ScatterChart`, a chart of your own with `Chart`, or a map of nodes with `Graph`. The main skill points here from its "Show counts or trends by day or week" and "Draw memories as a map" sections.
|
|
4
|
+
|
|
5
|
+
Every chart in `abby/chart` is drawn by TanStack Charts (`@tanstack/charts`) in abby's look: the palette is `chart-1` to `chart-5`, the grid and the axes are hairlines, and the tooltip and the focus ring are abby's. The plot is one image named by the chart's `aria-label` or `aria-labelledby`, which is required (without one it throws in development). It is one tab stop: the arrows, Home and End move between points, and the tooltip announces each point it reaches. The presets also put a hidden table with every value under the plot.
|
|
4
6
|
|
|
5
7
|
## Counts by day or week with `BarChart`
|
|
6
8
|
|
|
7
|
-
`BarChart` from `abby/chart` draws
|
|
9
|
+
`BarChart` from `abby/chart` draws one column per category, one bar per series in that column, a Y axis with its ticks and grid, and x labels that thin out when there are many. Each bar is a point for the pointer and the arrows, and its tooltip names the category, the series and the value.
|
|
8
10
|
|
|
9
11
|
- `data`: one row per category, `{ label, id?, values }`. `label` is the x label; `values` holds one number per series key, and `null` or a missing key draws no bar.
|
|
10
12
|
- `series`: `{ key, name, color?, variant? }` in the order the bars are drawn. `key` reads `values`, `name` reads in the tooltip and the table.
|
|
@@ -12,7 +14,7 @@ Read this when you build a bar chart with `BarChart`, a line chart with `LineCha
|
|
|
12
14
|
- Colors: without `color`, series take `chart-1` to `chart-5` in order. `color` takes a token (`chart-1`…`chart-5`, `primary`, `muted`, `warning`, `success`, `destructive`) or any CSS color, such as `var(--area)`.
|
|
13
15
|
- `variant: "forecast"` draws what hasn't happened yet as a dashed outline in the first series' column. It is not a column of its own.
|
|
14
16
|
- `format` takes `Intl.NumberFormat` options for the axis, the tooltip and the table. `empty`, `categoryHeader` and `missing` replace the texts.
|
|
15
|
-
-
|
|
17
|
+
- `height` is the whole chart's, x labels included. `description` is read after the name: the units, the period.
|
|
16
18
|
|
|
17
19
|
```tsx
|
|
18
20
|
import { BarChart } from "abby/chart";
|
|
@@ -100,7 +102,7 @@ export function MemoryStates() {
|
|
|
100
102
|
|
|
101
103
|
## Trends by week with `LineChart`
|
|
102
104
|
|
|
103
|
-
`LineChart` from `abby/chart` draws one line over one series, one point per category,
|
|
105
|
+
`LineChart` from `abby/chart` draws one line over one series, one point per category, like `BarChart`: a name, a tooltip on each point and a table for screen readers. Use it when the question is whether something rises or falls over time; use `BarChart` to compare counts with each other. Its `data` rows and `series` are `BarChart`'s, and the first series is the line.
|
|
104
106
|
|
|
105
107
|
- `mark`: which points get a dot and their value. `"ends"` (the default) marks the first and the last, `"last"` only the last. A small chart always marks only the last.
|
|
106
108
|
- `references`: `{ value, label?, color? }` horizontal lines to compare against, each labeled at the start. `color` defaults to a hairline.
|
|
@@ -133,6 +135,119 @@ export function AnswersPerWeek() {
|
|
|
133
135
|
}
|
|
134
136
|
```
|
|
135
137
|
|
|
138
|
+
## Relationships with `ScatterChart`
|
|
139
|
+
|
|
140
|
+
`ScatterChart` from `abby/chart` plots the app's own rows by two numbers, to answer whether one thing goes with another (revenue and retention, size and cost). It keeps each row as it is: `onFocusChange(row)` and `onSelect(row)` hand back the app's row, typed, and `null` when the pointer or focus leaves.
|
|
141
|
+
|
|
142
|
+
- `data`: the rows, any shape. `x` and `y` name two number fields; `size` names a third, and the dot's area grows with it (a square-root scale from 0 to the largest value, so twice the value is twice the area). `color` names a text field, like a segment.
|
|
143
|
+
- `colors`: `{ [value]: color }`, the color of each `color` value and the legend's order. A value that isn't listed takes the next of `chart-1` to `chart-5`.
|
|
144
|
+
- `label(row)` is a row's name, the tooltip's title and the table's first column; `rowKey(row)` keeps a row's identity across updates.
|
|
145
|
+
- `xLabel`, `yLabel`, `sizeLabel`, `colorLabel` name the axes and the fields in the tooltip and the table; `xFormat`, `yFormat`, `sizeFormat` take `Intl.NumberFormat` options, with `locale`.
|
|
146
|
+
- `radius`: `[smallest, largest]` in px, `[3, 18]` by default. `sqrtRadius(largest, radius)` is the same scale, for a chart of your own. `legend={false}` hides the `ChartLegend` of the colors.
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { ScatterChart } from "abby/chart";
|
|
150
|
+
|
|
151
|
+
type Account = {
|
|
152
|
+
id: string;
|
|
153
|
+
name: string;
|
|
154
|
+
segment: "Enterprise" | "Mid-market" | "SMB";
|
|
155
|
+
monthlyRevenue: number;
|
|
156
|
+
retention: number;
|
|
157
|
+
seats: number;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const accounts: Account[] = [
|
|
161
|
+
{
|
|
162
|
+
id: "a1",
|
|
163
|
+
name: "Northwind",
|
|
164
|
+
segment: "Enterprise",
|
|
165
|
+
monthlyRevenue: 48000,
|
|
166
|
+
retention: 0.94,
|
|
167
|
+
seats: 420,
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: "a2",
|
|
171
|
+
name: "Fabrikam",
|
|
172
|
+
segment: "Mid-market",
|
|
173
|
+
monthlyRevenue: 14000,
|
|
174
|
+
retention: 0.81,
|
|
175
|
+
seats: 90,
|
|
176
|
+
},
|
|
177
|
+
{ id: "a3", name: "Litware", segment: "SMB", monthlyRevenue: 2400, retention: 0.62, seats: 12 },
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
export function AccountHealth({ onOpen }: { onOpen: (account: Account) => void }) {
|
|
181
|
+
return (
|
|
182
|
+
<ScatterChart
|
|
183
|
+
aria-label="Monthly revenue against retention by account, sized by seats"
|
|
184
|
+
data={accounts}
|
|
185
|
+
x="monthlyRevenue"
|
|
186
|
+
y="retention"
|
|
187
|
+
size="seats"
|
|
188
|
+
color="segment"
|
|
189
|
+
label={(account) => account.name}
|
|
190
|
+
rowKey={(account) => account.id}
|
|
191
|
+
xLabel="Monthly revenue"
|
|
192
|
+
yLabel="Retention"
|
|
193
|
+
sizeLabel="Seats"
|
|
194
|
+
colorLabel="Segment"
|
|
195
|
+
xFormat={{ style: "currency", currency: "USD", notation: "compact" }}
|
|
196
|
+
yFormat={{ style: "percent" }}
|
|
197
|
+
onSelect={(account) => {
|
|
198
|
+
if (account) onOpen(account);
|
|
199
|
+
}}
|
|
200
|
+
/>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## A chart of your own with `Chart`
|
|
206
|
+
|
|
207
|
+
When no preset fits (a target line over bars, an area, a histogram), build the chart with TanStack's grammar and draw it with `Chart` from `abby/chart`, which gives it abby's look, name and focus. The marks, scales and tooltip come from `@tanstack/charts` itself: add it to the app at the exact version abby depends on, and follow TanStack's own skills for the grammar.
|
|
208
|
+
|
|
209
|
+
- `definition`: what `defineChart` returns. Build it in the component that renders the chart; React Compiler keeps it while its inputs stay the same.
|
|
210
|
+
- Scales: `scaleLinear` from `@tanstack/charts/scales/linear`, `scaleBand` and `scalePoint` for categories, passed as factories so TanStack infers the domain. Never set a pixel range.
|
|
211
|
+
- Colors: leave a mark's paint out and it takes the palette (`chart-1` …), or set `fill`/`stroke` to `var(--chart-2)`, `var(--warning)` and the like. No hex colors: the tokens carry dark mode.
|
|
212
|
+
- A mark that only labels (a total, a rule's text) takes `decorative()` from `@tanstack/charts/mark/decorative`, so the arrows skip it.
|
|
213
|
+
- `height`, `description`, `onFocusChange` and `onSelect` go on `Chart`; `children` draw under the plot: a `ChartLegend`, a table of the values.
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
import { barY, defineChart, ruleY } from "@tanstack/charts";
|
|
217
|
+
import { scaleBand } from "@tanstack/charts/scales/band";
|
|
218
|
+
import { scaleLinear } from "@tanstack/charts/scales/linear";
|
|
219
|
+
import { tooltip } from "@tanstack/charts/tooltip";
|
|
220
|
+
import { Chart } from "abby/chart";
|
|
221
|
+
|
|
222
|
+
const quarters = [
|
|
223
|
+
{ quarter: "Q1", revenue: 42 },
|
|
224
|
+
{ quarter: "Q2", revenue: 58 },
|
|
225
|
+
{ quarter: "Q3", revenue: 51 },
|
|
226
|
+
{ quarter: "Q4", revenue: 66 },
|
|
227
|
+
];
|
|
228
|
+
|
|
229
|
+
export function RevenueAgainstTarget() {
|
|
230
|
+
const definition = defineChart({
|
|
231
|
+
marks: [
|
|
232
|
+
barY(quarters, { x: "quarter", y: "revenue", radius: 6 }),
|
|
233
|
+
ruleY([60], { stroke: "var(--warning)", strokeDasharray: "3 3" }),
|
|
234
|
+
],
|
|
235
|
+
scales: {
|
|
236
|
+
x: { scale: () => scaleBand<string>().paddingInner(0.28).paddingOuter(0.14) },
|
|
237
|
+
y: { scale: scaleLinear, nice: true, grid: true },
|
|
238
|
+
},
|
|
239
|
+
tooltip,
|
|
240
|
+
});
|
|
241
|
+
return (
|
|
242
|
+
<Chart
|
|
243
|
+
aria-label="Revenue by quarter against a target of 60"
|
|
244
|
+
definition={definition}
|
|
245
|
+
height={220}
|
|
246
|
+
/>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
136
251
|
## Draw memories as a map with `Graph`
|
|
137
252
|
|
|
138
253
|
`Graph` from `abby/graph` draws nodes as buttons and the lines between them in SVG, with no layout of its own. The app places every node: `x` and `y` are its center in map units at zoom 1. The map never lays out, drags or pans. A node's `name` is its button's name; `meta` is the line under it, `current` widens it for the memory being read, `replaced` strikes it through, and `color` takes `chart-1` to `chart-5`.
|
|
@@ -12,7 +12,7 @@ metadata:
|
|
|
12
12
|
and keep both usable by an agent without loading the editor.
|
|
13
13
|
type: core
|
|
14
14
|
library: abby
|
|
15
|
-
library_version: 0.
|
|
15
|
+
library_version: 0.6.0
|
|
16
16
|
sources:
|
|
17
17
|
- src/components/note-status/note-status.tsx
|
|
18
18
|
- src/components/note-place/note-place.tsx
|
package/skills/setup/SKILL.md
CHANGED
package/skills/theming/SKILL.md
CHANGED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { c } from "react/compiler-runtime";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
// src/components/chart/parts/axes.tsx
|
|
5
|
-
/** The horizontal lines at each tick, drawn inside the plot's SVG. */
|
|
6
|
-
function ChartGrid(t0) {
|
|
7
|
-
const $ = c(4);
|
|
8
|
-
const { plot } = t0;
|
|
9
|
-
let t1;
|
|
10
|
-
if ($[0] !== plot) {
|
|
11
|
-
t1 = plot.ticks.map((tick) => {
|
|
12
|
-
const y = plot.baseline - plot.rise(tick);
|
|
13
|
-
return /* @__PURE__ */ jsx("line", {
|
|
14
|
-
x1: "0",
|
|
15
|
-
x2: "100%",
|
|
16
|
-
y1: y + .5,
|
|
17
|
-
y2: y + .5
|
|
18
|
-
}, tick);
|
|
19
|
-
});
|
|
20
|
-
$[0] = plot;
|
|
21
|
-
$[1] = t1;
|
|
22
|
-
} else t1 = $[1];
|
|
23
|
-
let t2;
|
|
24
|
-
if ($[2] !== t1) {
|
|
25
|
-
t2 = /* @__PURE__ */ jsx("g", {
|
|
26
|
-
"aria-hidden": "true",
|
|
27
|
-
className: "stroke-border",
|
|
28
|
-
shapeRendering: "crispEdges",
|
|
29
|
-
children: t1
|
|
30
|
-
});
|
|
31
|
-
$[2] = t1;
|
|
32
|
-
$[3] = t2;
|
|
33
|
-
} else t2 = $[3];
|
|
34
|
-
return t2;
|
|
35
|
-
}
|
|
36
|
-
/** The value of each tick, in a column to the left of the plot. */
|
|
37
|
-
function ChartYAxis(t0) {
|
|
38
|
-
const $ = c(12);
|
|
39
|
-
const { plot, format } = t0;
|
|
40
|
-
const t1 = plot.top + .5;
|
|
41
|
-
const t2 = plot.height - plot.baseline - .5;
|
|
42
|
-
let t3;
|
|
43
|
-
if ($[0] !== plot.height || $[1] !== t1 || $[2] !== t2) {
|
|
44
|
-
t3 = {
|
|
45
|
-
height: plot.height,
|
|
46
|
-
paddingTop: t1,
|
|
47
|
-
paddingBottom: t2
|
|
48
|
-
};
|
|
49
|
-
$[0] = plot.height;
|
|
50
|
-
$[1] = t1;
|
|
51
|
-
$[2] = t2;
|
|
52
|
-
$[3] = t3;
|
|
53
|
-
} else t3 = $[3];
|
|
54
|
-
let t4;
|
|
55
|
-
if ($[4] !== format || $[5] !== plot.ticks) {
|
|
56
|
-
let t5;
|
|
57
|
-
if ($[7] !== format) {
|
|
58
|
-
t5 = (tick) => /* @__PURE__ */ jsx("div", {
|
|
59
|
-
className: "flex h-0 items-center justify-end whitespace-nowrap",
|
|
60
|
-
children: format(tick)
|
|
61
|
-
}, tick);
|
|
62
|
-
$[7] = format;
|
|
63
|
-
$[8] = t5;
|
|
64
|
-
} else t5 = $[8];
|
|
65
|
-
t4 = plot.ticks.map(t5);
|
|
66
|
-
$[4] = format;
|
|
67
|
-
$[5] = plot.ticks;
|
|
68
|
-
$[6] = t4;
|
|
69
|
-
} else t4 = $[6];
|
|
70
|
-
let t5;
|
|
71
|
-
if ($[9] !== t3 || $[10] !== t4) {
|
|
72
|
-
t5 = /* @__PURE__ */ jsx("div", {
|
|
73
|
-
"aria-hidden": "true",
|
|
74
|
-
"data-slot": "chart-y-axis",
|
|
75
|
-
className: "flex flex-col-reverse justify-between pe-2 text-supporting text-subtle tabular-nums",
|
|
76
|
-
style: t3,
|
|
77
|
-
children: t4
|
|
78
|
-
});
|
|
79
|
-
$[9] = t3;
|
|
80
|
-
$[10] = t4;
|
|
81
|
-
$[11] = t5;
|
|
82
|
-
} else t5 = $[11];
|
|
83
|
-
return t5;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* The category labels under the plot, each centered under its column. `shown`
|
|
87
|
-
* says which categories have one, and `highlighted` which one is the current.
|
|
88
|
-
*/
|
|
89
|
-
function ChartXAxis(t0) {
|
|
90
|
-
const $ = c(11);
|
|
91
|
-
const { labels, count, shown, highlighted } = t0;
|
|
92
|
-
let t1;
|
|
93
|
-
if ($[0] !== count || $[1] !== highlighted || $[2] !== labels || $[3] !== shown) {
|
|
94
|
-
let t2;
|
|
95
|
-
if ($[5] !== count || $[6] !== highlighted || $[7] !== labels) {
|
|
96
|
-
t2 = (index) => /* @__PURE__ */ jsx("div", {
|
|
97
|
-
className: index === highlighted ? "absolute top-0 -translate-x-1/2 text-supporting font-medium whitespace-nowrap text-foreground" : "absolute top-0 -translate-x-1/2 text-supporting whitespace-nowrap text-subtle",
|
|
98
|
-
style: { left: `${(index + .5) / count * 100}%` },
|
|
99
|
-
children: labels[index]
|
|
100
|
-
}, index);
|
|
101
|
-
$[5] = count;
|
|
102
|
-
$[6] = highlighted;
|
|
103
|
-
$[7] = labels;
|
|
104
|
-
$[8] = t2;
|
|
105
|
-
} else t2 = $[8];
|
|
106
|
-
t1 = shown.map(t2);
|
|
107
|
-
$[0] = count;
|
|
108
|
-
$[1] = highlighted;
|
|
109
|
-
$[2] = labels;
|
|
110
|
-
$[3] = shown;
|
|
111
|
-
$[4] = t1;
|
|
112
|
-
} else t1 = $[4];
|
|
113
|
-
let t2;
|
|
114
|
-
if ($[9] !== t1) {
|
|
115
|
-
t2 = /* @__PURE__ */ jsx("div", {
|
|
116
|
-
"aria-hidden": "true",
|
|
117
|
-
"data-slot": "chart-x-axis",
|
|
118
|
-
className: "relative h-4",
|
|
119
|
-
children: t1
|
|
120
|
-
});
|
|
121
|
-
$[9] = t1;
|
|
122
|
-
$[10] = t2;
|
|
123
|
-
} else t2 = $[10];
|
|
124
|
-
return t2;
|
|
125
|
-
}
|
|
126
|
-
export { ChartGrid, ChartXAxis, ChartYAxis };
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { cn } from "../../../utilities/cn/index.js";
|
|
3
|
-
import { ChartGrid, ChartXAxis, ChartYAxis } from "./axes.js";
|
|
4
|
-
import { ChartTooltip, useChartTooltip } from "./points.js";
|
|
5
|
-
import { labelIndices, plotScale, rowId, valueFormatter } from "./scale.js";
|
|
6
|
-
import { ChartTable } from "./table.js";
|
|
7
|
-
import { defaultTexts } from "./types.js";
|
|
8
|
-
import { c } from "react/compiler-runtime";
|
|
9
|
-
import { useState } from "react";
|
|
10
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
// src/components/chart/parts/frame.tsx
|
|
12
|
-
/**
|
|
13
|
-
* Whether the app was built for production. A bundler replaces
|
|
14
|
-
* `process.env.NODE_ENV` with a string; where nothing does and `process`
|
|
15
|
-
* doesn't exist (a browser loading the module as is), reading it throws and
|
|
16
|
-
* the chart counts as in development. Read once, never during render.
|
|
17
|
-
*/
|
|
18
|
-
const production = (() => {
|
|
19
|
-
try {
|
|
20
|
-
return process.env.NODE_ENV === "production";
|
|
21
|
-
} catch {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
})();
|
|
25
|
-
/** The width of an element in px, kept up to date as it resizes. */
|
|
26
|
-
function useWidth() {
|
|
27
|
-
const $ = c(4);
|
|
28
|
-
const [width, setWidth] = useState(0);
|
|
29
|
-
let t0;
|
|
30
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
31
|
-
t0 = () => (node) => {
|
|
32
|
-
if (!node) return;
|
|
33
|
-
setWidth(node.getBoundingClientRect().width);
|
|
34
|
-
if (typeof ResizeObserver === "undefined") return;
|
|
35
|
-
const observer = new ResizeObserver(() => setWidth(node.getBoundingClientRect().width));
|
|
36
|
-
observer.observe(node);
|
|
37
|
-
return () => observer.disconnect();
|
|
38
|
-
};
|
|
39
|
-
$[0] = t0;
|
|
40
|
-
} else t0 = $[0];
|
|
41
|
-
const [ref] = useState(t0);
|
|
42
|
-
let t1;
|
|
43
|
-
if ($[1] !== ref || $[2] !== width) {
|
|
44
|
-
t1 = {
|
|
45
|
-
width,
|
|
46
|
-
ref
|
|
47
|
-
};
|
|
48
|
-
$[1] = ref;
|
|
49
|
-
$[2] = width;
|
|
50
|
-
$[3] = t1;
|
|
51
|
-
} else t1 = $[3];
|
|
52
|
-
return t1;
|
|
53
|
-
}
|
|
54
|
-
function ChartFrame(t0) {
|
|
55
|
-
const $ = c(45);
|
|
56
|
-
let children;
|
|
57
|
-
let className;
|
|
58
|
-
let data;
|
|
59
|
-
let domain;
|
|
60
|
-
let format;
|
|
61
|
-
let highlight;
|
|
62
|
-
let locale;
|
|
63
|
-
let max;
|
|
64
|
-
let name;
|
|
65
|
-
let series;
|
|
66
|
-
let t1;
|
|
67
|
-
let t10;
|
|
68
|
-
let t11;
|
|
69
|
-
let t12;
|
|
70
|
-
let t13;
|
|
71
|
-
let t2;
|
|
72
|
-
let t3;
|
|
73
|
-
let t4;
|
|
74
|
-
let t5;
|
|
75
|
-
let t6;
|
|
76
|
-
let t7;
|
|
77
|
-
let t8;
|
|
78
|
-
let t9;
|
|
79
|
-
if ($[0] !== t0) {
|
|
80
|
-
({data, series, highlight, height: t1, yAxis: t2, xAxis: t3, grid: t4, format, locale, maxLabels: t5, labels: t6, max, empty: t7, categoryHeader: t8, missing: t9, totalHeader: t10, stack: t11, room: t12, bottom: t13, domain, className, children, ...name} = t0);
|
|
81
|
-
$[0] = t0;
|
|
82
|
-
$[1] = children;
|
|
83
|
-
$[2] = className;
|
|
84
|
-
$[3] = data;
|
|
85
|
-
$[4] = domain;
|
|
86
|
-
$[5] = format;
|
|
87
|
-
$[6] = highlight;
|
|
88
|
-
$[7] = locale;
|
|
89
|
-
$[8] = max;
|
|
90
|
-
$[9] = name;
|
|
91
|
-
$[10] = series;
|
|
92
|
-
$[11] = t1;
|
|
93
|
-
$[12] = t10;
|
|
94
|
-
$[13] = t11;
|
|
95
|
-
$[14] = t12;
|
|
96
|
-
$[15] = t13;
|
|
97
|
-
$[16] = t2;
|
|
98
|
-
$[17] = t3;
|
|
99
|
-
$[18] = t4;
|
|
100
|
-
$[19] = t5;
|
|
101
|
-
$[20] = t6;
|
|
102
|
-
$[21] = t7;
|
|
103
|
-
$[22] = t8;
|
|
104
|
-
$[23] = t9;
|
|
105
|
-
} else {
|
|
106
|
-
children = $[1];
|
|
107
|
-
className = $[2];
|
|
108
|
-
data = $[3];
|
|
109
|
-
domain = $[4];
|
|
110
|
-
format = $[5];
|
|
111
|
-
highlight = $[6];
|
|
112
|
-
locale = $[7];
|
|
113
|
-
max = $[8];
|
|
114
|
-
name = $[9];
|
|
115
|
-
series = $[10];
|
|
116
|
-
t1 = $[11];
|
|
117
|
-
t10 = $[12];
|
|
118
|
-
t11 = $[13];
|
|
119
|
-
t12 = $[14];
|
|
120
|
-
t13 = $[15];
|
|
121
|
-
t2 = $[16];
|
|
122
|
-
t3 = $[17];
|
|
123
|
-
t4 = $[18];
|
|
124
|
-
t5 = $[19];
|
|
125
|
-
t6 = $[20];
|
|
126
|
-
t7 = $[21];
|
|
127
|
-
t8 = $[22];
|
|
128
|
-
t9 = $[23];
|
|
129
|
-
}
|
|
130
|
-
const height = t1 === void 0 ? 96 : t1;
|
|
131
|
-
const yAxis = t2 === void 0 ? true : t2;
|
|
132
|
-
const xAxis = t3 === void 0 ? true : t3;
|
|
133
|
-
const grid = t4 === void 0 ? true : t4;
|
|
134
|
-
const maxLabels = t5 === void 0 ? 8 : t5;
|
|
135
|
-
const labels = t6 === void 0 ? "auto" : t6;
|
|
136
|
-
const empty = t7 === void 0 ? defaultTexts.empty : t7;
|
|
137
|
-
const categoryHeader = t8 === void 0 ? defaultTexts.categoryHeader : t8;
|
|
138
|
-
const missing = t9 === void 0 ? defaultTexts.missing : t9;
|
|
139
|
-
const totalHeader = t10 === void 0 ? defaultTexts.totalHeader : t10;
|
|
140
|
-
const stack = t11 === void 0 ? false : t11;
|
|
141
|
-
const room = t12 === void 0 ? 0 : t12;
|
|
142
|
-
const bottom = t13 === void 0 ? 0 : t13;
|
|
143
|
-
if (!production && !name["aria-label"] && !name["aria-labelledby"]) throw new Error("A chart needs a name: pass aria-label or aria-labelledby");
|
|
144
|
-
const tooltip = useChartTooltip();
|
|
145
|
-
const plot = plotScale(data, series, height, max, {
|
|
146
|
-
stack,
|
|
147
|
-
room,
|
|
148
|
-
bottom,
|
|
149
|
-
domain
|
|
150
|
-
});
|
|
151
|
-
const { width, ref } = useWidth();
|
|
152
|
-
const text = valueFormatter(locale, format);
|
|
153
|
-
const show = (value) => text(value, missing);
|
|
154
|
-
const highlighted = highlight === void 0 ? -1 : data.findIndex((row) => rowId(row) === highlight);
|
|
155
|
-
const shown = labels === "ends" ? Array.from(/* @__PURE__ */ new Set([
|
|
156
|
-
0,
|
|
157
|
-
data.length - 1,
|
|
158
|
-
...highlighted >= 0 ? [highlighted] : []
|
|
159
|
-
])).sort(_temp) : labelIndices(data.length, maxLabels, highlighted);
|
|
160
|
-
const t14 = name["aria-label"];
|
|
161
|
-
const t15 = name["aria-labelledby"];
|
|
162
|
-
let t16;
|
|
163
|
-
if ($[24] !== t14 || $[25] !== t15) {
|
|
164
|
-
t16 = {
|
|
165
|
-
"aria-label": t14,
|
|
166
|
-
"aria-labelledby": t15
|
|
167
|
-
};
|
|
168
|
-
$[24] = t14;
|
|
169
|
-
$[25] = t15;
|
|
170
|
-
$[26] = t16;
|
|
171
|
-
} else t16 = $[26];
|
|
172
|
-
const labelled = t16;
|
|
173
|
-
const t17 = "group";
|
|
174
|
-
const t18 = "chart";
|
|
175
|
-
let t19;
|
|
176
|
-
if ($[27] !== className) {
|
|
177
|
-
t19 = cn("flex w-full min-w-0 flex-col gap-1.5", className);
|
|
178
|
-
$[27] = className;
|
|
179
|
-
$[28] = t19;
|
|
180
|
-
} else t19 = $[28];
|
|
181
|
-
const t20 = data.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
182
|
-
"data-slot": "chart-empty",
|
|
183
|
-
className: "flex items-center justify-center text-sm text-muted-foreground",
|
|
184
|
-
style: { height },
|
|
185
|
-
children: empty
|
|
186
|
-
}) : /* @__PURE__ */ jsxs("div", {
|
|
187
|
-
className: "grid grid-cols-[auto_minmax(0,1fr)]",
|
|
188
|
-
children: [
|
|
189
|
-
yAxis ? /* @__PURE__ */ jsx(ChartYAxis, {
|
|
190
|
-
plot,
|
|
191
|
-
format: (value_0) => text(value_0, "")
|
|
192
|
-
}) : /* @__PURE__ */ jsx("div", {}),
|
|
193
|
-
/* @__PURE__ */ jsxs("svg", {
|
|
194
|
-
ref,
|
|
195
|
-
"data-slot": "chart-plot",
|
|
196
|
-
width: "100%",
|
|
197
|
-
height,
|
|
198
|
-
className: "block overflow-visible",
|
|
199
|
-
children: [grid ? /* @__PURE__ */ jsx(ChartGrid, { plot }) : /* @__PURE__ */ jsx("line", {
|
|
200
|
-
"aria-hidden": "true",
|
|
201
|
-
x1: "0",
|
|
202
|
-
x2: "100%",
|
|
203
|
-
y1: plot.baseline + .5,
|
|
204
|
-
y2: plot.baseline + .5,
|
|
205
|
-
className: "stroke-border",
|
|
206
|
-
shapeRendering: "crispEdges"
|
|
207
|
-
}), children({
|
|
208
|
-
plot,
|
|
209
|
-
tooltip,
|
|
210
|
-
text: show,
|
|
211
|
-
highlighted,
|
|
212
|
-
width
|
|
213
|
-
})]
|
|
214
|
-
}),
|
|
215
|
-
xAxis ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {}), /* @__PURE__ */ jsx(ChartXAxis, {
|
|
216
|
-
labels: data.map(_temp2),
|
|
217
|
-
count: data.length,
|
|
218
|
-
shown,
|
|
219
|
-
highlighted
|
|
220
|
-
})] }) : null
|
|
221
|
-
]
|
|
222
|
-
});
|
|
223
|
-
const t21 = stack ? totalHeader : void 0;
|
|
224
|
-
let t22;
|
|
225
|
-
if ($[29] !== categoryHeader || $[30] !== data || $[31] !== labelled || $[32] !== missing || $[33] !== series || $[34] !== t21 || $[35] !== text) {
|
|
226
|
-
t22 = /* @__PURE__ */ jsx(ChartTable, {
|
|
227
|
-
rows: data,
|
|
228
|
-
series,
|
|
229
|
-
categoryHeader,
|
|
230
|
-
missing,
|
|
231
|
-
format: text,
|
|
232
|
-
name: labelled,
|
|
233
|
-
totalHeader: t21
|
|
234
|
-
});
|
|
235
|
-
$[29] = categoryHeader;
|
|
236
|
-
$[30] = data;
|
|
237
|
-
$[31] = labelled;
|
|
238
|
-
$[32] = missing;
|
|
239
|
-
$[33] = series;
|
|
240
|
-
$[34] = t21;
|
|
241
|
-
$[35] = text;
|
|
242
|
-
$[36] = t22;
|
|
243
|
-
} else t22 = $[36];
|
|
244
|
-
let t23;
|
|
245
|
-
if ($[37] !== tooltip) {
|
|
246
|
-
t23 = /* @__PURE__ */ jsx(ChartTooltip, { controller: tooltip });
|
|
247
|
-
$[37] = tooltip;
|
|
248
|
-
$[38] = t23;
|
|
249
|
-
} else t23 = $[38];
|
|
250
|
-
let t24;
|
|
251
|
-
if ($[39] !== labelled || $[40] !== t19 || $[41] !== t20 || $[42] !== t22 || $[43] !== t23) {
|
|
252
|
-
t24 = /* @__PURE__ */ jsxs("div", {
|
|
253
|
-
role: t17,
|
|
254
|
-
"data-slot": t18,
|
|
255
|
-
className: t19,
|
|
256
|
-
...labelled,
|
|
257
|
-
children: [
|
|
258
|
-
t20,
|
|
259
|
-
t22,
|
|
260
|
-
t23
|
|
261
|
-
]
|
|
262
|
-
});
|
|
263
|
-
$[39] = labelled;
|
|
264
|
-
$[40] = t19;
|
|
265
|
-
$[41] = t20;
|
|
266
|
-
$[42] = t22;
|
|
267
|
-
$[43] = t23;
|
|
268
|
-
$[44] = t24;
|
|
269
|
-
} else t24 = $[44];
|
|
270
|
-
return t24;
|
|
271
|
-
}
|
|
272
|
-
function _temp2(row_0) {
|
|
273
|
-
return row_0.label;
|
|
274
|
-
}
|
|
275
|
-
function _temp(a, b) {
|
|
276
|
-
return a - b;
|
|
277
|
-
}
|
|
278
|
-
export { ChartFrame };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|