gridsmith-ui 0.3.5 → 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 +63 -3
- package/dist/charts.d.ts +246 -0
- package/dist/charts.js +1028 -0
- package/dist/charts.js.map +1 -0
- package/dist/chunk-4SDKQDYV.js +93 -0
- package/dist/chunk-4SDKQDYV.js.map +1 -0
- package/dist/chunk-CHNY75QI.js +278 -0
- package/dist/chunk-CHNY75QI.js.map +1 -0
- package/dist/chunk-DPF6776I.js +36 -0
- package/dist/chunk-DPF6776I.js.map +1 -0
- package/dist/{chunk-5XIPPVH7.js → chunk-IUBWNDUK.js} +15 -4
- package/dist/chunk-IUBWNDUK.js.map +1 -0
- package/dist/chunk-OUYJXVLQ.js +41 -0
- package/dist/chunk-OUYJXVLQ.js.map +1 -0
- package/dist/chunk-XUBVMRIE.js +149 -0
- package/dist/chunk-XUBVMRIE.js.map +1 -0
- package/dist/data-grid.d.ts +27 -0
- package/dist/data-grid.js +293 -0
- package/dist/data-grid.js.map +1 -0
- package/dist/editor.d.ts +18 -0
- package/dist/editor.js +632 -0
- package/dist/editor.js.map +1 -0
- package/dist/feather-V32UNIQL.js +71 -0
- package/dist/feather-V32UNIQL.js.map +1 -0
- package/dist/heroicons-CA5OQ76O.js +71 -0
- package/dist/heroicons-CA5OQ76O.js.map +1 -0
- package/dist/icons.d.ts +9 -1
- package/dist/icons.js +1 -2
- package/dist/index.d.ts +430 -133
- package/dist/index.js +10510 -98031
- package/dist/index.js.map +1 -1
- package/dist/kanban.d.ts +25 -0
- package/dist/kanban.js +224 -0
- package/dist/kanban.js.map +1 -0
- package/dist/lucide-AILUUOAJ.js +71 -0
- package/dist/lucide-AILUUOAJ.js.map +1 -0
- package/dist/phosphor-A4JOBGMT.js +71 -0
- package/dist/phosphor-A4JOBGMT.js.map +1 -0
- package/dist/resizable.d.ts +39 -0
- package/dist/resizable.js +89 -0
- package/dist/resizable.js.map +1 -0
- package/dist/roots.css +46 -11
- package/dist/tabler-TVOR6AFM.js +71 -0
- package/dist/tabler-TVOR6AFM.js.map +1 -0
- package/dist/use-breakpoint-Cn51IubK.d.ts +30 -0
- package/dist/utils.js +1 -2
- package/dist/virtualized.d.ts +16 -0
- package/dist/virtualized.js +55 -0
- package/dist/virtualized.js.map +1 -0
- package/package.json +144 -4
- package/dist/chunk-5WRI5ZAA.js +0 -29
- package/dist/chunk-5WRI5ZAA.js.map +0 -1
- package/dist/chunk-5XIPPVH7.js.map +0 -1
- package/dist/chunk-WVB3SRXW.js +0 -82
- package/dist/chunk-WVB3SRXW.js.map +0 -1
- package/dist/feather-N37QZ7LA.js +0 -72
- package/dist/feather-N37QZ7LA.js.map +0 -1
- package/dist/heroicons-HJTKMLIJ.js +0 -72
- package/dist/heroicons-HJTKMLIJ.js.map +0 -1
- package/dist/lucide-6TGT4G26.js +0 -67
- package/dist/lucide-6TGT4G26.js.map +0 -1
- package/dist/phosphor-BWDP4PU7.js +0 -72
- package/dist/phosphor-BWDP4PU7.js.map +0 -1
- package/dist/tabler-6TPNTLFV.js +0 -72
- package/dist/tabler-6TPNTLFV.js.map +0 -1
package/dist/charts.js
ADDED
|
@@ -0,0 +1,1028 @@
|
|
|
1
|
+
import { Skeleton } from './chunk-OUYJXVLQ.js';
|
|
2
|
+
import { cn, GLASS_SURFACE } from './chunk-IUBWNDUK.js';
|
|
3
|
+
import { createContext, forwardRef, useId, useContext, useSyncExternalStore, useState, useLayoutEffect } from 'react';
|
|
4
|
+
import { ResponsiveContainer, BarChart as BarChart$1, CartesianGrid, XAxis, YAxis, Tooltip, Legend, Bar, LineChart as LineChart$1, Line, AreaChart as AreaChart$1, Area, PieChart as PieChart$1, Pie, Cell, ComposedChart, ScatterChart as ScatterChart$1, ZAxis, Scatter, RadarChart as RadarChart$1, PolarGrid, PolarAngleAxis, PolarRadiusAxis, Radar, RadialBarChart as RadialBarChart$1, RadialBar, FunnelChart as FunnelChart$1, Funnel, LabelList, Treemap, Sankey, Text } from 'recharts';
|
|
5
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var CHART_TOKENS = [
|
|
8
|
+
"--ds-chart-1",
|
|
9
|
+
"--ds-chart-2",
|
|
10
|
+
"--ds-chart-3",
|
|
11
|
+
"--ds-chart-4",
|
|
12
|
+
"--ds-chart-5",
|
|
13
|
+
"--ds-chart-6"
|
|
14
|
+
];
|
|
15
|
+
var CHART_TOKENS_SOFT = [
|
|
16
|
+
"--ds-chart-1-soft",
|
|
17
|
+
"--ds-chart-2-soft",
|
|
18
|
+
"--ds-chart-3-soft",
|
|
19
|
+
"--ds-chart-4-soft",
|
|
20
|
+
"--ds-chart-5-soft",
|
|
21
|
+
"--ds-chart-6-soft"
|
|
22
|
+
];
|
|
23
|
+
var FALLBACK_COLORS = {
|
|
24
|
+
"--ds-chart-1": "#6366f1",
|
|
25
|
+
"--ds-chart-2": "#d97706",
|
|
26
|
+
"--ds-chart-3": "#059669",
|
|
27
|
+
"--ds-chart-4": "#dc2626",
|
|
28
|
+
"--ds-chart-5": "#0891b2",
|
|
29
|
+
"--ds-chart-6": "#7c3aed",
|
|
30
|
+
"--ds-chart-1-soft": "rgba(99, 102, 241, 0.3)",
|
|
31
|
+
"--ds-chart-2-soft": "rgba(217, 119, 6, 0.3)",
|
|
32
|
+
"--ds-chart-3-soft": "rgba(5, 150, 105, 0.3)",
|
|
33
|
+
"--ds-chart-4-soft": "rgba(220, 38, 38, 0.3)",
|
|
34
|
+
"--ds-chart-5-soft": "rgba(8, 145, 178, 0.3)",
|
|
35
|
+
"--ds-chart-6-soft": "rgba(124, 58, 237, 0.3)",
|
|
36
|
+
"--ds-bg-surface": "#ffffff",
|
|
37
|
+
"--ds-border-subtle": "#e5e7eb",
|
|
38
|
+
"--ds-text-primary": "#111827",
|
|
39
|
+
"--ds-text-secondary": "#6b7280",
|
|
40
|
+
"--ds-text-muted": "#9ca3af"
|
|
41
|
+
};
|
|
42
|
+
var modeVersion = 0;
|
|
43
|
+
var subscribers = /* @__PURE__ */ new Set();
|
|
44
|
+
var observerAttached = false;
|
|
45
|
+
function attachObserver() {
|
|
46
|
+
if (observerAttached || typeof document === "undefined") return;
|
|
47
|
+
observerAttached = true;
|
|
48
|
+
const observer = new MutationObserver((mutations) => {
|
|
49
|
+
for (const m of mutations) {
|
|
50
|
+
if (m.attributeName === "data-mode") {
|
|
51
|
+
modeVersion++;
|
|
52
|
+
for (const sub of subscribers) sub();
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
observer.observe(document.documentElement, {
|
|
58
|
+
attributes: true,
|
|
59
|
+
attributeFilter: ["data-mode"]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function subscribe(cb) {
|
|
63
|
+
attachObserver();
|
|
64
|
+
subscribers.add(cb);
|
|
65
|
+
return () => {
|
|
66
|
+
subscribers.delete(cb);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function getSnapshot() {
|
|
70
|
+
return modeVersion;
|
|
71
|
+
}
|
|
72
|
+
function getServerSnapshot() {
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
function resolveToken(token) {
|
|
76
|
+
if (typeof document === "undefined") return FALLBACK_COLORS[token] ?? "#6366f1";
|
|
77
|
+
const val = getComputedStyle(document.documentElement).getPropertyValue(token).trim();
|
|
78
|
+
return val || FALLBACK_COLORS[token] || "#6366f1";
|
|
79
|
+
}
|
|
80
|
+
function useChartColors(count, soft = false) {
|
|
81
|
+
const version = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
82
|
+
const [colors, setColors] = useState(() => fallbackColors(count, soft));
|
|
83
|
+
useLayoutEffect(() => {
|
|
84
|
+
setColors(resolveColors(count, soft));
|
|
85
|
+
}, [count, soft, version]);
|
|
86
|
+
return colors;
|
|
87
|
+
}
|
|
88
|
+
function fallbackColors(count, soft) {
|
|
89
|
+
const tokens = soft ? CHART_TOKENS_SOFT : CHART_TOKENS;
|
|
90
|
+
const result = [];
|
|
91
|
+
for (let i = 0; i < count; i++) {
|
|
92
|
+
const token = tokens[i % tokens.length];
|
|
93
|
+
result.push(FALLBACK_COLORS[token] ?? "#6366f1");
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
function resolveColors(count, soft) {
|
|
98
|
+
const tokens = soft ? CHART_TOKENS_SOFT : CHART_TOKENS;
|
|
99
|
+
const result = [];
|
|
100
|
+
for (let i = 0; i < count; i++) {
|
|
101
|
+
const token = tokens[i % tokens.length];
|
|
102
|
+
result.push(resolveToken(token));
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
function useResolvedToken(token) {
|
|
107
|
+
const version = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
108
|
+
const [value, setValue] = useState(() => FALLBACK_COLORS[token] ?? "#6366f1");
|
|
109
|
+
useLayoutEffect(() => {
|
|
110
|
+
setValue(resolveToken(token));
|
|
111
|
+
}, [token, version]);
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
function useReducedMotion() {
|
|
115
|
+
const [reduced, setReduced] = useState(() => {
|
|
116
|
+
if (typeof window === "undefined") return false;
|
|
117
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
118
|
+
});
|
|
119
|
+
useLayoutEffect(() => {
|
|
120
|
+
const mql = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
121
|
+
const handler = (e) => setReduced(e.matches);
|
|
122
|
+
mql.addEventListener("change", handler);
|
|
123
|
+
return () => mql.removeEventListener("change", handler);
|
|
124
|
+
}, []);
|
|
125
|
+
return reduced;
|
|
126
|
+
}
|
|
127
|
+
var useChartAnimation = (animated) => {
|
|
128
|
+
const reduced = useReducedMotion();
|
|
129
|
+
return animated !== false && !reduced;
|
|
130
|
+
};
|
|
131
|
+
function ChartTooltipContent({ active, payload, label }) {
|
|
132
|
+
const bgSurface = useResolvedToken("--ds-bg-surface");
|
|
133
|
+
const borderSubtle = useResolvedToken("--ds-border-subtle");
|
|
134
|
+
const textPrimary = useResolvedToken("--ds-text-primary");
|
|
135
|
+
const textSecondary = useResolvedToken("--ds-text-secondary");
|
|
136
|
+
if (!active || !payload?.length) return null;
|
|
137
|
+
const showLabel = label != null && label !== "" && typeof label !== "number";
|
|
138
|
+
return /* @__PURE__ */ jsxs(
|
|
139
|
+
"div",
|
|
140
|
+
{
|
|
141
|
+
className: "rounded-[var(--ds-radius-md)] shadow-[var(--ds-shadow-popover)] font-[family-name:var(--ds-font-sans)] text-sm",
|
|
142
|
+
style: {
|
|
143
|
+
backgroundColor: bgSurface,
|
|
144
|
+
border: `var(--ds-border-width) solid ${borderSubtle}`,
|
|
145
|
+
padding: "var(--ds-space-2) var(--ds-space-3)"
|
|
146
|
+
},
|
|
147
|
+
children: [
|
|
148
|
+
showLabel && /* @__PURE__ */ jsx("p", { className: "font-medium mb-ds-1", style: { color: textPrimary }, children: label }),
|
|
149
|
+
payload.map((entry, i) => {
|
|
150
|
+
const dotColor = entry.payload?.fill || entry.color || textSecondary;
|
|
151
|
+
const displayName = typeof entry.payload?.name === "string" && entry.payload.name || entry.name;
|
|
152
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-ds-2", style: { marginTop: i > 0 ? 2 : 0 }, children: [
|
|
153
|
+
/* @__PURE__ */ jsx(
|
|
154
|
+
"span",
|
|
155
|
+
{
|
|
156
|
+
className: "shrink-0 rounded-[var(--ds-radius-full)]",
|
|
157
|
+
style: { width: 8, height: 8, backgroundColor: dotColor }
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ jsxs("span", { style: { color: textSecondary }, children: [
|
|
161
|
+
displayName,
|
|
162
|
+
":"
|
|
163
|
+
] }),
|
|
164
|
+
/* @__PURE__ */ jsx("span", { className: "tabular-nums", style: { color: textPrimary }, children: typeof entry.value === "number" ? entry.value.toLocaleString() : entry.value })
|
|
165
|
+
] }, i);
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
function ChartLegendContent({ payload }) {
|
|
172
|
+
const textSecondary = useResolvedToken("--ds-text-secondary");
|
|
173
|
+
if (!payload?.length) return null;
|
|
174
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-wrap justify-center gap-y-ds-1 gap-x-ds-4 font-[family-name:var(--ds-font-sans)] text-sm", children: payload.map((entry, i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-ds-1.5", children: [
|
|
175
|
+
/* @__PURE__ */ jsx(
|
|
176
|
+
"span",
|
|
177
|
+
{
|
|
178
|
+
className: "shrink-0 rounded-[var(--ds-radius-full)]",
|
|
179
|
+
style: { width: 8, height: 8, backgroundColor: entry.color }
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
/* @__PURE__ */ jsx("span", { style: { color: textSecondary }, children: entry.value })
|
|
183
|
+
] }, i)) });
|
|
184
|
+
}
|
|
185
|
+
function useGridStroke() {
|
|
186
|
+
return useResolvedToken("--ds-border-subtle");
|
|
187
|
+
}
|
|
188
|
+
function useAxisStyle() {
|
|
189
|
+
const textMuted = useResolvedToken("--ds-text-muted");
|
|
190
|
+
return {
|
|
191
|
+
tick: {
|
|
192
|
+
fontSize: "var(--ds-font-size-xs)",
|
|
193
|
+
fontFamily: "var(--ds-font-sans)",
|
|
194
|
+
fill: textMuted
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function useRadius() {
|
|
199
|
+
const val = useResolvedToken("--ds-radius-md");
|
|
200
|
+
const parsed = parseInt(val, 10);
|
|
201
|
+
return isNaN(parsed) ? 6 : parsed;
|
|
202
|
+
}
|
|
203
|
+
function xAxisTick(props) {
|
|
204
|
+
const { x, y, payload, width, visibleTicksCount, ...rest } = props;
|
|
205
|
+
const tickWidth = width && visibleTicksCount ? Math.floor(width / visibleTicksCount) : 100;
|
|
206
|
+
return /* @__PURE__ */ jsx(Text, { ...rest, x, y, width: tickWidth, textAnchor: "middle", verticalAnchor: "start", maxLines: 2, children: payload.value });
|
|
207
|
+
}
|
|
208
|
+
function yAxisTick(props) {
|
|
209
|
+
const { x, y, payload, ...rest } = props;
|
|
210
|
+
return /* @__PURE__ */ jsx(Text, { ...rest, x, y, textAnchor: "end", verticalAnchor: "middle", width: 200, maxLines: 2, children: payload.value });
|
|
211
|
+
}
|
|
212
|
+
var ChartContainerContext = createContext(false);
|
|
213
|
+
function useInsideChartContainer() {
|
|
214
|
+
return useContext(ChartContainerContext);
|
|
215
|
+
}
|
|
216
|
+
var HEIGHT_MAP = {
|
|
217
|
+
sm: "var(--ds-chart-height-sm)",
|
|
218
|
+
md: "var(--ds-chart-height-md)",
|
|
219
|
+
lg: "var(--ds-chart-height-lg)"
|
|
220
|
+
};
|
|
221
|
+
var ChartWrapper = forwardRef(function ChartWrapper2({ height = "md", className, children, "aria-label": ariaLabel }, ref) {
|
|
222
|
+
const insideContainer = useInsideChartContainer();
|
|
223
|
+
if (insideContainer) {
|
|
224
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("h-full w-full", className), ...ariaLabel ? { role: "img", "aria-label": ariaLabel } : {}, children });
|
|
225
|
+
}
|
|
226
|
+
const heightValue = typeof height === "number" ? `${height}px` : HEIGHT_MAP[height];
|
|
227
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("w-full", className), style: { height: heightValue }, ...ariaLabel ? { role: "img", "aria-label": ariaLabel } : {}, children });
|
|
228
|
+
});
|
|
229
|
+
var BarChart = forwardRef(function BarChart2({
|
|
230
|
+
data,
|
|
231
|
+
bars,
|
|
232
|
+
xAxisKey,
|
|
233
|
+
height = "md",
|
|
234
|
+
stacked = false,
|
|
235
|
+
horizontal = false,
|
|
236
|
+
showGrid = true,
|
|
237
|
+
showTooltip = true,
|
|
238
|
+
showLegend,
|
|
239
|
+
xAxisLabel,
|
|
240
|
+
yAxisLabel,
|
|
241
|
+
animated,
|
|
242
|
+
"aria-label": ariaLabel,
|
|
243
|
+
className
|
|
244
|
+
}, ref) {
|
|
245
|
+
const solidColors = useChartColors(bars.length, false);
|
|
246
|
+
const softColors = useChartColors(bars.length, true);
|
|
247
|
+
const gridStroke = useGridStroke();
|
|
248
|
+
const axisStyle = useAxisStyle();
|
|
249
|
+
const isAnimated = useChartAnimation(animated);
|
|
250
|
+
const radius = useRadius();
|
|
251
|
+
const legendVisible = showLegend ?? bars.length >= 2;
|
|
252
|
+
const layout = horizontal ? "vertical" : "horizontal";
|
|
253
|
+
function getBarRadius(index) {
|
|
254
|
+
if (!stacked) {
|
|
255
|
+
return horizontal ? [0, radius, radius, 0] : [radius, radius, 0, 0];
|
|
256
|
+
}
|
|
257
|
+
const isTopmost = index === bars.length - 1;
|
|
258
|
+
if (!isTopmost) return [0, 0, 0, 0];
|
|
259
|
+
return horizontal ? [0, radius, radius, 0] : [radius, radius, 0, 0];
|
|
260
|
+
}
|
|
261
|
+
const axisLabelStyle = { fontSize: "var(--ds-font-size-xs)", fontFamily: "var(--ds-font-sans)", fill: axisStyle.tick.fill };
|
|
262
|
+
if (!data?.length) return null;
|
|
263
|
+
return /* @__PURE__ */ jsx(ChartWrapper, { ref, height, className, "aria-label": ariaLabel, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
264
|
+
BarChart$1,
|
|
265
|
+
{
|
|
266
|
+
data,
|
|
267
|
+
layout,
|
|
268
|
+
margin: { top: 4, right: 4, bottom: 4, left: 4 },
|
|
269
|
+
accessibilityLayer: true,
|
|
270
|
+
children: [
|
|
271
|
+
showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", stroke: gridStroke, vertical: !horizontal, horizontal: true }),
|
|
272
|
+
horizontal ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
273
|
+
/* @__PURE__ */ jsx(
|
|
274
|
+
XAxis,
|
|
275
|
+
{
|
|
276
|
+
type: "number",
|
|
277
|
+
...axisStyle.tick,
|
|
278
|
+
axisLine: false,
|
|
279
|
+
tickLine: false,
|
|
280
|
+
label: xAxisLabel ? { value: xAxisLabel, position: "insideBottom", offset: -2, style: axisLabelStyle } : void 0
|
|
281
|
+
}
|
|
282
|
+
),
|
|
283
|
+
/* @__PURE__ */ jsx(
|
|
284
|
+
YAxis,
|
|
285
|
+
{
|
|
286
|
+
dataKey: xAxisKey,
|
|
287
|
+
type: "category",
|
|
288
|
+
width: "auto",
|
|
289
|
+
...axisStyle.tick,
|
|
290
|
+
axisLine: false,
|
|
291
|
+
tickLine: false,
|
|
292
|
+
tick: yAxisTick
|
|
293
|
+
}
|
|
294
|
+
)
|
|
295
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
296
|
+
/* @__PURE__ */ jsx(
|
|
297
|
+
XAxis,
|
|
298
|
+
{
|
|
299
|
+
dataKey: xAxisKey,
|
|
300
|
+
...axisStyle.tick,
|
|
301
|
+
axisLine: false,
|
|
302
|
+
tickLine: false,
|
|
303
|
+
tick: xAxisTick,
|
|
304
|
+
height: "auto",
|
|
305
|
+
label: xAxisLabel ? { value: xAxisLabel, position: "insideBottom", offset: -2, style: axisLabelStyle } : void 0
|
|
306
|
+
}
|
|
307
|
+
),
|
|
308
|
+
/* @__PURE__ */ jsx(
|
|
309
|
+
YAxis,
|
|
310
|
+
{
|
|
311
|
+
width: "auto",
|
|
312
|
+
...axisStyle.tick,
|
|
313
|
+
axisLine: false,
|
|
314
|
+
tickLine: false,
|
|
315
|
+
label: yAxisLabel ? { value: yAxisLabel, angle: -90, position: "insideLeft", style: axisLabelStyle } : void 0
|
|
316
|
+
}
|
|
317
|
+
)
|
|
318
|
+
] }),
|
|
319
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}), cursor: { fill: "var(--ds-bg-muted)", opacity: 0.5 } }),
|
|
320
|
+
legendVisible && /* @__PURE__ */ jsx(Legend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}), wrapperStyle: { paddingTop: "var(--ds-space-3)" } }),
|
|
321
|
+
bars.map((bar, i) => /* @__PURE__ */ jsx(
|
|
322
|
+
Bar,
|
|
323
|
+
{
|
|
324
|
+
dataKey: bar.dataKey,
|
|
325
|
+
name: bar.label ?? bar.dataKey,
|
|
326
|
+
fill: bar.soft ? softColors[i] : solidColors[i],
|
|
327
|
+
radius: getBarRadius(i),
|
|
328
|
+
stackId: stacked ? "stack" : void 0,
|
|
329
|
+
isAnimationActive: isAnimated
|
|
330
|
+
},
|
|
331
|
+
bar.dataKey
|
|
332
|
+
))
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
) }) });
|
|
336
|
+
});
|
|
337
|
+
var LineChart = forwardRef(function LineChart2({
|
|
338
|
+
data,
|
|
339
|
+
lines,
|
|
340
|
+
xAxisKey,
|
|
341
|
+
height = "md",
|
|
342
|
+
curved = true,
|
|
343
|
+
showDots = false,
|
|
344
|
+
showGrid = true,
|
|
345
|
+
showTooltip = true,
|
|
346
|
+
showLegend,
|
|
347
|
+
xAxisLabel,
|
|
348
|
+
yAxisLabel,
|
|
349
|
+
animated,
|
|
350
|
+
"aria-label": ariaLabel,
|
|
351
|
+
className
|
|
352
|
+
}, ref) {
|
|
353
|
+
const colors = useChartColors(lines.length, false);
|
|
354
|
+
const gridStroke = useGridStroke();
|
|
355
|
+
const axisStyle = useAxisStyle();
|
|
356
|
+
const isAnimated = useChartAnimation(animated);
|
|
357
|
+
const legendVisible = showLegend ?? lines.length >= 2;
|
|
358
|
+
const axisLabelStyle = { fontSize: "var(--ds-font-size-xs)", fontFamily: "var(--ds-font-sans)", fill: axisStyle.tick.fill };
|
|
359
|
+
if (!data?.length) return null;
|
|
360
|
+
return /* @__PURE__ */ jsx(ChartWrapper, { ref, height, className, "aria-label": ariaLabel, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(LineChart$1, { data, margin: { top: 4, right: 4, bottom: 4, left: 4 }, accessibilityLayer: true, children: [
|
|
361
|
+
showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", stroke: gridStroke }),
|
|
362
|
+
/* @__PURE__ */ jsx(
|
|
363
|
+
XAxis,
|
|
364
|
+
{
|
|
365
|
+
dataKey: xAxisKey,
|
|
366
|
+
...axisStyle.tick,
|
|
367
|
+
axisLine: false,
|
|
368
|
+
tickLine: false,
|
|
369
|
+
tick: xAxisTick,
|
|
370
|
+
height: "auto",
|
|
371
|
+
label: xAxisLabel ? { value: xAxisLabel, position: "insideBottom", offset: -2, style: axisLabelStyle } : void 0
|
|
372
|
+
}
|
|
373
|
+
),
|
|
374
|
+
/* @__PURE__ */ jsx(
|
|
375
|
+
YAxis,
|
|
376
|
+
{
|
|
377
|
+
width: "auto",
|
|
378
|
+
...axisStyle.tick,
|
|
379
|
+
axisLine: false,
|
|
380
|
+
tickLine: false,
|
|
381
|
+
label: yAxisLabel ? { value: yAxisLabel, angle: -90, position: "insideLeft", style: axisLabelStyle } : void 0
|
|
382
|
+
}
|
|
383
|
+
),
|
|
384
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
|
|
385
|
+
legendVisible && /* @__PURE__ */ jsx(Legend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}), wrapperStyle: { paddingTop: "var(--ds-space-3)" } }),
|
|
386
|
+
lines.map((line, i) => /* @__PURE__ */ jsx(
|
|
387
|
+
Line,
|
|
388
|
+
{
|
|
389
|
+
type: curved ? "monotone" : "linear",
|
|
390
|
+
dataKey: line.dataKey,
|
|
391
|
+
name: line.label ?? line.dataKey,
|
|
392
|
+
stroke: colors[i],
|
|
393
|
+
strokeWidth: 2,
|
|
394
|
+
strokeDasharray: line.dashed ? "5 5" : void 0,
|
|
395
|
+
dot: showDots,
|
|
396
|
+
activeDot: { r: 5, strokeWidth: 2 },
|
|
397
|
+
isAnimationActive: isAnimated
|
|
398
|
+
},
|
|
399
|
+
line.dataKey
|
|
400
|
+
))
|
|
401
|
+
] }) }) });
|
|
402
|
+
});
|
|
403
|
+
var AreaChart = forwardRef(function AreaChart2({
|
|
404
|
+
data,
|
|
405
|
+
areas,
|
|
406
|
+
xAxisKey,
|
|
407
|
+
height = "md",
|
|
408
|
+
stacked = false,
|
|
409
|
+
curved = true,
|
|
410
|
+
showGrid = true,
|
|
411
|
+
showTooltip = true,
|
|
412
|
+
showLegend,
|
|
413
|
+
gradient = true,
|
|
414
|
+
xAxisLabel,
|
|
415
|
+
yAxisLabel,
|
|
416
|
+
animated,
|
|
417
|
+
"aria-label": ariaLabel,
|
|
418
|
+
className
|
|
419
|
+
}, ref) {
|
|
420
|
+
const instanceId = useId();
|
|
421
|
+
const solidColors = useChartColors(areas.length, false);
|
|
422
|
+
const softColors = useChartColors(areas.length, true);
|
|
423
|
+
const gridStroke = useGridStroke();
|
|
424
|
+
const axisStyle = useAxisStyle();
|
|
425
|
+
const isAnimated = useChartAnimation(animated);
|
|
426
|
+
const legendVisible = showLegend ?? areas.length >= 2;
|
|
427
|
+
const axisLabelStyle = { fontSize: "var(--ds-font-size-xs)", fontFamily: "var(--ds-font-sans)", fill: axisStyle.tick.fill };
|
|
428
|
+
if (!data?.length) return null;
|
|
429
|
+
return /* @__PURE__ */ jsx(ChartWrapper, { ref, height, className, "aria-label": ariaLabel, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(AreaChart$1, { data, margin: { top: 4, right: 4, bottom: 4, left: 4 }, accessibilityLayer: true, children: [
|
|
430
|
+
/* @__PURE__ */ jsx("defs", { children: areas.map((area, i) => /* @__PURE__ */ jsxs("linearGradient", { id: `gradient-${instanceId}-${area.dataKey}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
431
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: softColors[i], stopOpacity: 1 }),
|
|
432
|
+
/* @__PURE__ */ jsx("stop", { offset: "95%", stopColor: softColors[i], stopOpacity: 0.1 })
|
|
433
|
+
] }, area.dataKey)) }),
|
|
434
|
+
showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", stroke: gridStroke }),
|
|
435
|
+
/* @__PURE__ */ jsx(
|
|
436
|
+
XAxis,
|
|
437
|
+
{
|
|
438
|
+
dataKey: xAxisKey,
|
|
439
|
+
...axisStyle.tick,
|
|
440
|
+
axisLine: false,
|
|
441
|
+
tickLine: false,
|
|
442
|
+
tick: xAxisTick,
|
|
443
|
+
height: "auto",
|
|
444
|
+
label: xAxisLabel ? { value: xAxisLabel, position: "insideBottom", offset: -2, style: axisLabelStyle } : void 0
|
|
445
|
+
}
|
|
446
|
+
),
|
|
447
|
+
/* @__PURE__ */ jsx(
|
|
448
|
+
YAxis,
|
|
449
|
+
{
|
|
450
|
+
width: "auto",
|
|
451
|
+
...axisStyle.tick,
|
|
452
|
+
axisLine: false,
|
|
453
|
+
tickLine: false,
|
|
454
|
+
label: yAxisLabel ? { value: yAxisLabel, angle: -90, position: "insideLeft", style: axisLabelStyle } : void 0
|
|
455
|
+
}
|
|
456
|
+
),
|
|
457
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
|
|
458
|
+
legendVisible && /* @__PURE__ */ jsx(Legend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}), wrapperStyle: { paddingTop: "var(--ds-space-3)" } }),
|
|
459
|
+
areas.map((area, i) => /* @__PURE__ */ jsx(
|
|
460
|
+
Area,
|
|
461
|
+
{
|
|
462
|
+
type: curved ? "monotone" : "linear",
|
|
463
|
+
dataKey: area.dataKey,
|
|
464
|
+
name: area.label ?? area.dataKey,
|
|
465
|
+
stroke: solidColors[i],
|
|
466
|
+
strokeWidth: 2,
|
|
467
|
+
fill: gradient ? `url(#gradient-${instanceId}-${area.dataKey})` : softColors[i],
|
|
468
|
+
stackId: stacked ? "stack" : void 0,
|
|
469
|
+
isAnimationActive: isAnimated
|
|
470
|
+
},
|
|
471
|
+
area.dataKey
|
|
472
|
+
))
|
|
473
|
+
] }) }) });
|
|
474
|
+
});
|
|
475
|
+
var PieChart = forwardRef(function PieChart2({
|
|
476
|
+
data,
|
|
477
|
+
height = "md",
|
|
478
|
+
donut = false,
|
|
479
|
+
showTooltip = true,
|
|
480
|
+
showLegend = true,
|
|
481
|
+
showLabels = false,
|
|
482
|
+
animated,
|
|
483
|
+
"aria-label": ariaLabel,
|
|
484
|
+
className
|
|
485
|
+
}, ref) {
|
|
486
|
+
const colors = useChartColors(data.length, false);
|
|
487
|
+
const isAnimated = useChartAnimation(animated);
|
|
488
|
+
const renderLabel = showLabels ? ({ percent }) => `${((percent ?? 0) * 100).toFixed(0)}%` : false;
|
|
489
|
+
if (!data?.length) return null;
|
|
490
|
+
return /* @__PURE__ */ jsx(ChartWrapper, { ref, height, className, "aria-label": ariaLabel, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(PieChart$1, { accessibilityLayer: true, children: [
|
|
491
|
+
/* @__PURE__ */ jsx(
|
|
492
|
+
Pie,
|
|
493
|
+
{
|
|
494
|
+
data,
|
|
495
|
+
dataKey: "value",
|
|
496
|
+
nameKey: "name",
|
|
497
|
+
cx: "50%",
|
|
498
|
+
cy: "50%",
|
|
499
|
+
outerRadius: "75%",
|
|
500
|
+
innerRadius: donut ? "55%" : 0,
|
|
501
|
+
label: renderLabel,
|
|
502
|
+
labelLine: showLabels,
|
|
503
|
+
isAnimationActive: isAnimated,
|
|
504
|
+
fontSize: "var(--ds-font-size-xs)",
|
|
505
|
+
fontFamily: "var(--ds-font-sans)",
|
|
506
|
+
children: data.map((_, i) => /* @__PURE__ */ jsx(Cell, { fill: colors[i % colors.length] }, i))
|
|
507
|
+
}
|
|
508
|
+
),
|
|
509
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
|
|
510
|
+
showLegend && /* @__PURE__ */ jsx(Legend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}), wrapperStyle: { paddingTop: "var(--ds-space-3)" } })
|
|
511
|
+
] }) }) });
|
|
512
|
+
});
|
|
513
|
+
var CompositeChart = forwardRef(function CompositeChart2({
|
|
514
|
+
data,
|
|
515
|
+
bars,
|
|
516
|
+
lines,
|
|
517
|
+
xAxisKey,
|
|
518
|
+
height = "md",
|
|
519
|
+
dualAxis = true,
|
|
520
|
+
showGrid = true,
|
|
521
|
+
showTooltip = true,
|
|
522
|
+
showLegend = true,
|
|
523
|
+
xAxisLabel,
|
|
524
|
+
yAxisLabel,
|
|
525
|
+
animated,
|
|
526
|
+
"aria-label": ariaLabel,
|
|
527
|
+
className
|
|
528
|
+
}, ref) {
|
|
529
|
+
const barSoftColors = useChartColors(bars.length, true);
|
|
530
|
+
const lineColors = useChartColors(lines.length, false);
|
|
531
|
+
const gridStroke = useGridStroke();
|
|
532
|
+
const axisStyle = useAxisStyle();
|
|
533
|
+
const isAnimated = useChartAnimation(animated);
|
|
534
|
+
const radius = useRadius();
|
|
535
|
+
const axisLabelStyle = { fontSize: "var(--ds-font-size-xs)", fontFamily: "var(--ds-font-sans)", fill: axisStyle.tick.fill };
|
|
536
|
+
if (!data?.length) return null;
|
|
537
|
+
return /* @__PURE__ */ jsx(ChartWrapper, { ref, height, className, "aria-label": ariaLabel, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data, margin: { top: 4, right: 4, bottom: 4, left: 4 }, accessibilityLayer: true, children: [
|
|
538
|
+
showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", stroke: gridStroke }),
|
|
539
|
+
/* @__PURE__ */ jsx(
|
|
540
|
+
XAxis,
|
|
541
|
+
{
|
|
542
|
+
dataKey: xAxisKey,
|
|
543
|
+
...axisStyle.tick,
|
|
544
|
+
axisLine: false,
|
|
545
|
+
tickLine: false,
|
|
546
|
+
tick: xAxisTick,
|
|
547
|
+
height: "auto",
|
|
548
|
+
label: xAxisLabel ? { value: xAxisLabel, position: "insideBottom", offset: -2, style: axisLabelStyle } : void 0
|
|
549
|
+
}
|
|
550
|
+
),
|
|
551
|
+
/* @__PURE__ */ jsx(
|
|
552
|
+
YAxis,
|
|
553
|
+
{
|
|
554
|
+
yAxisId: "left",
|
|
555
|
+
width: "auto",
|
|
556
|
+
...axisStyle.tick,
|
|
557
|
+
axisLine: false,
|
|
558
|
+
tickLine: false,
|
|
559
|
+
label: yAxisLabel ? { value: yAxisLabel, angle: -90, position: "insideLeft", style: axisLabelStyle } : void 0
|
|
560
|
+
}
|
|
561
|
+
),
|
|
562
|
+
dualAxis && /* @__PURE__ */ jsx(YAxis, { yAxisId: "right", orientation: "right", width: "auto", ...axisStyle.tick, axisLine: false, tickLine: false }),
|
|
563
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
|
|
564
|
+
showLegend && /* @__PURE__ */ jsx(Legend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}), wrapperStyle: { paddingTop: "var(--ds-space-3)" } }),
|
|
565
|
+
bars.map((bar, i) => /* @__PURE__ */ jsx(
|
|
566
|
+
Bar,
|
|
567
|
+
{
|
|
568
|
+
dataKey: bar.dataKey,
|
|
569
|
+
name: bar.label ?? bar.dataKey,
|
|
570
|
+
fill: barSoftColors[i],
|
|
571
|
+
radius: [radius, radius, 0, 0],
|
|
572
|
+
yAxisId: "left",
|
|
573
|
+
isAnimationActive: isAnimated
|
|
574
|
+
},
|
|
575
|
+
bar.dataKey
|
|
576
|
+
)),
|
|
577
|
+
lines.map((line, i) => /* @__PURE__ */ jsx(
|
|
578
|
+
Line,
|
|
579
|
+
{
|
|
580
|
+
type: "monotone",
|
|
581
|
+
dataKey: line.dataKey,
|
|
582
|
+
name: line.label ?? line.dataKey,
|
|
583
|
+
stroke: lineColors[i],
|
|
584
|
+
strokeWidth: 2,
|
|
585
|
+
strokeDasharray: line.dashed ? "5 5" : void 0,
|
|
586
|
+
dot: false,
|
|
587
|
+
yAxisId: dualAxis ? "right" : "left",
|
|
588
|
+
isAnimationActive: isAnimated
|
|
589
|
+
},
|
|
590
|
+
line.dataKey
|
|
591
|
+
))
|
|
592
|
+
] }) }) });
|
|
593
|
+
});
|
|
594
|
+
var ScatterChart = forwardRef(function ScatterChart2({
|
|
595
|
+
data,
|
|
596
|
+
xLabel,
|
|
597
|
+
yLabel,
|
|
598
|
+
height = "md",
|
|
599
|
+
showGrid = true,
|
|
600
|
+
showTooltip = true,
|
|
601
|
+
showLegend,
|
|
602
|
+
animated,
|
|
603
|
+
"aria-label": ariaLabel,
|
|
604
|
+
className
|
|
605
|
+
}, ref) {
|
|
606
|
+
const colors = useChartColors(data.length, false);
|
|
607
|
+
const gridStroke = useGridStroke();
|
|
608
|
+
const axisStyle = useAxisStyle();
|
|
609
|
+
const isAnimated = useChartAnimation(animated);
|
|
610
|
+
const legendVisible = showLegend ?? data.length >= 2;
|
|
611
|
+
const axisLabelStyle = { fontSize: "var(--ds-font-size-xs)", fontFamily: "var(--ds-font-sans)", fill: axisStyle.tick.fill };
|
|
612
|
+
if (!data?.length) return null;
|
|
613
|
+
return /* @__PURE__ */ jsx(ChartWrapper, { ref, height, className, "aria-label": ariaLabel, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
614
|
+
ScatterChart$1,
|
|
615
|
+
{
|
|
616
|
+
margin: { top: 8, right: 8, bottom: xLabel ? 20 : 4, left: yLabel ? 20 : 4 },
|
|
617
|
+
accessibilityLayer: true,
|
|
618
|
+
children: [
|
|
619
|
+
showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", stroke: gridStroke }),
|
|
620
|
+
/* @__PURE__ */ jsx(
|
|
621
|
+
XAxis,
|
|
622
|
+
{
|
|
623
|
+
type: "number",
|
|
624
|
+
dataKey: "x",
|
|
625
|
+
name: xLabel ?? "x",
|
|
626
|
+
...axisStyle.tick,
|
|
627
|
+
axisLine: false,
|
|
628
|
+
tickLine: false,
|
|
629
|
+
label: xLabel ? { value: xLabel, position: "bottom", offset: 0, style: { ...axisLabelStyle, textAnchor: "middle" } } : void 0
|
|
630
|
+
}
|
|
631
|
+
),
|
|
632
|
+
/* @__PURE__ */ jsx(
|
|
633
|
+
YAxis,
|
|
634
|
+
{
|
|
635
|
+
type: "number",
|
|
636
|
+
dataKey: "y",
|
|
637
|
+
name: yLabel ?? "y",
|
|
638
|
+
width: "auto",
|
|
639
|
+
...axisStyle.tick,
|
|
640
|
+
axisLine: false,
|
|
641
|
+
tickLine: false,
|
|
642
|
+
label: yLabel ? { value: yLabel, angle: -90, position: "left", offset: 0, style: { ...axisLabelStyle, textAnchor: "middle" } } : void 0
|
|
643
|
+
}
|
|
644
|
+
),
|
|
645
|
+
/* @__PURE__ */ jsx(ZAxis, { type: "number", dataKey: "z", range: [40, 400] }),
|
|
646
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
|
|
647
|
+
legendVisible && /* @__PURE__ */ jsx(Legend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}), wrapperStyle: { paddingTop: "var(--ds-space-3)" } }),
|
|
648
|
+
data.map((series, i) => /* @__PURE__ */ jsx(
|
|
649
|
+
Scatter,
|
|
650
|
+
{
|
|
651
|
+
name: series.name,
|
|
652
|
+
data: series.points,
|
|
653
|
+
fill: colors[i],
|
|
654
|
+
isAnimationActive: isAnimated
|
|
655
|
+
},
|
|
656
|
+
series.name
|
|
657
|
+
))
|
|
658
|
+
]
|
|
659
|
+
}
|
|
660
|
+
) }) });
|
|
661
|
+
});
|
|
662
|
+
var RadarChart = forwardRef(function RadarChart2({
|
|
663
|
+
data,
|
|
664
|
+
dataKeys,
|
|
665
|
+
axisKey,
|
|
666
|
+
height = "md",
|
|
667
|
+
filled = true,
|
|
668
|
+
showDots = true,
|
|
669
|
+
showTooltip = true,
|
|
670
|
+
showLegend,
|
|
671
|
+
animated,
|
|
672
|
+
"aria-label": ariaLabel,
|
|
673
|
+
className
|
|
674
|
+
}, ref) {
|
|
675
|
+
const solidColors = useChartColors(dataKeys.length, false);
|
|
676
|
+
const softColors = useChartColors(dataKeys.length, true);
|
|
677
|
+
const isAnimated = useChartAnimation(animated);
|
|
678
|
+
const legendVisible = showLegend ?? dataKeys.length >= 2;
|
|
679
|
+
if (!data?.length) return null;
|
|
680
|
+
return /* @__PURE__ */ jsx(ChartWrapper, { ref, height, className, "aria-label": ariaLabel, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(RadarChart$1, { data, cx: "50%", cy: "50%", outerRadius: "75%", accessibilityLayer: true, children: [
|
|
681
|
+
/* @__PURE__ */ jsx(PolarGrid, { stroke: "var(--ds-border-subtle)" }),
|
|
682
|
+
/* @__PURE__ */ jsx(
|
|
683
|
+
PolarAngleAxis,
|
|
684
|
+
{
|
|
685
|
+
dataKey: axisKey,
|
|
686
|
+
tick: { fontSize: "var(--ds-font-size-xs)", fontFamily: "var(--ds-font-sans)", fill: "var(--ds-text-muted)" }
|
|
687
|
+
}
|
|
688
|
+
),
|
|
689
|
+
/* @__PURE__ */ jsx(
|
|
690
|
+
PolarRadiusAxis,
|
|
691
|
+
{
|
|
692
|
+
tick: { fontSize: "var(--ds-font-size-xs)", fontFamily: "var(--ds-font-sans)", fill: "var(--ds-text-muted)" },
|
|
693
|
+
axisLine: false
|
|
694
|
+
}
|
|
695
|
+
),
|
|
696
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
|
|
697
|
+
legendVisible && /* @__PURE__ */ jsx(Legend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}), wrapperStyle: { paddingTop: "var(--ds-space-3)" } }),
|
|
698
|
+
dataKeys.map((dk, i) => /* @__PURE__ */ jsx(
|
|
699
|
+
Radar,
|
|
700
|
+
{
|
|
701
|
+
name: dk.label ?? dk.key,
|
|
702
|
+
dataKey: dk.key,
|
|
703
|
+
stroke: solidColors[i],
|
|
704
|
+
fill: filled ? softColors[i] : "transparent",
|
|
705
|
+
strokeWidth: 2,
|
|
706
|
+
dot: showDots ? { r: 3, fill: solidColors[i] } : false,
|
|
707
|
+
isAnimationActive: isAnimated
|
|
708
|
+
},
|
|
709
|
+
dk.key
|
|
710
|
+
))
|
|
711
|
+
] }) }) });
|
|
712
|
+
});
|
|
713
|
+
var RadialBarChart = forwardRef(function RadialBarChart2({
|
|
714
|
+
data,
|
|
715
|
+
height = "md",
|
|
716
|
+
showTooltip = true,
|
|
717
|
+
showLegend = true,
|
|
718
|
+
showLabels = false,
|
|
719
|
+
startAngle = 90,
|
|
720
|
+
endAngle = -270,
|
|
721
|
+
animated,
|
|
722
|
+
"aria-label": ariaLabel,
|
|
723
|
+
className
|
|
724
|
+
}, ref) {
|
|
725
|
+
const colors = useChartColors(data.length, false);
|
|
726
|
+
const isAnimated = useChartAnimation(animated);
|
|
727
|
+
const chartData = data.map((d, i) => ({
|
|
728
|
+
...d,
|
|
729
|
+
fill: colors[i % colors.length]
|
|
730
|
+
}));
|
|
731
|
+
if (!data?.length) return null;
|
|
732
|
+
return /* @__PURE__ */ jsx(ChartWrapper, { ref, height, className, "aria-label": ariaLabel, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
733
|
+
RadialBarChart$1,
|
|
734
|
+
{
|
|
735
|
+
data: chartData,
|
|
736
|
+
cx: "50%",
|
|
737
|
+
cy: "50%",
|
|
738
|
+
innerRadius: "20%",
|
|
739
|
+
outerRadius: "90%",
|
|
740
|
+
startAngle,
|
|
741
|
+
endAngle,
|
|
742
|
+
accessibilityLayer: true,
|
|
743
|
+
children: [
|
|
744
|
+
/* @__PURE__ */ jsx(
|
|
745
|
+
RadialBar,
|
|
746
|
+
{
|
|
747
|
+
dataKey: "value",
|
|
748
|
+
background: { fill: "var(--ds-bg-muted)" },
|
|
749
|
+
label: showLabels ? { position: "insideStart", fill: "var(--ds-text-primary)", fontSize: "var(--ds-font-size-xs)" } : false,
|
|
750
|
+
isAnimationActive: isAnimated
|
|
751
|
+
}
|
|
752
|
+
),
|
|
753
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
|
|
754
|
+
showLegend && /* @__PURE__ */ jsx(Legend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}), wrapperStyle: { paddingTop: "var(--ds-space-3)" } })
|
|
755
|
+
]
|
|
756
|
+
}
|
|
757
|
+
) }) });
|
|
758
|
+
});
|
|
759
|
+
var FunnelChart = forwardRef(function FunnelChart2({
|
|
760
|
+
data,
|
|
761
|
+
height = "md",
|
|
762
|
+
showTooltip = true,
|
|
763
|
+
showLegend = true,
|
|
764
|
+
showLabels = true,
|
|
765
|
+
animated,
|
|
766
|
+
"aria-label": ariaLabel,
|
|
767
|
+
className
|
|
768
|
+
}, ref) {
|
|
769
|
+
const colors = useChartColors(data.length, false);
|
|
770
|
+
const isAnimated = useChartAnimation(animated);
|
|
771
|
+
const chartData = data.map((d, i) => ({
|
|
772
|
+
...d,
|
|
773
|
+
fill: colors[i % colors.length]
|
|
774
|
+
}));
|
|
775
|
+
if (!data?.length) return null;
|
|
776
|
+
return /* @__PURE__ */ jsx(ChartWrapper, { ref, height, className, "aria-label": ariaLabel, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(FunnelChart$1, { accessibilityLayer: true, children: [
|
|
777
|
+
/* @__PURE__ */ jsx(Funnel, { dataKey: "value", data: chartData, isAnimationActive: isAnimated, children: showLabels && /* @__PURE__ */ jsx(
|
|
778
|
+
LabelList,
|
|
779
|
+
{
|
|
780
|
+
dataKey: "name",
|
|
781
|
+
position: "right",
|
|
782
|
+
fill: "var(--ds-text-primary)",
|
|
783
|
+
fontSize: "var(--ds-font-size-sm)",
|
|
784
|
+
fontFamily: "var(--ds-font-sans)"
|
|
785
|
+
}
|
|
786
|
+
) }),
|
|
787
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
|
|
788
|
+
showLegend && /* @__PURE__ */ jsx(Legend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}), wrapperStyle: { paddingTop: "var(--ds-space-3)" } })
|
|
789
|
+
] }) }) });
|
|
790
|
+
});
|
|
791
|
+
function contrastColor(hex) {
|
|
792
|
+
const c = hex.replace("#", "");
|
|
793
|
+
if (c.length < 6) return "#ffffff";
|
|
794
|
+
const r = parseInt(c.substring(0, 2), 16);
|
|
795
|
+
const g = parseInt(c.substring(2, 4), 16);
|
|
796
|
+
const b = parseInt(c.substring(4, 6), 16);
|
|
797
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
798
|
+
return luminance > 0.55 ? "#1f2937" : "#ffffff";
|
|
799
|
+
}
|
|
800
|
+
function TreemapContent({ x = 0, y = 0, width = 0, height: h = 0, name, depth, colors, radius, index = 0 }) {
|
|
801
|
+
const fill = colors[index % colors.length];
|
|
802
|
+
const showLabel = width > 40 && h > 20;
|
|
803
|
+
const labelColor = contrastColor(fill);
|
|
804
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
805
|
+
/* @__PURE__ */ jsx(
|
|
806
|
+
"rect",
|
|
807
|
+
{
|
|
808
|
+
x,
|
|
809
|
+
y,
|
|
810
|
+
width,
|
|
811
|
+
height: h,
|
|
812
|
+
fill,
|
|
813
|
+
stroke: "var(--ds-bg-surface)",
|
|
814
|
+
strokeWidth: 2,
|
|
815
|
+
rx: depth === 1 ? radius : 0,
|
|
816
|
+
style: { opacity: depth === 1 ? 1 : 0.85 }
|
|
817
|
+
}
|
|
818
|
+
),
|
|
819
|
+
showLabel && /* @__PURE__ */ jsx(
|
|
820
|
+
"text",
|
|
821
|
+
{
|
|
822
|
+
x: x + width / 2,
|
|
823
|
+
y: y + h / 2,
|
|
824
|
+
textAnchor: "middle",
|
|
825
|
+
dominantBaseline: "central",
|
|
826
|
+
fill: labelColor,
|
|
827
|
+
stroke: "none",
|
|
828
|
+
fontSize: "var(--ds-font-size-xs)",
|
|
829
|
+
fontFamily: "var(--ds-font-sans)",
|
|
830
|
+
style: { pointerEvents: "none" },
|
|
831
|
+
children: name
|
|
832
|
+
}
|
|
833
|
+
)
|
|
834
|
+
] });
|
|
835
|
+
}
|
|
836
|
+
function addFillToNodes(nodes, colors, counter = { i: 0 }) {
|
|
837
|
+
return nodes.map((node) => {
|
|
838
|
+
if (node.children) {
|
|
839
|
+
return { ...node, children: addFillToNodes(node.children, colors, counter) };
|
|
840
|
+
}
|
|
841
|
+
const fill = colors[counter.i % colors.length];
|
|
842
|
+
counter.i++;
|
|
843
|
+
return { ...node, fill };
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
var TreemapChart = forwardRef(function TreemapChart2({
|
|
847
|
+
data,
|
|
848
|
+
height = "md",
|
|
849
|
+
showTooltip = true,
|
|
850
|
+
animated,
|
|
851
|
+
"aria-label": ariaLabel,
|
|
852
|
+
className
|
|
853
|
+
}, ref) {
|
|
854
|
+
const colors = useChartColors(6, false);
|
|
855
|
+
const isAnimated = useChartAnimation(animated);
|
|
856
|
+
const radius = useRadius();
|
|
857
|
+
const chartData = addFillToNodes(data, colors);
|
|
858
|
+
if (!data?.length) return null;
|
|
859
|
+
return /* @__PURE__ */ jsx(ChartWrapper, { ref, height, className, "aria-label": ariaLabel, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsx(
|
|
860
|
+
Treemap,
|
|
861
|
+
{
|
|
862
|
+
data: chartData,
|
|
863
|
+
dataKey: "value",
|
|
864
|
+
nameKey: "name",
|
|
865
|
+
aspectRatio: 4 / 3,
|
|
866
|
+
stroke: "var(--ds-bg-surface)",
|
|
867
|
+
isAnimationActive: isAnimated,
|
|
868
|
+
content: /* @__PURE__ */ jsx(TreemapContent, { colors, radius }),
|
|
869
|
+
children: showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) })
|
|
870
|
+
}
|
|
871
|
+
) }) });
|
|
872
|
+
});
|
|
873
|
+
var SankeyChart = forwardRef(function SankeyChart2({
|
|
874
|
+
data,
|
|
875
|
+
height = "md",
|
|
876
|
+
showTooltip = true,
|
|
877
|
+
"aria-label": ariaLabel,
|
|
878
|
+
className
|
|
879
|
+
}, ref) {
|
|
880
|
+
const colors = useChartColors(data.nodes.length, false);
|
|
881
|
+
const linkStroke = useResolvedToken("--ds-border-subtle");
|
|
882
|
+
const nodesWithColor = data.nodes.map((node, i) => ({
|
|
883
|
+
...node,
|
|
884
|
+
fill: colors[i % colors.length]
|
|
885
|
+
}));
|
|
886
|
+
const sankeyData = {
|
|
887
|
+
nodes: nodesWithColor,
|
|
888
|
+
links: data.links
|
|
889
|
+
};
|
|
890
|
+
if (!data?.nodes?.length) return null;
|
|
891
|
+
return /* @__PURE__ */ jsx(ChartWrapper, { ref, height, className, "aria-label": ariaLabel, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsx(
|
|
892
|
+
Sankey,
|
|
893
|
+
{
|
|
894
|
+
data: sankeyData,
|
|
895
|
+
nodeWidth: 10,
|
|
896
|
+
nodePadding: 24,
|
|
897
|
+
margin: { top: 8, right: 8, bottom: 8, left: 8 },
|
|
898
|
+
link: { stroke: linkStroke, strokeOpacity: 0.4 },
|
|
899
|
+
children: showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) })
|
|
900
|
+
}
|
|
901
|
+
) }) });
|
|
902
|
+
});
|
|
903
|
+
var Sparkline = forwardRef(function Sparkline2({
|
|
904
|
+
data,
|
|
905
|
+
variant = "line",
|
|
906
|
+
color = 1,
|
|
907
|
+
height = 40,
|
|
908
|
+
width = "100%",
|
|
909
|
+
showTooltip = false,
|
|
910
|
+
curved = true,
|
|
911
|
+
animated,
|
|
912
|
+
"aria-label": ariaLabel,
|
|
913
|
+
className
|
|
914
|
+
}, ref) {
|
|
915
|
+
const instanceId = useId();
|
|
916
|
+
const isAnimated = useChartAnimation(animated);
|
|
917
|
+
const insideContainer = useInsideChartContainer();
|
|
918
|
+
const tokenName = `--ds-chart-${color}`;
|
|
919
|
+
const softTokenName = `--ds-chart-${color}-soft`;
|
|
920
|
+
const chartColor = useResolvedToken(tokenName);
|
|
921
|
+
const softColor = useResolvedToken(softTokenName);
|
|
922
|
+
const chartData = data.map((value, i) => ({ value, index: i }));
|
|
923
|
+
const containerStyle = insideContainer ? { width: "100%", height: "100%" } : { width: typeof width === "number" ? `${width}px` : width, height: `${height}px` };
|
|
924
|
+
if (!data?.length) return null;
|
|
925
|
+
if (variant === "bar") {
|
|
926
|
+
return /* @__PURE__ */ jsx("div", { ref, style: containerStyle, className, ...ariaLabel ? { role: "img", "aria-label": ariaLabel } : {}, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(BarChart$1, { data: chartData, margin: { top: 0, right: 0, bottom: 0, left: 0 }, children: [
|
|
927
|
+
/* @__PURE__ */ jsx(XAxis, { dataKey: "index", hide: true }),
|
|
928
|
+
/* @__PURE__ */ jsx(YAxis, { hide: true }),
|
|
929
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}), cursor: false }),
|
|
930
|
+
/* @__PURE__ */ jsx(
|
|
931
|
+
Bar,
|
|
932
|
+
{
|
|
933
|
+
dataKey: "value",
|
|
934
|
+
fill: chartColor,
|
|
935
|
+
radius: [2, 2, 0, 0],
|
|
936
|
+
isAnimationActive: isAnimated
|
|
937
|
+
}
|
|
938
|
+
)
|
|
939
|
+
] }) }) });
|
|
940
|
+
}
|
|
941
|
+
if (variant === "area") {
|
|
942
|
+
const gradientId = `sparkline-gradient-${instanceId}-${color}`;
|
|
943
|
+
return /* @__PURE__ */ jsx("div", { ref, style: containerStyle, className, ...ariaLabel ? { role: "img", "aria-label": ariaLabel } : {}, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(AreaChart$1, { data: chartData, margin: { top: 2, right: 2, bottom: 2, left: 2 }, children: [
|
|
944
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
945
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: softColor, stopOpacity: 1 }),
|
|
946
|
+
/* @__PURE__ */ jsx("stop", { offset: "95%", stopColor: softColor, stopOpacity: 0.1 })
|
|
947
|
+
] }) }),
|
|
948
|
+
/* @__PURE__ */ jsx(XAxis, { dataKey: "index", hide: true }),
|
|
949
|
+
/* @__PURE__ */ jsx(YAxis, { hide: true, domain: ["dataMin - 1", "dataMax + 1"] }),
|
|
950
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}), cursor: false }),
|
|
951
|
+
/* @__PURE__ */ jsx(
|
|
952
|
+
Area,
|
|
953
|
+
{
|
|
954
|
+
type: curved ? "monotone" : "linear",
|
|
955
|
+
dataKey: "value",
|
|
956
|
+
stroke: chartColor,
|
|
957
|
+
strokeWidth: 1.5,
|
|
958
|
+
fill: `url(#${gradientId})`,
|
|
959
|
+
dot: false,
|
|
960
|
+
activeDot: showTooltip ? { r: 3, fill: chartColor } : false,
|
|
961
|
+
isAnimationActive: isAnimated
|
|
962
|
+
}
|
|
963
|
+
)
|
|
964
|
+
] }) }) });
|
|
965
|
+
}
|
|
966
|
+
return /* @__PURE__ */ jsx("div", { ref, style: containerStyle, className, ...ariaLabel ? { role: "img", "aria-label": ariaLabel } : {}, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(LineChart$1, { data: chartData, margin: { top: 2, right: 2, bottom: 2, left: 2 }, children: [
|
|
967
|
+
/* @__PURE__ */ jsx(XAxis, { dataKey: "index", hide: true }),
|
|
968
|
+
/* @__PURE__ */ jsx(YAxis, { hide: true, domain: ["dataMin - 1", "dataMax + 1"] }),
|
|
969
|
+
showTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}), cursor: false }),
|
|
970
|
+
/* @__PURE__ */ jsx(
|
|
971
|
+
Line,
|
|
972
|
+
{
|
|
973
|
+
type: curved ? "monotone" : "linear",
|
|
974
|
+
dataKey: "value",
|
|
975
|
+
stroke: chartColor,
|
|
976
|
+
strokeWidth: 1.5,
|
|
977
|
+
dot: false,
|
|
978
|
+
activeDot: showTooltip ? { r: 3, fill: chartColor } : false,
|
|
979
|
+
isAnimationActive: isAnimated
|
|
980
|
+
}
|
|
981
|
+
)
|
|
982
|
+
] }) }) });
|
|
983
|
+
});
|
|
984
|
+
var HEIGHT_MAP2 = {
|
|
985
|
+
sm: "var(--ds-chart-height-sm)",
|
|
986
|
+
md: "var(--ds-chart-height-md)",
|
|
987
|
+
lg: "var(--ds-chart-height-lg)"
|
|
988
|
+
};
|
|
989
|
+
function ChartContainer({
|
|
990
|
+
height = "md",
|
|
991
|
+
title,
|
|
992
|
+
loading = false,
|
|
993
|
+
emptyState,
|
|
994
|
+
children,
|
|
995
|
+
className
|
|
996
|
+
}) {
|
|
997
|
+
return /* @__PURE__ */ jsxs(
|
|
998
|
+
"div",
|
|
999
|
+
{
|
|
1000
|
+
className: cn(
|
|
1001
|
+
"rounded-[var(--ds-radius-md)]",
|
|
1002
|
+
"border-[length:var(--ds-border-width)] border-[var(--ds-border-subtle)]",
|
|
1003
|
+
GLASS_SURFACE,
|
|
1004
|
+
"p-ds-4",
|
|
1005
|
+
className
|
|
1006
|
+
),
|
|
1007
|
+
children: [
|
|
1008
|
+
title && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-[var(--ds-text-primary)] mb-ds-4", children: title }),
|
|
1009
|
+
/* @__PURE__ */ jsx("div", { style: { height: HEIGHT_MAP2[height] }, className: "relative", children: loading ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-end h-full gap-ds-2 px-ds-2", children: [
|
|
1010
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-end h-full gap-ds-1", children: [65, 40, 80, 55, 72, 45, 60].map((h, i) => /* @__PURE__ */ jsx(
|
|
1011
|
+
Skeleton,
|
|
1012
|
+
{
|
|
1013
|
+
variant: "custom",
|
|
1014
|
+
className: "flex-1",
|
|
1015
|
+
height: `${h}%`
|
|
1016
|
+
},
|
|
1017
|
+
i
|
|
1018
|
+
)) }),
|
|
1019
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "text", lines: 1, className: "w-full" })
|
|
1020
|
+
] }) : children ? /* @__PURE__ */ jsx(ChartContainerContext.Provider, { value: true, children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children }) }) : emptyState ? /* @__PURE__ */ jsx("div", { className: "h-full w-full flex items-center justify-center", children: emptyState }) : null })
|
|
1021
|
+
]
|
|
1022
|
+
}
|
|
1023
|
+
);
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
export { AreaChart, BarChart, ChartContainer, CompositeChart, FunnelChart, LineChart, PieChart, RadarChart, RadialBarChart, SankeyChart, ScatterChart, Sparkline, TreemapChart, useChartColors };
|
|
1027
|
+
//# sourceMappingURL=charts.js.map
|
|
1028
|
+
//# sourceMappingURL=charts.js.map
|