@siyahi/ui 0.1.9-next.23 → 0.1.9-next.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/examples/change-grid-money.tsx +36 -0
- package/agents/examples/change-grid.tsx +42 -0
- package/agents/examples/delta.tsx +11 -6
- package/agents/examples/drawdown-chart.tsx +35 -0
- package/agents/examples/heatmap-calendar-signed.tsx +67 -0
- package/agents/examples/heatmap-status.tsx +6 -4
- package/agents/examples/histogram-chart.tsx +28 -0
- package/agents/examples/scatter-chart-quadrants.tsx +63 -0
- package/agents/examples/scatter-chart.tsx +75 -0
- package/agents/examples/slope-chart-market.tsx +33 -0
- package/agents/examples/slope-chart.tsx +26 -0
- package/agents/examples/waterfall-chart-stores.tsx +27 -0
- package/agents/examples/waterfall-chart.tsx +37 -0
- package/agents/manifest.json +160 -0
- package/dist/components/registry/heatmap/calendar-heatmap.d.ts +8 -2
- package/dist/components/registry/heatmap/calendar-heatmap.js +96 -18
- package/dist/components/registry/heatmap/status-heatmap.js +86 -47
- package/dist/components/siyahi/change-grid.d.ts +31 -0
- package/dist/components/siyahi/change-grid.js +74 -0
- package/dist/components/siyahi/delta.js +2 -2
- package/dist/components/siyahi/drawdown-chart.d.ts +34 -0
- package/dist/components/siyahi/drawdown-chart.js +102 -0
- package/dist/components/siyahi/histogram-chart.d.ts +57 -0
- package/dist/components/siyahi/histogram-chart.js +134 -0
- package/dist/components/siyahi/scatter-chart.d.ts +59 -0
- package/dist/components/siyahi/scatter-chart.js +367 -0
- package/dist/components/siyahi/slope-chart.d.ts +35 -0
- package/dist/components/siyahi/slope-chart.js +159 -0
- package/dist/components/siyahi/treemap.js +3 -7
- package/dist/components/siyahi/waterfall-chart.d.ts +51 -0
- package/dist/components/siyahi/waterfall-chart.js +147 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.js +7 -1
- package/dist/lib/chart-frame.d.ts +7 -2
- package/dist/lib/chart-frame.js +44 -10
- package/dist/lib/chart-series.d.ts +2 -3
- package/dist/lib/fit-text.d.ts +6 -0
- package/dist/lib/fit-text.js +11 -0
- package/dist/lib/heat.d.ts +7 -0
- package/dist/lib/heat.js +14 -0
- package/dist/lib/scatter.d.ts +98 -0
- package/dist/lib/scatter.js +218 -0
- package/dist/lib/treemap.d.ts +0 -5
- package/dist/lib/treemap.js +1 -16
- package/package.json +1 -1
- package/report.css +9 -0
- package/styles/siyahi.css +23 -5
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { useFormat } from "../../lib/format.js";
|
|
2
|
+
import { useElementWidth } from "../../lib/use-element-width.js";
|
|
3
|
+
import { fit, textWidth } from "../../lib/fit-text.js";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/siyahi/slope-chart.tsx
|
|
7
|
+
const ROW = 18;
|
|
8
|
+
const TOP = 32;
|
|
9
|
+
const BOTTOM = 8;
|
|
10
|
+
const GAP = 12;
|
|
11
|
+
const NONE = [];
|
|
12
|
+
/**
|
|
13
|
+
* Pushes labels apart so none sits closer than `gap` to the next, keeping their order and staying inside [min, max]:
|
|
14
|
+
* down from the top first, then back up from the bottom when the last one ran past it.
|
|
15
|
+
*/
|
|
16
|
+
function spread(ys, gap, min, max) {
|
|
17
|
+
const order = ys.map((y, index) => ({
|
|
18
|
+
y,
|
|
19
|
+
index
|
|
20
|
+
})).toSorted((a, b) => a.y - b.y);
|
|
21
|
+
let floor = min;
|
|
22
|
+
for (const label of order) {
|
|
23
|
+
label.y = Math.max(label.y, floor);
|
|
24
|
+
floor = label.y + gap;
|
|
25
|
+
}
|
|
26
|
+
let ceiling = max;
|
|
27
|
+
for (const label of order.toReversed()) {
|
|
28
|
+
label.y = Math.min(label.y, ceiling);
|
|
29
|
+
ceiling = label.y - gap;
|
|
30
|
+
}
|
|
31
|
+
const placed = Array.from({ length: ys.length }, () => 0);
|
|
32
|
+
for (const { y, index } of order) placed[index] = y;
|
|
33
|
+
return placed;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Each item as a line from its value on the left to its value on the right, so rises, falls and crossings read at a
|
|
37
|
+
* glance: allocation against a target, a weight against an index's, or one year against the next. Lines are grey and
|
|
38
|
+
* the page picks the few to draw in the accent; names sit on the left, values at both ends, nudged apart when close.
|
|
39
|
+
*/
|
|
40
|
+
function SlopeChart({ items: given, fromLabel, toLabel, highlighted = NONE, valueFormatter, className }) {
|
|
41
|
+
const [ref, width] = useElementWidth();
|
|
42
|
+
const { pct } = useFormat();
|
|
43
|
+
const format = valueFormatter ?? ((value) => pct(value));
|
|
44
|
+
const items = given.filter(({ from, to }) => Number.isFinite(from) && Number.isFinite(to));
|
|
45
|
+
const height = TOP + Math.max(items.length * ROW * 1.5, 180) + BOTTOM;
|
|
46
|
+
const values = items.flatMap(({ from, to }) => [from, to]);
|
|
47
|
+
const low = Math.min(...values);
|
|
48
|
+
const high = Math.max(...values);
|
|
49
|
+
const y = (value) => high === low ? (TOP + height - BOTTOM) / 2 : TOP + (high - value) / (high - low) * (height - TOP - BOTTOM - ROW) + ROW / 2;
|
|
50
|
+
const rightTexts = [toLabel, ...items.map(({ to }) => format(to))];
|
|
51
|
+
const column = Math.min(Math.ceil(Math.max(...rightTexts.map(textWidth)) * 1.1) + 8, Math.round(width * .4));
|
|
52
|
+
const left = Math.min(Math.max(Math.round(width * .45), width - column - 96), 240);
|
|
53
|
+
const right = width - column;
|
|
54
|
+
const lefts = spread(items.map(({ from }) => y(from)), ROW, 41, height - BOTTOM - ROW / 2);
|
|
55
|
+
const rights = spread(items.map(({ to }) => y(to)), ROW, 41, height - BOTTOM - ROW / 2);
|
|
56
|
+
const marked = new Set(highlighted);
|
|
57
|
+
const isMarked = (item) => marked.has(item.key ?? item.name);
|
|
58
|
+
const order = items.map((item, index) => ({
|
|
59
|
+
item,
|
|
60
|
+
index
|
|
61
|
+
})).toSorted((a, b) => Number(isMarked(a.item)) - Number(isMarked(b.item)));
|
|
62
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
63
|
+
ref,
|
|
64
|
+
"data-slot": "slope-chart",
|
|
65
|
+
className: cn("w-full max-w-2xl", className),
|
|
66
|
+
style: { height },
|
|
67
|
+
children: [width > 0 && /* @__PURE__ */ jsxs("svg", {
|
|
68
|
+
width,
|
|
69
|
+
height,
|
|
70
|
+
"aria-hidden": "true",
|
|
71
|
+
className: "text-xs",
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ jsx("text", {
|
|
74
|
+
x: left,
|
|
75
|
+
y: 14,
|
|
76
|
+
textAnchor: "end",
|
|
77
|
+
className: "fill-muted-foreground font-medium",
|
|
78
|
+
children: fit(fromLabel, left)
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ jsx("text", {
|
|
81
|
+
x: right,
|
|
82
|
+
y: 14,
|
|
83
|
+
className: "fill-muted-foreground font-medium",
|
|
84
|
+
children: fit(toLabel, column)
|
|
85
|
+
}),
|
|
86
|
+
[left, right].map((x) => /* @__PURE__ */ jsx("line", {
|
|
87
|
+
x1: x,
|
|
88
|
+
x2: x,
|
|
89
|
+
y1: 26,
|
|
90
|
+
y2: height - BOTTOM,
|
|
91
|
+
className: "stroke-border"
|
|
92
|
+
}, x)),
|
|
93
|
+
order.map(({ item, index }) => {
|
|
94
|
+
const strong = isMarked(item);
|
|
95
|
+
const ink = strong ? "var(--chart-1)" : "var(--muted-foreground)";
|
|
96
|
+
const a = y(item.from);
|
|
97
|
+
const b = y(item.to);
|
|
98
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
99
|
+
"data-slot": "slope-chart-item",
|
|
100
|
+
"data-highlighted": strong || void 0,
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ jsx("title", { children: `${item.name}: ${format(item.from)} to ${format(item.to)}` }),
|
|
103
|
+
strong && /* @__PURE__ */ jsx("line", {
|
|
104
|
+
x1: left + GAP,
|
|
105
|
+
y1: a,
|
|
106
|
+
x2: right - GAP,
|
|
107
|
+
y2: b,
|
|
108
|
+
stroke: "var(--card)",
|
|
109
|
+
strokeWidth: 6.5,
|
|
110
|
+
strokeLinecap: "round"
|
|
111
|
+
}),
|
|
112
|
+
/* @__PURE__ */ jsx("line", {
|
|
113
|
+
x1: left + GAP,
|
|
114
|
+
y1: a,
|
|
115
|
+
x2: right - GAP,
|
|
116
|
+
y2: b,
|
|
117
|
+
stroke: ink,
|
|
118
|
+
strokeWidth: strong ? 2.5 : 1.5
|
|
119
|
+
}),
|
|
120
|
+
[[left + GAP, a], [right - GAP, b]].map(([cx, cy]) => /* @__PURE__ */ jsx("circle", {
|
|
121
|
+
cx,
|
|
122
|
+
cy,
|
|
123
|
+
r: strong ? 4 : 3,
|
|
124
|
+
fill: ink,
|
|
125
|
+
stroke: strong ? "var(--card)" : void 0,
|
|
126
|
+
strokeWidth: strong ? 2 : void 0
|
|
127
|
+
}, cx)),
|
|
128
|
+
/* @__PURE__ */ jsxs("text", {
|
|
129
|
+
x: left - 4,
|
|
130
|
+
y: lefts[index],
|
|
131
|
+
dominantBaseline: "central",
|
|
132
|
+
textAnchor: "end",
|
|
133
|
+
className: cn("tabular-nums", strong ? "fill-foreground font-medium" : "fill-muted-foreground"),
|
|
134
|
+
children: [
|
|
135
|
+
fit(item.name, left - 8 - textWidth(` ${format(item.from)}`)),
|
|
136
|
+
" ",
|
|
137
|
+
format(item.from)
|
|
138
|
+
]
|
|
139
|
+
}),
|
|
140
|
+
/* @__PURE__ */ jsx("text", {
|
|
141
|
+
x: right + 4,
|
|
142
|
+
y: rights[index],
|
|
143
|
+
dominantBaseline: "central",
|
|
144
|
+
className: cn("tabular-nums", strong ? "fill-foreground font-medium" : "fill-muted-foreground"),
|
|
145
|
+
children: format(item.to)
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
}, item.key ?? item.name);
|
|
149
|
+
})
|
|
150
|
+
]
|
|
151
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
152
|
+
className: "sr-only",
|
|
153
|
+
"aria-label": `${fromLabel} against ${toLabel}`,
|
|
154
|
+
children: items.map((item) => /* @__PURE__ */ jsx("li", { children: `${item.name}: ${fromLabel} ${format(item.from)}, ${toLabel} ${format(item.to)}` }, item.key ?? item.name))
|
|
155
|
+
})]
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
export { SlopeChart, spread };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useFormat } from "../../lib/format.js";
|
|
2
2
|
import { useElementWidth } from "../../lib/use-element-width.js";
|
|
3
|
-
import { heat, heatFill, heatRange
|
|
3
|
+
import { heat, heatFill, heatRange } from "../../lib/heat.js";
|
|
4
|
+
import { fit, textWidth } from "../../lib/fit-text.js";
|
|
5
|
+
import { layout } from "../../lib/treemap.js";
|
|
4
6
|
import { cn } from "cn";
|
|
5
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
8
|
import { useEffect, useEffectEvent, useMemo, useState } from "react";
|
|
@@ -138,12 +140,6 @@ function Treemap({ items, height, range, onHover, selected, onSelect }) {
|
|
|
138
140
|
})
|
|
139
141
|
});
|
|
140
142
|
}
|
|
141
|
-
const CHAR_PX = 6.6;
|
|
142
|
-
const textWidth = (text) => text.length * CHAR_PX;
|
|
143
|
-
function fit(text, width) {
|
|
144
|
-
const room = Math.floor(width / CHAR_PX);
|
|
145
|
-
return text.length <= room ? text : `${text.slice(0, Math.max(room - 1, 1)).trimEnd()}…`;
|
|
146
|
-
}
|
|
147
143
|
const MIN_LABEL_WIDTH = 56;
|
|
148
144
|
const MIN_LABEL_HEIGHT = 28;
|
|
149
145
|
const TWO_LINE_HEIGHT = 44;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { SeriesChartProps } from "../../lib/chart-series.js";
|
|
2
|
+
//#region src/components/siyahi/waterfall-chart.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* One bar of a waterfall. A change moves the running total by its value. A total draws the running total from zero;
|
|
5
|
+
* give it a value to set the total instead, as an opening balance does. Labels may repeat, such as "Balance" at
|
|
6
|
+
* both ends: each bar is placed by its position.
|
|
7
|
+
*/
|
|
8
|
+
export type WaterfallStep = {
|
|
9
|
+
kind: "change";
|
|
10
|
+
label: string;
|
|
11
|
+
value: number;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "total";
|
|
14
|
+
label: string;
|
|
15
|
+
value?: number;
|
|
16
|
+
};
|
|
17
|
+
/** A step as drawn: the running total after it, and the span its bar covers. */
|
|
18
|
+
export interface WaterfallBar {
|
|
19
|
+
/** The step's position, as text: the category the bar is placed by. */
|
|
20
|
+
key: string;
|
|
21
|
+
label: string;
|
|
22
|
+
kind: "rise" | "fall" | "total";
|
|
23
|
+
/** How far the step moved the running total. */
|
|
24
|
+
change: number;
|
|
25
|
+
/** The running total after the step. */
|
|
26
|
+
level: number;
|
|
27
|
+
/** The bar's low and high ends, low first whichever way the step moved: Recharts reads a range that way. */
|
|
28
|
+
span: [number, number];
|
|
29
|
+
/** The bar picks up at the level the one before left, so a dashed line joins them. */
|
|
30
|
+
continues: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** Walks the steps in order, keeping the running total. */
|
|
33
|
+
export declare function waterfallBars(steps: readonly WaterfallStep[]): WaterfallBar[];
|
|
34
|
+
export interface WaterfallChartCardProps extends Pick<SeriesChartProps<WaterfallBar, "key">, "title" | "description" | "action" | "height" | "valueFormatter" | "yTickFormatter" | "yLabel" | "referenceLines" | "placeholder" | "footer"> {
|
|
35
|
+
/** The bars in order: usually a total to start from, the changes, and a total to end on. */
|
|
36
|
+
steps: readonly WaterfallStep[];
|
|
37
|
+
/** Bars run sideways with the labels down the left, for long names such as product categories. */
|
|
38
|
+
horizontal?: boolean;
|
|
39
|
+
/** What the legend calls each kind of bar. */
|
|
40
|
+
labels?: {
|
|
41
|
+
rise: string;
|
|
42
|
+
fall: string;
|
|
43
|
+
total: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A running total bridged step by step: where it starts, each change that moved it, and where it ends, such as a
|
|
48
|
+
* year's profit built up month by month. Rises and falls float at the level the one before left; totals stand on zero.
|
|
49
|
+
*/
|
|
50
|
+
export declare function WaterfallChartCard({ steps, horizontal, labels, ...props }: WaterfallChartCardProps): import("react").JSX.Element;
|
|
51
|
+
//#endregion
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { useLocale } from "./siyahi-provider.js";
|
|
2
|
+
import { ChartFrame } from "../../lib/chart-frame.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { Bar, BarChart, Cell, ReferenceLine } from "recharts";
|
|
6
|
+
//#region src/components/siyahi/waterfall-chart.tsx
|
|
7
|
+
const span = (a, b) => [Math.min(a, b), Math.max(a, b)];
|
|
8
|
+
/** Walks the steps in order, keeping the running total. */
|
|
9
|
+
function waterfallBars(steps) {
|
|
10
|
+
let level = 0;
|
|
11
|
+
return steps.map((step, index) => {
|
|
12
|
+
const before = level;
|
|
13
|
+
const key = String(index);
|
|
14
|
+
if (step.kind === "total") {
|
|
15
|
+
level = step.value ?? level;
|
|
16
|
+
const continues = level === before;
|
|
17
|
+
return {
|
|
18
|
+
key,
|
|
19
|
+
label: step.label,
|
|
20
|
+
kind: "total",
|
|
21
|
+
change: level - before,
|
|
22
|
+
level,
|
|
23
|
+
span: span(0, level),
|
|
24
|
+
continues
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
level += step.value;
|
|
28
|
+
const kind = step.value < 0 ? "fall" : "rise";
|
|
29
|
+
return {
|
|
30
|
+
key,
|
|
31
|
+
label: step.label,
|
|
32
|
+
kind,
|
|
33
|
+
change: step.value,
|
|
34
|
+
level,
|
|
35
|
+
span: span(before, level),
|
|
36
|
+
continues: true
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The first step whose figure is not a number. Every bar after it stands on the running total, so a missing change
|
|
42
|
+
* cannot be skipped without drawing wrong balances; the card says which step is missing instead.
|
|
43
|
+
*/
|
|
44
|
+
const unknownStep = (steps) => steps.find((step) => step.value !== void 0 && !Number.isFinite(step.value));
|
|
45
|
+
const COLOR = {
|
|
46
|
+
rise: "var(--positive)",
|
|
47
|
+
fall: "var(--negative)",
|
|
48
|
+
total: "var(--chart-1)"
|
|
49
|
+
};
|
|
50
|
+
const LABELS = {
|
|
51
|
+
rise: "Increase",
|
|
52
|
+
fall: "Decrease",
|
|
53
|
+
total: "Total"
|
|
54
|
+
};
|
|
55
|
+
const MINUS = "−";
|
|
56
|
+
const fill = (kind) => kind === "total" ? COLOR.total : `color-mix(in oklab, ${COLOR[kind]} 35%, var(--card))`;
|
|
57
|
+
function Legend({ labels }) {
|
|
58
|
+
return /* @__PURE__ */ jsx("div", {
|
|
59
|
+
className: "flex items-center justify-center gap-4 pt-3",
|
|
60
|
+
children: [
|
|
61
|
+
"rise",
|
|
62
|
+
"fall",
|
|
63
|
+
"total"
|
|
64
|
+
].map((kind) => /* @__PURE__ */ jsxs("div", {
|
|
65
|
+
className: "flex items-center gap-1.5",
|
|
66
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: "size-2 shrink-0 rounded-xs border",
|
|
68
|
+
style: {
|
|
69
|
+
backgroundColor: fill(kind),
|
|
70
|
+
borderColor: COLOR[kind]
|
|
71
|
+
}
|
|
72
|
+
}), labels[kind]]
|
|
73
|
+
}, kind))
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A running total bridged step by step: where it starts, each change that moved it, and where it ends, such as a
|
|
78
|
+
* year's profit built up month by month. Rises and falls float at the level the one before left; totals stand on zero.
|
|
79
|
+
*/
|
|
80
|
+
function WaterfallChartCard({ steps, horizontal = false, labels = LABELS, ...props }) {
|
|
81
|
+
const { numberLocale } = useLocale();
|
|
82
|
+
const bars = useMemo(() => waterfallBars(steps), [steps]);
|
|
83
|
+
const format = props.valueFormatter ?? new Intl.NumberFormat(numberLocale).format;
|
|
84
|
+
const signed = (value) => `${value > 0 ? "+" : value < 0 ? MINUS : ""}${format(Math.abs(value))}`;
|
|
85
|
+
const names = new Map(bars.map((bar) => [bar.key, bar.label]));
|
|
86
|
+
const unknown = unknownStep(steps);
|
|
87
|
+
return /* @__PURE__ */ jsxs(ChartFrame, {
|
|
88
|
+
chart: BarChart,
|
|
89
|
+
...props,
|
|
90
|
+
placeholder: props.placeholder ?? (unknown && /* @__PURE__ */ jsxs("p", {
|
|
91
|
+
className: "text-sm text-muted-foreground",
|
|
92
|
+
children: [unknown.label, " has no figure, so the running total after it is unknown."]
|
|
93
|
+
})),
|
|
94
|
+
horizontal,
|
|
95
|
+
data: bars,
|
|
96
|
+
xKey: "key",
|
|
97
|
+
xFormatter: (key) => names.get(key) ?? key,
|
|
98
|
+
series: [{
|
|
99
|
+
key: "level",
|
|
100
|
+
label: labels.total,
|
|
101
|
+
color: COLOR.total
|
|
102
|
+
}],
|
|
103
|
+
legend: /* @__PURE__ */ jsx(Legend, { labels }),
|
|
104
|
+
tooltipRow: (_value, _name, item) => {
|
|
105
|
+
const bar = item.payload;
|
|
106
|
+
return (bar.kind === "total" ? [[labels.total, format(bar.level)]] : [[bar.kind === "rise" ? labels.rise : labels.fall, signed(bar.change)], ["Running total", format(bar.level)]]).map(([name, figure]) => /* @__PURE__ */ jsxs("div", {
|
|
107
|
+
className: "flex w-full items-center gap-2",
|
|
108
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
109
|
+
className: "text-muted-foreground",
|
|
110
|
+
children: name
|
|
111
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
112
|
+
className: "ml-auto font-mono font-medium text-foreground tabular-nums",
|
|
113
|
+
children: figure
|
|
114
|
+
})]
|
|
115
|
+
}, name));
|
|
116
|
+
},
|
|
117
|
+
children: [bars.slice(0, -1).map((bar, i) => {
|
|
118
|
+
const next = bars[i + 1];
|
|
119
|
+
if (!next.continues) return null;
|
|
120
|
+
const at = (key) => horizontal ? {
|
|
121
|
+
x: bar.level,
|
|
122
|
+
y: key
|
|
123
|
+
} : {
|
|
124
|
+
x: key,
|
|
125
|
+
y: bar.level
|
|
126
|
+
};
|
|
127
|
+
return /* @__PURE__ */ jsx(ReferenceLine, {
|
|
128
|
+
segment: [at(bar.key), at(next.key)],
|
|
129
|
+
stroke: "var(--muted-foreground)",
|
|
130
|
+
strokeDasharray: "2 2",
|
|
131
|
+
"data-slot": "waterfall-connector"
|
|
132
|
+
}, bar.key);
|
|
133
|
+
}), /* @__PURE__ */ jsx(Bar, {
|
|
134
|
+
dataKey: "span",
|
|
135
|
+
name: labels.total,
|
|
136
|
+
maxBarSize: horizontal ? 24 : 48,
|
|
137
|
+
radius: 2,
|
|
138
|
+
children: bars.map((bar) => /* @__PURE__ */ jsx(Cell, {
|
|
139
|
+
fill: fill(bar.kind),
|
|
140
|
+
stroke: COLOR[bar.kind],
|
|
141
|
+
strokeWidth: 1.5
|
|
142
|
+
}, bar.key))
|
|
143
|
+
})]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
export { WaterfallChartCard, waterfallBars };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChartColor, ChartCurve, ChartReferenceLine, ChartSeries, ChartSeriesItem, NumericXProps, SeriesChartProps } from "./lib/chart-series.js";
|
|
1
|
+
import { ChartColor, ChartCurve, ChartReferenceLine, ChartSeries, ChartSeriesItem, NumericKey, NumericXProps, SeriesChartProps } from "./lib/chart-series.js";
|
|
2
2
|
import { AreaChartCard, AreaChartCardProps } from "./components/registry/charts/area-chart-card.js";
|
|
3
3
|
import { BarChartCard, BarChartCardProps } from "./components/registry/charts/bar-chart-card.js";
|
|
4
4
|
import { LineChartCard, LineChartCardProps } from "./components/registry/charts/line-chart-card.js";
|
|
@@ -52,6 +52,7 @@ import { AppSidebar, AppSidebarProps } from "./components/registry/sidebar-07/ap
|
|
|
52
52
|
import { Callout, CalloutProps } from "./components/siyahi/callout.js";
|
|
53
53
|
import { Delta, DeltaProps } from "./components/siyahi/delta.js";
|
|
54
54
|
import { ChangeBar, ChangeBarProps } from "./components/siyahi/change-bar.js";
|
|
55
|
+
import { ChangeGrid, ChangeGridProps, ChangeGridRow } from "./components/siyahi/change-grid.js";
|
|
55
56
|
import { DataBar, DataBarProps } from "./components/siyahi/data-bar.js";
|
|
56
57
|
import { DataList, DataListItem, DataListItemProps } from "./components/siyahi/data-list.js";
|
|
57
58
|
import { DataTableCompactColumnsToggle } from "./components/siyahi/data-table-compact-columns-toggle.js";
|
|
@@ -59,6 +60,8 @@ import { DataTableFootnote, DataTableFootnoteProps } from "./components/siyahi/d
|
|
|
59
60
|
import { DataTableRowCount, DataTableRowCountProps } from "./components/siyahi/data-table-row-count.js";
|
|
60
61
|
import { DataTableSortHeader } from "./components/siyahi/data-table-sort-header.js";
|
|
61
62
|
import { defaultSidebarOpen } from "./components/siyahi/default-sidebar-open.js";
|
|
63
|
+
import { DrawdownChartCard, DrawdownChartCardProps, DrawdownPoint, drawdowns } from "./components/siyahi/drawdown-chart.js";
|
|
64
|
+
import { HistogramBin, HistogramChartCard, HistogramChartCardProps, HistogramMark, bucketOf, histogram, markLines, percentile } from "./components/siyahi/histogram-chart.js";
|
|
62
65
|
import { InlineCode } from "./components/siyahi/inline-code.js";
|
|
63
66
|
import { LocalTime, LocalTimeProps } from "./components/siyahi/local-time.js";
|
|
64
67
|
import { PageHero, PageHeroProps } from "./components/siyahi/page-hero.js";
|
|
@@ -68,8 +71,11 @@ import { PanelGrid, PanelGridProps } from "./components/siyahi/panel-grid.js";
|
|
|
68
71
|
import { PriceChart, PriceChartProps } from "./components/siyahi/price-chart.js";
|
|
69
72
|
import { Quote, QuoteProps } from "./components/siyahi/quote.js";
|
|
70
73
|
import { RangePosition, RangePositionProps } from "./components/siyahi/range-position.js";
|
|
74
|
+
import { ScatterQuadrants } from "./lib/scatter.js";
|
|
75
|
+
import { ScatterChartCard, ScatterChartCardProps, ScatterDetail, ScatterPoint } from "./components/siyahi/scatter-chart.js";
|
|
71
76
|
import { SiyahiLocale, defaultLocale } from "./lib/locale.js";
|
|
72
77
|
import { SiyahiProvider, SiyahiProviderProps, Surface, useLocale, useSurface } from "./components/siyahi/siyahi-provider.js";
|
|
78
|
+
import { SlopeChart, SlopeChartProps, SlopeItem, spread } from "./components/siyahi/slope-chart.js";
|
|
73
79
|
import { Alert, AlertAction, AlertDescription, AlertTitle } from "./components/ui/alert.js";
|
|
74
80
|
import { StatusAlert, StatusAlertProps } from "./components/siyahi/status-alert.js";
|
|
75
81
|
import { Badge, badgeVariants } from "./components/ui/badge.js";
|
|
@@ -78,6 +84,7 @@ import { TargetRow, TargetRows, TargetRowsProps, TargetStatus } from "./componen
|
|
|
78
84
|
import { Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue } from "./components/ui/progress.js";
|
|
79
85
|
import { ToneProgress, ToneProgressProps } from "./components/siyahi/tone-progress.js";
|
|
80
86
|
import { Treemap, TreemapItem, TreemapLegend, TreemapLegendProps, TreemapProps } from "./components/siyahi/treemap.js";
|
|
87
|
+
import { WaterfallBar, WaterfallChartCard, WaterfallChartCardProps, WaterfallStep, waterfallBars } from "./components/siyahi/waterfall-chart.js";
|
|
81
88
|
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "./components/ui/accordion.js";
|
|
82
89
|
import { Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage } from "./components/ui/avatar.js";
|
|
83
90
|
import { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "./components/ui/breadcrumb.js";
|
|
@@ -101,4 +108,4 @@ import { Textarea } from "./components/ui/textarea.js";
|
|
|
101
108
|
import { Toggle, toggleVariants } from "./components/ui/toggle.js";
|
|
102
109
|
import { ToggleGroup, ToggleGroupItem } from "./components/ui/toggle-group.js";
|
|
103
110
|
import { Formatters, TimeOptions, count, money, moneyCompact, pct, time, useFormat } from "./lib/format.js";
|
|
104
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActiveCell, ActiveSelection, Activity, Alert, AlertAction, AlertDescription, AlertTitle, AppSidebar, AppSidebarProps, AreaChartCard, AreaChartCardProps, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BarChartCard, BarChartCardProps, BarList, BarListItem, BarListProps, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, CalendarDayButton, CalendarHeatmap, CalendarHeatmapBlock, CalendarHeatmapBlockProps, CalendarHeatmapBody, CalendarHeatmapBodyProps, CalendarHeatmapFooter, CalendarHeatmapFooterProps, CalendarHeatmapLegend, CalendarHeatmapLegendProps, CalendarHeatmapProps, CalendarHeatmapStat, CalendarHeatmapStatProps, Callout, CalloutProps, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChangeBar, ChangeBarProps, ChartColor, ChartConfig, ChartContainer, ChartCurve, ChartLegend, ChartLegendContent, ChartReferenceLine, ChartSeries, ChartSeriesItem, ChartStyle, ChartTooltip, ChartTooltipContent, CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle, Collapsible, CollapsibleContent, CollapsibleTrigger, ColorConfig, ColumnResizeInfo, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CompactColumns, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyButton, DataBar, DataBarProps, DataList, DataListItem, DataListItemProps, DataTable, DataTableActions, DataTableBody, DataTableBodyProps, type DataTableCell, type DataTableColumn, DataTableColumnActions, type DataTableColumnDef, DataTableColumnFilter, DataTableColumnHeader, DataTableColumnHeaderProps, DataTableColumnHeaderRoot, DataTableColumnSortMenu, DataTableColumnSortOptions, DataTableColumnTitle, type DataTableColumns, DataTableCompactColumnsToggle, DataTableConfig, DataTableContainerProps, DataTableContext, DataTableContextState, DataTableEmptyActions, DataTableEmptyActionsProps, DataTableEmptyBody, DataTableEmptyBodyProps, DataTableEmptyDescription, DataTableEmptyDescriptionProps, DataTableEmptyFilteredMessage, DataTableEmptyFilteredMessageProps, DataTableEmptyIcon, DataTableEmptyIconProps, DataTableEmptyMessage, DataTableEmptyMessageProps, DataTableEmptyState, DataTableEmptyStateProps, DataTableEmptyTitle, DataTableEmptyTitleProps, DataTableErrorBoundary, DataTableErrorBoundaryProps, DataTableFacetedFilter, DataTableFacetedFilterContent, DataTableFootnote, DataTableFootnoteProps, DataTableGroupRowContextValue, DataTableGroupRowProvider, DataTableGroupedRowCells, DataTableGroupedRows, DataTableGroupedRowsProps, DataTableHeader, type DataTableHeader$1 as DataTableHeaderCell, DataTableHeaderProps, type DataTableInstance, DataTableLoading, DataTableLoadingMore, DataTableLoadingMoreProps, DataTableLoadingProps, DataTableProvider, DataTableRoot, type DataTableRow, DataTableRowContextMenu, DataTableRowContextMenuProps, DataTableRowContextMenuSlot, DataTableRowContextMenuSlotProps, DataTableRowCount, DataTableRowCountProps, DataTableRowMenuScope, DataTableSearchFilter, DataTableSkeleton, DataTableSkeletonProps, DataTableSortHeader, DataTableToolbarSection, DataTableToolbarSectionProps, Delta, DeltaProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DistributionBar, DistributionBarProps, DistributionMarker, DistributionSegment, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, type ExtendedColumnFilter, type ExtendedColumnSort, type FilterOperator, type FilterOperatorValues, type FilterVariant, type FilterVariantValues, FlashCellRef, FlashCells, FlashRows, FlashRowsOptions, Formatters, type GlobalFilter, GroupedBodyRow, GroupedBodyRowProps, InlineCode, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, type JoinOperator, type JoinOperatorValues, Labels, LineChartCard, LineChartCardProps, LocalTime, LocalTimeProps, MetricStrip, MetricStripItem, MetricStripProps, NavMain, NavProjects, NavUser, NumericXProps, type Option, PageHero, PageHeroProps, PageSection, PageSectionProps, PageSubheading, PageToc, PageTocItem, PageTocProps, PanelGrid, PanelGridProps, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, PriceChart, PriceChartProps, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, type QueryKeys, Quote, QuoteProps, RangePosition, RangePositionProps, RowMenuGroup, RowMenuItem, RowMenuLabel, RowMenuSeparator, RowMenuSub, RowMenuSubContent, RowMenuSubTrigger, ScrollAlign, ScrollArea, ScrollBar, type ScrollEvent, ScrollRowIntoView, SectionCard, SectionCards, SectionCardsProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SeriesChartProps, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, SiyahiLocale, SiyahiProvider, SiyahiProviderProps, Skeleton, Slider, Sparkline, SparklineProps, StatusActivity, StatusAlert, StatusAlertProps, StatusBadge, StatusBadgeProps, StatusColorConfig, StatusHeatmap, StatusHeatmapBlock, StatusHeatmapBlockProps, StatusHeatmapBody, StatusHeatmapBodyProps, StatusHeatmapFooter, StatusHeatmapFooterProps, StatusHeatmapLabels, StatusHeatmapLegend, StatusHeatmapLegendProps, StatusHeatmapProps, StatusHeatmapStat, StatusHeatmapStatProps, StatusValue, Surface, Table, TableBody, TableCaption, TableCell, TableColumnActions, TableColumnActionsProps, TableColumnSortMenu, TableColumnSortOptions, TableColumnTitle, TableFacetedFilter, TableFacetedFilterContent, TableFacetedFilterProps, TableFooter, TableHead, TableHeader, TableRow, TableSearchFilter, TableSearchFilterProps, Tabs, TabsContent, TabsList, TabsTrigger, TargetRow, TargetRows, TargetRowsProps, TargetStatus, TeamSwitcher, Textarea, TimeOptions, Toggle, ToggleGroup, ToggleGroupItem, ToneProgress, ToneProgressProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Treemap, TreemapItem, TreemapLegend, TreemapLegendProps, TreemapProps, type ValueOf, type ColorConfig$1 as WeekdayColorConfig, type WeekdayExtraColumnSpec, type WeekdayExtraRowSpec, WeekdayHeatmap, WeekdayHeatmapBlock, type WeekdayHeatmapBlockProps, WeekdayHeatmapBody, type WeekdayHeatmapBodyProps, WeekdayHeatmapFooter, type WeekdayHeatmapFooterProps, type WeekdayHeatmapLabels, WeekdayHeatmapLegend, type WeekdayHeatmapLegendProps, type WeekdayHeatmapProps, WeekdayHeatmapStat, type WeekdayHeatmapStatProps, type WeekdayHour, type WeekdayHourlyActivity, type WeekdayIndex, badgeVariants, buttonVariants, count, defaultLocale, defaultSidebarOpen, flashCellKey, money, moneyCompact, pct, resolveGroupedRowsSlot, resolveRowContextMenuRenderer, tabsListVariants, time, toggleVariants, useColumnHeaderContext, useColumnResizeInfo, useDataTable, useDataTableActiveCell, useDataTableActiveCellSetter, useDataTableGroupRow, useDataTableRow, useFormat, useLocale, useResolvedRowContextMenuRenderer, useSidebar, useSurface, useTableFacetedFilter };
|
|
111
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActiveCell, ActiveSelection, Activity, Alert, AlertAction, AlertDescription, AlertTitle, AppSidebar, AppSidebarProps, AreaChartCard, AreaChartCardProps, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BarChartCard, BarChartCardProps, BarList, BarListItem, BarListProps, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, CalendarDayButton, CalendarHeatmap, CalendarHeatmapBlock, CalendarHeatmapBlockProps, CalendarHeatmapBody, CalendarHeatmapBodyProps, CalendarHeatmapFooter, CalendarHeatmapFooterProps, CalendarHeatmapLegend, CalendarHeatmapLegendProps, CalendarHeatmapProps, CalendarHeatmapStat, CalendarHeatmapStatProps, Callout, CalloutProps, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChangeBar, ChangeBarProps, ChangeGrid, ChangeGridProps, ChangeGridRow, ChartColor, ChartConfig, ChartContainer, ChartCurve, ChartLegend, ChartLegendContent, ChartReferenceLine, ChartSeries, ChartSeriesItem, ChartStyle, ChartTooltip, ChartTooltipContent, CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle, Collapsible, CollapsibleContent, CollapsibleTrigger, ColorConfig, ColumnResizeInfo, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CompactColumns, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyButton, DataBar, DataBarProps, DataList, DataListItem, DataListItemProps, DataTable, DataTableActions, DataTableBody, DataTableBodyProps, type DataTableCell, type DataTableColumn, DataTableColumnActions, type DataTableColumnDef, DataTableColumnFilter, DataTableColumnHeader, DataTableColumnHeaderProps, DataTableColumnHeaderRoot, DataTableColumnSortMenu, DataTableColumnSortOptions, DataTableColumnTitle, type DataTableColumns, DataTableCompactColumnsToggle, DataTableConfig, DataTableContainerProps, DataTableContext, DataTableContextState, DataTableEmptyActions, DataTableEmptyActionsProps, DataTableEmptyBody, DataTableEmptyBodyProps, DataTableEmptyDescription, DataTableEmptyDescriptionProps, DataTableEmptyFilteredMessage, DataTableEmptyFilteredMessageProps, DataTableEmptyIcon, DataTableEmptyIconProps, DataTableEmptyMessage, DataTableEmptyMessageProps, DataTableEmptyState, DataTableEmptyStateProps, DataTableEmptyTitle, DataTableEmptyTitleProps, DataTableErrorBoundary, DataTableErrorBoundaryProps, DataTableFacetedFilter, DataTableFacetedFilterContent, DataTableFootnote, DataTableFootnoteProps, DataTableGroupRowContextValue, DataTableGroupRowProvider, DataTableGroupedRowCells, DataTableGroupedRows, DataTableGroupedRowsProps, DataTableHeader, type DataTableHeader$1 as DataTableHeaderCell, DataTableHeaderProps, type DataTableInstance, DataTableLoading, DataTableLoadingMore, DataTableLoadingMoreProps, DataTableLoadingProps, DataTableProvider, DataTableRoot, type DataTableRow, DataTableRowContextMenu, DataTableRowContextMenuProps, DataTableRowContextMenuSlot, DataTableRowContextMenuSlotProps, DataTableRowCount, DataTableRowCountProps, DataTableRowMenuScope, DataTableSearchFilter, DataTableSkeleton, DataTableSkeletonProps, DataTableSortHeader, DataTableToolbarSection, DataTableToolbarSectionProps, Delta, DeltaProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DistributionBar, DistributionBarProps, DistributionMarker, DistributionSegment, DrawdownChartCard, DrawdownChartCardProps, DrawdownPoint, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, type ExtendedColumnFilter, type ExtendedColumnSort, type FilterOperator, type FilterOperatorValues, type FilterVariant, type FilterVariantValues, FlashCellRef, FlashCells, FlashRows, FlashRowsOptions, Formatters, type GlobalFilter, GroupedBodyRow, GroupedBodyRowProps, HistogramBin, HistogramChartCard, HistogramChartCardProps, HistogramMark, InlineCode, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, type JoinOperator, type JoinOperatorValues, Labels, LineChartCard, LineChartCardProps, LocalTime, LocalTimeProps, MetricStrip, MetricStripItem, MetricStripProps, NavMain, NavProjects, NavUser, NumericKey, NumericXProps, type Option, PageHero, PageHeroProps, PageSection, PageSectionProps, PageSubheading, PageToc, PageTocItem, PageTocProps, PanelGrid, PanelGridProps, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, PriceChart, PriceChartProps, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, type QueryKeys, Quote, QuoteProps, RangePosition, RangePositionProps, RowMenuGroup, RowMenuItem, RowMenuLabel, RowMenuSeparator, RowMenuSub, RowMenuSubContent, RowMenuSubTrigger, ScatterChartCard, ScatterChartCardProps, ScatterDetail, ScatterPoint, type ScatterQuadrants, ScrollAlign, ScrollArea, ScrollBar, type ScrollEvent, ScrollRowIntoView, SectionCard, SectionCards, SectionCardsProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SeriesChartProps, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, SiyahiLocale, SiyahiProvider, SiyahiProviderProps, Skeleton, Slider, SlopeChart, SlopeChartProps, SlopeItem, Sparkline, SparklineProps, StatusActivity, StatusAlert, StatusAlertProps, StatusBadge, StatusBadgeProps, StatusColorConfig, StatusHeatmap, StatusHeatmapBlock, StatusHeatmapBlockProps, StatusHeatmapBody, StatusHeatmapBodyProps, StatusHeatmapFooter, StatusHeatmapFooterProps, StatusHeatmapLabels, StatusHeatmapLegend, StatusHeatmapLegendProps, StatusHeatmapProps, StatusHeatmapStat, StatusHeatmapStatProps, StatusValue, Surface, Table, TableBody, TableCaption, TableCell, TableColumnActions, TableColumnActionsProps, TableColumnSortMenu, TableColumnSortOptions, TableColumnTitle, TableFacetedFilter, TableFacetedFilterContent, TableFacetedFilterProps, TableFooter, TableHead, TableHeader, TableRow, TableSearchFilter, TableSearchFilterProps, Tabs, TabsContent, TabsList, TabsTrigger, TargetRow, TargetRows, TargetRowsProps, TargetStatus, TeamSwitcher, Textarea, TimeOptions, Toggle, ToggleGroup, ToggleGroupItem, ToneProgress, ToneProgressProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Treemap, TreemapItem, TreemapLegend, TreemapLegendProps, TreemapProps, type ValueOf, WaterfallBar, WaterfallChartCard, WaterfallChartCardProps, WaterfallStep, type ColorConfig$1 as WeekdayColorConfig, type WeekdayExtraColumnSpec, type WeekdayExtraRowSpec, WeekdayHeatmap, WeekdayHeatmapBlock, type WeekdayHeatmapBlockProps, WeekdayHeatmapBody, type WeekdayHeatmapBodyProps, WeekdayHeatmapFooter, type WeekdayHeatmapFooterProps, type WeekdayHeatmapLabels, WeekdayHeatmapLegend, type WeekdayHeatmapLegendProps, type WeekdayHeatmapProps, WeekdayHeatmapStat, type WeekdayHeatmapStatProps, type WeekdayHour, type WeekdayHourlyActivity, type WeekdayIndex, badgeVariants, bucketOf, buttonVariants, count, defaultLocale, defaultSidebarOpen, drawdowns, flashCellKey, histogram, markLines, money, moneyCompact, pct, percentile, resolveGroupedRowsSlot, resolveRowContextMenuRenderer, spread, tabsListVariants, time, toggleVariants, useColumnHeaderContext, useColumnResizeInfo, useDataTable, useDataTableActiveCell, useDataTableActiveCellSetter, useDataTableGroupRow, useDataTableRow, useFormat, useLocale, useResolvedRowContextMenuRenderer, useSidebar, useSurface, useTableFacetedFilter, waterfallBars };
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,7 @@ import { TeamSwitcher } from "./components/registry/sidebar-07/team-switcher.js"
|
|
|
77
77
|
import { AppSidebar } from "./components/registry/sidebar-07/app-sidebar.js";
|
|
78
78
|
import { Callout } from "./components/siyahi/callout.js";
|
|
79
79
|
import { ChangeBar } from "./components/siyahi/change-bar.js";
|
|
80
|
+
import { ChangeGrid } from "./components/siyahi/change-grid.js";
|
|
80
81
|
import { DataBar } from "./components/siyahi/data-bar.js";
|
|
81
82
|
import { DataList, DataListItem } from "./components/siyahi/data-list.js";
|
|
82
83
|
import { DataTableCompactColumnsToggle } from "./components/siyahi/data-table-compact-columns-toggle.js";
|
|
@@ -84,6 +85,8 @@ import { DataTableFootnote } from "./components/siyahi/data-table-footnote.js";
|
|
|
84
85
|
import { DataTableRowCount } from "./components/siyahi/data-table-row-count.js";
|
|
85
86
|
import { DataTableSortHeader } from "./components/siyahi/data-table-sort-header.js";
|
|
86
87
|
import { defaultSidebarOpen } from "./components/siyahi/default-sidebar-open.js";
|
|
88
|
+
import { DrawdownChartCard, drawdowns } from "./components/siyahi/drawdown-chart.js";
|
|
89
|
+
import { HistogramChartCard, bucketOf, histogram, markLines, percentile } from "./components/siyahi/histogram-chart.js";
|
|
87
90
|
import { InlineCode } from "./components/siyahi/inline-code.js";
|
|
88
91
|
import { LocalTime } from "./components/siyahi/local-time.js";
|
|
89
92
|
import { PageHero } from "./components/siyahi/page-hero.js";
|
|
@@ -93,9 +96,12 @@ import { PanelGrid } from "./components/siyahi/panel-grid.js";
|
|
|
93
96
|
import { PriceChart } from "./components/siyahi/price-chart.js";
|
|
94
97
|
import { Quote } from "./components/siyahi/quote.js";
|
|
95
98
|
import { RangePosition } from "./components/siyahi/range-position.js";
|
|
99
|
+
import { ScatterChartCard } from "./components/siyahi/scatter-chart.js";
|
|
100
|
+
import { SlopeChart, spread } from "./components/siyahi/slope-chart.js";
|
|
96
101
|
import { StatusAlert } from "./components/siyahi/status-alert.js";
|
|
97
102
|
import { StatusBadge } from "./components/siyahi/status-badge.js";
|
|
98
103
|
import { TargetRows } from "./components/siyahi/target-rows.js";
|
|
99
104
|
import { ToneProgress } from "./components/siyahi/tone-progress.js";
|
|
100
105
|
import { Treemap, TreemapLegend } from "./components/siyahi/treemap.js";
|
|
101
|
-
|
|
106
|
+
import { WaterfallChartCard, waterfallBars } from "./components/siyahi/waterfall-chart.js";
|
|
107
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertAction, AlertDescription, AlertTitle, AppSidebar, AreaChartCard, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BarChartCard, BarList, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, CalendarDayButton, CalendarHeatmap, CalendarHeatmapBlock, CalendarHeatmapBody, CalendarHeatmapFooter, CalendarHeatmapLegend, CalendarHeatmapStat, Callout, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChangeBar, ChangeGrid, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, CodeBlock, CodeBlockActions, CodeBlockContent, CodeBlockCopyButton, CodeBlockFooter, CodeBlockHeader, CodeBlockLine, CodeBlockTitle, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyButton, DataBar, DataList, DataListItem, DataTable, DataTableActions, DataTableBody, DataTableColumnActions, DataTableColumnFilter, DataTableColumnHeader, DataTableColumnHeaderRoot, DataTableColumnSortMenu, DataTableColumnSortOptions, DataTableColumnTitle, DataTableCompactColumnsToggle, DataTableContext, DataTableEmptyActions, DataTableEmptyBody, DataTableEmptyDescription, DataTableEmptyFilteredMessage, DataTableEmptyIcon, DataTableEmptyMessage, DataTableEmptyState, DataTableEmptyTitle, DataTableErrorBoundary, DataTableFacetedFilter, DataTableFacetedFilterContent, DataTableFootnote, DataTableGroupRowProvider, DataTableGroupedRowCells, DataTableGroupedRows, DataTableHeader, DataTableLoading, DataTableLoadingMore, DataTableProvider, DataTableRoot, DataTableRowContextMenu, DataTableRowContextMenuSlot, DataTableRowCount, DataTableRowMenuScope, DataTableSearchFilter, DataTableSkeleton, DataTableSortHeader, DataTableToolbarSection, Delta, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DistributionBar, DrawdownChartCard, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, GroupedBodyRow, HistogramChartCard, InlineCode, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, LineChartCard, LocalTime, MetricStrip, NavMain, NavProjects, NavUser, PageHero, PageSection, PageSubheading, PageToc, PanelGrid, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, PriceChart, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, Quote, RangePosition, RowMenuGroup, RowMenuItem, RowMenuLabel, RowMenuSeparator, RowMenuSub, RowMenuSubContent, RowMenuSubTrigger, ScatterChartCard, ScrollArea, ScrollBar, SectionCards, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, SiyahiProvider, Skeleton, Slider, SlopeChart, Sparkline, StatusAlert, StatusBadge, StatusHeatmap, StatusHeatmapBlock, StatusHeatmapBody, StatusHeatmapFooter, StatusHeatmapLegend, StatusHeatmapStat, Table, TableBody, TableCaption, TableCell, TableColumnActions, TableColumnSortMenu, TableColumnSortOptions, TableColumnTitle, TableFacetedFilter, TableFacetedFilterContent, TableFooter, TableHead, TableHeader, TableRow, TableSearchFilter, Tabs, TabsContent, TabsList, TabsTrigger, TargetRows, TeamSwitcher, Textarea, Toggle, ToggleGroup, ToggleGroupItem, ToneProgress, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Treemap, TreemapLegend, WaterfallChartCard, WeekdayHeatmap, WeekdayHeatmapBlock, WeekdayHeatmapBody, WeekdayHeatmapFooter, WeekdayHeatmapLegend, WeekdayHeatmapStat, badgeVariants, bucketOf, buttonVariants, count, defaultLocale, defaultSidebarOpen, drawdowns, flashCellKey, histogram, markLines, money, moneyCompact, pct, percentile, resolveGroupedRowsSlot, resolveRowContextMenuRenderer, spread, tabsListVariants, time, toggleVariants, useColumnHeaderContext, useColumnResizeInfo, useDataTable, useDataTableActiveCell, useDataTableActiveCellSetter, useDataTableGroupRow, useDataTableRow, useFormat, useLocale, useResolvedRowContextMenuRenderer, useSidebar, useSurface, useTableFacetedFilter, waterfallBars };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChartColor, ChartSeries, ChartSeriesItem, NumericXProps, SeriesChartProps } from "./chart-series.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ChartTooltipContent } from "../components/ui/chart.js";
|
|
3
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
3
4
|
import { AreaChart, BarChart, LineChart, YAxisProps } from "recharts";
|
|
4
5
|
//#region src/lib/chart-frame.d.ts
|
|
5
6
|
interface ChartFrameProps<T extends object, K extends keyof T> extends Omit<SeriesChartProps<T, K>, "yDomain">, NumericXProps {
|
|
@@ -17,6 +18,10 @@ interface ChartFrameProps<T extends object, K extends keyof T> extends Omit<Seri
|
|
|
17
18
|
/** "sign" stacks negative values below zero and positive ones above, rather than on one running total. */
|
|
18
19
|
stackOffset?: "sign";
|
|
19
20
|
onClick?: ComponentProps<typeof BarChart>["onClick"];
|
|
21
|
+
/** A tooltip row per hovered mark; by default each series' colour, label and formatted value (seriesRow). */
|
|
22
|
+
tooltipRow?: ComponentProps<typeof ChartTooltipContent>["formatter"];
|
|
23
|
+
/** The legend under the plot; by default one chip per series. */
|
|
24
|
+
legend?: ReactElement;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* The colour a series' Bar takes, which its legend chip shows: the negative colour when every value drawn is below
|
|
@@ -42,6 +47,6 @@ export declare function seriesRow<T>(series: ChartSeries<T>, formatValue: (value
|
|
|
42
47
|
* that gave its category axis its own id (dash#88) got a plot split in two
|
|
43
48
|
* and every tooltip headed with the series name instead of the category.
|
|
44
49
|
*/
|
|
45
|
-
export declare function ChartFrame<T extends object, K extends keyof T>({ chart: Chart, children, horizontal, stackOffset, onClick, title, description, action, data, xKey, series, xFormatter, xTooltipFormatter, valueFormatter, yTickFormatter, yDomain, yTicks, height, xTickDetail, xLabel, yLabel, referenceLines, placeholder, footer, xDomain, xTicks }: ChartFrameProps<T, K>): import("react").JSX.Element;
|
|
50
|
+
export declare function ChartFrame<T extends object, K extends keyof T>({ chart: Chart, children, horizontal, stackOffset, onClick, tooltipRow, legend, title, description, action, data, xKey, series, xFormatter, xTooltipFormatter, valueFormatter, yTickFormatter, yDomain, yTicks, height, xTickDetail, xLabel, yLabel, referenceLines, placeholder, footer, xDomain, xTicks }: ChartFrameProps<T, K>): import("react").JSX.Element;
|
|
46
51
|
//#endregion
|
|
47
52
|
export {};
|
package/dist/lib/chart-frame.js
CHANGED
|
@@ -9,6 +9,31 @@ import { CartesianGrid, ReferenceLine, Text, XAxis, YAxis, useChartWidth, useXAx
|
|
|
9
9
|
const AXIS_TITLE = "fill-muted-foreground text-xs";
|
|
10
10
|
const TICK = { className: "fill-muted-foreground font-mono" };
|
|
11
11
|
const NO_LINES = [];
|
|
12
|
+
const SERIES_LEGEND = /* @__PURE__ */ jsx(ChartLegendContent, { className: "flex-wrap gap-y-1" });
|
|
13
|
+
/**
|
|
14
|
+
* A reference line over a card-coloured band, so it stays traceable where it crosses a bar or an area: the text
|
|
15
|
+
* colour on --chart-1 is only 2:1, but each against the card is well over 3:1.
|
|
16
|
+
*/
|
|
17
|
+
function haloLine({ x1, y1, x2, y2, stroke, strokeDasharray }) {
|
|
18
|
+
return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
19
|
+
"data-slot": "reference-line-halo",
|
|
20
|
+
x1,
|
|
21
|
+
y1,
|
|
22
|
+
x2,
|
|
23
|
+
y2,
|
|
24
|
+
stroke: "var(--card)",
|
|
25
|
+
strokeWidth: 4
|
|
26
|
+
}), /* @__PURE__ */ jsx("line", {
|
|
27
|
+
className: "recharts-reference-line-line",
|
|
28
|
+
x1,
|
|
29
|
+
y1,
|
|
30
|
+
x2,
|
|
31
|
+
y2,
|
|
32
|
+
stroke,
|
|
33
|
+
strokeDasharray,
|
|
34
|
+
strokeWidth: 1
|
|
35
|
+
})] });
|
|
36
|
+
}
|
|
12
37
|
/**
|
|
13
38
|
* The colour a series' Bar takes, which its legend chip shows: the negative colour when every value drawn is below
|
|
14
39
|
* zero, since each bar's own Cell follows its sign but the chip follows the Bar.
|
|
@@ -161,7 +186,7 @@ function HorizontalAxis({ data, xKey, xFormatter, xTickDetail, xTicks }) {
|
|
|
161
186
|
* that gave its category axis its own id (dash#88) got a plot split in two
|
|
162
187
|
* and every tooltip headed with the series name instead of the category.
|
|
163
188
|
*/
|
|
164
|
-
function ChartFrame({ chart: Chart, children, horizontal = false, stackOffset, onClick, title, description, action, data, xKey, series, xFormatter = String, xTooltipFormatter = xFormatter, valueFormatter, yTickFormatter, yDomain, yTicks, height, xTickDetail, xLabel, yLabel, referenceLines = NO_LINES, placeholder, footer, xDomain, xTicks }) {
|
|
189
|
+
function ChartFrame({ chart: Chart, children, horizontal = false, stackOffset, onClick, tooltipRow, legend = SERIES_LEGEND, title, description, action, data, xKey, series, xFormatter = String, xTooltipFormatter = xFormatter, valueFormatter, yTickFormatter, yDomain, yTicks, height, xTickDetail, xLabel, yLabel, referenceLines = NO_LINES, placeholder, footer, xDomain, xTicks }) {
|
|
165
190
|
const { numberLocale } = useLocale();
|
|
166
191
|
const formatValue = useMemo(() => valueFormatter ?? new Intl.NumberFormat(numberLocale).format, [valueFormatter, numberLocale]);
|
|
167
192
|
const config = Object.fromEntries(series.map(({ key, label, color }) => [key, {
|
|
@@ -293,23 +318,32 @@ function ChartFrame({ chart: Chart, children, horizontal = false, stackOffset, o
|
|
|
293
318
|
y: at.x
|
|
294
319
|
} : at,
|
|
295
320
|
stroke: emphasis === "strong" ? "var(--foreground)" : "var(--muted-foreground)",
|
|
321
|
+
shape: haloLine,
|
|
296
322
|
strokeDasharray: at.y === void 0 ? void 0 : "4 4",
|
|
297
323
|
label: label === void 0 ? void 0 : {
|
|
298
324
|
value: label,
|
|
299
325
|
position: labelPosition,
|
|
300
|
-
className: "fill-muted-foreground text-xs"
|
|
326
|
+
className: "fill-muted-foreground stroke-card text-xs",
|
|
327
|
+
style: {
|
|
328
|
+
paintOrder: "stroke",
|
|
329
|
+
strokeWidth: 3,
|
|
330
|
+
strokeLinejoin: "round"
|
|
331
|
+
}
|
|
301
332
|
}
|
|
302
333
|
}, `${at.x ?? ""}:${at.y ?? ""}:${label ?? ""}`)),
|
|
303
|
-
/* @__PURE__ */ jsx(ChartTooltip, {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
334
|
+
/* @__PURE__ */ jsx(ChartTooltip, {
|
|
335
|
+
cursor: { fillOpacity: .4 },
|
|
336
|
+
content: /* @__PURE__ */ jsx(ChartTooltipContent, {
|
|
337
|
+
labelFormatter: (_, payload) => {
|
|
338
|
+
const row = payload[0]?.payload;
|
|
339
|
+
return row ? xTooltipFormatter(row[xKey]) : null;
|
|
340
|
+
},
|
|
341
|
+
formatter: tooltipRow ?? seriesRow(series, formatValue)
|
|
342
|
+
})
|
|
343
|
+
}),
|
|
310
344
|
children,
|
|
311
345
|
/* @__PURE__ */ jsx(ChartLegend, {
|
|
312
|
-
content:
|
|
346
|
+
content: legend,
|
|
313
347
|
itemSorter: null
|
|
314
348
|
})
|
|
315
349
|
]
|
|
@@ -6,7 +6,7 @@ import { ReactNode } from "react";
|
|
|
6
6
|
*/
|
|
7
7
|
export type ChartColor = "var(--chart-1)" | "var(--chart-2)" | "var(--chart-3)" | "var(--chart-4)" | "var(--chart-5)" | "var(--muted-foreground)" | "var(--positive)" | "var(--negative)";
|
|
8
8
|
/** The fields of a row that hold numbers: the ones a series can plot. */
|
|
9
|
-
type NumericKey<T> = { [K in keyof T]-?: T[K] extends number | null | undefined ? K : never; }[keyof T] & string;
|
|
9
|
+
export type NumericKey<T> = { [K in keyof T]-?: T[K] extends number | null | undefined ? K : never; }[keyof T] & string;
|
|
10
10
|
/** One series: the field it plots, its name in the legend and tooltip, and its colour. */
|
|
11
11
|
export interface ChartSeriesItem<T> {
|
|
12
12
|
key: NumericKey<T>;
|
|
@@ -94,5 +94,4 @@ export interface NumericXProps {
|
|
|
94
94
|
* be drawn; "monotone", the default, smooths between them without overshooting a point.
|
|
95
95
|
*/
|
|
96
96
|
export type ChartCurve = "monotone" | "linear";
|
|
97
|
-
//#endregion
|
|
98
|
-
export {};
|
|
97
|
+
//#endregion
|