@misoto22/design 0.3.1 → 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/README.md +124 -0
- package/bin/misoto22-design.mjs +205 -0
- package/dist/agent/Accordion.md +41 -0
- package/dist/agent/Alert.md +42 -0
- package/dist/agent/AppShell.md +40 -0
- package/dist/agent/AreaChart.md +68 -0
- package/dist/agent/Article.md +41 -0
- package/dist/agent/Avatar.md +32 -0
- package/dist/agent/Badge.md +40 -0
- package/dist/agent/BarChart.md +65 -0
- package/dist/agent/BarList.md +40 -0
- package/dist/agent/BigNumber.md +45 -0
- package/dist/agent/BoxPlot.md +58 -0
- package/dist/agent/Breadcrumb.md +32 -0
- package/dist/agent/BulletChart.md +48 -0
- package/dist/agent/Button.md +56 -0
- package/dist/agent/Calendar.md +42 -0
- package/dist/agent/Card.md +49 -0
- package/dist/agent/Checkbox.md +35 -0
- package/dist/agent/Collapsible.md +46 -0
- package/dist/agent/Combobox.md +50 -0
- package/dist/agent/Command.md +93 -0
- package/dist/agent/ComposedChart.md +57 -0
- package/dist/agent/ContextMenu.md +59 -0
- package/dist/agent/DatePicker.md +75 -0
- package/dist/agent/Diagram.md +46 -0
- package/dist/agent/Dialog.md +52 -0
- package/dist/agent/DropdownMenu.md +70 -0
- package/dist/agent/EmptyState.md +37 -0
- package/dist/agent/ErrorState.md +41 -0
- package/dist/agent/Facet.md +82 -0
- package/dist/agent/Field.md +37 -0
- package/dist/agent/FigureBand.md +37 -0
- package/dist/agent/FloatingIconButton.md +38 -0
- package/dist/agent/FunnelChart.md +52 -0
- package/dist/agent/Heatmap.md +53 -0
- package/dist/agent/Histogram.md +63 -0
- package/dist/agent/Input.md +30 -0
- package/dist/agent/Kbd.md +29 -0
- package/dist/agent/LineChart.md +60 -0
- package/dist/agent/LinkArrow.md +29 -0
- package/dist/agent/NativeSelect.md +40 -0
- package/dist/agent/NavItem.md +35 -0
- package/dist/agent/Pagination.md +43 -0
- package/dist/agent/PieChart.md +55 -0
- package/dist/agent/Popover.md +57 -0
- package/dist/agent/Progress.md +33 -0
- package/dist/agent/RadarChart.md +54 -0
- package/dist/agent/RadialChart.md +57 -0
- package/dist/agent/RadioGroup.md +44 -0
- package/dist/agent/SankeyChart.md +61 -0
- package/dist/agent/ScatterChart.md +54 -0
- package/dist/agent/ScrollArea.md +40 -0
- package/dist/agent/SearchableMenu.md +46 -0
- package/dist/agent/Select.md +75 -0
- package/dist/agent/Separator.md +35 -0
- package/dist/agent/Sheet.md +57 -0
- package/dist/agent/Skeleton.md +73 -0
- package/dist/agent/Slider.md +39 -0
- package/dist/agent/Sparkline.md +45 -0
- package/dist/agent/Spinner.md +39 -0
- package/dist/agent/StatusDot.md +36 -0
- package/dist/agent/StatusPill.md +28 -0
- package/dist/agent/Steps.md +44 -0
- package/dist/agent/Switch.md +29 -0
- package/dist/agent/Table.md +85 -0
- package/dist/agent/Tabs.md +48 -0
- package/dist/agent/Tag.md +35 -0
- package/dist/agent/Textarea.md +26 -0
- package/dist/agent/Toast.md +26 -0
- package/dist/agent/ToggleGroup.md +44 -0
- package/dist/agent/Tooltip.md +51 -0
- package/dist/agent/TreemapChart.md +52 -0
- package/dist/agent/WaterfallChart.md +62 -0
- package/dist/agent/catalog.json +1791 -0
- package/dist/agent/index.md +131 -0
- package/dist/article.css +393 -0
- package/dist/charts/AreaChart/AreaChart.d.ts +191 -0
- package/dist/charts/AreaChart/AreaChart.js +480 -0
- package/dist/charts/AreaChart/AreaChart.js.map +1 -0
- package/dist/charts/BarChart/BarChart.d.ts +179 -0
- package/dist/charts/BarChart/BarChart.js +591 -0
- package/dist/charts/BarChart/BarChart.js.map +1 -0
- package/dist/charts/BarList/BarList.d.ts +57 -0
- package/dist/charts/BarList/BarList.js +71 -0
- package/dist/charts/BarList/BarList.js.map +1 -0
- package/dist/charts/BigNumber/BigNumber.d.ts +56 -0
- package/dist/charts/BigNumber/BigNumber.js +31 -0
- package/dist/charts/BigNumber/BigNumber.js.map +1 -0
- package/dist/charts/BoxPlot/BoxPlot.d.ts +177 -0
- package/dist/charts/BoxPlot/BoxPlot.js +495 -0
- package/dist/charts/BoxPlot/BoxPlot.js.map +1 -0
- package/dist/charts/BulletChart/BulletChart.d.ts +100 -0
- package/dist/charts/BulletChart/BulletChart.js +162 -0
- package/dist/charts/BulletChart/BulletChart.js.map +1 -0
- package/dist/charts/ComposedChart/ComposedChart.d.ts +171 -0
- package/dist/charts/ComposedChart/ComposedChart.js +667 -0
- package/dist/charts/ComposedChart/ComposedChart.js.map +1 -0
- package/dist/charts/Facet/Facet.d.ts +240 -0
- package/dist/charts/Facet/Facet.js +133 -0
- package/dist/charts/Facet/Facet.js.map +1 -0
- package/dist/charts/Facet/panels.d.ts +187 -0
- package/dist/charts/Facet/panels.js +203 -0
- package/dist/charts/Facet/panels.js.map +1 -0
- package/dist/charts/FunnelChart/FunnelChart.d.ts +101 -0
- package/dist/charts/FunnelChart/FunnelChart.js +147 -0
- package/dist/charts/FunnelChart/FunnelChart.js.map +1 -0
- package/dist/charts/Heatmap/Heatmap.d.ts +78 -0
- package/dist/charts/Heatmap/Heatmap.js +108 -0
- package/dist/charts/Heatmap/Heatmap.js.map +1 -0
- package/dist/charts/Histogram/Histogram.d.ts +165 -0
- package/dist/charts/Histogram/Histogram.js +350 -0
- package/dist/charts/Histogram/Histogram.js.map +1 -0
- package/dist/charts/LineChart/LineChart.d.ts +167 -0
- package/dist/charts/LineChart/LineChart.js +486 -0
- package/dist/charts/LineChart/LineChart.js.map +1 -0
- package/dist/charts/PieChart/PieChart.d.ts +128 -0
- package/dist/charts/PieChart/PieChart.js +309 -0
- package/dist/charts/PieChart/PieChart.js.map +1 -0
- package/dist/charts/RadarChart/RadarChart.d.ts +123 -0
- package/dist/charts/RadarChart/RadarChart.js +299 -0
- package/dist/charts/RadarChart/RadarChart.js.map +1 -0
- package/dist/charts/RadialChart/RadialChart.d.ts +124 -0
- package/dist/charts/RadialChart/RadialChart.js +257 -0
- package/dist/charts/RadialChart/RadialChart.js.map +1 -0
- package/dist/charts/SankeyChart/SankeyChart.d.ts +137 -0
- package/dist/charts/SankeyChart/SankeyChart.js +501 -0
- package/dist/charts/SankeyChart/SankeyChart.js.map +1 -0
- package/dist/charts/ScatterChart/ScatterChart.d.ts +128 -0
- package/dist/charts/ScatterChart/ScatterChart.js +269 -0
- package/dist/charts/ScatterChart/ScatterChart.js.map +1 -0
- package/dist/charts/Sparkline/Sparkline.d.ts +53 -0
- package/dist/charts/Sparkline/Sparkline.js +93 -0
- package/dist/charts/Sparkline/Sparkline.js.map +1 -0
- package/dist/charts/TreemapChart/TreemapChart.d.ts +93 -0
- package/dist/charts/TreemapChart/TreemapChart.js +118 -0
- package/dist/charts/TreemapChart/TreemapChart.js.map +1 -0
- package/dist/charts/WaterfallChart/WaterfallChart.d.ts +164 -0
- package/dist/charts/WaterfallChart/WaterfallChart.js +319 -0
- package/dist/charts/WaterfallChart/WaterfallChart.js.map +1 -0
- package/dist/charts/index.d.ts +41 -0
- package/dist/charts/index.js +128 -0
- package/dist/charts/index.js.map +1 -0
- package/dist/charts/lib/annotations.d.ts +103 -0
- package/dist/charts/lib/annotations.js +99 -0
- package/dist/charts/lib/annotations.js.map +1 -0
- package/dist/charts/lib/axis.d.ts +18 -0
- package/dist/charts/lib/axis.js +21 -0
- package/dist/charts/lib/axis.js.map +1 -0
- package/dist/charts/lib/background.d.ts +33 -0
- package/dist/charts/lib/background.js +173 -0
- package/dist/charts/lib/background.js.map +1 -0
- package/dist/charts/lib/brush.d.ts +94 -0
- package/dist/charts/lib/brush.js +535 -0
- package/dist/charts/lib/brush.js.map +1 -0
- package/dist/charts/lib/chart.d.ts +94 -0
- package/dist/charts/lib/chart.js +134 -0
- package/dist/charts/lib/chart.js.map +1 -0
- package/dist/charts/lib/dot.d.ts +29 -0
- package/dist/charts/lib/dot.js +78 -0
- package/dist/charts/lib/dot.js.map +1 -0
- package/dist/charts/lib/empty.d.ts +31 -0
- package/dist/charts/lib/empty.js +13 -0
- package/dist/charts/lib/empty.js.map +1 -0
- package/dist/charts/lib/export.d.ts +103 -0
- package/dist/charts/lib/export.js +204 -0
- package/dist/charts/lib/export.js.map +1 -0
- package/dist/charts/lib/figure.d.ts +61 -0
- package/dist/charts/lib/figure.js +59 -0
- package/dist/charts/lib/figure.js.map +1 -0
- package/dist/charts/lib/format.d.ts +46 -0
- package/dist/charts/lib/format.js +56 -0
- package/dist/charts/lib/format.js.map +1 -0
- package/dist/charts/lib/legend.d.ts +45 -0
- package/dist/charts/lib/legend.js +117 -0
- package/dist/charts/lib/legend.js.map +1 -0
- package/dist/charts/lib/loading.d.ts +48 -0
- package/dist/charts/lib/loading.js +105 -0
- package/dist/charts/lib/loading.js.map +1 -0
- package/dist/charts/lib/paint.d.ts +154 -0
- package/dist/charts/lib/paint.js +551 -0
- package/dist/charts/lib/paint.js.map +1 -0
- package/dist/charts/lib/sonify-control.d.ts +163 -0
- package/dist/charts/lib/sonify-control.js +172 -0
- package/dist/charts/lib/sonify-control.js.map +1 -0
- package/dist/charts/lib/sonify.d.ts +248 -0
- package/dist/charts/lib/sonify.js +262 -0
- package/dist/charts/lib/sonify.js.map +1 -0
- package/dist/charts/lib/toolbar.d.ts +143 -0
- package/dist/charts/lib/toolbar.js +156 -0
- package/dist/charts/lib/toolbar.js.map +1 -0
- package/dist/charts/lib/tooltip.d.ts +59 -0
- package/dist/charts/lib/tooltip.js +135 -0
- package/dist/charts/lib/tooltip.js.map +1 -0
- package/dist/charts/lib/values.d.ts +56 -0
- package/dist/charts/lib/values.js +71 -0
- package/dist/charts/lib/values.js.map +1 -0
- package/dist/charts/lib/zoom.d.ts +139 -0
- package/dist/charts/lib/zoom.js +314 -0
- package/dist/charts/lib/zoom.js.map +1 -0
- package/dist/components/AppShell/AppShell.d.ts +15 -1
- package/dist/components/AppShell/AppShell.js +8 -4
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/Article/Article.d.ts +51 -0
- package/dist/components/Article/Article.js +21 -0
- package/dist/components/Article/Article.js.map +1 -0
- package/dist/components/Button/Button.js +2 -2
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.d.ts +1 -1
- package/dist/components/Calendar/Calendar.js +259 -24
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.js +1 -1
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Collapsible/Collapsible.d.ts +15 -1
- package/dist/components/Collapsible/Collapsible.js +18 -0
- package/dist/components/Collapsible/Collapsible.js.map +1 -1
- package/dist/components/Combobox/Combobox.js +1 -1
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/Command/Command.js +7 -7
- package/dist/components/Command/Command.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.js +2 -2
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/Diagram/Diagram.d.ts +81 -0
- package/dist/components/Diagram/Diagram.js +139 -0
- package/dist/components/Diagram/Diagram.js.map +1 -0
- package/dist/components/Dialog/Dialog.js +1 -1
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +2 -2
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/FigureBand/FigureBand.js +41 -30
- package/dist/components/FigureBand/FigureBand.js.map +1 -1
- package/dist/components/Popover/Popover.js +1 -1
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/Select/Select.js +2 -2
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Sheet/Sheet.js +1 -1
- package/dist/components/Sheet/Sheet.js.map +1 -1
- package/dist/components/Slider/Slider.js +1 -1
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/Steps/Steps.d.ts +65 -0
- package/dist/components/Steps/Steps.js +55 -0
- package/dist/components/Steps/Steps.js.map +1 -0
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +1 -1
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/useSelectionIndicator.js +14 -10
- package/dist/lib/useSelectionIndicator.js.map +1 -1
- package/dist/semantic.css +19 -0
- package/dist/styles.css +1 -1
- package/dist/themes.css +103 -7
- package/dist/tokens.css +193 -10
- package/dist/tokens.d.ts +25 -0
- package/dist/tokens.js +154 -8
- package/dist/tokens.json +154 -8
- package/package.json +45 -20
- package/skills/misoto22-design/SKILL.md +171 -0
- package/skills/misoto22-design/evals/claims.json +95 -0
- package/skills/misoto22-design/rules/a11y.md +115 -0
- package/skills/misoto22-design/rules/composition.md +108 -0
- package/skills/misoto22-design/rules/forms.md +128 -0
- package/skills/misoto22-design/rules/naming.md +155 -0
- package/skills/misoto22-design/rules/tokens.md +131 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useContext,
|
|
6
|
+
useId,
|
|
7
|
+
useMemo
|
|
8
|
+
} from "react";
|
|
9
|
+
import {
|
|
10
|
+
Bar as RechartsBar,
|
|
11
|
+
BarChart as RechartsBarChart,
|
|
12
|
+
CartesianGrid,
|
|
13
|
+
ReferenceLine as RechartsReferenceLine,
|
|
14
|
+
XAxis as RechartsXAxis,
|
|
15
|
+
YAxis as RechartsYAxis,
|
|
16
|
+
usePlotArea
|
|
17
|
+
} from "recharts";
|
|
18
|
+
import { ChartContainer } from "../lib/chart.js";
|
|
19
|
+
import { ChartFigure } from "../lib/figure.js";
|
|
20
|
+
import { ChartEmpty } from "../lib/empty.js";
|
|
21
|
+
import { ChartBackground } from "../lib/background.js";
|
|
22
|
+
import { ChartTooltip } from "../lib/tooltip.js";
|
|
23
|
+
import { BarHatchedFill, SeriesGradient } from "../lib/paint.js";
|
|
24
|
+
import { Annotation, ReferenceBand, ReferenceLine } from "../lib/annotations.js";
|
|
25
|
+
import { axisLabel } from "../lib/axis.js";
|
|
26
|
+
import { defaultTick } from "../lib/format.js";
|
|
27
|
+
import { cn } from "../../lib/cn.js";
|
|
28
|
+
const DEFAULT_CONFIG = { value: { label: "Change" } };
|
|
29
|
+
const CHART_MARGIN = { top: 20, right: 12, bottom: 0, left: 12 };
|
|
30
|
+
const BAR_RADIUS = 2;
|
|
31
|
+
function ascending(a, b) {
|
|
32
|
+
return a <= b ? [a, b] : [b, a];
|
|
33
|
+
}
|
|
34
|
+
function resolve(data) {
|
|
35
|
+
let running = 0;
|
|
36
|
+
return data.map((step) => {
|
|
37
|
+
const type = step.type ?? "delta";
|
|
38
|
+
if (type === "total") {
|
|
39
|
+
const total = step.value ?? running;
|
|
40
|
+
const resolved = {
|
|
41
|
+
...step,
|
|
42
|
+
type,
|
|
43
|
+
change: total - running,
|
|
44
|
+
total,
|
|
45
|
+
span: ascending(0, total),
|
|
46
|
+
direction: "total"
|
|
47
|
+
};
|
|
48
|
+
running = total;
|
|
49
|
+
return resolved;
|
|
50
|
+
}
|
|
51
|
+
const change = step.value ?? 0;
|
|
52
|
+
const from = running;
|
|
53
|
+
running += change;
|
|
54
|
+
return {
|
|
55
|
+
...step,
|
|
56
|
+
type,
|
|
57
|
+
change,
|
|
58
|
+
total: running,
|
|
59
|
+
span: ascending(from, running),
|
|
60
|
+
direction: change < 0 ? "decrease" : "increase"
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const WaterfallContext = createContext(null);
|
|
65
|
+
function useWaterfall() {
|
|
66
|
+
const context = useContext(WaterfallContext);
|
|
67
|
+
if (!context) throw new Error("A waterfall part must be rendered inside <WaterfallChart>");
|
|
68
|
+
return context;
|
|
69
|
+
}
|
|
70
|
+
function WaterfallChart({
|
|
71
|
+
config = DEFAULT_CONFIG,
|
|
72
|
+
data,
|
|
73
|
+
title,
|
|
74
|
+
showTitle,
|
|
75
|
+
description,
|
|
76
|
+
children,
|
|
77
|
+
className,
|
|
78
|
+
chartProps,
|
|
79
|
+
formatValue = defaultTick,
|
|
80
|
+
hideDataTable = false,
|
|
81
|
+
empty
|
|
82
|
+
}) {
|
|
83
|
+
const chartId = useId().replace(/:/g, "");
|
|
84
|
+
const seriesKey = Object.keys(config)[0] ?? "value";
|
|
85
|
+
const steps = useMemo(() => resolve(data), [data]);
|
|
86
|
+
const context = useMemo(
|
|
87
|
+
() => ({ config, seriesKey, steps, formatValue }),
|
|
88
|
+
[config, seriesKey, steps, formatValue]
|
|
89
|
+
);
|
|
90
|
+
const isEmpty = empty !== false && steps.length === 0;
|
|
91
|
+
return /* @__PURE__ */ jsx(WaterfallContext.Provider, { value: context, children: /* @__PURE__ */ jsx(
|
|
92
|
+
ChartFigure,
|
|
93
|
+
{
|
|
94
|
+
title,
|
|
95
|
+
showTitle,
|
|
96
|
+
description,
|
|
97
|
+
className,
|
|
98
|
+
table: hideDataTable ? false : {
|
|
99
|
+
rows: steps,
|
|
100
|
+
rowKey: "name",
|
|
101
|
+
columns: [
|
|
102
|
+
{ key: "change", label: "Change" },
|
|
103
|
+
{ key: "total", label: "Running total" }
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
children: isEmpty ? /* @__PURE__ */ jsx(ChartEmpty, { ...empty || {} }) : /* @__PURE__ */ jsx(ChartContainer, { config, children: /* @__PURE__ */ jsx(
|
|
107
|
+
RechartsBarChart,
|
|
108
|
+
{
|
|
109
|
+
id: chartId,
|
|
110
|
+
accessibilityLayer: true,
|
|
111
|
+
margin: CHART_MARGIN,
|
|
112
|
+
data: steps,
|
|
113
|
+
barCategoryGap: "25%",
|
|
114
|
+
...chartProps,
|
|
115
|
+
children
|
|
116
|
+
}
|
|
117
|
+
) })
|
|
118
|
+
}
|
|
119
|
+
) });
|
|
120
|
+
}
|
|
121
|
+
function Bars({
|
|
122
|
+
radius = BAR_RADIUS,
|
|
123
|
+
connectors = true,
|
|
124
|
+
showValues = false,
|
|
125
|
+
barProps
|
|
126
|
+
}) {
|
|
127
|
+
const { config, seriesKey, steps, formatValue } = useWaterfall();
|
|
128
|
+
const id = useId().replace(/:/g, "");
|
|
129
|
+
const shared = {
|
|
130
|
+
id,
|
|
131
|
+
seriesKey,
|
|
132
|
+
radius,
|
|
133
|
+
connectors,
|
|
134
|
+
showValues,
|
|
135
|
+
stepCount: steps.length,
|
|
136
|
+
formatValue
|
|
137
|
+
};
|
|
138
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
139
|
+
/* @__PURE__ */ jsx(RechartsReferenceLine, { y: 0, stroke: "var(--chart-grid)", strokeWidth: 1 }),
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
RechartsBar,
|
|
142
|
+
{
|
|
143
|
+
dataKey: (row) => row.span,
|
|
144
|
+
name: seriesKey,
|
|
145
|
+
isAnimationActive: false,
|
|
146
|
+
fill: "transparent",
|
|
147
|
+
shape: (props) => /* @__PURE__ */ jsx(StepShape, { ...props, ...shared }),
|
|
148
|
+
activeBar: (props) => /* @__PURE__ */ jsx(StepShape, { ...props, ...shared }),
|
|
149
|
+
...barProps
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
153
|
+
/* @__PURE__ */ jsx(SeriesGradient, { id, dataKey: seriesKey, config, direction: "vertical" }),
|
|
154
|
+
/* @__PURE__ */ jsx(BarHatchedFill, { id, dataKey: seriesKey })
|
|
155
|
+
] })
|
|
156
|
+
] });
|
|
157
|
+
}
|
|
158
|
+
function StepShape({
|
|
159
|
+
x = 0,
|
|
160
|
+
y = 0,
|
|
161
|
+
width = 0,
|
|
162
|
+
height = 0,
|
|
163
|
+
index = -1,
|
|
164
|
+
payload,
|
|
165
|
+
id,
|
|
166
|
+
seriesKey,
|
|
167
|
+
radius,
|
|
168
|
+
connectors,
|
|
169
|
+
showValues,
|
|
170
|
+
stepCount,
|
|
171
|
+
formatValue
|
|
172
|
+
}) {
|
|
173
|
+
const plot = usePlotArea();
|
|
174
|
+
if (!payload) return null;
|
|
175
|
+
const step = payload;
|
|
176
|
+
const fill = step.direction === "decrease" ? `url(#${id}-hatched-${seriesKey})` : `url(#${id}-colors-${seriesKey})`;
|
|
177
|
+
const closesAtTop = step.total >= step.span[1];
|
|
178
|
+
const closingY = closesAtTop ? y : y + height;
|
|
179
|
+
const drawnHeight = Math.max(height, 1);
|
|
180
|
+
const band = plot && stepCount > 0 ? plot.width / stepCount : width;
|
|
181
|
+
const hasNext = index >= 0 && index < stepCount - 1;
|
|
182
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
183
|
+
connectors && hasNext && /* @__PURE__ */ jsx(
|
|
184
|
+
"line",
|
|
185
|
+
{
|
|
186
|
+
x1: x + width,
|
|
187
|
+
y1: closingY,
|
|
188
|
+
x2: x + band,
|
|
189
|
+
y2: closingY,
|
|
190
|
+
stroke: "var(--chart-cursor)",
|
|
191
|
+
strokeWidth: 1,
|
|
192
|
+
strokeDasharray: "3 3"
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
/* @__PURE__ */ jsx("rect", { x, y, width, height: drawnHeight, rx: radius || void 0, fill }),
|
|
196
|
+
showValues && /* @__PURE__ */ jsx(
|
|
197
|
+
"text",
|
|
198
|
+
{
|
|
199
|
+
x: x + width / 2,
|
|
200
|
+
y: closesAtTop ? y - 6 : y + drawnHeight + 13,
|
|
201
|
+
textAnchor: "middle",
|
|
202
|
+
className: "fill-(--ink) font-mono text-[11px] font-medium tabular-nums",
|
|
203
|
+
style: { pointerEvents: "none" },
|
|
204
|
+
children: step.direction === "total" ? formatValue(step.total) : `${step.change > 0 ? "+" : ""}${formatValue(step.change)}`
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
] });
|
|
208
|
+
}
|
|
209
|
+
function XAxis({
|
|
210
|
+
dataKey = "name",
|
|
211
|
+
tickLine = false,
|
|
212
|
+
axisLine = false,
|
|
213
|
+
tickMargin = 8,
|
|
214
|
+
minTickGap = 8,
|
|
215
|
+
label,
|
|
216
|
+
...rest
|
|
217
|
+
}) {
|
|
218
|
+
return /* @__PURE__ */ jsx(
|
|
219
|
+
RechartsXAxis,
|
|
220
|
+
{
|
|
221
|
+
dataKey,
|
|
222
|
+
tickLine,
|
|
223
|
+
axisLine,
|
|
224
|
+
tickMargin,
|
|
225
|
+
minTickGap,
|
|
226
|
+
...rest,
|
|
227
|
+
children: axisLabel(label, "x")
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
function YAxis({
|
|
232
|
+
tickLine = false,
|
|
233
|
+
axisLine = false,
|
|
234
|
+
tickMargin = 8,
|
|
235
|
+
width = "auto",
|
|
236
|
+
label,
|
|
237
|
+
tickFormatter,
|
|
238
|
+
...rest
|
|
239
|
+
}) {
|
|
240
|
+
const { formatValue } = useWaterfall();
|
|
241
|
+
return /* @__PURE__ */ jsx(
|
|
242
|
+
RechartsYAxis,
|
|
243
|
+
{
|
|
244
|
+
tickLine,
|
|
245
|
+
axisLine,
|
|
246
|
+
tickMargin,
|
|
247
|
+
width,
|
|
248
|
+
tickFormatter: tickFormatter ?? formatValue,
|
|
249
|
+
...rest,
|
|
250
|
+
children: axisLabel(label, "y")
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
function Grid({
|
|
255
|
+
strokeDasharray = "3 3",
|
|
256
|
+
vertical = false,
|
|
257
|
+
...rest
|
|
258
|
+
}) {
|
|
259
|
+
return /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray, vertical, ...rest });
|
|
260
|
+
}
|
|
261
|
+
function Tooltip({ variant = "solid", roundness = "lg", defaultIndex }) {
|
|
262
|
+
const { formatValue } = useWaterfall();
|
|
263
|
+
return /* @__PURE__ */ jsx(
|
|
264
|
+
ChartTooltip,
|
|
265
|
+
{
|
|
266
|
+
cursor: false,
|
|
267
|
+
defaultIndex,
|
|
268
|
+
content: (props) => {
|
|
269
|
+
const { active, payload } = props;
|
|
270
|
+
const step = payload?.[0]?.payload;
|
|
271
|
+
if (!active || !step) return /* @__PURE__ */ jsx("span", { className: "p-4" });
|
|
272
|
+
return /* @__PURE__ */ jsxs(
|
|
273
|
+
"div",
|
|
274
|
+
{
|
|
275
|
+
className: cn(
|
|
276
|
+
"grid min-w-40 gap-1.5 border border-(--rule-2) px-2.5 py-1.5 text-xs",
|
|
277
|
+
roundness === "sm" && "rounded-(--radius-sm)",
|
|
278
|
+
roundness === "md" && "rounded-(--radius)",
|
|
279
|
+
roundness === "lg" && "rounded-(--radius-lg)",
|
|
280
|
+
variant === "frosted" ? "bg-(--chart-surface)/75 backdrop-blur-sm" : "bg-(--chart-surface)"
|
|
281
|
+
),
|
|
282
|
+
children: [
|
|
283
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-(--ink)", children: step.name }),
|
|
284
|
+
step.direction !== "total" && /* @__PURE__ */ jsxs("div", { className: "flex justify-between gap-4 leading-none", children: [
|
|
285
|
+
/* @__PURE__ */ jsx("span", { className: "text-(--ink-3-aa)", children: "Change" }),
|
|
286
|
+
/* @__PURE__ */ jsxs("span", { className: "font-mono font-medium tabular-nums text-(--ink)", children: [
|
|
287
|
+
step.change > 0 ? "+" : "",
|
|
288
|
+
formatValue(step.change)
|
|
289
|
+
] })
|
|
290
|
+
] }),
|
|
291
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-between gap-4 leading-none", children: [
|
|
292
|
+
/* @__PURE__ */ jsx("span", { className: "text-(--ink-3-aa)", children: step.direction === "total" ? "Total" : "Running total" }),
|
|
293
|
+
/* @__PURE__ */ jsx("span", { className: "font-mono font-medium tabular-nums text-(--ink)", children: formatValue(step.total) })
|
|
294
|
+
] })
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
function Background({ variant }) {
|
|
303
|
+
return /* @__PURE__ */ jsx(ChartBackground, { variant });
|
|
304
|
+
}
|
|
305
|
+
WaterfallChart.Bars = Bars;
|
|
306
|
+
WaterfallChart.XAxis = XAxis;
|
|
307
|
+
WaterfallChart.YAxis = YAxis;
|
|
308
|
+
WaterfallChart.Grid = Grid;
|
|
309
|
+
WaterfallChart.Tooltip = Tooltip;
|
|
310
|
+
WaterfallChart.Background = Background;
|
|
311
|
+
WaterfallChart.ReferenceLine = ReferenceLine;
|
|
312
|
+
WaterfallChart.ReferenceBand = ReferenceBand;
|
|
313
|
+
WaterfallChart.Annotation = Annotation;
|
|
314
|
+
var WaterfallChart_default = WaterfallChart;
|
|
315
|
+
export {
|
|
316
|
+
WaterfallChart,
|
|
317
|
+
WaterfallChart_default as default
|
|
318
|
+
};
|
|
319
|
+
//# sourceMappingURL=WaterfallChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/charts/WaterfallChart/WaterfallChart.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useContext,\n useId,\n useMemo,\n type ComponentProps,\n type ReactNode,\n} from 'react'\nimport {\n Bar as RechartsBar,\n BarChart as RechartsBarChart,\n CartesianGrid,\n ReferenceLine as RechartsReferenceLine,\n XAxis as RechartsXAxis,\n YAxis as RechartsYAxis,\n usePlotArea,\n} from 'recharts'\nimport { ChartContainer, type ChartConfig } from '../lib/chart'\nimport { ChartFigure } from '../lib/figure'\nimport { ChartEmpty, type ChartEmptyProps } from '../lib/empty'\nimport { ChartBackground, type ChartBackgroundVariant } from '../lib/background'\nimport { ChartTooltip } from '../lib/tooltip'\nimport { BarHatchedFill, SeriesGradient } from '../lib/paint'\nimport { Annotation, ReferenceBand, ReferenceLine } from '../lib/annotations'\nimport { axisLabel } from '../lib/axis'\nimport { defaultTick } from '../lib/format'\nimport { cn } from '../../lib/cn'\nimport type { ChartXAxisProps, ChartYAxisProps } from '../BarChart/BarChart'\nimport type { ChartTooltipSlotProps } from '../AreaChart/AreaChart'\n\n/** The series a chart with only one of them falls back to. */\nconst DEFAULT_CONFIG: ChartConfig = { value: { label: 'Change' } }\n\nconst CHART_MARGIN = { top: 20, right: 12, bottom: 0, left: 12 }\n\n/** The corner every bar rounds to. */\nconst BAR_RADIUS = 2\n\n/** How a step moves the running total. */\nexport type WaterfallStepType = 'delta' | 'total'\n\n/** Which way a bar goes, which is what its texture encodes. */\nexport type WaterfallDirection = 'increase' | 'decrease' | 'total'\n\nexport interface WaterfallStep {\n /** The step's name on the category axis. Doubles as its key. */\n name: string\n /**\n * The signed change this step makes, or — on a `total` step — the absolute\n * figure the running total is set to.\n *\n * Omit it on a `total` and the running total is used, which is the right\n * default for the closing bar: an end total typed by hand can disagree with\n * the deltas above it, and the chart would draw the disagreement without\n * saying anything.\n */\n value?: number\n /**\n * `delta` (the default) adds `value` to the running total and floats the bar\n * where that lands. `total` plants a bar on the baseline — an opening\n * balance, a subtotal, a closing figure.\n */\n type?: WaterfallStepType\n}\n\n/** A step with its span, its direction and its running total worked out. */\ninterface ResolvedStep extends WaterfallStep {\n type: WaterfallStepType\n /**\n * What this step moved the total by. On a `total` step that is the gap it\n * closes — zero whenever the deltas above it already add up to it.\n */\n change: number\n /** The running total once this step has been applied. */\n total: number\n /**\n * The bar's two ends on the value axis, LOW first.\n *\n * Ascending because Recharts reads a floating bar's range that way and\n * collapses a descending one to nothing — which is every decrease in the\n * cascade. Which end the running total is at is recovered from `total`\n * rather than from the order here.\n */\n span: [number, number]\n direction: WaterfallDirection\n}\n\n/** A bar's two ends, low first — see `ResolvedStep.span`. */\nfunction ascending(a: number, b: number): [number, number] {\n return a <= b ? [a, b] : [b, a]\n}\n\n/** The steps, walked in order, each carrying the total it leaves behind. */\nfunction resolve(data: WaterfallStep[]): ResolvedStep[] {\n let running = 0\n\n return data.map((step) => {\n const type = step.type ?? 'delta'\n\n if (type === 'total') {\n const total = step.value ?? running\n const resolved: ResolvedStep = {\n ...step,\n type,\n change: total - running,\n total,\n span: ascending(0, total),\n direction: 'total',\n }\n running = total\n return resolved\n }\n\n const change = step.value ?? 0\n const from = running\n running += change\n\n return {\n ...step,\n type,\n change,\n total: running,\n span: ascending(from, running),\n direction: change < 0 ? 'decrease' : 'increase',\n }\n })\n}\n\ninterface WaterfallContextValue {\n config: ChartConfig\n seriesKey: string\n steps: ResolvedStep[]\n formatValue: (value: number) => string\n}\n\nconst WaterfallContext = createContext<WaterfallContextValue | null>(null)\n\nfunction useWaterfall(): WaterfallContextValue {\n const context = useContext(WaterfallContext)\n if (!context) throw new Error('A waterfall part must be rendered inside <WaterfallChart>')\n return context\n}\n\nexport interface WaterfallChartProps {\n /**\n * The single series — its label and its paint. Only the FIRST entry is read;\n * a waterfall has one quantity and as many bars as it has steps.\n */\n config?: ChartConfig\n /**\n * The steps, in the order they are applied. Order is the arithmetic: the\n * chart does not sort, because a different order is a different total at\n * every intermediate bar.\n */\n data: WaterfallStep[]\n /**\n * What the chart shows, in a sentence a reader could act on. Required, and\n * announced to a screen reader even when it is not printed.\n */\n title: string\n /** Prints the title above the plot instead of hiding it from sight. */\n showTitle?: boolean\n /** A line under the title — the unit, the window, the caveat. */\n description?: ReactNode\n /** The composed parts — axes, grid, tooltip, and `<WaterfallChart.Bars>`. */\n children: ReactNode\n /** Merged onto the figure, last, so a call site can size or space it. */\n className?: string\n /** Escape hatch onto the raw Recharts chart element. */\n chartProps?: ComponentProps<typeof RechartsBarChart>\n /** Formats every number the chart prints — ticks, labels, tooltip, table. */\n formatValue?: (value: number) => string\n /** Drops the hidden table view. Only correct when the page prints the data itself. */\n hideDataTable?: boolean\n /**\n * What the chart shows when it has nothing to draw. `false` keeps the axes,\n * for a chart whose emptiness is itself the reading.\n */\n empty?: ChartEmptyProps | false\n}\n\n/**\n * How a total got from one figure to another — an opening balance, the signed\n * contributions that moved it, and where it closed.\n *\n * The form for \"why did this change\", which a pair of bars cannot answer and a\n * pie chart answers wrongly, because contributions can be NEGATIVE and a slice\n * cannot. Reach for `<BarChart>` when the parts do not have to add up to the\n * gap between two totals, and for `<FunnelChart>` when the quantity only ever\n * shrinks.\n *\n * **The connectors are the claim to be careful about.** They draw the steps as\n * a sequence — this happened, then this — and most breakdowns are not\n * sequential at all: churn and expansion in the same month are simultaneous,\n * and the order they are listed in is an editorial choice. The arithmetic\n * survives any order; the STORY does not, and a reader will take the leftmost\n * bar as the first cause. Two related traps: the intermediate bars are floating\n * lengths read against no baseline, so a small step high up the cascade is hard\n * to compare with a large one near zero; and any step that is itself a net of\n * two larger opposing movements is invisible as such. Where the order is\n * arbitrary, say so in the `description`.\n *\n * Recharts earns its place for the axes, grid and tooltip. Each bar is a\n * floating range — from the running total to the new one — with a custom shape\n * over it, because Recharts has no waterfall mark and the connectors have to be\n * drawn from the same geometry as the bars they join.\n *\n * @example\n * <WaterfallChart title=\"Revenue bridge, FY25\" data={steps}>\n * <WaterfallChart.Grid />\n * <WaterfallChart.XAxis />\n * <WaterfallChart.YAxis label=\"AUD\" />\n * <WaterfallChart.Tooltip />\n * <WaterfallChart.Bars showValues />\n * </WaterfallChart>\n *\n * @example\n * const steps = [\n * { name: 'FY24', value: 1200, type: 'total' as const },\n * { name: 'New', value: 340 },\n * { name: 'Churn', value: -180 },\n * // No value: the closing bar is whatever the deltas add up to.\n * { name: 'FY25', type: 'total' as const },\n * ]\n */\nexport function WaterfallChart({\n config = DEFAULT_CONFIG,\n data,\n title,\n showTitle,\n description,\n children,\n className,\n chartProps,\n formatValue = defaultTick,\n hideDataTable = false,\n empty,\n}: WaterfallChartProps) {\n const chartId = useId().replace(/:/g, '')\n const seriesKey = Object.keys(config)[0] ?? 'value'\n const steps = useMemo(() => resolve(data), [data])\n\n const context = useMemo<WaterfallContextValue>(\n () => ({ config, seriesKey, steps, formatValue }),\n [config, seriesKey, steps, formatValue],\n )\n\n const isEmpty = empty !== false && steps.length === 0\n\n return (\n <WaterfallContext.Provider value={context}>\n <ChartFigure\n title={title}\n showTitle={showTitle}\n description={description}\n className={className}\n table={\n hideDataTable\n ? false\n : {\n rows: steps as unknown as Record<string, unknown>[],\n rowKey: 'name',\n columns: [\n { key: 'change', label: 'Change' },\n { key: 'total', label: 'Running total' },\n ],\n }\n }\n >\n {isEmpty ? (\n <ChartEmpty {...(empty || {})} />\n ) : (\n <ChartContainer config={config}>\n <RechartsBarChart\n id={chartId}\n accessibilityLayer\n margin={CHART_MARGIN}\n data={steps}\n barCategoryGap=\"25%\"\n {...chartProps}\n >\n {children}\n </RechartsBarChart>\n </ChartContainer>\n )}\n </ChartFigure>\n </WaterfallContext.Provider>\n )\n}\n\nexport interface WaterfallBarsProps {\n /** The bars' corner. */\n radius?: number\n /**\n * Joins each bar's closing edge to where the next one starts.\n *\n * On by default: without them a waterfall is a row of bars floating at\n * unrelated heights, and the cascade — which is the entire point of the form\n * — has to be reconstructed by the reader.\n */\n connectors?: boolean\n /**\n * Prints each step's signed change above or below its bar.\n *\n * Worth more here than on most charts: an intermediate bar has no baseline\n * under it, so its length is the one thing a reader cannot get off the axis.\n */\n showValues?: boolean\n /** Escape hatch onto the underlying Recharts bar. */\n barProps?: ComponentProps<typeof RechartsBar>\n}\n\n/**\n * The bars and the connectors between them.\n *\n * Increases and totals take the solid series fill; decreases take the 45°\n * hatch. Texture rather than a second colour, because the whole set has to stay\n * legible in greyscale and under forced colours — and a total is told from an\n * increase by geometry instead, since it is the only kind of bar that stands on\n * the baseline.\n */\nfunction Bars({\n radius = BAR_RADIUS,\n connectors = true,\n showValues = false,\n barProps,\n}: WaterfallBarsProps) {\n const { config, seriesKey, steps, formatValue } = useWaterfall()\n const id = useId().replace(/:/g, '')\n\n const shared = {\n id,\n seriesKey,\n radius,\n connectors,\n showValues,\n stepCount: steps.length,\n formatValue,\n }\n\n return (\n <>\n {/* The baseline the totals stand on. A waterfall without a visible zero\n asks the reader to take the floating bars on trust. */}\n <RechartsReferenceLine y={0} stroke=\"var(--chart-grid)\" strokeWidth={1} />\n <RechartsBar\n dataKey={(row: unknown) => (row as ResolvedStep).span}\n name={seriesKey}\n isAnimationActive={false}\n fill=\"transparent\"\n shape={(props: unknown) => <StepShape {...(props as StepGeometry)} {...shared} />}\n activeBar={(props: unknown) => <StepShape {...(props as StepGeometry)} {...shared} />}\n {...barProps}\n />\n <defs>\n <SeriesGradient id={id} dataKey={seriesKey} config={config} direction=\"vertical\" />\n <BarHatchedFill id={id} dataKey={seriesKey} />\n </defs>\n </>\n )\n}\n\n/** The geometry Recharts hands a custom bar shape, plus the step behind it. */\ninterface StepGeometry {\n x?: number\n y?: number\n width?: number\n height?: number\n index?: number\n payload?: ResolvedStep\n}\n\ninterface StepShapeProps extends StepGeometry {\n id: string\n seriesKey: string\n radius: number\n connectors: boolean\n showValues: boolean\n stepCount: number\n formatValue: (value: number) => string\n}\n\n/** One step: its bar, its connector to the next step, and its label. */\nfunction StepShape({\n x = 0,\n y = 0,\n width = 0,\n height = 0,\n index = -1,\n payload,\n id,\n seriesKey,\n radius,\n connectors,\n showValues,\n stepCount,\n formatValue,\n}: StepShapeProps) {\n const plot = usePlotArea()\n\n if (!payload) return null\n\n const step = payload\n const fill =\n step.direction === 'decrease'\n ? `url(#${id}-hatched-${seriesKey})`\n : `url(#${id}-colors-${seriesKey})`\n\n // Which edge of the rect the running total lands on. Everything downstream —\n // the connector's height, where the label sits — hangs off this one fact,\n // and it is a comparison rather than a re-derived scale so it stays right\n // whatever domain the axis ends up with.\n const closesAtTop = step.total >= step.span[1]\n const closingY = closesAtTop ? y : y + height\n\n // A zero-change step has no rect to see. It still has to appear, or the\n // cascade silently loses a category and the axis stops matching the bars.\n const drawnHeight = Math.max(height, 1)\n\n // Recharts leaves a gap between category bands, and the connector has to\n // cross it. One band is the plot's width over the number of steps, so the\n // next bar's near edge is exactly one band along from this one's.\n const band = plot && stepCount > 0 ? plot.width / stepCount : width\n const hasNext = index >= 0 && index < stepCount - 1\n\n return (\n <g>\n {connectors && hasNext && (\n <line\n x1={x + width}\n y1={closingY}\n x2={x + band}\n y2={closingY}\n stroke=\"var(--chart-cursor)\"\n strokeWidth={1}\n strokeDasharray=\"3 3\"\n />\n )}\n <rect x={x} y={y} width={width} height={drawnHeight} rx={radius || undefined} fill={fill} />\n {showValues && (\n <text\n x={x + width / 2}\n // Above a rise, below a fall — so the label never sits inside the bar\n // it is describing and never collides with the connector leaving it.\n y={closesAtTop ? y - 6 : y + drawnHeight + 13}\n textAnchor=\"middle\"\n className=\"fill-(--ink) font-mono text-[11px] font-medium tabular-nums\"\n style={{ pointerEvents: 'none' }}\n >\n {step.direction === 'total'\n ? formatValue(step.total)\n : `${step.change > 0 ? '+' : ''}${formatValue(step.change)}`}\n </text>\n )}\n </g>\n )\n}\n\n/** The step axis. */\nfunction XAxis({\n dataKey = 'name',\n tickLine = false,\n axisLine = false,\n tickMargin = 8,\n minTickGap = 8,\n label,\n ...rest\n}: ChartXAxisProps) {\n return (\n <RechartsXAxis\n dataKey={dataKey}\n tickLine={tickLine}\n axisLine={axisLine}\n tickMargin={tickMargin}\n minTickGap={minTickGap}\n {...rest}\n >\n {axisLabel(label, 'x')}\n </RechartsXAxis>\n )\n}\n\n/** The value axis. */\nfunction YAxis({\n tickLine = false,\n axisLine = false,\n tickMargin = 8,\n width = 'auto',\n label,\n tickFormatter,\n ...rest\n}: ChartYAxisProps) {\n const { formatValue } = useWaterfall()\n\n return (\n <RechartsYAxis\n tickLine={tickLine}\n axisLine={axisLine}\n tickMargin={tickMargin}\n width={width}\n tickFormatter={tickFormatter ?? formatValue}\n {...rest}\n >\n {axisLabel(label, 'y')}\n </RechartsYAxis>\n )\n}\n\n/** Rules across the value axis. */\nfunction Grid({\n strokeDasharray = '3 3',\n vertical = false,\n ...rest\n}: ComponentProps<typeof CartesianGrid>) {\n return <CartesianGrid strokeDasharray={strokeDasharray} vertical={vertical} {...rest} />\n}\n\n/**\n * The hover panel, printing the change AND the total it leaves behind.\n *\n * The generic tooltip would print the bar's raw span, which is a pair of\n * running totals and reads as two unrelated numbers. Both facts a waterfall\n * carries — what this step did, and where the total stood afterwards — are\n * named here instead.\n */\nfunction Tooltip({ variant = 'solid', roundness = 'lg', defaultIndex }: ChartTooltipSlotProps) {\n const { formatValue } = useWaterfall()\n\n return (\n <ChartTooltip\n cursor={false}\n defaultIndex={defaultIndex}\n content={(props) => {\n const { active, payload } = props as unknown as {\n active?: boolean\n payload?: { payload?: ResolvedStep }[]\n }\n const step = payload?.[0]?.payload\n if (!active || !step) return <span className=\"p-4\" />\n\n return (\n <div\n className={cn(\n 'grid min-w-40 gap-1.5 border border-(--rule-2) px-2.5 py-1.5 text-xs',\n roundness === 'sm' && 'rounded-(--radius-sm)',\n roundness === 'md' && 'rounded-(--radius)',\n roundness === 'lg' && 'rounded-(--radius-lg)',\n variant === 'frosted'\n ? 'bg-(--chart-surface)/75 backdrop-blur-sm'\n : 'bg-(--chart-surface)',\n )}\n >\n <div className=\"font-medium text-(--ink)\">{step.name}</div>\n {step.direction !== 'total' && (\n <div className=\"flex justify-between gap-4 leading-none\">\n <span className=\"text-(--ink-3-aa)\">Change</span>\n <span className=\"font-mono font-medium tabular-nums text-(--ink)\">\n {step.change > 0 ? '+' : ''}\n {formatValue(step.change)}\n </span>\n </div>\n )}\n <div className=\"flex justify-between gap-4 leading-none\">\n <span className=\"text-(--ink-3-aa)\">\n {step.direction === 'total' ? 'Total' : 'Running total'}\n </span>\n <span className=\"font-mono font-medium tabular-nums text-(--ink)\">\n {formatValue(step.total)}\n </span>\n </div>\n </div>\n )\n }}\n />\n )\n}\n\n/** The decorative plate behind the plot. */\nfunction Background({ variant }: { variant: ChartBackgroundVariant }) {\n return <ChartBackground variant={variant} />\n}\n\nWaterfallChart.Bars = Bars\nWaterfallChart.XAxis = XAxis\nWaterfallChart.YAxis = YAxis\nWaterfallChart.Grid = Grid\nWaterfallChart.Tooltip = Tooltip\nWaterfallChart.Background = Background\nWaterfallChart.ReferenceLine = ReferenceLine\nWaterfallChart.ReferenceBand = ReferenceBand\nWaterfallChart.Annotation = Annotation\n\nexport default WaterfallChart\n"],"mappings":";AAgRU,SAuEN,UAvEM,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AAK,MAAM;AAAA,mBAC1B;AAAA,iBACF;AAAA,cAEF,qBAAC,SAAI,WAAU,2CACb;AAAA,oCAAC,UAAK,WAAU,qBACb,eAAK,cAAc,UAAU,UAAU,iBAC1C;AAAA,gBACA,oBAAC,UAAK,WAAU,mDACb,sBAAY,KAAK,KAAK,GACzB;AAAA,iBACF;AAAA;AAAA;AAAA,QACF;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;AAGA,SAAS,WAAW,EAAE,QAAQ,GAAwC;AACpE,SAAO,oBAAC,mBAAgB,SAAkB;AAC5C;AAEA,eAAe,OAAO;AACtB,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,OAAO;AACtB,eAAe,UAAU;AACzB,eAAe,aAAa;AAC5B,eAAe,gBAAgB;AAC/B,eAAe,gBAAgB;AAC/B,eAAe,aAAa;AAE5B,IAAO,yBAAQ;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export { AreaChart, AreaChartProps, AreaProps, AreaStackType, AreaStrokeVariant, AreaVariant, ChartCurveType, ChartLegendSlotProps, ChartTooltipSlotProps } from './AreaChart/AreaChart.js';
|
|
2
|
+
export { BarChart, BarChartProps, BarOrientation, BarProps, BarStackType, BarVariant } from './BarChart/BarChart.js';
|
|
3
|
+
export { LineChart, LineChartProps, LineProps, LineStrokeVariant } from './LineChart/LineChart.js';
|
|
4
|
+
export { ComposedBarProps, ComposedChart, ComposedChartProps, ComposedLineProps } from './ComposedChart/ComposedChart.js';
|
|
5
|
+
export { ScatterChart, ScatterChartProps, ScatterProps, ScatterShape, ScatterTable, ScatterVariant } from './ScatterChart/ScatterChart.js';
|
|
6
|
+
export { PieChart, PieChartProps, PieLabelProps, PieProps, PieVariant } from './PieChart/PieChart.js';
|
|
7
|
+
export { RadarChart, RadarChartProps, RadarProps, RadarVariant } from './RadarChart/RadarChart.js';
|
|
8
|
+
export { RadialBarProps, RadialChart, RadialChartProps, RadialVariant } from './RadialChart/RadialChart.js';
|
|
9
|
+
export { FunnelChart, FunnelChartProps, FunnelLabelProps, FunnelProps, FunnelVariant } from './FunnelChart/FunnelChart.js';
|
|
10
|
+
export { TreemapChart, TreemapChartProps, TreemapExtras, TreemapNode, TreemapVariant } from './TreemapChart/TreemapChart.js';
|
|
11
|
+
export { Heatmap, HeatmapCell, HeatmapProps, HeatmapScale } from './Heatmap/Heatmap.js';
|
|
12
|
+
export { Sparkline, SparklineProps, SparklineVariant } from './Sparkline/Sparkline.js';
|
|
13
|
+
export { BarList, BarListItem, BarListProps } from './BarList/BarList.js';
|
|
14
|
+
export { BigNumber, BigNumberDelta, BigNumberProps, DeltaIntent } from './BigNumber/BigNumber.js';
|
|
15
|
+
export { SankeyChart, SankeyChartProps, SankeyLabelPosition, LinkProps as SankeyLinkSlotProps, SankeyLinkVariant, NodeLabelProps as SankeyNodeLabelProps, NodeProps as SankeyNodeSlotProps } from './SankeyChart/SankeyChart.js';
|
|
16
|
+
export { ChartConfig, ChartContainer, ChartContainerProps, ChartSeries, SERIES_SLOTS, percentTick, useChart } from './lib/chart.js';
|
|
17
|
+
export { ChartColumn, ChartDataTable, ChartDataTableProps, ChartFigure, ChartFigureProps } from './lib/figure.js';
|
|
18
|
+
export { ChartBackground, ChartBackgroundProps, ChartBackgroundVariant } from './lib/background.js';
|
|
19
|
+
export { ChartDot, ChartDotProps, ChartDotVariant } from './lib/dot.js';
|
|
20
|
+
export { ChartLegend, ChartLegendAlign, ChartLegendContent, ChartLegendContentProps, ChartLegendVariant } from './lib/legend.js';
|
|
21
|
+
export { ChartTooltip, ChartTooltipContent, ChartTooltipContentProps, ChartTooltipIndicator, ChartTooltipRoundness, ChartTooltipVariant } from './lib/tooltip.js';
|
|
22
|
+
export { Brush, BrushProps, ChartBrush, ChartBrushProps, ChartBrushRange, ChartBrushVariant, useChartBrush } from './lib/brush.js';
|
|
23
|
+
export { ChartRevealDirection, ChartRevealType } from './lib/paint.js';
|
|
24
|
+
export { BoxPlot, BoxPlotBoxesProps, BoxPlotDatum, BoxPlotOrientation, BoxPlotProps, BoxPlotSample, BoxPlotSummary } from './BoxPlot/BoxPlot.js';
|
|
25
|
+
export { Histogram, HistogramBarsProps, HistogramBin, HistogramMode, HistogramProps } from './Histogram/Histogram.js';
|
|
26
|
+
export { WaterfallBarsProps, WaterfallChart, WaterfallChartProps, WaterfallDirection, WaterfallStep, WaterfallStepType } from './WaterfallChart/WaterfallChart.js';
|
|
27
|
+
export { BulletChart, BulletChartProps, BulletMeasure } from './BulletChart/BulletChart.js';
|
|
28
|
+
export { Facet, FacetOverflowInfo, FacetProps } from './Facet/Facet.js';
|
|
29
|
+
export { FacetGroup, FacetOptions, FacetOverflow, FacetPanel, FacetResult, FacetScales, FacetSort, FacetSortKey, FacetStats, buildPanels, groupRows, niceDomain, sortGroups, statsOf } from './Facet/panels.js';
|
|
30
|
+
export { SONIFY_DEFAULTS, SonifyController, SonifyOptions, SonifyPoint, SonifySeries, SonifyState, SonifyStep, SonifyWave, createSonification, describeSeries, hasAudioSupport, sonifyDomain, sonifyDuration, sonifyTimeline, valueToFrequency } from './lib/sonify.js';
|
|
31
|
+
export { ChartSonifyButton, ChartSonifyButtonProps, Sonify, SonifyAlign, SonifyProps, UseSonifyOptions, UseSonifyResult, chartSonifySeries, useChartSonifySeries, useSonify } from './lib/sonify-control.js';
|
|
32
|
+
export { ChartControls, ChartControlsProps, ChartExportFormat, ChartToolbar, ChartToolbarProps, Toolbar, ToolbarProps } from './lib/toolbar.js';
|
|
33
|
+
export { ChartZoom, ChartZoomOptions, ChartZoomSurface, ChartZoomSurfaceProps, clampWindow, panWindow, useChartZoom, zoomWindow } from './lib/zoom.js';
|
|
34
|
+
export { ChartPngOptions, chartToCsv, chartToPng, downloadBlob, exportFilename } from './lib/export.js';
|
|
35
|
+
export { ANNOTATION_LAYER, Annotation, AnnotationProps, AnnotationWeight, ReferenceBand, ReferenceBandProps, ReferenceLine, ReferenceLineProps } from './lib/annotations.js';
|
|
36
|
+
export { ValueLabelMode, Values, ValuesProps } from './lib/values.js';
|
|
37
|
+
export { ChartEmpty, ChartEmptyProps } from './lib/empty.js';
|
|
38
|
+
export { NumberFormatOptions, NumberStyle, defaultTick, formatNumber } from './lib/format.js';
|
|
39
|
+
import 'react';
|
|
40
|
+
import 'recharts';
|
|
41
|
+
import 'recharts/types/component/DefaultTooltipContent';
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { AreaChart } from "./AreaChart/AreaChart.js";
|
|
2
|
+
import { BarChart } from "./BarChart/BarChart.js";
|
|
3
|
+
import { LineChart } from "./LineChart/LineChart.js";
|
|
4
|
+
import { ComposedChart } from "./ComposedChart/ComposedChart.js";
|
|
5
|
+
import { ScatterChart } from "./ScatterChart/ScatterChart.js";
|
|
6
|
+
import { PieChart } from "./PieChart/PieChart.js";
|
|
7
|
+
import { RadarChart } from "./RadarChart/RadarChart.js";
|
|
8
|
+
import { RadialChart } from "./RadialChart/RadialChart.js";
|
|
9
|
+
import { FunnelChart } from "./FunnelChart/FunnelChart.js";
|
|
10
|
+
import { TreemapChart } from "./TreemapChart/TreemapChart.js";
|
|
11
|
+
import { Heatmap } from "./Heatmap/Heatmap.js";
|
|
12
|
+
import { Sparkline } from "./Sparkline/Sparkline.js";
|
|
13
|
+
import { BarList } from "./BarList/BarList.js";
|
|
14
|
+
import { BigNumber } from "./BigNumber/BigNumber.js";
|
|
15
|
+
import { SankeyChart } from "./SankeyChart/SankeyChart.js";
|
|
16
|
+
import { ChartContainer, SERIES_SLOTS, percentTick, useChart } from "./lib/chart.js";
|
|
17
|
+
import { ChartFigure, ChartDataTable } from "./lib/figure.js";
|
|
18
|
+
import { ChartBackground } from "./lib/background.js";
|
|
19
|
+
import { ChartDot } from "./lib/dot.js";
|
|
20
|
+
import { ChartLegend, ChartLegendContent } from "./lib/legend.js";
|
|
21
|
+
import { ChartTooltip, ChartTooltipContent } from "./lib/tooltip.js";
|
|
22
|
+
import { Brush, ChartBrush, useChartBrush } from "./lib/brush.js";
|
|
23
|
+
import { BoxPlot } from "./BoxPlot/BoxPlot.js";
|
|
24
|
+
import { Histogram } from "./Histogram/Histogram.js";
|
|
25
|
+
import { WaterfallChart } from "./WaterfallChart/WaterfallChart.js";
|
|
26
|
+
import { BulletChart } from "./BulletChart/BulletChart.js";
|
|
27
|
+
import { Facet } from "./Facet/Facet.js";
|
|
28
|
+
import { buildPanels, groupRows, niceDomain, sortGroups, statsOf } from "./Facet/panels.js";
|
|
29
|
+
import {
|
|
30
|
+
createSonification,
|
|
31
|
+
describeSeries,
|
|
32
|
+
hasAudioSupport,
|
|
33
|
+
sonifyDomain,
|
|
34
|
+
sonifyDuration,
|
|
35
|
+
sonifyTimeline,
|
|
36
|
+
valueToFrequency,
|
|
37
|
+
SONIFY_DEFAULTS
|
|
38
|
+
} from "./lib/sonify.js";
|
|
39
|
+
import {
|
|
40
|
+
ChartSonifyButton,
|
|
41
|
+
Sonify,
|
|
42
|
+
chartSonifySeries,
|
|
43
|
+
useChartSonifySeries,
|
|
44
|
+
useSonify
|
|
45
|
+
} from "./lib/sonify-control.js";
|
|
46
|
+
import { Toolbar, ChartToolbar, ChartControls } from "./lib/toolbar.js";
|
|
47
|
+
import { useChartZoom, ChartZoomSurface, clampWindow, panWindow, zoomWindow } from "./lib/zoom.js";
|
|
48
|
+
import { chartToCsv, chartToPng, downloadBlob, exportFilename } from "./lib/export.js";
|
|
49
|
+
import { Annotation, ReferenceBand, ReferenceLine, ANNOTATION_LAYER } from "./lib/annotations.js";
|
|
50
|
+
import { Values } from "./lib/values.js";
|
|
51
|
+
import { ChartEmpty } from "./lib/empty.js";
|
|
52
|
+
import { defaultTick, formatNumber } from "./lib/format.js";
|
|
53
|
+
export {
|
|
54
|
+
ANNOTATION_LAYER,
|
|
55
|
+
Annotation,
|
|
56
|
+
AreaChart,
|
|
57
|
+
BarChart,
|
|
58
|
+
BarList,
|
|
59
|
+
BigNumber,
|
|
60
|
+
BoxPlot,
|
|
61
|
+
Brush,
|
|
62
|
+
BulletChart,
|
|
63
|
+
ChartBackground,
|
|
64
|
+
ChartBrush,
|
|
65
|
+
ChartContainer,
|
|
66
|
+
ChartControls,
|
|
67
|
+
ChartDataTable,
|
|
68
|
+
ChartDot,
|
|
69
|
+
ChartEmpty,
|
|
70
|
+
ChartFigure,
|
|
71
|
+
ChartLegend,
|
|
72
|
+
ChartLegendContent,
|
|
73
|
+
ChartSonifyButton,
|
|
74
|
+
ChartToolbar,
|
|
75
|
+
ChartTooltip,
|
|
76
|
+
ChartTooltipContent,
|
|
77
|
+
ChartZoomSurface,
|
|
78
|
+
ComposedChart,
|
|
79
|
+
Facet,
|
|
80
|
+
FunnelChart,
|
|
81
|
+
Heatmap,
|
|
82
|
+
Histogram,
|
|
83
|
+
LineChart,
|
|
84
|
+
PieChart,
|
|
85
|
+
RadarChart,
|
|
86
|
+
RadialChart,
|
|
87
|
+
ReferenceBand,
|
|
88
|
+
ReferenceLine,
|
|
89
|
+
SERIES_SLOTS,
|
|
90
|
+
SONIFY_DEFAULTS,
|
|
91
|
+
SankeyChart,
|
|
92
|
+
ScatterChart,
|
|
93
|
+
Sonify,
|
|
94
|
+
Sparkline,
|
|
95
|
+
Toolbar,
|
|
96
|
+
TreemapChart,
|
|
97
|
+
Values,
|
|
98
|
+
WaterfallChart,
|
|
99
|
+
buildPanels,
|
|
100
|
+
chartSonifySeries,
|
|
101
|
+
chartToCsv,
|
|
102
|
+
chartToPng,
|
|
103
|
+
clampWindow,
|
|
104
|
+
createSonification,
|
|
105
|
+
defaultTick,
|
|
106
|
+
describeSeries,
|
|
107
|
+
downloadBlob,
|
|
108
|
+
exportFilename,
|
|
109
|
+
formatNumber,
|
|
110
|
+
groupRows,
|
|
111
|
+
hasAudioSupport,
|
|
112
|
+
niceDomain,
|
|
113
|
+
panWindow,
|
|
114
|
+
percentTick,
|
|
115
|
+
sonifyDomain,
|
|
116
|
+
sonifyDuration,
|
|
117
|
+
sonifyTimeline,
|
|
118
|
+
sortGroups,
|
|
119
|
+
statsOf,
|
|
120
|
+
useChart,
|
|
121
|
+
useChartBrush,
|
|
122
|
+
useChartSonifySeries,
|
|
123
|
+
useChartZoom,
|
|
124
|
+
useSonify,
|
|
125
|
+
valueToFrequency,
|
|
126
|
+
zoomWindow
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/charts/index.ts"],"sourcesContent":["/**\n * @misoto22/design/charts — the data-visualisation entry.\n *\n * Separate from the main entry on purpose. Charts need a rendering engine and\n * an animation runtime that nothing else in the package does, and both are\n * peer dependencies:\n *\n * pnpm add recharts motion\n * import { AreaChart } from '@misoto22/design/charts'\n *\n * Keeping them behind their own entry is what stops an app that renders a\n * Badge from paying for Recharts, and it is why the package's size budget\n * still describes the core (DESIGN-ARCH-001).\n *\n * The look ships with the rest of the system — `styles.css`, or the portable\n * `tokens.css` + `semantic.css` layers. A chart reads `--series-1…8` and the\n * `--chart-*` roles from there and defines no colour of its own.\n *\n * Everything below is a consumer contract. Adding an export is cheap; changing\n * or removing one is a breaking change (DESIGN-API-001).\n */\n\n// ─── Cartesian ───\nexport { AreaChart } from './AreaChart/AreaChart'\nexport type {\n AreaChartProps,\n AreaProps,\n AreaStackType,\n AreaStrokeVariant,\n AreaVariant,\n ChartCurveType,\n ChartLegendSlotProps,\n ChartTooltipSlotProps,\n} from './AreaChart/AreaChart'\n\nexport { BarChart } from './BarChart/BarChart'\nexport type {\n BarChartProps,\n BarOrientation,\n BarProps,\n BarStackType,\n BarVariant,\n} from './BarChart/BarChart'\n\nexport { LineChart } from './LineChart/LineChart'\nexport type { LineChartProps, LineProps, LineStrokeVariant } from './LineChart/LineChart'\n\nexport { ComposedChart } from './ComposedChart/ComposedChart'\nexport type {\n ComposedBarProps,\n ComposedChartProps,\n ComposedLineProps,\n} from './ComposedChart/ComposedChart'\n\nexport { ScatterChart } from './ScatterChart/ScatterChart'\nexport type {\n ScatterChartProps,\n ScatterProps,\n ScatterShape,\n ScatterTable,\n ScatterVariant,\n} from './ScatterChart/ScatterChart'\n\n// ─── Polar ───\nexport { PieChart } from './PieChart/PieChart'\nexport type { PieChartProps, PieLabelProps, PieProps, PieVariant } from './PieChart/PieChart'\n\nexport { RadarChart } from './RadarChart/RadarChart'\nexport type { RadarChartProps, RadarProps, RadarVariant } from './RadarChart/RadarChart'\n\nexport { RadialChart } from './RadialChart/RadialChart'\nexport type { RadialBarProps, RadialChartProps, RadialVariant } from './RadialChart/RadialChart'\n\nexport { FunnelChart } from './FunnelChart/FunnelChart'\nexport type {\n FunnelChartProps,\n FunnelLabelProps,\n FunnelProps,\n FunnelVariant,\n} from './FunnelChart/FunnelChart'\n\nexport { TreemapChart } from './TreemapChart/TreemapChart'\nexport type {\n TreemapChartProps,\n TreemapExtras,\n TreemapNode,\n TreemapVariant,\n} from './TreemapChart/TreemapChart'\n\n// ─── Grid and inline ───\n// Neither needs a rendering engine: a heatmap is a table with weighted cells,\n// and a sparkline is one path. Both are usable with `recharts` absent.\nexport { Heatmap } from './Heatmap/Heatmap'\nexport type { HeatmapCell, HeatmapProps, HeatmapScale } from './Heatmap/Heatmap'\n\nexport { Sparkline } from './Sparkline/Sparkline'\nexport type { SparklineProps, SparklineVariant } from './Sparkline/Sparkline'\n\nexport { BarList } from './BarList/BarList'\nexport type { BarListItem, BarListProps } from './BarList/BarList'\n\nexport { BigNumber } from './BigNumber/BigNumber'\nexport type { BigNumberDelta, BigNumberProps, DeltaIntent } from './BigNumber/BigNumber'\n\n// ─── Flow ───\nexport { SankeyChart } from './SankeyChart/SankeyChart'\nexport type {\n LinkProps as SankeyLinkSlotProps,\n NodeLabelProps as SankeyNodeLabelProps,\n NodeProps as SankeyNodeSlotProps,\n SankeyChartProps,\n SankeyLabelPosition,\n SankeyLinkVariant,\n} from './SankeyChart/SankeyChart'\n\n// ─── Shared pieces ───\nexport { ChartContainer, SERIES_SLOTS, percentTick, useChart } from './lib/chart'\nexport type { ChartConfig, ChartContainerProps, ChartSeries } from './lib/chart'\n\nexport { ChartFigure, ChartDataTable } from './lib/figure'\nexport type { ChartColumn, ChartDataTableProps, ChartFigureProps } from './lib/figure'\n\nexport { ChartBackground } from './lib/background'\nexport type { ChartBackgroundProps, ChartBackgroundVariant } from './lib/background'\n\nexport { ChartDot } from './lib/dot'\nexport type { ChartDotProps, ChartDotVariant } from './lib/dot'\n\nexport { ChartLegend, ChartLegendContent } from './lib/legend'\nexport type {\n ChartLegendAlign,\n ChartLegendContentProps,\n ChartLegendVariant,\n} from './lib/legend'\n\nexport { ChartTooltip, ChartTooltipContent } from './lib/tooltip'\nexport type {\n ChartTooltipContentProps,\n ChartTooltipIndicator,\n ChartTooltipRoundness,\n ChartTooltipVariant,\n} from './lib/tooltip'\n\nexport { Brush, ChartBrush, useChartBrush } from './lib/brush'\nexport type { BrushProps, ChartBrushProps, ChartBrushRange, ChartBrushVariant } from './lib/brush'\n\nexport type { ChartRevealDirection, ChartRevealType } from './lib/paint'\n\n// ─── Distribution and contribution ───\n// The statistical family. Each one hides something specific, and each says so\n// in its own description rather than in a footnote: a box plot hides\n// multimodality and sample size, a histogram's shape is a property of its bin\n// width, a bullet's bands are a judgement drawn in the same ink as the\n// measurement, and a waterfall's connectors imply a sequence that usually is\n// not one.\nexport { BoxPlot } from './BoxPlot/BoxPlot'\nexport type {\n BoxPlotBoxesProps,\n BoxPlotDatum,\n BoxPlotOrientation,\n BoxPlotProps,\n BoxPlotSample,\n BoxPlotSummary,\n} from './BoxPlot/BoxPlot'\n\nexport { Histogram } from './Histogram/Histogram'\nexport type {\n HistogramBarsProps,\n HistogramBin,\n HistogramMode,\n HistogramProps,\n} from './Histogram/Histogram'\n\nexport { WaterfallChart } from './WaterfallChart/WaterfallChart'\nexport type {\n WaterfallBarsProps,\n WaterfallChartProps,\n WaterfallDirection,\n WaterfallStep,\n WaterfallStepType,\n} from './WaterfallChart/WaterfallChart'\n\n// Engine-free, like Heatmap and BarList: plain HTML with logical properties,\n// server-renderable, and correct in a right-to-left document.\nexport { BulletChart } from './BulletChart/BulletChart'\nexport type { BulletChartProps, BulletMeasure } from './BulletChart/BulletChart'\n\n// ─── Small multiples ───\n// The same chart once per group, on one shared scale. The shared domain is the\n// default and the whole point: on independent scales a group peaking at 40 and\n// one peaking at 4,000 draw the same shape, and the comparison the reader came\n// for is not merely lost but inverted.\nexport { Facet } from './Facet/Facet'\nexport type { FacetProps, FacetOverflowInfo } from './Facet/Facet'\nexport { buildPanels, groupRows, niceDomain, sortGroups, statsOf } from './Facet/panels'\nexport type {\n FacetGroup,\n FacetOptions,\n FacetOverflow,\n FacetPanel,\n FacetResult,\n FacetScales,\n FacetSort,\n FacetSortKey,\n FacetStats,\n} from './Facet/panels'\n\n// ─── Sonification ───\n// The data as sound, for a reader who cannot see the plot. Never autoplays;\n// sound only ever starts from an explicit user action.\nexport {\n createSonification,\n describeSeries,\n hasAudioSupport,\n sonifyDomain,\n sonifyDuration,\n sonifyTimeline,\n valueToFrequency,\n SONIFY_DEFAULTS,\n} from './lib/sonify'\nexport type {\n SonifyController,\n SonifyOptions,\n SonifyPoint,\n SonifySeries,\n SonifyState,\n SonifyStep,\n SonifyWave,\n} from './lib/sonify'\n\nexport {\n ChartSonifyButton,\n Sonify,\n chartSonifySeries,\n useChartSonifySeries,\n useSonify,\n} from './lib/sonify-control'\nexport type {\n ChartSonifyButtonProps,\n SonifyAlign,\n SonifyProps,\n UseSonifyOptions,\n UseSonifyResult,\n} from './lib/sonify-control'\n\n// ─── Toolbar, zoom and export ───\n// Zoom and the brush are two views of ONE window: `useChartZoom` owns it and\n// hands the brush a controlled range, so dragging a handle moves the toolbar's\n// window and \"reset\" is unambiguous.\nexport { Toolbar, ChartToolbar, ChartControls } from './lib/toolbar'\nexport type {\n ChartExportFormat,\n ChartToolbarProps,\n ChartControlsProps,\n ToolbarProps,\n} from './lib/toolbar'\n\nexport { useChartZoom, ChartZoomSurface, clampWindow, panWindow, zoomWindow } from './lib/zoom'\nexport type { ChartZoom, ChartZoomOptions, ChartZoomSurfaceProps } from './lib/zoom'\n\nexport { chartToCsv, chartToPng, downloadBlob, exportFilename } from './lib/export'\nexport type { ChartPngOptions } from './lib/export'\n\n// ─── Annotation layer ───\n// A target line, a shaded period, a note on the plot. Drawn in the order\n// editorial charting settled on: bands behind the grid, lines above the data,\n// text above both.\nexport { Annotation, ReferenceBand, ReferenceLine, ANNOTATION_LAYER } from './lib/annotations'\nexport type {\n AnnotationProps,\n AnnotationWeight,\n ReferenceBandProps,\n ReferenceLineProps,\n} from './lib/annotations'\n\nexport { Values } from './lib/values'\nexport type { ValueLabelMode, ValuesProps } from './lib/values'\n\nexport { ChartEmpty } from './lib/empty'\nexport type { ChartEmptyProps } from './lib/empty'\n\nexport { defaultTick, formatNumber } from './lib/format'\nexport type { NumberFormatOptions, NumberStyle } from './lib/format'\n"],"mappings":"AAuBA,SAAS,iBAAiB;AAY1B,SAAS,gBAAgB;AASzB,SAAS,iBAAiB;AAG1B,SAAS,qBAAqB;AAO9B,SAAS,oBAAoB;AAU7B,SAAS,gBAAgB;AAGzB,SAAS,kBAAkB;AAG3B,SAAS,mBAAmB;AAG5B,SAAS,mBAAmB;AAQ5B,SAAS,oBAAoB;AAW7B,SAAS,eAAe;AAGxB,SAAS,iBAAiB;AAG1B,SAAS,eAAe;AAGxB,SAAS,iBAAiB;AAI1B,SAAS,mBAAmB;AAW5B,SAAS,gBAAgB,cAAc,aAAa,gBAAgB;AAGpE,SAAS,aAAa,sBAAsB;AAG5C,SAAS,uBAAuB;AAGhC,SAAS,gBAAgB;AAGzB,SAAS,aAAa,0BAA0B;AAOhD,SAAS,cAAc,2BAA2B;AAQlD,SAAS,OAAO,YAAY,qBAAqB;AAYjD,SAAS,eAAe;AAUxB,SAAS,iBAAiB;AAQ1B,SAAS,sBAAsB;AAW/B,SAAS,mBAAmB;AAQ5B,SAAS,aAAa;AAEtB,SAAS,aAAa,WAAW,YAAY,YAAY,eAAe;AAgBxE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAWP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAaP,SAAS,SAAS,cAAc,qBAAqB;AAQrD,SAAS,cAAc,kBAAkB,aAAa,WAAW,kBAAkB;AAGnF,SAAS,YAAY,YAAY,cAAc,sBAAsB;AAOrE,SAAS,YAAY,eAAe,eAAe,wBAAwB;AAQ3E,SAAS,cAAc;AAGvB,SAAS,kBAAkB;AAG3B,SAAS,aAAa,oBAAoB;","names":[]}
|