@siyahi/ui 0.1.9-next.3 → 0.1.9-next.30
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/DESIGN.md +170 -0
- package/README.md +94 -177
- package/THIRD_PARTY_NOTICES.md +11 -11
- package/agents/examples/accordion.tsx +39 -0
- package/agents/examples/alert.tsx +24 -0
- package/agents/examples/app-sidebar.tsx +40 -0
- package/agents/examples/avatar.tsx +24 -0
- package/agents/examples/badge.tsx +26 -0
- package/agents/examples/bar-list-labels.tsx +22 -0
- package/agents/examples/bar-list-sides.tsx +40 -0
- package/agents/examples/bar-list.tsx +24 -0
- package/agents/examples/breadcrumb.tsx +28 -0
- package/agents/examples/button-states.tsx +23 -0
- package/agents/examples/button.tsx +21 -0
- package/agents/examples/calendar.tsx +11 -0
- package/agents/examples/callout.tsx +33 -0
- package/agents/examples/card.tsx +36 -0
- package/agents/examples/change-bar.tsx +104 -0
- package/agents/examples/change-grid-money.tsx +36 -0
- package/agents/examples/change-grid.tsx +42 -0
- package/agents/examples/chart-area-log.tsx +45 -0
- package/agents/examples/chart-area.tsx +39 -0
- package/agents/examples/chart-bar-flows.tsx +32 -0
- package/agents/examples/chart-bar-hourly.tsx +28 -0
- package/agents/examples/chart-bar-losses.tsx +29 -0
- package/agents/examples/chart-bar-teams.tsx +72 -0
- package/agents/examples/chart-bar-years.tsx +40 -0
- package/agents/examples/chart-bar.tsx +56 -0
- package/agents/examples/chart-category-ticks.tsx +50 -0
- package/agents/examples/chart-line-events.tsx +47 -0
- package/agents/examples/chart-line-forecast.tsx +36 -0
- package/agents/examples/chart-line-log.tsx +39 -0
- package/agents/examples/chart-line-quiet.tsx +114 -0
- package/agents/examples/chart-line-timeline.tsx +41 -0
- package/agents/examples/chart-line.tsx +57 -0
- package/agents/examples/chart-panels.tsx +94 -0
- package/agents/examples/code-block.tsx +40 -0
- package/agents/examples/collapsible.tsx +18 -0
- package/agents/examples/command.tsx +29 -0
- package/agents/examples/context-menu.tsx +17 -0
- package/agents/examples/copy-button.tsx +8 -0
- package/agents/examples/data-bar.tsx +108 -0
- package/agents/examples/data-table-compact.tsx +96 -0
- package/agents/examples/data-table-filters.tsx +103 -0
- package/agents/examples/data-table.tsx +99 -0
- package/agents/examples/delta.tsx +18 -0
- package/agents/examples/dialog.tsx +28 -0
- package/agents/examples/distribution-bar-budget.tsx +30 -0
- package/agents/examples/distribution-bar-tug.tsx +74 -0
- package/agents/examples/drawdown-chart.tsx +35 -0
- package/agents/examples/dropdown-menu.tsx +31 -0
- package/agents/examples/field.tsx +108 -0
- package/agents/examples/formatters.tsx +42 -0
- package/agents/examples/heatmap-calendar-signed.tsx +67 -0
- package/agents/examples/heatmap-calendar.tsx +62 -0
- package/agents/examples/heatmap-status.tsx +61 -0
- package/agents/examples/heatmap-weekday.tsx +72 -0
- package/agents/examples/histogram-chart.tsx +28 -0
- package/agents/examples/input-states.tsx +23 -0
- package/agents/examples/input.tsx +17 -0
- package/agents/examples/local-time.tsx +14 -0
- package/agents/examples/metric-strip.tsx +46 -0
- package/agents/examples/overview-dashboard.tsx +180 -0
- package/agents/examples/page-hero.tsx +38 -0
- package/agents/examples/page-section.tsx +52 -0
- package/agents/examples/popover.tsx +23 -0
- package/agents/examples/price-chart.tsx +32 -0
- package/agents/examples/progress-tone.tsx +29 -0
- package/agents/examples/progress.tsx +10 -0
- package/agents/examples/range-position-table.tsx +101 -0
- package/agents/examples/range-position.tsx +55 -0
- package/agents/examples/scatter-chart-quadrants.tsx +63 -0
- package/agents/examples/scatter-chart-scales.tsx +46 -0
- package/agents/examples/scatter-chart.tsx +78 -0
- package/agents/examples/scroll-area.tsx +22 -0
- package/agents/examples/section-cards-select.tsx +28 -0
- package/agents/examples/section-cards-trend.tsx +32 -0
- package/agents/examples/section-cards.tsx +48 -0
- package/agents/examples/select.tsx +27 -0
- package/agents/examples/separator.tsx +13 -0
- package/agents/examples/sheet.tsx +15 -0
- package/agents/examples/skeleton.tsx +11 -0
- package/agents/examples/slider.tsx +5 -0
- package/agents/examples/slope-chart-market.tsx +33 -0
- package/agents/examples/slope-chart.tsx +26 -0
- package/agents/examples/stale-blocks.tsx +56 -0
- package/agents/examples/surfaces.tsx +116 -0
- package/agents/examples/table.tsx +60 -0
- package/agents/examples/tabs.tsx +16 -0
- package/agents/examples/target-rows.tsx +74 -0
- package/agents/examples/toggle-group.tsx +12 -0
- package/agents/examples/toggle.tsx +11 -0
- package/agents/examples/tooltip.tsx +13 -0
- package/agents/examples/treemap.tsx +93 -0
- package/agents/examples/waterfall-chart-stores.tsx +27 -0
- package/agents/examples/waterfall-chart.tsx +37 -0
- package/agents/manifest.json +1391 -0
- package/agents/report-rules.json +7 -0
- package/dist/components/registry/charts/area-chart-card.d.ts +7 -3
- package/dist/components/registry/charts/area-chart-card.js +56 -10
- package/dist/components/registry/charts/bar-chart-card.d.ts +1 -1
- package/dist/components/registry/charts/bar-chart-card.js +20 -22
- package/dist/components/registry/charts/line-chart-card.d.ts +3 -3
- package/dist/components/registry/charts/line-chart-card.js +44 -9
- package/dist/components/registry/dashboard-01/section-cards.d.ts +6 -0
- package/dist/components/registry/dashboard-01/section-cards.js +51 -35
- package/dist/components/registry/dashboardcn/bar-list.js +17 -10
- package/dist/components/registry/dashboardcn/distribution-bar.js +6 -4
- package/dist/components/registry/dashboardcn/kpi-row-card.d.ts +29 -0
- package/dist/components/registry/dashboardcn/kpi-row-card.js +81 -0
- package/dist/components/registry/dashboardcn/sparkline.d.ts +22 -0
- package/dist/components/registry/dashboardcn/sparkline.js +117 -0
- package/dist/components/registry/heatmap/calendar-heatmap.d.ts +11 -3
- package/dist/components/registry/heatmap/calendar-heatmap.js +164 -45
- package/dist/components/registry/heatmap/status-heatmap.d.ts +5 -3
- package/dist/components/registry/heatmap/status-heatmap.js +115 -54
- package/dist/components/registry/heatmap/weekday-heatmap.d.ts +9 -3
- package/dist/components/registry/heatmap/weekday-heatmap.js +83 -53
- package/dist/components/registry/niko-table/core/data-table-context.d.ts +18 -1
- package/dist/components/registry/niko-table/core/data-table-context.js +7 -1
- package/dist/components/registry/niko-table/core/data-table-grouped-row.js +3 -1
- package/dist/components/registry/niko-table/core/data-table-root.js +39 -4
- package/dist/components/registry/niko-table/core/data-table-structure.js +17 -12
- package/dist/components/registry/niko-table/core/data-table.d.ts +2 -2
- package/dist/components/registry/niko-table/core/data-table.js +5 -1
- package/dist/components/registry/niko-table/filters/table-faceted-filter.js +5 -5
- package/dist/components/registry/niko-table/filters/table-search-filter.js +1 -1
- package/dist/components/registry/niko-table/lib/flex-columns.d.ts +1 -1
- package/dist/components/registry/niko-table/lib/flex-columns.js +3 -3
- package/dist/components/registry/niko-table/lib/styles.d.ts +1 -1
- package/dist/components/registry/niko-table/lib/styles.js +3 -3
- package/dist/components/registry/niko-table/types/index.d.ts +9 -0
- package/dist/components/registry/niko-table/ui/table.js +2 -2
- package/dist/components/registry/sidebar-07/app-sidebar.d.ts +1 -1
- package/dist/components/registry/sidebar-07/app-sidebar.js +3 -1
- package/dist/components/registry/sidebar-07/nav-main.d.ts +2 -1
- package/dist/components/registry/sidebar-07/nav-main.js +16 -3
- package/dist/components/siyahi/callout.d.ts +17 -0
- package/dist/components/siyahi/callout.js +34 -0
- package/dist/components/siyahi/change-bar.d.ts +21 -0
- package/dist/components/siyahi/change-bar.js +35 -0
- package/dist/components/siyahi/change-grid.d.ts +31 -0
- package/dist/components/siyahi/change-grid.js +74 -0
- package/dist/components/siyahi/data-bar.d.ts +19 -0
- package/dist/components/siyahi/data-bar.js +29 -0
- package/dist/components/siyahi/data-table-compact-columns-toggle.d.ts +4 -0
- package/dist/components/siyahi/data-table-compact-columns-toggle.js +19 -0
- package/dist/components/siyahi/data-table-footnote.d.ts +12 -0
- package/dist/components/siyahi/data-table-footnote.js +35 -0
- package/dist/components/siyahi/default-sidebar-open.d.ts +8 -0
- package/dist/components/siyahi/default-sidebar-open.js +13 -0
- package/dist/components/siyahi/delta.d.ts +5 -1
- package/dist/components/siyahi/delta.js +14 -9
- 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/page-hero.d.ts +23 -0
- package/dist/components/siyahi/page-hero.js +43 -0
- package/dist/components/siyahi/page-section.d.ts +4 -1
- package/dist/components/siyahi/page-section.js +6 -3
- package/dist/components/siyahi/page-toc.d.ts +20 -0
- package/dist/components/siyahi/page-toc.js +76 -0
- package/dist/components/siyahi/panel-grid.d.ts +24 -0
- package/dist/components/siyahi/panel-grid.js +37 -0
- package/dist/components/siyahi/quote.d.ts +12 -0
- package/dist/components/siyahi/quote.js +23 -0
- package/dist/components/siyahi/range-position.d.ts +24 -0
- package/dist/components/siyahi/range-position.js +105 -0
- package/dist/components/siyahi/scale-toggle.d.ts +32 -0
- package/dist/components/siyahi/scale-toggle.js +61 -0
- package/dist/components/siyahi/scatter-chart.d.ts +69 -0
- package/dist/components/siyahi/scatter-chart.js +395 -0
- package/dist/components/siyahi/siyahi-provider.d.ts +15 -2
- package/dist/components/siyahi/siyahi-provider.js +17 -4
- package/dist/components/siyahi/slope-chart.d.ts +35 -0
- package/dist/components/siyahi/slope-chart.js +159 -0
- package/dist/components/siyahi/stale-note.d.ts +9 -0
- package/dist/components/siyahi/stale-note.js +12 -0
- package/dist/components/siyahi/status-alert.d.ts +15 -0
- package/dist/components/siyahi/status-alert.js +29 -0
- package/dist/components/siyahi/status-badge.d.ts +15 -0
- package/dist/components/siyahi/status-badge.js +24 -0
- package/dist/components/siyahi/target-rows.d.ts +34 -0
- package/dist/components/siyahi/target-rows.js +97 -0
- package/dist/components/siyahi/tone-progress.d.ts +1 -1
- package/dist/components/siyahi/tone-progress.js +1 -1
- package/dist/components/siyahi/treemap.d.ts +8 -5
- package/dist/components/siyahi/treemap.js +80 -34
- package/dist/components/siyahi/waterfall-chart.d.ts +51 -0
- package/dist/components/siyahi/waterfall-chart.js +147 -0
- package/dist/components/ui/accordion.js +5 -5
- package/dist/components/ui/alert.js +2 -2
- package/dist/components/ui/badge.js +1 -1
- package/dist/components/ui/breadcrumb.js +2 -2
- package/dist/components/ui/button.js +10 -10
- package/dist/components/ui/calendar.js +1 -1
- package/dist/components/ui/card.js +4 -4
- package/dist/components/ui/chart.js +1 -1
- package/dist/components/ui/code-block.js +13 -12
- package/dist/components/ui/command.js +7 -6
- package/dist/components/ui/context-menu.js +7 -7
- package/dist/components/ui/dialog.js +5 -5
- package/dist/components/ui/dropdown-menu.js +8 -8
- package/dist/components/ui/field.d.ts +26 -0
- package/dist/components/ui/field.js +109 -0
- package/dist/components/ui/input-group.js +11 -11
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/label.d.ts +5 -0
- package/dist/components/ui/label.js +13 -0
- package/dist/components/ui/popover.js +3 -3
- package/dist/components/ui/progress.js +1 -1
- package/dist/components/ui/select.js +6 -6
- package/dist/components/ui/sheet.js +5 -5
- package/dist/components/ui/sidebar.js +17 -18
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/slider.js +2 -2
- package/dist/components/ui/table.js +2 -2
- package/dist/components/ui/tabs.js +2 -2
- package/dist/components/ui/textarea.js +1 -1
- package/dist/components/ui/toggle-group.js +2 -2
- package/dist/components/ui/toggle.js +4 -4
- package/dist/components/ui/tooltip.js +2 -2
- package/dist/index.d.ts +35 -8
- package/dist/index.js +30 -4
- package/dist/lib/chart-frame.d.ts +51 -7
- package/dist/lib/chart-frame.js +390 -133
- package/dist/lib/chart-marks.d.ts +83 -0
- package/dist/lib/chart-marks.js +216 -0
- package/dist/lib/chart-series.d.ts +42 -10
- package/dist/lib/compact-columns.d.ts +19 -0
- package/dist/lib/compact-columns.js +55 -0
- package/dist/lib/fit-text.d.ts +6 -0
- package/dist/lib/fit-text.js +11 -0
- package/dist/lib/format.d.ts +8 -3
- package/dist/lib/format.js +55 -17
- package/dist/lib/heat.d.ts +7 -0
- package/dist/lib/heat.js +14 -0
- package/dist/lib/heatmap-navigation.d.ts +8 -0
- package/dist/lib/heatmap-navigation.js +49 -0
- package/dist/lib/scatter.d.ts +88 -0
- package/dist/lib/scatter.js +179 -0
- package/dist/lib/ticks.d.ts +27 -0
- package/dist/lib/ticks.js +67 -0
- package/dist/lib/tone.d.ts +36 -0
- package/dist/lib/tone.js +35 -0
- package/dist/lib/treemap.d.ts +0 -5
- package/dist/lib/treemap.js +1 -11
- package/dist/lib/use-element-width.d.ts +5 -0
- package/dist/lib/use-element-width.js +15 -0
- package/package.json +5 -1
- package/registry.lock.json +16 -0
- package/report.css +63 -47
- package/styles/siyahi.css +708 -55
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Card,
|
|
3
|
+
CardContent,
|
|
4
|
+
CardDescription,
|
|
5
|
+
CardHeader,
|
|
6
|
+
CardTitle,
|
|
7
|
+
TargetRows,
|
|
8
|
+
useFormat,
|
|
9
|
+
type TargetRow,
|
|
10
|
+
type TargetStatus,
|
|
11
|
+
} from "@siyahi/ui";
|
|
12
|
+
|
|
13
|
+
interface Team {
|
|
14
|
+
name: string;
|
|
15
|
+
costs: string;
|
|
16
|
+
/** The team's share of this year's spend so far and the budget's share, as fractions; made-up figures. */
|
|
17
|
+
weight: number;
|
|
18
|
+
target: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const teams: Team[] = [
|
|
22
|
+
{ name: "Engineering", costs: "Cloud hosting, tools, contractors", weight: 0.426, target: 0.4 },
|
|
23
|
+
{ name: "Marketing", costs: "Ads, events, design agency", weight: 0.189, target: 0.2 },
|
|
24
|
+
{ name: "Sales", costs: "Travel, commissions, CRM seats", weight: 0.194, target: 0.25 },
|
|
25
|
+
{ name: "Support", costs: "Help desk seats, training", weight: 0.093, target: 0.1 },
|
|
26
|
+
{ name: "Operations", costs: "Office rent, facilities", weight: 0.098, target: 0.05 },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
// Within two points of the budget is on target; past five is far enough to review it.
|
|
30
|
+
const NEAR = 0.02;
|
|
31
|
+
const FAR = 0.05;
|
|
32
|
+
|
|
33
|
+
const pts = (value: number) => `${(value * 100).toFixed(1)} pts`;
|
|
34
|
+
|
|
35
|
+
function statusOf({ weight, target }: Team): TargetStatus {
|
|
36
|
+
const gap = weight - target;
|
|
37
|
+
const size = `${pts(Math.abs(gap))} ${gap > 0 ? "over" : "under"}`;
|
|
38
|
+
if (Math.abs(gap) <= NEAR) return { kind: "met", label: "On target" };
|
|
39
|
+
if (Math.abs(gap) <= FAR) return { kind: "missed", label: size };
|
|
40
|
+
return { kind: "warning", label: `${size}, review` };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default function TargetRowsExample() {
|
|
44
|
+
const f = useFormat();
|
|
45
|
+
const rows: TargetRow[] = teams.map((team) => ({
|
|
46
|
+
label: team.name,
|
|
47
|
+
detail: team.costs,
|
|
48
|
+
value: team.weight,
|
|
49
|
+
target: team.target,
|
|
50
|
+
bands: [
|
|
51
|
+
[team.target - FAR, team.target + FAR],
|
|
52
|
+
[team.target - NEAR, team.target + NEAR],
|
|
53
|
+
],
|
|
54
|
+
status: statusOf(team),
|
|
55
|
+
}));
|
|
56
|
+
return (
|
|
57
|
+
<Card>
|
|
58
|
+
<CardHeader>
|
|
59
|
+
<CardTitle>Sales is 5.6 points under its budget</CardTitle>
|
|
60
|
+
<CardDescription>
|
|
61
|
+
Each team's share of spend against its share of the budget, on one 0–50% scale
|
|
62
|
+
</CardDescription>
|
|
63
|
+
</CardHeader>
|
|
64
|
+
<CardContent>
|
|
65
|
+
<div className="grid gap-2">
|
|
66
|
+
<p className="text-sm text-muted-foreground">
|
|
67
|
+
Bar: the share spent so far. Tall tick: the budgeted share. Shading: within 5 points of it, darker within 2.
|
|
68
|
+
</p>
|
|
69
|
+
<TargetRows rows={rows} domain={[0, 0.5]} valueFormatter={(value) => f.pct(value)} />
|
|
70
|
+
</div>
|
|
71
|
+
</CardContent>
|
|
72
|
+
</Card>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ToggleGroup, ToggleGroupItem } from "@siyahi/ui";
|
|
2
|
+
|
|
3
|
+
export default function ToggleGroupExample() {
|
|
4
|
+
return (
|
|
5
|
+
<ToggleGroup defaultValue={["1Y"]} variant="outline" size="sm" aria-label="Range">
|
|
6
|
+
<ToggleGroupItem value="1M">1M</ToggleGroupItem>
|
|
7
|
+
<ToggleGroupItem value="6M">6M</ToggleGroupItem>
|
|
8
|
+
<ToggleGroupItem value="1Y">1Y</ToggleGroupItem>
|
|
9
|
+
<ToggleGroupItem value="All">All</ToggleGroupItem>
|
|
10
|
+
</ToggleGroup>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Button, Tooltip, TooltipContent, TooltipTrigger } from "@siyahi/ui";
|
|
2
|
+
import { InfoIcon } from "lucide-react";
|
|
3
|
+
|
|
4
|
+
export default function TooltipExample() {
|
|
5
|
+
return (
|
|
6
|
+
<Tooltip>
|
|
7
|
+
<TooltipTrigger render={<Button variant="outline" size="icon" aria-label="About churn" />}>
|
|
8
|
+
<InfoIcon />
|
|
9
|
+
</TooltipTrigger>
|
|
10
|
+
<TooltipContent>Churn counts customers who did not renew this month.</TooltipContent>
|
|
11
|
+
</Tooltip>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Card,
|
|
3
|
+
CardContent,
|
|
4
|
+
CardDescription,
|
|
5
|
+
CardHeader,
|
|
6
|
+
CardTitle,
|
|
7
|
+
Tooltip,
|
|
8
|
+
TooltipContent,
|
|
9
|
+
TooltipTrigger,
|
|
10
|
+
Treemap,
|
|
11
|
+
TreemapLegend,
|
|
12
|
+
useFormat,
|
|
13
|
+
type TreemapItem,
|
|
14
|
+
} from "@siyahi/ui";
|
|
15
|
+
import { useState } from "react";
|
|
16
|
+
|
|
17
|
+
interface City extends TreemapItem {
|
|
18
|
+
channel: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// weight is the month's sales in ₹ and change their growth on the same month last year; Guwahati opened this year,
|
|
22
|
+
// so it has no last year to grow from. Mumbai sells online and in stores, so it draws two tiles under one name.
|
|
23
|
+
const cities: City[] = [
|
|
24
|
+
{ name: "Mumbai", key: "mumbai-online", channel: "Online", group: "West", weight: 224400, change: 0.38 },
|
|
25
|
+
{ name: "Mumbai", key: "mumbai-stores", channel: "Stores", group: "West", weight: 152000, change: 0.12 },
|
|
26
|
+
{ name: "Pune", channel: "Stores", group: "West", weight: 166000, change: 0.09 },
|
|
27
|
+
{ name: "Surat", channel: "Online", group: "West", weight: 98000, change: -0.21 },
|
|
28
|
+
{ name: "Bengaluru", channel: "Stores", group: "South", weight: 262500, change: -0.06 },
|
|
29
|
+
{ name: "Chennai", channel: "Stores", group: "South", weight: 258000, change: 0.44 },
|
|
30
|
+
{ name: "Kochi", channel: "Online", group: "South", weight: 87000, change: 0.58 },
|
|
31
|
+
{ name: "Delhi", channel: "Stores", group: "North", weight: 276000, change: 0.27 },
|
|
32
|
+
{ name: "Jaipur", channel: "Online", group: "North", weight: 64000, change: -0.33 },
|
|
33
|
+
{ name: "Kolkata", channel: "Stores", group: "East", weight: 255600, change: 0.16 },
|
|
34
|
+
{ name: "Guwahati", channel: "Online", group: "Northeast", weight: 52000, change: null },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export default function TreemapExample() {
|
|
38
|
+
const [hovered, setHovered] = useState<City | null>(null);
|
|
39
|
+
const [selected, setSelected] = useState<City | null>(null);
|
|
40
|
+
const { money, pct } = useFormat();
|
|
41
|
+
const figures = (c: City) =>
|
|
42
|
+
`${money(c.weight)} · ${c.change === null ? "new this year" : `${c.change < 0 ? "\u2212" : "+"}${pct(Math.abs(c.change))}`}`;
|
|
43
|
+
return (
|
|
44
|
+
<Card>
|
|
45
|
+
<CardHeader>
|
|
46
|
+
<CardTitle>Sales by region</CardTitle>
|
|
47
|
+
<CardDescription>
|
|
48
|
+
Area is the city's sales this month; colour is its growth on last year, deepest at ±60%
|
|
49
|
+
</CardDescription>
|
|
50
|
+
</CardHeader>
|
|
51
|
+
<CardContent>
|
|
52
|
+
<Tooltip open={hovered !== null} trackCursorAxis="both">
|
|
53
|
+
<TooltipTrigger render={<div />}>
|
|
54
|
+
<Treemap
|
|
55
|
+
items={cities}
|
|
56
|
+
height={320}
|
|
57
|
+
range={0.6}
|
|
58
|
+
onHover={setHovered}
|
|
59
|
+
selected={selected}
|
|
60
|
+
onSelect={setSelected}
|
|
61
|
+
/>
|
|
62
|
+
</TooltipTrigger>
|
|
63
|
+
<TooltipContent side="bottom">
|
|
64
|
+
<div className="flex flex-col items-start">
|
|
65
|
+
{hovered && (
|
|
66
|
+
<>
|
|
67
|
+
<span className="font-medium">
|
|
68
|
+
{hovered.name} · {hovered.channel}
|
|
69
|
+
</span>
|
|
70
|
+
<span>{hovered.group}</span>
|
|
71
|
+
<span>{figures(hovered)}</span>
|
|
72
|
+
</>
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
75
|
+
</TooltipContent>
|
|
76
|
+
</Tooltip>
|
|
77
|
+
<TreemapLegend range={0.6} className="mt-3 ml-auto" />
|
|
78
|
+
<p data-slot="treemap-selection" aria-live="polite" className="mt-3 text-sm tabular-nums">
|
|
79
|
+
{selected ? (
|
|
80
|
+
<>
|
|
81
|
+
<span className="font-medium">
|
|
82
|
+
{selected.name} · {selected.channel}
|
|
83
|
+
</span>{" "}
|
|
84
|
+
· {selected.group} · {figures(selected)}
|
|
85
|
+
</>
|
|
86
|
+
) : (
|
|
87
|
+
<span className="text-muted-foreground">Tap a tile for its figures</span>
|
|
88
|
+
)}
|
|
89
|
+
</p>
|
|
90
|
+
</CardContent>
|
|
91
|
+
</Card>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { WaterfallChartCard, useFormat, type WaterfallStep } from "@siyahi/ui";
|
|
2
|
+
|
|
3
|
+
// Revenue from last year to this, store by store; made-up figures.
|
|
4
|
+
const steps: WaterfallStep[] = [
|
|
5
|
+
{ kind: "total", label: "Last year", value: 4_820_000 },
|
|
6
|
+
{ kind: "change", label: "Koramangala flagship", value: 640_000 },
|
|
7
|
+
{ kind: "change", label: "Indiranagar high street", value: 310_000 },
|
|
8
|
+
{ kind: "change", label: "Whitefield mall kiosk", value: -420_000 },
|
|
9
|
+
{ kind: "change", label: "Online orders and delivery", value: 880_000 },
|
|
10
|
+
{ kind: "change", label: "Jayanagar (closed in June)", value: -560_000 },
|
|
11
|
+
{ kind: "total", label: "This year" },
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
export default function WaterfallChartStoresExample() {
|
|
15
|
+
const { money, moneyCompact } = useFormat();
|
|
16
|
+
return (
|
|
17
|
+
<WaterfallChartCard
|
|
18
|
+
title="Revenue, last year to this"
|
|
19
|
+
description="What each store added or lost on the way from last year's total to this year's"
|
|
20
|
+
steps={steps}
|
|
21
|
+
horizontal
|
|
22
|
+
valueFormatter={money}
|
|
23
|
+
yTickFormatter={moneyCompact}
|
|
24
|
+
height={steps.length * 48 + 64}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { WaterfallChartCard, useFormat, type WaterfallStep } from "@siyahi/ui";
|
|
2
|
+
|
|
3
|
+
// A bakery's profit for the year, April to March, month by month; made-up figures.
|
|
4
|
+
const months: [string, number][] = [
|
|
5
|
+
["Apr", 42000],
|
|
6
|
+
["May", 38000],
|
|
7
|
+
["Jun", -12000],
|
|
8
|
+
["Jul", 26000],
|
|
9
|
+
["Aug", 31000],
|
|
10
|
+
["Sep", -8000],
|
|
11
|
+
["Oct", 54000],
|
|
12
|
+
["Nov", 61000],
|
|
13
|
+
["Dec", 72000],
|
|
14
|
+
["Jan", -21000],
|
|
15
|
+
["Feb", 18000],
|
|
16
|
+
["Mar", 35000],
|
|
17
|
+
];
|
|
18
|
+
const steps: WaterfallStep[] = [
|
|
19
|
+
...months.map(([label, value]): WaterfallStep => ({ kind: "change", label, value })),
|
|
20
|
+
// No value: the year's total is wherever the months left it.
|
|
21
|
+
{ kind: "total", label: "Year" },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export default function WaterfallChartExample() {
|
|
25
|
+
const { money, moneyCompact } = useFormat();
|
|
26
|
+
return (
|
|
27
|
+
<WaterfallChartCard
|
|
28
|
+
title="Profit for the year, month by month"
|
|
29
|
+
description="April to March, before tax. Each bar starts where the month before left off."
|
|
30
|
+
steps={steps}
|
|
31
|
+
labels={{ rise: "Profit", fall: "Loss", total: "Year to date" }}
|
|
32
|
+
valueFormatter={money}
|
|
33
|
+
yTickFormatter={moneyCompact}
|
|
34
|
+
height={300}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|