@squadbase/vantage 0.6.2-dev1.42c4e48 → 0.6.2-dev1.72360fb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-MFWRPYKW.js → build-X5NVCQKT.js} +4 -4
- package/dist/{build-MFWRPYKW.js.map → build-X5NVCQKT.js.map} +1 -1
- package/dist/chunk-2IAPIOPS.js +152 -0
- package/dist/chunk-2IAPIOPS.js.map +1 -0
- package/dist/{chunk-IBGOCWJB.js → chunk-2ICNHUG6.js} +186 -82
- package/dist/chunk-2ICNHUG6.js.map +1 -0
- package/dist/{chunk-5ZOP4SQR.js → chunk-2N72FKLB.js} +12 -7
- package/dist/chunk-2N72FKLB.js.map +1 -0
- package/dist/chunk-57GHR5LN.js +163 -0
- package/dist/chunk-57GHR5LN.js.map +1 -0
- package/dist/chunk-6OTTGAPO.js +44 -0
- package/dist/chunk-6OTTGAPO.js.map +1 -0
- package/dist/{chunk-OB6UBJXF.js → chunk-7S52M2SL.js} +127 -36
- package/dist/chunk-7S52M2SL.js.map +1 -0
- package/dist/chunk-JXFCSF3K.js +673 -0
- package/dist/chunk-JXFCSF3K.js.map +1 -0
- package/dist/{chunk-PXRX5PEC.js → chunk-PDOBHMUQ.js} +3 -3
- package/dist/chunk-PDOBHMUQ.js.map +1 -0
- package/dist/chunk-QOXXOFGL.js +7051 -0
- package/dist/chunk-QOXXOFGL.js.map +1 -0
- package/dist/{chunk-A2UUGASH.js → chunk-U736PVHY.js} +2 -2
- package/dist/chunk-U736PVHY.js.map +1 -0
- package/dist/{chunk-QEWCYW3I.js → chunk-WAMZWZJB.js} +13 -3
- package/dist/chunk-WAMZWZJB.js.map +1 -0
- package/dist/cli.js +3 -3
- package/dist/components/index.d.ts +1596 -100
- package/dist/components/index.js +7 -4
- package/dist/delta-text-CvwBGJ95.d.ts +15 -0
- package/dist/{dev-DCTOHQ6W.js → dev-4XEDTELV.js} +4 -4
- package/dist/{dev-DCTOHQ6W.js.map → dev-4XEDTELV.js.map} +1 -1
- package/dist/doc/index.d.ts +215 -2
- package/dist/doc/index.js +302 -5
- package/dist/doc/index.js.map +1 -1
- package/dist/format-U0cQl069.d.ts +243 -0
- package/dist/markdown/index.js +1 -1
- package/dist/markdown/index.js.map +1 -1
- package/dist/slide/index.d.ts +272 -1
- package/dist/slide/index.js +968 -3
- package/dist/slide/index.js.map +1 -1
- package/dist/table/index.js +9 -6
- package/dist/table/index.js.map +1 -1
- package/dist/ui/index.d.ts +8 -2
- package/dist/ui/index.js +22 -112
- package/dist/ui/index.js.map +1 -1
- package/dist/{upgrade-DBBE6GIR.js → upgrade-JHXZBGQS.js} +3 -3
- package/dist/{upgrade-DBBE6GIR.js.map → upgrade-JHXZBGQS.js.map} +1 -1
- package/dist/vite/index.js +2 -2
- package/docs/en/components.md +42 -17
- package/docs/en/doc/delta-text.md +40 -0
- package/docs/en/doc/doc-action-items.md +49 -0
- package/docs/en/doc/doc-callout.md +38 -0
- package/docs/en/doc/doc-data-table.md +60 -0
- package/docs/en/doc/doc-executive-summary.md +64 -0
- package/docs/en/doc/doc-figure.md +56 -0
- package/docs/en/doc/doc-key-findings.md +61 -0
- package/docs/en/doc/doc-kpi-scorecard.md +80 -0
- package/docs/en/doc/doc-notes-and-sources.md +43 -0
- package/docs/en/doc/doc-report-header.md +46 -0
- package/docs/en/parts/area-chart.md +99 -0
- package/docs/en/parts/bar-chart.md +91 -0
- package/docs/en/parts/bar-list.md +50 -0
- package/docs/en/parts/category-bar.md +37 -0
- package/docs/en/parts/chart-frame.md +39 -0
- package/docs/en/parts/data-table.md +22 -0
- package/docs/en/parts/delta.md +51 -0
- package/docs/en/parts/donut-chart.md +72 -0
- package/docs/en/parts/format.md +43 -0
- package/docs/en/parts/funnel-steps.md +2 -1
- package/docs/en/parts/heatmap.md +53 -0
- package/docs/en/parts/kpi-card.md +58 -0
- package/docs/en/parts/legend.md +35 -0
- package/docs/en/parts/line-chart.md +94 -0
- package/docs/en/parts/metric-value.md +3 -2
- package/docs/en/parts/progress-circle.md +33 -0
- package/docs/en/parts/sample-data.md +39 -0
- package/docs/en/parts/scatter-chart.md +56 -0
- package/docs/en/parts/sparkline.md +1 -1
- package/docs/en/parts/tracker.md +36 -0
- package/docs/en/parts/trend-indicator.md +17 -1
- package/docs/en/parts/updated-at.md +30 -0
- package/docs/en/parts/waterfall-chart.md +56 -0
- package/docs/en/slide/slide-chart-full.md +48 -0
- package/docs/en/slide/slide-chart-insight.md +52 -0
- package/docs/en/slide/slide-columns.md +46 -0
- package/docs/en/slide/slide-comparison.md +68 -0
- package/docs/en/slide/slide-cover.md +39 -0
- package/docs/en/slide/slide-exec-summary.md +47 -0
- package/docs/en/slide/slide-heading.md +38 -0
- package/docs/en/slide/slide-kpi-grid.md +55 -0
- package/docs/en/slide/slide-kpi-hero.md +58 -0
- package/docs/en/slide/slide-next-actions.md +49 -0
- package/docs/en/slide/slide-scorecard-table.md +54 -0
- package/docs/en/slide/slide-section.md +44 -0
- package/docs/en/slide/slide-source-line.md +34 -0
- package/docs/en/ui/alert-dialog.md +42 -0
- package/docs/en/ui/avatar.md +31 -0
- package/docs/en/ui/combobox.md +74 -0
- package/docs/en/ui/drawer.md +41 -0
- package/docs/en/ui/empty.md +1 -1
- package/docs/en/ui/error-state.md +4 -3
- package/docs/en/ui/field.md +42 -0
- package/docs/en/ui/hover-card.md +21 -0
- package/docs/en/ui/kbd.md +17 -0
- package/docs/en/ui/loading.md +1 -1
- package/docs/en/ui/pagination.md +36 -0
- package/docs/en/ui/radio-group.md +21 -0
- package/docs/en/ui/toast.md +44 -0
- package/docs/en/ui/toggle-group.md +4 -3
- package/docs/en/ui-and-theming.md +1 -1
- package/docs/index.json +917 -77
- package/docs/ja/components.md +39 -16
- package/docs/ja/doc/delta-text.md +40 -0
- package/docs/ja/doc/doc-action-items.md +49 -0
- package/docs/ja/doc/doc-callout.md +38 -0
- package/docs/ja/doc/doc-data-table.md +60 -0
- package/docs/ja/doc/doc-executive-summary.md +64 -0
- package/docs/ja/doc/doc-figure.md +56 -0
- package/docs/ja/doc/doc-key-findings.md +61 -0
- package/docs/ja/doc/doc-kpi-scorecard.md +80 -0
- package/docs/ja/doc/doc-notes-and-sources.md +43 -0
- package/docs/ja/doc/doc-report-header.md +46 -0
- package/docs/ja/parts/area-chart.md +49 -25
- package/docs/ja/parts/bar-chart.md +50 -24
- package/docs/ja/parts/bar-list.md +31 -8
- package/docs/ja/parts/chart-frame.md +36 -0
- package/docs/ja/parts/data-table.md +22 -0
- package/docs/ja/parts/delta.md +51 -0
- package/docs/ja/parts/donut-chart.md +45 -26
- package/docs/ja/parts/format.md +44 -0
- package/docs/ja/parts/funnel-steps.md +27 -8
- package/docs/ja/parts/heatmap.md +45 -0
- package/docs/ja/parts/kpi-card.md +56 -0
- package/docs/ja/parts/legend.md +36 -0
- package/docs/ja/parts/line-chart.md +48 -22
- package/docs/ja/parts/metric-value.md +3 -2
- package/docs/ja/parts/sample-data.md +61 -0
- package/docs/ja/parts/scatter-chart.md +69 -0
- package/docs/ja/parts/sparkline.md +1 -1
- package/docs/ja/parts/trend-indicator.md +17 -1
- package/docs/ja/parts/updated-at.md +27 -0
- package/docs/ja/parts/waterfall-chart.md +61 -0
- package/docs/ja/slide/slide-chart-full.md +48 -0
- package/docs/ja/slide/slide-chart-insight.md +52 -0
- package/docs/ja/slide/slide-columns.md +46 -0
- package/docs/ja/slide/slide-comparison.md +68 -0
- package/docs/ja/slide/slide-cover.md +39 -0
- package/docs/ja/slide/slide-exec-summary.md +47 -0
- package/docs/ja/slide/slide-heading.md +38 -0
- package/docs/ja/slide/slide-kpi-grid.md +55 -0
- package/docs/ja/slide/slide-kpi-hero.md +58 -0
- package/docs/ja/slide/slide-next-actions.md +49 -0
- package/docs/ja/slide/slide-scorecard-table.md +54 -0
- package/docs/ja/slide/slide-section.md +44 -0
- package/docs/ja/slide/slide-source-line.md +34 -0
- package/docs/ja/ui/empty.md +1 -1
- package/docs/ja/ui/error-state.md +4 -3
- package/docs/ja/ui/loading.md +1 -1
- package/docs/ja/ui/toggle-group.md +4 -3
- package/docs/ja/ui-and-theming.md +2 -2
- package/package.json +26 -24
- package/registry/ui/accordion.tsx +4 -2
- package/registry/ui/alert-dialog.tsx +3 -3
- package/registry/ui/alert.tsx +3 -1
- package/registry/ui/app-shell.tsx +7 -1
- package/registry/ui/area-chart.tsx +2852 -166
- package/registry/ui/attention-list.tsx +303 -0
- package/registry/ui/avatar.tsx +1 -1
- package/registry/ui/badge.tsx +3 -1
- package/registry/ui/bar-chart.tsx +2851 -166
- package/registry/ui/bar-list.tsx +3531 -90
- package/registry/ui/box-plot-chart.tsx +3906 -0
- package/registry/ui/breadcrumb.tsx +3 -1
- package/registry/ui/button.tsx +3 -1
- package/registry/ui/calendar.tsx +3 -1
- package/registry/ui/card.tsx +4 -2
- package/registry/ui/category-bar.tsx +1025 -16
- package/registry/ui/chart-frame.tsx +1393 -0
- package/registry/ui/checkbox.tsx +3 -1
- package/registry/ui/collapsible.tsx +3 -1
- package/registry/ui/combobox.tsx +2 -2
- package/registry/ui/command.tsx +3 -1
- package/registry/ui/dashboard-card.tsx +71 -28
- package/registry/ui/data-table.tsx +678 -56
- package/registry/ui/date-range-picker.tsx +245 -64
- package/registry/ui/delta.tsx +191 -0
- package/registry/ui/dialog.tsx +5 -3
- package/registry/ui/donut-chart.tsx +2929 -182
- package/registry/ui/drawer.tsx +1 -1
- package/registry/ui/dropdown-menu.tsx +5 -3
- package/registry/ui/echart.tsx +621 -67
- package/registry/ui/field.tsx +1 -1
- package/registry/ui/filter-bar.tsx +33 -6
- package/registry/ui/funnel-steps.tsx +3344 -49
- package/registry/ui/heatmap.tsx +1786 -0
- package/registry/ui/histogram-chart.tsx +3986 -0
- package/registry/ui/hover-card.tsx +2 -2
- package/registry/ui/input-group.tsx +3 -1
- package/registry/ui/input.tsx +3 -1
- package/registry/ui/kbd.tsx +3 -1
- package/registry/ui/kpi-card.tsx +704 -0
- package/registry/ui/label.tsx +3 -1
- package/registry/ui/legend.tsx +3563 -0
- package/registry/ui/line-chart.tsx +2852 -160
- package/registry/ui/metric-value.tsx +9 -1
- package/registry/ui/multi-select.tsx +11 -5
- package/registry/ui/page-shell.tsx +106 -51
- package/registry/ui/pagination.tsx +3 -1
- package/registry/ui/paired-chart.tsx +3827 -0
- package/registry/ui/placeholder.tsx +8 -2
- package/registry/ui/popover.tsx +4 -2
- package/registry/ui/progress-circle.tsx +607 -12
- package/registry/ui/progress.tsx +3 -1
- package/registry/ui/radio-group.tsx +1 -1
- package/registry/ui/sample-data.tsx +86 -0
- package/registry/ui/scatter-chart.tsx +4212 -0
- package/registry/ui/scroll-area.tsx +3 -2
- package/registry/ui/searchable-select.tsx +8 -3
- package/registry/ui/section-header.tsx +5 -3
- package/registry/ui/segmented-control.tsx +7 -2
- package/registry/ui/select.tsx +4 -2
- package/registry/ui/separator.tsx +3 -1
- package/registry/ui/sheet.tsx +4 -2
- package/registry/ui/sidebar.tsx +4 -2
- package/registry/ui/skeleton.tsx +4 -2
- package/registry/ui/slider.tsx +4 -2
- package/registry/ui/sparkline.tsx +84 -9
- package/registry/ui/spinner.tsx +3 -1
- package/registry/ui/states.tsx +34 -5
- package/registry/ui/status-badge.tsx +83 -41
- package/registry/ui/switch.tsx +3 -1
- package/registry/ui/table.tsx +4 -2
- package/registry/ui/tabs.tsx +5 -3
- package/registry/ui/textarea.tsx +3 -1
- package/registry/ui/toast.tsx +2 -2
- package/registry/ui/toggle-group.tsx +3 -1
- package/registry/ui/toggle.tsx +3 -1
- package/registry/ui/tooltip.tsx +10 -4
- package/registry/ui/tracker.tsx +632 -19
- package/registry/ui/trend-indicator.tsx +15 -3
- package/registry/ui/updated-at.tsx +122 -0
- package/registry/ui/waterfall-chart.tsx +4248 -0
- package/skills/vantage-design/SKILL.md +34 -24
- package/skills/vantage-design/references/extract.md +16 -14
- package/skills/vantage-design/references/format.md +6 -5
- package/skills/vantage-design/references/presets.md +60 -110
- package/skills/vantage-slide/SKILL.md +54 -36
- package/templates/AGENTS.md +15 -3
- package/templates/agents/doc.md +48 -0
- package/templates/agents/page.md +32 -1
- package/templates/agents/slide.md +70 -2
- package/theme.css +244 -149
- package/dist/chunk-5ZOP4SQR.js.map +0 -1
- package/dist/chunk-A2UUGASH.js.map +0 -1
- package/dist/chunk-AG6RZ2RR.js +0 -3208
- package/dist/chunk-AG6RZ2RR.js.map +0 -1
- package/dist/chunk-IBGOCWJB.js.map +0 -1
- package/dist/chunk-OB6UBJXF.js.map +0 -1
- package/dist/chunk-PXRX5PEC.js.map +0 -1
- package/dist/chunk-QEWCYW3I.js.map +0 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# DocReportHeader
|
|
2
|
+
|
|
3
|
+
> The opening of a document — title, subtitle, period, as-of, author and source.
|
|
4
|
+
|
|
5
|
+
The section that opens a document: an `h1` title and a short fact sheet (`dl`) of period, data as-of, author and source. It is the only block that owns the `h1`; the rest start at `h2`.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { DocReportHeader } from "@squadbase/vantage/doc";
|
|
9
|
+
import type { DocReportHeaderProps } from "@squadbase/vantage/doc";
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
> [!NOTE]
|
|
13
|
+
> This is **one section to place directly under `<Document>`**. The document sets heading and body sizes and the width, so no dimensions are set here. `subtitle` is a `string` or a `ReactNode`; Markdown strings are not parsed. The fact labels this block prints ("対象期間", "データ時点", "作成者", "出典") are fixed in Japanese and cannot be overridden, so an English page shows them in Japanese. For the whole page, see [Document](page-types/doc).
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Description |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| `title` | `string` | The document title (`h1`). State the subject and period, not a slogan. **Required.** |
|
|
20
|
+
| `subtitle` | `ReactNode` | One line under the title (who it is for, …). A `string` or a `ReactNode`. |
|
|
21
|
+
| `period` | `string` | The period the numbers cover ("2026 年 9 月", "2026-07-01 〜 2026-09-30"). |
|
|
22
|
+
| `asOf` | `string` | The date the data was taken, as a date only ("2026-10-03"). The block adds the label "データ時点". |
|
|
23
|
+
| `author` | `string` | Author. |
|
|
24
|
+
| `source` | `string` | Where the numbers come from ("受注管理システム、会計システム"), as one string. |
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { Document, DocReportHeader } from "@squadbase/vantage/doc";
|
|
30
|
+
|
|
31
|
+
<Document>
|
|
32
|
+
<DocReportHeader
|
|
33
|
+
title="2026 年 9 月 月次事業報告"
|
|
34
|
+
subtitle="経営会議向け"
|
|
35
|
+
period="2026-09-01 〜 2026-09-30"
|
|
36
|
+
asOf="2026-10-03"
|
|
37
|
+
author="事業企画チーム"
|
|
38
|
+
source="受注管理システム、会計システム"
|
|
39
|
+
/>
|
|
40
|
+
</Document>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Notes
|
|
44
|
+
|
|
45
|
+
- An empty fact is left out, row and all, instead of showing "—".
|
|
46
|
+
- When printed, the whole header stays on one page; it does not break across pages.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# AreaChart
|
|
2
|
+
|
|
3
|
+
> A typed area chart for trends over time. Pass rows, the x-axis column and the series columns.
|
|
4
|
+
|
|
5
|
+
Draws a trend as filled areas. Instead of building an ECharts option, pass **the rows (`data`), the
|
|
6
|
+
x-axis column (`index`) and the series columns (`categories`)**; the legend, tooltip and axis
|
|
7
|
+
formats come with it. Colours follow the `--chart-1` … `--chart-5` tokens in fixed order and track
|
|
8
|
+
light / dark. Under the hood it is an [`EChart`](parts/echart) inside a chart frame
|
|
9
|
+
(title, summary, loading skeleton, empty state). The value axis always starts at 0.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { AreaChart } from "@squadbase/vantage/components";
|
|
13
|
+
import type { AreaChartProps, ChartEventPayload } from "@squadbase/vantage/components";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
| Prop | Type | Default | Description |
|
|
17
|
+
| --- | --- | --- | --- |
|
|
18
|
+
| `data` | `Record<string, unknown>[]` | | An array of rows. **Required.** One row is one x-axis point. Numeric columns are a number or a numeric string (such as a SQL DECIMAL); anything else counts as a gap. |
|
|
19
|
+
| `index` | `string` | | The column used for the x axis. **Required.** |
|
|
20
|
+
| `categories` | `string[]` | | The columns drawn as series. **Required.** Their order is the legend and colour order. Six or more fold into the five largest by total plus an Other series. |
|
|
21
|
+
| `areaOptions` | `AreaChartOptions` | | Area-specific settings: `{ type, curveType, fill, connectNulls }`. **Prefer this.** Takes precedence over the deprecated flat props of the same name. See below. |
|
|
22
|
+
| `forecast` | `ChartForecast` | | A forecast continuing one series: `{ data, category?, label? }`. `data` rows share the `index` key and carry the predicted value and an optional range. Always drawn as a dashed, lighter line. |
|
|
23
|
+
| `comparison` | `ChartComparison` | | Turns one of `categories` into a comparison line (prior year, plan…): `{ category, vs: "prior-period" \| "prior-year" \| "target" \| "custom", label? }`. Drawn as a thin grey line with no fill; the tooltip adds the main series' difference from it. `label` is required for `custom`. |
|
|
24
|
+
| `colors` | `ChartColors` | `["chart-1", …, "chart-5"]` | Series colours: `"chart-1"` … `"chart-5"` or a semantic tone (`"positive"` / `"warning"` / `"negative"` / `"neutral"`). An array follows series order; a record is keyed by series name. |
|
|
25
|
+
| `labels` | `Record<string, string>` | | Maps `index` values and series names to display names (axes, legend, tooltip, data table). |
|
|
26
|
+
| `format` | `ValueFormat` | `"compact"` | Number format: `"compact"` / `"number"` / `"currency"` / `"percent"` / `"multiple"` / `"duration"`, or `{ type, digits, currency, notation, unit, divisor, durationUnit }`. Same values as the KPI components. Axes use a short form; the tooltip uses the same format. |
|
|
27
|
+
| `valueFormatter` | `(value: number) => string` | | A function escape hatch for the format. Takes precedence over `format`; kept for compatibility. |
|
|
28
|
+
| `title` | `string` | | The chart heading. It labels the plot area for screen readers. |
|
|
29
|
+
| `summary` | `string \| "auto"` | | A one-sentence summary shown under the title and used as the plot's `aria-describedby`. `"auto"` builds one from `data`. Omitted means no summary. |
|
|
30
|
+
| `isLoading` | `boolean` | | Show a skeleton shaped like the final chart, at the same height. |
|
|
31
|
+
| `emptyState` | `ChartEmptyState` | | What to show when `data` is empty: `{ title?, description?, action? }`. The frame keeps its height. `action` takes one node, such as a button. |
|
|
32
|
+
| `height` | `number \| string` | `288` | Plot-area height in px. A CSS length string is accepted for compatibility only and is deprecated; pass a number. |
|
|
33
|
+
| `actions` | `boolean \| { includeTitle?: boolean }` | `false` | Show PNG save / copy buttons at the top right on hover. The PNG includes the title and summary unless you pass `{ includeTitle: false }`. |
|
|
34
|
+
| `fileName` | `string` | `"chart.png"` | File name for the saved PNG. Use with `actions`. |
|
|
35
|
+
| `chartOptions` | `EChartsOption` | | An escape hatch deep-merged last into the generated ECharts option. |
|
|
36
|
+
| `highlight` | `"auto" \| "none"` | `"auto"` | Label the max and latest value (first series only, two series or fewer). For `percent` stacking it labels the first and latest share of the bottom band. |
|
|
37
|
+
| `provisionalFrom` | `string \| number` | | An `index` value; points from here on are provisional and drawn lighter or dashed. Distinct from `forecast`. |
|
|
38
|
+
| `provisionalLabel` | `string` | | Name of the provisional range in legend and tooltip. |
|
|
39
|
+
| `target` | `number` | | A target value, drawn as a dotted horizontal line. The value axis always includes it. |
|
|
40
|
+
| `targetLabel` | `string` | | Label for the target line. |
|
|
41
|
+
| `annotations` | `ChartAnnotation[]` | | Notes at given positions: `{ at, label, to? }`. `at` / `to` are `index` values; with `to` it becomes a band, otherwise a vertical line. |
|
|
42
|
+
| `showLegend` | `boolean` | `true` | Show the legend. |
|
|
43
|
+
| `showTooltip` | `boolean` | `true` | Show the tooltip on hover. |
|
|
44
|
+
| `showGridLines` | `boolean` | `true` | Grid lines on the value axis. |
|
|
45
|
+
| `showXAxis` | `boolean` | `true` | Show the x axis. |
|
|
46
|
+
| `showYAxis` | `boolean` | `true` | Show the y axis. |
|
|
47
|
+
| `startEndOnly` | `boolean` | `false` | Label only the first and last x-axis ticks. |
|
|
48
|
+
| `yAxisWidth` | `number` | | Width of the y-axis labels (px). Fix it to align plot areas across stacked charts. |
|
|
49
|
+
| `minValue` | `number` | | Lower bound of the value axis. Area charts always start at 0, so only values of 0 or below take effect (room under negative values). |
|
|
50
|
+
| `maxValue` | `number` | | Upper bound of the value axis. The axis widens if the data exceeds it. Pass the same value to charts you compare side by side. |
|
|
51
|
+
| `allowDecimals` | `boolean` | `true` | `false` limits ticks to integers. |
|
|
52
|
+
| `xAxisLabel` | `string` | | Name of the x axis. |
|
|
53
|
+
| `yAxisLabel` | `string` | | Name of the y axis. |
|
|
54
|
+
| `onValueChange` | `(value: ChartEventPayload \| null) => void` | | Called on a click. Receives the clicked row plus `eventType` and `categoryClicked` (the series name); clicking the same point again passes `null`. When set, everything but the selection dims. |
|
|
55
|
+
| `ariaLabel` | `string` | | Screen-reader label for the plot area when there is no `title`. |
|
|
56
|
+
| `className` | `string` | | Classes to add (to the outer `<figure>`). |
|
|
57
|
+
| `type` | `"default" \| "stacked" \| "percent"` | | **Deprecated.** Use `areaOptions.type`. |
|
|
58
|
+
| `curveType` | `"linear" \| "smooth" \| "step"` | | **Deprecated.** Use `areaOptions.curveType`. |
|
|
59
|
+
| `fill` | `"gradient" \| "solid" \| "none"` | | **Deprecated.** Use `areaOptions.fill`. |
|
|
60
|
+
| `connectNulls` | `boolean` | | **Deprecated.** Use `areaOptions.connectNulls`. |
|
|
61
|
+
| `loading` | `boolean` | | **Deprecated.** Use `isLoading`. |
|
|
62
|
+
|
|
63
|
+
## areaOptions
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Default | Description |
|
|
66
|
+
| --- | --- | --- | --- |
|
|
67
|
+
| `type` | `"default" \| "stacked" \| "percent"` | `"default"` | `stacked` stacks the series; `percent` stacks them as shares of each point's total (the tooltip still shows the original values). |
|
|
68
|
+
| `curveType` | `"linear" \| "smooth" \| "step"` | `"linear"` | The line shape. |
|
|
69
|
+
| `fill` | `"gradient" \| "solid" \| "none"` | `"gradient"` | How the area is filled. |
|
|
70
|
+
| `connectNulls` | `boolean` | `false` | Join the line across gaps (`null` values). |
|
|
71
|
+
|
|
72
|
+
> [!WARNING]
|
|
73
|
+
> The flat `type`, `curveType`, `fill` and `connectNulls` props still work but are **deprecated**. Use
|
|
74
|
+
> `areaOptions`; when both are given, `areaOptions` wins.
|
|
75
|
+
|
|
76
|
+
## Showing a change in composition
|
|
77
|
+
|
|
78
|
+
`areaOptions.type: "percent"` stacks each point to 100%. The value axis is fixed to 0–100%, and the
|
|
79
|
+
tooltip shows the **original values**.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
<AreaChart
|
|
83
|
+
data={rows}
|
|
84
|
+
index="month"
|
|
85
|
+
categories={["Online", "Store"]}
|
|
86
|
+
areaOptions={{ type: "percent" }}
|
|
87
|
+
/>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
> [!NOTE]
|
|
91
|
+
> `colors` are not Tailwind classes but **colour values** (the chart is drawn on a canvas). Token
|
|
92
|
+
> names such as `"chart-2"` follow light / dark. Axis, legend and tooltip colours always come from the
|
|
93
|
+
> theme.
|
|
94
|
+
|
|
95
|
+
## AreaChart or EChart
|
|
96
|
+
|
|
97
|
+
Start with this typed chart. Reach for [`EChart`](parts/echart) only for what these
|
|
98
|
+
props cannot express — dual axes, scatter plots, heatmaps. Small tweaks can go through
|
|
99
|
+
`chartOptions`.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# BarChart
|
|
2
|
+
|
|
3
|
+
> A typed bar chart for comparing categories. Grouped, stacked or 100% stacked; vertical or horizontal bars.
|
|
4
|
+
|
|
5
|
+
Draws categories as bars. Pass **the rows (`data`), the category column (`index`) and the series
|
|
6
|
+
columns (`categories`)** instead of an ECharts option; the legend, tooltip and axis formats come
|
|
7
|
+
with it. Grouped, stacked or 100%-stacked, with vertical or horizontal bars. Colours follow the
|
|
8
|
+
`--chart-1` … `--chart-5` tokens and track light / dark. Under the hood it is an
|
|
9
|
+
[`EChart`](parts/echart) inside a chart frame (title, summary, loading skeleton,
|
|
10
|
+
empty state). The value axis always starts at 0.
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { BarChart } from "@squadbase/vantage/components";
|
|
14
|
+
import type { BarChartProps, ChartEventPayload } from "@squadbase/vantage/components";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Description |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| `data` | `Record<string, unknown>[]` | | An array of rows. **Required.** One row is one category. Numeric columns are a number or a numeric string (such as a SQL DECIMAL); anything else counts as a gap. |
|
|
20
|
+
| `index` | `string` | | The column used for the category axis. **Required.** |
|
|
21
|
+
| `categories` | `string[]` | | The columns drawn as series. **Required.** Their order is the legend and colour order. Six or more fold into the five largest by total plus an Other series. |
|
|
22
|
+
| `barOptions` | `BarChartOptions` | | Bar-specific settings: `{ type, layout, barCategoryGap, showZeroValues, targetKey, highlight }`. **Prefer this.** Takes precedence over the deprecated flat props of the same name. See below. Bar charts have no forecast. |
|
|
23
|
+
| `thresholds` | `ChartThreshold[]` | | Colour bars by value. Rules are checked top to bottom and the first match wins; each is `{ lt?, lte?, gt?, gte?, tone }` (all given conditions must hold). Unmatched bars keep the normal colour. With several series it applies per bar and keeps the series colour on the edge; **ignored for stacked bars**. Example: `[{ gt: 2, tone: "negative" }, { gt: 1.5, tone: "warning" }]`. |
|
|
24
|
+
| `colors` | `ChartColors` | `["chart-1", …, "chart-5"]` | Series colours: `"chart-1"` … `"chart-5"` or a semantic tone (`"positive"` / `"warning"` / `"negative"` / `"neutral"`). An array follows series order; a record is keyed by series name. |
|
|
25
|
+
| `labels` | `Record<string, string>` | | Maps `index` values and series names to display names (axes, legend, tooltip, data table). |
|
|
26
|
+
| `format` | `ValueFormat` | `"compact"` | Number format: `"compact"` / `"number"` / `"currency"` / `"percent"` / `"multiple"` / `"duration"`, or `{ type, digits, currency, notation, unit, divisor, durationUnit }`. Same values as the KPI components. Axes use a short form; the tooltip uses the same format. |
|
|
27
|
+
| `valueFormatter` | `(value: number) => string` | | A function escape hatch for the format. Takes precedence over `format`; kept for compatibility. |
|
|
28
|
+
| `title` | `string` | | The chart heading. It labels the plot area for screen readers. |
|
|
29
|
+
| `summary` | `string \| "auto"` | | A one-sentence summary shown under the title and used as the plot's `aria-describedby`. `"auto"` builds one from `data`. Omitted means no summary. |
|
|
30
|
+
| `isLoading` | `boolean` | | Show a skeleton shaped like the final chart, at the same height. |
|
|
31
|
+
| `emptyState` | `ChartEmptyState` | | What to show when `data` is empty: `{ title?, description?, action? }`. The frame keeps its height. `action` takes one node, such as a button. |
|
|
32
|
+
| `height` | `number \| string` | `288` | Plot-area height in px. A CSS length string is accepted for compatibility only and is deprecated; pass a number. |
|
|
33
|
+
| `actions` | `boolean \| { includeTitle?: boolean }` | `false` | Show PNG save / copy buttons at the top right on hover. The PNG includes the title and summary unless you pass `{ includeTitle: false }`. |
|
|
34
|
+
| `fileName` | `string` | `"chart.png"` | File name for the saved PNG. Use with `actions`. |
|
|
35
|
+
| `chartOptions` | `EChartsOption` | | An escape hatch deep-merged last into the generated ECharts option. |
|
|
36
|
+
| `highlight` | `"auto" \| "none"` | | Label the max and latest value (first series only, two series or fewer). Defaults to `"auto"` only when `index` is a date, month or year. Not to be confused with `barOptions.highlight`. |
|
|
37
|
+
| `provisionalFrom` | `string \| number` | | An `index` value; bars from here on are provisional (light fill, dashed edge). |
|
|
38
|
+
| `provisionalLabel` | `string` | | Name of the provisional range in legend and tooltip. |
|
|
39
|
+
| `target` | `number` | | A target value, drawn as a dotted line. The value axis always includes it. Not drawn when `barOptions.targetKey` is set. |
|
|
40
|
+
| `targetLabel` | `string` | | Label for the target line (or the marker name with `barOptions.targetKey`). |
|
|
41
|
+
| `annotations` | `ChartAnnotation[]` | | Notes at given positions: `{ at, label, to? }`. `at` / `to` are `index` values. Drawn for vertical bars (the default `layout`), not for horizontal bars. |
|
|
42
|
+
| `showLegend` | `boolean` | `true` | Show the legend. |
|
|
43
|
+
| `showTooltip` | `boolean` | `true` | Show the tooltip on hover. |
|
|
44
|
+
| `showGridLines` | `boolean` | `true` | Grid lines on the value axis. |
|
|
45
|
+
| `showXAxis` | `boolean` | `true` | Show the x axis. |
|
|
46
|
+
| `showYAxis` | `boolean` | `true` | Show the y axis. |
|
|
47
|
+
| `startEndOnly` | `boolean` | `false` | Label only the first and last x-axis ticks. |
|
|
48
|
+
| `yAxisWidth` | `number` | | Width of the y-axis labels (px). Fix it to align plot areas across stacked charts. |
|
|
49
|
+
| `minValue` | `number` | | Lower bound of the value axis. Bar charts always start at 0, so only values of 0 or below take effect (room under negative values). |
|
|
50
|
+
| `maxValue` | `number` | | Upper bound of the value axis (the horizontal axis for horizontal bars). The axis widens if the data exceeds it. |
|
|
51
|
+
| `allowDecimals` | `boolean` | `true` | `false` limits ticks to integers. |
|
|
52
|
+
| `xAxisLabel` | `string` | | Name of the x axis. |
|
|
53
|
+
| `yAxisLabel` | `string` | | Name of the y axis. |
|
|
54
|
+
| `onValueChange` | `(value: ChartEventPayload \| null) => void` | | Called on a click. Receives the clicked row plus `eventType` and `categoryClicked` (the series name); clicking the same bar again passes `null`. When set, everything but the selection dims. |
|
|
55
|
+
| `ariaLabel` | `string` | | Screen-reader label for the plot area when there is no `title`. |
|
|
56
|
+
| `className` | `string` | | Classes to add (to the outer `<figure>`). |
|
|
57
|
+
| `type` | `"default" \| "stacked" \| "percent"` | | **Deprecated.** Use `barOptions.type`. |
|
|
58
|
+
| `layout` | `"horizontal" \| "vertical"` | | **Deprecated.** Use `barOptions.layout`. |
|
|
59
|
+
| `barCategoryGap` | `string \| number` | | **Deprecated.** Use `barOptions.barCategoryGap`. |
|
|
60
|
+
| `loading` | `boolean` | | **Deprecated.** Use `isLoading`. |
|
|
61
|
+
|
|
62
|
+
## barOptions
|
|
63
|
+
|
|
64
|
+
| Prop | Type | Default | Description |
|
|
65
|
+
| --- | --- | --- | --- |
|
|
66
|
+
| `type` | `"default" \| "stacked" \| "percent"` | `"default"` | `default` groups series side by side; `stacked` stacks them; `percent` stacks them as shares of each category's total. |
|
|
67
|
+
| `layout` | `"horizontal" \| "vertical"` | `"horizontal"` | `horizontal` lines the categories up along the x axis (vertical bars). `vertical` stacks the categories top to bottom (horizontal bars), which suits rankings with long labels; the first row is on top. A one-series `vertical` chart is a light tint by default. |
|
|
68
|
+
| `barCategoryGap` | `string \| number` | | The gap between categories (`"20%"` or px). Omitted uses the ECharts default. |
|
|
69
|
+
| `showZeroValues` | `boolean` | `true` | Print a "0" label on zero-value bars so an undrawn bar does not read as "no data". Not shown when stacked. |
|
|
70
|
+
| `targetKey` | `string` | | A `data` column holding a per-bar target. Draws a short target marker on each bar and adds the target and achievement rate to the tooltip. Works for one series and stacked; not drawn for grouped multi-series or percent. When set, the single `target` line is not drawn. |
|
|
71
|
+
| `highlight` | `string \| number` | | For a one-series `layout: "vertical"` chart: the `index` value of the one bar the page is about, drawn in the full series colour while the rest stay light. No effect otherwise; a matching `thresholds` colour wins. |
|
|
72
|
+
|
|
73
|
+
> [!WARNING]
|
|
74
|
+
> The flat `type`, `layout` and `barCategoryGap` props still work but are **deprecated**. Use
|
|
75
|
+
> `barOptions`; when both are given, `barOptions` wins.
|
|
76
|
+
|
|
77
|
+
## A ranking with one bar highlighted
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
<BarChart
|
|
81
|
+
data={rows}
|
|
82
|
+
index="store"
|
|
83
|
+
categories={["Sales"]}
|
|
84
|
+
barOptions={{ layout: "vertical", highlight: "Tokyo" }}
|
|
85
|
+
/>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## BarChart or EChart
|
|
89
|
+
|
|
90
|
+
Start with this typed chart. Reach for [`EChart`](parts/echart) only for what these
|
|
91
|
+
props cannot express. Small tweaks can go through `chartOptions`.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# BarList
|
|
2
|
+
|
|
3
|
+
> A ranked list of horizontal bars, name and value per row. No axes, light enough for a card.
|
|
4
|
+
|
|
5
|
+
Lays out name and value pairs as rows with a bar whose length follows the value. It suits **top-N
|
|
6
|
+
lists**: most visited pages, sales by store, error counts by type. It is plain HTML, not ECharts,
|
|
7
|
+
so any number of them in cards stay cheap, and the colours follow the theme. It renders inside
|
|
8
|
+
[`ChartFrame`](parts/chart-frame), so title, summary, loading and empty states and a
|
|
9
|
+
screen-reader table come with it.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { BarList } from "@squadbase/vantage/components";
|
|
13
|
+
import type { BarListItem, BarListOptions } from "@squadbase/vantage/components";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
| Prop | Type | Default | Description |
|
|
17
|
+
| --- | --- | --- | --- |
|
|
18
|
+
| `data` | `T[]` | | The rows. **Required.** Without `index` / `categories` each row is read as `{ name, value, href?, key? }` (`BarListItem`). |
|
|
19
|
+
| `index` | `keyof T` | `"name"` | The column holding each row's name. |
|
|
20
|
+
| `categories` | `(keyof T)[]` | `["value"]` | The column holding the value, as a one-element array. Only the first is used. |
|
|
21
|
+
| `colors` | `ChartSeriesColor \| ChartSeriesColor[]` | `"chart-1"` | `"chart-1"` … `"chart-5"` or a meaning colour. Only the first is used. Every row gets the same light tint; rank reads from the bar length. |
|
|
22
|
+
| `highlight` | `string` | | The name (the `index` value) of the one row to draw in the full colour. The rest stay light. The folded "Other" row cannot be chosen. |
|
|
23
|
+
| `thresholds` | `ChartThreshold[]` | | Colour rows by value with meaning colours; the first matching rule wins, e.g. `[{ lt: 40, tone: "negative" }, { lt: 70, tone: "warning" }]`. |
|
|
24
|
+
| `labels` | `Record<string, string>` | | Row name → display name, used in the row labels and the data table. Pass the column keys too to rename the table's columns. |
|
|
25
|
+
| `format` | `ValueFormat` | | Number format, e.g. `"compact"` or `{ type: "number", unit: "…" }`. |
|
|
26
|
+
| `valueFormatter` | `(value: number) => string` | | Escape hatch: a function that wins over `format`. |
|
|
27
|
+
| `barListOptions` | `BarListOptions` | | BarList-only settings: `sortOrder` (`"descending"` default, `"ascending"`, `"none"`), `maxItems` (default 5; the rest fold into one "Other" row), `otherLabel`, `exclude` (names always folded into "Other"), `showShare` (append each row's share of the total). |
|
|
28
|
+
| `onValueChange` | `(item: T) => void` | | When given, rows become buttons and the clicked row is passed in (a starting point for filtering). The "Other" row is not clickable. |
|
|
29
|
+
| `title` | `string` | | Heading of the chart. |
|
|
30
|
+
| `summary` | `string` | | A one-sentence summary shown under the title. |
|
|
31
|
+
| `isLoading` | `boolean` | `false` | Show a skeleton with the height of the rows to come. |
|
|
32
|
+
| `emptyState` | `ChartEmptyState` | | Shown when `data` is empty: `{ title?, description?, action? }`. |
|
|
33
|
+
| `ariaLabel` | `string` | | Label read aloud when there is no `title`. |
|
|
34
|
+
| `className` | `string` | | Classes to add (on the outer figure). |
|
|
35
|
+
|
|
36
|
+
The list is as tall as its rows, so `height` is not taken. Remaining props go to the list's `<div>`.
|
|
37
|
+
`color`, `sortOrder`, `showAnimation`, `formatValue` and a per-row `color` still work but are
|
|
38
|
+
deprecated; use `colors`, `barListOptions.sortOrder` and `valueFormatter` / `format`.
|
|
39
|
+
|
|
40
|
+
## Making rows links
|
|
41
|
+
|
|
42
|
+
A row with `href` turns its name into a link. Anything starting with `http(s)://` opens in a new tab.
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
<BarList data={pages.map((p) => ({ name: p.path, value: p.views, href: p.url }))} />
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The bar length is **relative to the largest value**. To show a share of the whole, use
|
|
49
|
+
[`CategoryBar`](parts/category-bar) or `DonutChart`, or turn on
|
|
50
|
+
`barListOptions={{ showShare: true }}`.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# CategoryBar
|
|
2
|
+
|
|
3
|
+
> A single bar split into coloured segments, with an optional marker for the current value.
|
|
4
|
+
|
|
5
|
+
Splits one bar in proportion to `values` and prints the running totals at the boundaries. Pass
|
|
6
|
+
`marker` and a pin stands at that value. It suits score bands (needs work / standard / good), budget
|
|
7
|
+
consumption and a one-bar share breakdown. It is plain HTML, not ECharts, and the colours follow the
|
|
8
|
+
theme.
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { CategoryBar } from "@squadbase/vantage/components";
|
|
12
|
+
import type { CategoryBarMarker } from "@squadbase/vantage/components";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
| Prop | Type | Default | Description |
|
|
16
|
+
| --- | --- | --- | --- |
|
|
17
|
+
| `values` | `number[]` | | The width of each segment (relative). **Required.** They need not sum to 100. Negative values count as 0. |
|
|
18
|
+
| `colors` | `ChartColor[]` | `["chart-1", …, "chart-5"]` | Segment colours, in order: `"chart-1"` … `"chart-5"`, a meaning colour (`"positive"` …) or a CSS colour. |
|
|
19
|
+
| `marker` | `CategoryBarMarker` | | `{ value: number; tooltip?: string; showAnimation?: boolean }`. `value` is on the same scale as the sum of `values`. The pin takes the colour of the segment it sits in. |
|
|
20
|
+
| `showLabels` | `boolean` | `true` | Print the running totals above the bar. Labels that would overlap are thinned out. |
|
|
21
|
+
| `format` | `ValueFormat` | `"compact"` | Format of the boundary numbers: `"compact"`, `"currency"`, `{ type, currency }`. |
|
|
22
|
+
| `valueFormatter` | `(value: number) => string` | | Escape hatch: a function that wins over `format`. |
|
|
23
|
+
| `className` | `string` | | Classes to add. |
|
|
24
|
+
|
|
25
|
+
Remaining props go to the outer `<div>`.
|
|
26
|
+
|
|
27
|
+
## Matching colours to the bands
|
|
28
|
+
|
|
29
|
+
`colors` lines up with the segments. For a "bad to good" band, going from warm to cool reads well.
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
<CategoryBar
|
|
33
|
+
values={[60, 20, 20]}
|
|
34
|
+
colors={["chart-5", "chart-3", "chart-2"]}
|
|
35
|
+
marker={{ value: 72, tooltip: "This month's score: 72" }}
|
|
36
|
+
/>
|
|
37
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# ChartFrame
|
|
2
|
+
|
|
3
|
+
> The frame every typed chart renders in. A title, a summary and a plot area of fixed height.
|
|
4
|
+
|
|
5
|
+
`ChartFrame` is what the typed charts (`LineChart`, `BarChart`, `Heatmap` …) render inside: an
|
|
6
|
+
optional title and one-sentence summary above a plot area of fixed height. The plot is labelled by
|
|
7
|
+
the title and described by the summary, so a screen reader hears what the chart says, not just that
|
|
8
|
+
there is one. Use it directly when you build a chart of your own and want the same behaviour.
|
|
9
|
+
|
|
10
|
+
The plot area keeps its height in every state: while loading it shows a skeleton shaped like the
|
|
11
|
+
final chart, and with no data it says so (and offers one action) instead of drawing empty axes.
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { ChartFrame } from "@squadbase/vantage/components";
|
|
15
|
+
import type { ChartFrameProps, ChartSkeletonVariant } from "@squadbase/vantage/components";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
| Prop | Type | Default | Description |
|
|
19
|
+
| --- | --- | --- | --- |
|
|
20
|
+
| `title` | `string` | | Heading of the chart. It labels the plot area (`aria-labelledby`). |
|
|
21
|
+
| `summary` | `string` | | A one-sentence summary under the title. It describes the plot area (`aria-describedby`). |
|
|
22
|
+
| `isLoading` | `boolean` | `false` | Loading. Shows a skeleton in the shape of `variant`, at the same height. |
|
|
23
|
+
| `isEmpty` | `boolean` | `false` | No data. Shows `emptyState` at the same height. |
|
|
24
|
+
| `emptyState` | `ChartEmptyState` | | `{ title?, description?, action? }`. `action` is a single node, such as a button. The default title is a generic "no data to show" message. |
|
|
25
|
+
| `height` | `number \| string` | `288` | Height of the plot area. A number is px; a string is a CSS length (e.g. `"auto"`). |
|
|
26
|
+
| `variant` | `ChartSkeletonVariant` | `"line"` | Shape of the loading skeleton: `"line" \| "area" \| "bar" \| "donut" \| "list"`. |
|
|
27
|
+
| `ariaLabel` | `string` | | Label for the plot area when there is no `title`. |
|
|
28
|
+
| `plotRole` | `"img" \| "group"` | `"img"` | Role of the plot area. `"img"` suits a canvas chart. Use `"group"` for HTML charts whose rows are buttons or links, so their content is read. |
|
|
29
|
+
| `dataTable` | `ChartDataTable` | | The numbers as a visually-hidden (`sr-only`) table inside the figure, so a screen reader can read what a canvas only draws. Build it with `chartDataTable`. |
|
|
30
|
+
| `children` | `ReactNode` | | The plot itself. It is not drawn while loading or empty. |
|
|
31
|
+
| `className` | `string` | | Classes to add (on the outer `<figure>`). |
|
|
32
|
+
|
|
33
|
+
`ref` points at the plot area (the element with the fixed height). `className` and the other
|
|
34
|
+
attributes go to the outer `<figure>`.
|
|
35
|
+
|
|
36
|
+
## What the typed charts take from it
|
|
37
|
+
|
|
38
|
+
The typed charts forward `title`, `summary`, `isLoading`, `emptyState` and `height` to their frame
|
|
39
|
+
under the same names, so you set them on the chart, not on `ChartFrame`.
|
|
@@ -56,6 +56,28 @@ it.
|
|
|
56
56
|
|
|
57
57
|
`useDataTable()` gives a child component the TanStack `table` instance directly.
|
|
58
58
|
|
|
59
|
+
## Column formats and CSV export
|
|
60
|
+
|
|
61
|
+
A column without `cell` can format its number with `meta.format` (right-aligned, tabular-nums; null shows `meta.nullLabel`, default `—`). Pass a function when the currency changes per row. `DataTableExport` writes a BOM-prefixed UTF-8 CSV in the same sorted, filtered order as the screen; with `DataTablePreset`, `exportable` alone adds it to the toolbar.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
const columns: ColumnDef<Row>[] = [
|
|
65
|
+
{ accessorKey: "month", header: "Month" },
|
|
66
|
+
{
|
|
67
|
+
accessorKey: "revenue",
|
|
68
|
+
header: "Revenue",
|
|
69
|
+
meta: { format: (row) => ({ type: "currency", currency: row.currency, notation: "standard" }) },
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
<DataTable columns={columns} data={rows}>
|
|
74
|
+
<DataTableToolbar toolbar={<DataTableExport fileName="sales.csv" />} />
|
|
75
|
+
<DataTableContent />
|
|
76
|
+
</DataTable>;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`values="raw"` exports raw values; `scope="page"` exports only the visible page. For server-side paging, `rowCount` (total rows), `manualSorting`, `manualFiltering` and `isLoading` are also available.
|
|
80
|
+
|
|
59
81
|
## Paginating on the server
|
|
60
82
|
|
|
61
83
|
Own `pagination` and `onPaginationChange`, and pass the total in `pageCount`.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Delta
|
|
2
|
+
|
|
3
|
+
> The change against a comparison — arrow, signed rate and label, all derived from the values.
|
|
4
|
+
|
|
5
|
+
Shows a change as one line: "↑ +12.4% 前期比". **Direction, rate, colour and wording are all computed
|
|
6
|
+
from `value` and `comparison`** and cannot be passed in, so the arrow and the colour can never disagree.
|
|
7
|
+
Colour is never the only signal — the arrow and the sign always accompany it. For metrics where a rise
|
|
8
|
+
is bad (churn, error rate), pass `betterWhen="down"` (`polarity` is the older name and still works).
|
|
9
|
+
|
|
10
|
+
It replaces the deprecated [`TrendIndicator`](parts/trend-indicator).
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { Delta } from "@squadbase/vantage/components";
|
|
14
|
+
import type { DeltaProps, Comparison, Polarity } from "@squadbase/vantage/components";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Description |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| `value` | `number \| null \| undefined` | | The current value. **Required.** The previous one comes from `comparison`. |
|
|
20
|
+
| `comparison` | `Comparison` | | What the value is compared against. **Required**, so the change always carries its label. See below. |
|
|
21
|
+
| `betterWhen` | `"up" \| "down"` | `"up"` | Which direction is good. Use `"down"` for metrics like churn. Wins over `polarity`. |
|
|
22
|
+
| `polarity` | `"higher-is-better" \| "lower-is-better" \| "neutral"` | `"higher-is-better"` | Deprecated: the older name of `betterWhen`. `"neutral"` (no good or bad colouring) is only available here. |
|
|
23
|
+
| `neutralBand` | `number` | `0.01` | Absolute ratio below which the change reads as flat. Default 1%. |
|
|
24
|
+
| `variant` | `"badge" \| "inline"` | `"badge"` | A bordered badge, or plain text for use inline. |
|
|
25
|
+
| `locale` | `string` | `"ja-JP"` | Locale for the percent. |
|
|
26
|
+
| `showLabel` | `boolean` | `true` | Show the comparison label ("前期比") after the percent. |
|
|
27
|
+
| `className` | `string` | | Classes to add. |
|
|
28
|
+
|
|
29
|
+
## Comparison
|
|
30
|
+
|
|
31
|
+
| Prop | Type | Description |
|
|
32
|
+
| --- | --- | --- |
|
|
33
|
+
| `previous` | `number \| null \| undefined` | The value compared against. `null` or `0` yields no rate, shown as "—". |
|
|
34
|
+
| `vs` | `"prior-period" \| "prior-year" \| "target"` | The kind of comparison. Default labels: 前期比 / 前年同期比 / 目標比. |
|
|
35
|
+
| `label` | `string` | Override the label (e.g. "vs last week"). |
|
|
36
|
+
|
|
37
|
+
## Migrating from TrendIndicator
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
// Before: direction and colour chosen by hand
|
|
41
|
+
<TrendIndicator value={12.4} direction="up" />
|
|
42
|
+
|
|
43
|
+
// After: pass the current and previous values
|
|
44
|
+
<Delta value={1_240_000} comparison={{ previous: 1_103_000, vs: "prior-period" }} />
|
|
45
|
+
|
|
46
|
+
// A metric where down is good
|
|
47
|
+
<Delta value={0.021} comparison={{ previous: 0.026, vs: "prior-period" }} betterWhen="down" />
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The colours come from the `--positive` / `--negative` / `--neutral` tokens. To show a KPI as a whole
|
|
51
|
+
card, [`KpiCard`](parts/kpi-card) uses `Delta` inside.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# DonutChart
|
|
2
|
+
|
|
3
|
+
> A typed donut / pie chart for showing composition, with a legend that carries each share.
|
|
4
|
+
|
|
5
|
+
Draws composition as a donut (or a pie). Pass **the rows (`data`), the label column (`index`) and
|
|
6
|
+
the value column (`categories: [valueKey]`)**. Slices are sorted largest first and coloured with the
|
|
7
|
+
`--chart-1` … `--chart-5` tokens in fixed order; more than five fold into one grey Other slice. The
|
|
8
|
+
hole is empty by default; `donutOptions.centerLabel` can put the total, or the largest slice, in it.
|
|
9
|
+
The centre label is HTML, not canvas, so it takes the page's type and colours. Under the hood it is
|
|
10
|
+
an [`EChart`](parts/echart) inside a chart frame (title, summary, loading skeleton,
|
|
11
|
+
empty state).
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { DonutChart } from "@squadbase/vantage/components";
|
|
15
|
+
import type { DonutChartProps, ChartEventPayload } from "@squadbase/vantage/components";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
| Prop | Type | Default | Description |
|
|
19
|
+
| --- | --- | --- | --- |
|
|
20
|
+
| `data` | `Record<string, unknown>[]` | | An array of rows. **Required.** One row is one slice. |
|
|
21
|
+
| `index` | `string` | | The column used for slice names. |
|
|
22
|
+
| `categories` | `string[]` | | A one-element array naming the column used for slice sizes (`["Sales"]`). Only the first entry is used. Values are numbers or numeric strings; zero, negative and missing values count as 0. |
|
|
23
|
+
| `donutOptions` | `DonutChartOptions` | | Donut-specific settings: `{ variant, centerLabel, totalLabel, unit, showLegend, maxSlices }`. **Prefer this.** Takes precedence over the deprecated flat props of the same name. See below. |
|
|
24
|
+
| `colors` | `ChartSeriesColor[]` | `["chart-1", …, "chart-5"]` | Slice colours, largest first: `"chart-1"` … `"chart-5"` or a semantic tone (`"positive"` and so on). The Other slice is always grey. |
|
|
25
|
+
| `labels` | `Record<string, string>` | | Maps slice names (`index` values) to display names in the legend, tooltip, labels and data table. Example: `{ organic: "Organic search" }`. |
|
|
26
|
+
| `format` | `ValueFormat` | `"compact"` | Number format: `"compact"` / `"number"` / `"currency"` / `"percent"` / `"multiple"` / `"duration"`, or `{ type, digits, currency, notation, unit, divisor, durationUnit }`. |
|
|
27
|
+
| `valueFormatter` | `(value: number) => string` | | A function escape hatch for the format. Takes precedence over `format`; kept for compatibility. |
|
|
28
|
+
| `title` | `string` | | The chart heading. It labels the plot area for screen readers. |
|
|
29
|
+
| `summary` | `string \| "auto"` | | A one-sentence summary shown under the title and used as the plot's `aria-describedby`. `"auto"` builds one from the slices (the largest slice and its share). Omitted means no summary. |
|
|
30
|
+
| `isLoading` | `boolean` | | Show a ring-shaped skeleton at the same height. |
|
|
31
|
+
| `emptyState` | `ChartEmptyState` | | What to show when `data` is empty: `{ title?, description?, action? }`. The frame keeps its height. `action` takes one node, such as a button. |
|
|
32
|
+
| `height` | `number \| string` | `288` | Plot-area height in px. A CSS length string is accepted for compatibility only and is deprecated; pass a number. |
|
|
33
|
+
| `actions` | `boolean \| { includeTitle?: boolean }` | `false` | Show PNG save / copy buttons at the top right on hover. The PNG includes the title and summary unless you pass `{ includeTitle: false }`. |
|
|
34
|
+
| `fileName` | `string` | `"chart.png"` | File name for the saved PNG. Use with `actions`. |
|
|
35
|
+
| `chartOptions` | `EChartsOption` | | An escape hatch deep-merged last into the generated ECharts option. |
|
|
36
|
+
| `showTooltip` | `boolean` | `true` | Show the tooltip on hover. |
|
|
37
|
+
| `onValueChange` | `(value: ChartEventPayload \| null) => void` | | Called when a slice is clicked; clicking the same slice again passes `null`. When set, everything but the selection dims. |
|
|
38
|
+
| `ariaLabel` | `string` | | Screen-reader label for the plot area when there is no `title`. |
|
|
39
|
+
| `className` | `string` | | Classes to add (to the outer `<figure>`). |
|
|
40
|
+
| `category` | `string` | | **Deprecated.** Use `index`. |
|
|
41
|
+
| `value` | `string` | | **Deprecated.** Use `categories={[value]}`. |
|
|
42
|
+
| `variant` | `"donut" \| "pie"` | | **Deprecated.** Use `donutOptions.variant`. |
|
|
43
|
+
| `label` | `ReactNode` | | **Deprecated.** Use `donutOptions.centerLabel`. |
|
|
44
|
+
| `showLabel` | `boolean` | | **Deprecated.** Use `donutOptions.centerLabel` (`"none"` hides it). |
|
|
45
|
+
| `loading` | `boolean` | | **Deprecated.** Use `isLoading`. |
|
|
46
|
+
|
|
47
|
+
## donutOptions
|
|
48
|
+
|
|
49
|
+
| Prop | Type | Default | Description |
|
|
50
|
+
| --- | --- | --- | --- |
|
|
51
|
+
| `variant` | `"donut" \| "pie"` | `"donut"` | A ring with a hole, or a full pie. |
|
|
52
|
+
| `centerLabel` | `"none" \| "total" \| "top" \| ReactNode` | `"none"` | What to put in the hole (donut only). `"none"` leaves it empty (a total usually repeats a KPI); `"total"` shows the total with `totalLabel` and `unit`; `"top"` shows the largest slice and its share; any other node is placed as is. |
|
|
53
|
+
| `totalLabel` | `string` | | Heading of the centre total. Defaults to a built-in label. |
|
|
54
|
+
| `unit` | `string` | | A unit added to the centre total. |
|
|
55
|
+
| `showLegend` | `boolean` | `true` | Show the legend: every slice with its share, largest first, to the right of the ring when there is room and below it otherwise. The share is printed only in the legend; without it, a wide enough plot labels its two largest slices outside the ring. |
|
|
56
|
+
| `maxSlices` | `number` | `5` | How many slices are drawn individually. The rest, by size, fold into one Other slice. |
|
|
57
|
+
|
|
58
|
+
> [!WARNING]
|
|
59
|
+
> The flat `category`, `value`, `variant`, `label` and `showLabel` props still work but are
|
|
60
|
+
> **deprecated**. Use `index`, `categories`, and `donutOptions`; when both are given, `donutOptions`
|
|
61
|
+
> wins.
|
|
62
|
+
|
|
63
|
+
## Showing the total in the hole
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
<DonutChart
|
|
67
|
+
data={rows}
|
|
68
|
+
index="source"
|
|
69
|
+
categories={["sessions"]}
|
|
70
|
+
donutOptions={{ centerLabel: "total", unit: "sessions" }}
|
|
71
|
+
/>
|
|
72
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# format / comparison
|
|
2
|
+
|
|
3
|
+
> The number formatting (formatValue) and change calculation (computeComparison) shared by KPIs, tables and charts.
|
|
4
|
+
|
|
5
|
+
The formatting and comparison logic that `KpiCard` / `Delta` use internally, exposed as functions. Use
|
|
6
|
+
them when a table cell or a chart's `valueFormatter` should match the KPIs. Shortening (e.g. "4.8億")
|
|
7
|
+
is left to `Intl.NumberFormat`; no unit strings are hard-coded.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import {
|
|
11
|
+
formatValue,
|
|
12
|
+
formatDelta,
|
|
13
|
+
toValueFormatter,
|
|
14
|
+
computeComparison,
|
|
15
|
+
} from "@squadbase/vantage/components";
|
|
16
|
+
import type { ValueFormat, Comparison, ComparisonResult } from "@squadbase/vantage/components";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## ValueFormat
|
|
20
|
+
|
|
21
|
+
One of `"number" | "compact" | "currency" | "percent" | "multiple"`, or `{ type, digits?, currency? }`.
|
|
22
|
+
The default format is `"compact"`, the default currency `JPY`, the default locale `"ja-JP"`. `percent`
|
|
23
|
+
takes a ratio (`0.124` → 12.4%). `null` / `undefined` / `NaN` format as "—".
|
|
24
|
+
|
|
25
|
+
| Prop | Type | Description |
|
|
26
|
+
| --- | --- | --- |
|
|
27
|
+
| `formatValue(value, format?, locale?)` | `string` | Format a value. |
|
|
28
|
+
| `formatDelta(value, format?, locale?)` | `string` | For differences: always signed except zero (`+12.4%`). |
|
|
29
|
+
| `toValueFormatter(format?, locale?)` | `(value) => string` | A one-argument formatter with the format and locale bound — fits a chart's `valueFormatter`. |
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
formatValue(48_200_000, "currency"); // "¥48,200,000"
|
|
33
|
+
formatValue(0.021, { type: "percent", digits: 1 }); // "2.1%"
|
|
34
|
+
<LineChart valueFormatter={toValueFormatter("compact")} … />
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## computeComparison
|
|
38
|
+
|
|
39
|
+
`computeComparison(current, comparison, { polarity?, neutralBand? })` returns
|
|
40
|
+
`{ current, previous, difference, ratio, direction, sentiment, label, vs }`. A rate is produced only
|
|
41
|
+
when the previous value is a non-zero number; moves inside `neutralBand` (default 0.01) give
|
|
42
|
+
`direction: "flat"`. `sentiment` (`"positive" | "negative" | "neutral"`) follows `polarity`. Leave the
|
|
43
|
+
rendering to [`Delta`](parts/delta) rather than building arrows and colours yourself.
|
|
@@ -14,7 +14,8 @@ import type { FunnelStep } from "@squadbase/vantage/components";
|
|
|
14
14
|
| --- | --- | --- | --- |
|
|
15
15
|
| `data` | `FunnelStep[]` | | The stages. **The first one is the full-width bar.** |
|
|
16
16
|
| `showConversion` | `boolean` | | Show the conversion between stages. |
|
|
17
|
-
| `
|
|
17
|
+
| `valueFormatter` | `(value: number) => string` | | Format the numbers. Takes precedence over `format`. (`formatValue` is deprecated.) |
|
|
18
|
+
| `format` | `ValueFormat` | `"compact"` | Preset number format, as on the other charts. |
|
|
18
19
|
| `animate` | `boolean` | | Grow the bars on mount. |
|
|
19
20
|
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | |
|
|
20
21
|
| `direction` | `"vertical" \| "horizontal"` | `"vertical"` | |
|