@slotted/react 0.1.0-beta.42 → 0.1.0-beta.43
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/{app-shell-D54YkU7E.js → app-shell-DsWhsSMU.js} +3 -2
- package/dist/app-shell.js +1 -1
- package/dist/attachment-TZykYNu5.js +300 -0
- package/dist/attachment.js +2 -2
- package/dist/{avatar-group-bJaZE1_C.js → avatar-group-Bzmmj2HI.js} +2 -1
- package/dist/avatar-group.js +1 -1
- package/dist/{carousel-B9nMK7Yf.js → carousel-CRNz-T3g.js} +1 -1
- package/dist/carousel.js +1 -1
- package/dist/{command-palette-C90CzfQi.js → command-palette-Bgf5tfCI.js} +160 -156
- package/dist/command-palette.js +1 -1
- package/dist/{data-grid-D106baPp.js → data-grid-DUft3rJb.js} +1 -1
- package/dist/data-grid.js +1 -1
- package/dist/{data-list-BA0xrySM.js → data-list-Dv3orBtf.js} +15 -15
- package/dist/data-list.js +1 -1
- package/dist/detail-panel-Cke3ZFU3.js +342 -0
- package/dist/detail-panel.js +2 -2
- package/dist/docs/action-bar.examples.md +768 -0
- package/dist/docs/action-bar.json +74 -50
- package/dist/docs/action-bar.md +49 -311
- package/dist/docs/app-shell.examples.md +1221 -64
- package/dist/docs/app-shell.json +92 -60
- package/dist/docs/app-shell.md +92 -57
- package/dist/docs/attachment.examples.md +689 -0
- package/dist/docs/attachment.json +69 -37
- package/dist/docs/attachment.md +44 -203
- package/dist/docs/avatar-group.json +111 -23
- package/dist/docs/avatar-group.md +487 -28
- package/dist/docs/button-group.json +98 -2
- package/dist/docs/button-group.md +411 -8
- package/dist/docs/calendar.examples.md +512 -0
- package/dist/docs/calendar.json +72 -24
- package/dist/docs/calendar.md +18 -147
- package/dist/docs/carousel.examples.md +868 -0
- package/dist/docs/carousel.json +58 -50
- package/dist/docs/carousel.md +66 -300
- package/dist/docs/cascader.examples.md +1269 -0
- package/dist/docs/cascader.json +72 -16
- package/dist/docs/cascader.md +78 -154
- package/dist/docs/chart.examples.md +734 -24
- package/dist/docs/chart.json +93 -13
- package/dist/docs/chart.md +28 -7
- package/dist/docs/clock.json +71 -15
- package/dist/docs/clock.md +326 -21
- package/dist/docs/code-block.json +79 -55
- package/dist/docs/code-block.md +417 -74
- package/dist/docs/color-picker.json +60 -12
- package/dist/docs/color-picker.md +245 -22
- package/dist/docs/column-manager.examples.md +764 -0
- package/dist/docs/column-manager.json +68 -12
- package/dist/docs/column-manager.md +44 -203
- package/dist/docs/command-palette.examples.md +747 -0
- package/dist/docs/command-palette.json +48 -24
- package/dist/docs/command-palette.md +60 -339
- package/dist/docs/currency-field.examples.md +355 -73
- package/dist/docs/currency-field.json +96 -64
- package/dist/docs/currency-field.md +57 -50
- package/dist/docs/dashboard-grid.examples.md +629 -0
- package/dist/docs/dashboard-grid.json +64 -16
- package/dist/docs/dashboard-grid.md +34 -152
- package/dist/docs/data-list.examples.md +1556 -0
- package/dist/docs/data-list.json +58 -18
- package/dist/docs/data-list.md +139 -224
- package/dist/docs/date-field.examples.md +543 -0
- package/dist/docs/date-field.json +64 -24
- package/dist/docs/date-field.md +22 -168
- package/dist/docs/datetime-field.examples.md +699 -0
- package/dist/docs/datetime-field.json +79 -31
- package/dist/docs/datetime-field.md +24 -269
- package/dist/docs/datetime-range-picker.examples.md +682 -0
- package/dist/docs/datetime-range-picker.json +117 -61
- package/dist/docs/datetime-range-picker.md +59 -224
- package/dist/docs/description-list.examples.md +652 -0
- package/dist/docs/description-list.json +49 -25
- package/dist/docs/description-list.md +33 -188
- package/dist/docs/detail-panel.examples.md +1177 -0
- package/dist/docs/detail-panel.json +69 -53
- package/dist/docs/detail-panel.md +114 -324
- package/dist/docs/entity-picker.examples.md +1037 -0
- package/dist/docs/entity-picker.json +66 -18
- package/dist/docs/entity-picker.md +56 -246
- package/dist/docs/event-calendar.examples.md +749 -49
- package/dist/docs/event-calendar.json +46 -22
- package/dist/docs/event-calendar.md +81 -11
- package/dist/docs/field-group.examples.md +554 -0
- package/dist/docs/field-group.json +98 -34
- package/dist/docs/field-group.md +55 -133
- package/dist/docs/filter-bar.examples.md +772 -0
- package/dist/docs/filter-bar.json +41 -25
- package/dist/docs/filter-bar.md +42 -246
- package/dist/docs/form.examples.md +579 -0
- package/dist/docs/form.json +87 -39
- package/dist/docs/form.md +53 -177
- package/dist/docs/fullscreen.examples.md +558 -0
- package/dist/docs/fullscreen.json +58 -18
- package/dist/docs/fullscreen.md +50 -169
- package/dist/docs/highlight.json +57 -25
- package/dist/docs/highlight.md +402 -50
- package/dist/docs/icon.json +85 -5
- package/dist/docs/icon.md +401 -10
- package/dist/docs/image.examples.md +670 -0
- package/dist/docs/image.json +44 -28
- package/dist/docs/image.md +24 -176
- package/dist/docs/import-export-center.examples.md +1280 -0
- package/dist/docs/import-export-center.json +67 -27
- package/dist/docs/import-export-center.md +121 -226
- package/dist/docs/list-item.examples.md +769 -0
- package/dist/docs/list-item.json +110 -38
- package/dist/docs/list-item.md +84 -201
- package/dist/docs/listbox.examples.md +858 -0
- package/dist/docs/listbox.json +76 -28
- package/dist/docs/listbox.md +41 -263
- package/dist/docs/markdown.json +79 -55
- package/dist/docs/markdown.md +581 -85
- package/dist/docs/media-viewer.examples.md +1038 -0
- package/dist/docs/media-viewer.json +70 -15
- package/dist/docs/media-viewer.md +84 -135
- package/dist/docs/message-scroller.examples.md +1193 -0
- package/dist/docs/message-scroller.json +41 -17
- package/dist/docs/message-scroller.md +80 -134
- package/dist/docs/message.examples.md +944 -0
- package/dist/docs/message.json +64 -16
- package/dist/docs/message.md +34 -326
- package/dist/docs/meter.json +58 -26
- package/dist/docs/meter.md +312 -32
- package/dist/docs/navigation-menu.examples.md +1107 -0
- package/dist/docs/navigation-menu.json +57 -41
- package/dist/docs/navigation-menu.md +105 -298
- package/dist/docs/notification-center.examples.md +1045 -0
- package/dist/docs/notification-center.json +71 -15
- package/dist/docs/notification-center.md +76 -266
- package/dist/docs/otp-input.examples.md +490 -0
- package/dist/docs/otp-input.json +65 -25
- package/dist/docs/otp-input.md +20 -191
- package/dist/docs/page-header.examples.md +1041 -0
- package/dist/docs/page-header.json +75 -43
- package/dist/docs/page-header.md +79 -291
- package/dist/docs/page.examples.md +633 -0
- package/dist/docs/page.json +48 -16
- package/dist/docs/page.md +62 -129
- package/dist/docs/prompt-composer.examples.md +630 -0
- package/dist/docs/prompt-composer.json +66 -18
- package/dist/docs/prompt-composer.md +35 -161
- package/dist/docs/prose.json +69 -37
- package/dist/docs/prose.md +393 -75
- package/dist/docs/rating.examples.md +525 -0
- package/dist/docs/rating.json +92 -28
- package/dist/docs/rating.md +27 -241
- package/dist/docs/saved-views.examples.md +1108 -0
- package/dist/docs/saved-views.json +53 -21
- package/dist/docs/saved-views.md +86 -171
- package/dist/docs/scroll-area.examples.md +837 -0
- package/dist/docs/scroll-area.json +64 -24
- package/dist/docs/scroll-area.md +57 -140
- package/dist/docs/section.examples.md +676 -0
- package/dist/docs/section.json +68 -20
- package/dist/docs/section.md +39 -162
- package/dist/docs/segmented-control.examples.md +480 -0
- package/dist/docs/segmented-control.json +76 -28
- package/dist/docs/segmented-control.md +20 -191
- package/dist/docs/side-navigation.examples.md +1468 -0
- package/dist/docs/side-navigation.json +53 -53
- package/dist/docs/side-navigation.md +79 -354
- package/dist/docs/slider.examples.md +505 -0
- package/dist/docs/slider.json +91 -51
- package/dist/docs/slider.md +47 -212
- package/dist/docs/sparkline.json +60 -36
- package/dist/docs/sparkline.md +447 -71
- package/dist/docs/split-button.examples.md +509 -0
- package/dist/docs/split-button.json +73 -41
- package/dist/docs/split-button.md +64 -194
- package/dist/docs/splitter.examples.md +921 -0
- package/dist/docs/splitter.json +94 -46
- package/dist/docs/splitter.md +75 -182
- package/dist/docs/stat-card.examples.md +725 -0
- package/dist/docs/stat-card.json +89 -41
- package/dist/docs/stat-card.md +55 -227
- package/dist/docs/status-indicator.json +80 -32
- package/dist/docs/status-indicator.md +409 -65
- package/dist/docs/stepper.json +53 -21
- package/dist/docs/stepper.md +369 -48
- package/dist/docs/table-of-contents.examples.md +550 -0
- package/dist/docs/table-of-contents.json +60 -28
- package/dist/docs/table-of-contents.md +70 -205
- package/dist/docs/tags-input.examples.md +541 -0
- package/dist/docs/tags-input.json +64 -16
- package/dist/docs/tags-input.md +15 -262
- package/dist/docs/time-field.examples.md +587 -0
- package/dist/docs/time-field.json +69 -29
- package/dist/docs/time-field.md +21 -223
- package/dist/docs/time-picker.json +117 -53
- package/dist/docs/time-picker.md +499 -54
- package/dist/docs/time-range-picker.examples.md +750 -0
- package/dist/docs/time-range-picker.json +139 -75
- package/dist/docs/time-range-picker.md +63 -225
- package/dist/docs/timeline.examples.md +617 -0
- package/dist/docs/timeline.json +44 -28
- package/dist/docs/timeline.md +34 -208
- package/dist/docs/toolbar.json +56 -16
- package/dist/docs/toolbar.md +357 -63
- package/dist/docs/top-navigation.examples.md +1206 -140
- package/dist/docs/top-navigation.json +49 -33
- package/dist/docs/top-navigation.md +87 -36
- package/dist/docs/tour.examples.md +960 -0
- package/dist/docs/tour.json +57 -25
- package/dist/docs/tour.md +60 -244
- package/dist/docs/transfer.examples.md +631 -0
- package/dist/docs/transfer.json +80 -16
- package/dist/docs/transfer.md +41 -170
- package/dist/docs/typography.json +96 -0
- package/dist/docs/typography.md +352 -4
- package/dist/docs/upload.examples.md +555 -53
- package/dist/docs/upload.json +62 -30
- package/dist/docs/upload.md +46 -11
- package/dist/docs/wizard.examples.md +1389 -0
- package/dist/docs/wizard.json +89 -49
- package/dist/docs/wizard.md +122 -263
- package/dist/{entity-picker-CC4VoC3p.js → entity-picker-C78f3Z0o.js} +9 -6
- package/dist/entity-picker.js +1 -1
- package/dist/{event-calendar-CjmF_e0H.js → event-calendar-DJPoCi-O.js} +1 -1
- package/dist/event-calendar.js +1 -1
- package/dist/{filter-bar-B3QJD7SZ.js → filter-bar-D61wiQFP.js} +1 -1
- package/dist/filter-bar.js +1 -1
- package/dist/{import-export-center-CW8YVZev.js → import-export-center-mqvmlzwB.js} +44 -36
- package/dist/import-export-center.js +1 -1
- package/dist/index.js +58 -58
- package/dist/{markdown-BdskE4-L.js → markdown-8CtV4k44.js} +2 -2
- package/dist/markdown.js +1 -1
- package/dist/{media-viewer-zEXcwfEY.js → media-viewer-C_cbuAq-.js} +64 -60
- package/dist/media-viewer.js +2 -2
- package/dist/message-P91bEGyV.js +455 -0
- package/dist/message.js +2 -2
- package/dist/{page-header-DmwBGwlm.js → page-header-jeAIQSZM.js} +103 -108
- package/dist/page-header.js +1 -1
- package/dist/section-CVTQdWBl.js +216 -0
- package/dist/section.js +2 -2
- package/dist/{segmented-control-CbK7SurB.js → segmented-control-BSMVjukr.js} +1 -1
- package/dist/segmented-control.js +1 -1
- package/dist/{side-navigation-CKRETc8E.js → side-navigation-BQzBxz2B.js} +179 -179
- package/dist/side-navigation.js +1 -1
- package/dist/{stat-card-CL3Xe6pV.js → stat-card-BpGZiFbG.js} +12 -14
- package/dist/stat-card.js +1 -1
- package/dist/{stepper-DHdrANZI.js → stepper-Cxb_tHnA.js} +130 -127
- package/dist/stepper.js +2 -2
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/{timeline-BiL2CXfn.js → timeline-ZngK6zLC.js} +9 -6
- package/dist/timeline.js +1 -1
- package/dist/top-navigation-YSEQzBhD.js +744 -0
- package/dist/top-navigation.js +2 -2
- package/dist/{transfer-sKUvmEKe.js → transfer-Cv5yQuTN.js} +1 -1
- package/dist/transfer.js +1 -1
- package/dist/types/attachment/attachment-parts.d.ts +24 -11
- package/dist/types/attachment/attachment-parts.d.ts.map +1 -1
- package/dist/types/attachment/attachment.d.ts +3 -3
- package/dist/types/attachment/attachment.d.ts.map +1 -1
- package/dist/types/avatar-group/avatar-group.d.ts.map +1 -1
- package/dist/types/carousel/carousel-parts.d.ts +2 -2
- package/dist/types/command-palette/command-palette.d.ts.map +1 -1
- package/dist/types/data-list/data-list.d.ts.map +1 -1
- package/dist/types/detail-panel/detail-panel-parts.d.ts +10 -3
- package/dist/types/detail-panel/detail-panel-parts.d.ts.map +1 -1
- package/dist/types/detail-panel/detail-panel.d.ts.map +1 -1
- package/dist/types/detail-panel/detail-panel.types.d.ts +7 -0
- package/dist/types/detail-panel/detail-panel.types.d.ts.map +1 -1
- package/dist/types/entity-picker/entity-picker.d.ts.map +1 -1
- package/dist/types/import-export-center/import-export-center.d.ts.map +1 -1
- package/dist/types/media-viewer/index.d.ts +2 -2
- package/dist/types/media-viewer/index.d.ts.map +1 -1
- package/dist/types/media-viewer/media-viewer-bar.d.ts +3 -1
- package/dist/types/media-viewer/media-viewer-bar.d.ts.map +1 -1
- package/dist/types/media-viewer/media-viewer.types.d.ts +1 -0
- package/dist/types/media-viewer/media-viewer.types.d.ts.map +1 -1
- package/dist/types/message/message-parts.d.ts +7 -0
- package/dist/types/message/message-parts.d.ts.map +1 -1
- package/dist/types/message/message.d.ts.map +1 -1
- package/dist/types/page-header/page-header-parts.d.ts.map +1 -1
- package/dist/types/section/section-parts.d.ts +16 -8
- package/dist/types/section/section-parts.d.ts.map +1 -1
- package/dist/types/section/section.d.ts.map +1 -1
- package/dist/types/segmented-control/segmented-control-parts.d.ts.map +1 -1
- package/dist/types/side-navigation/side-navigation-parts.d.ts.map +1 -1
- package/dist/types/stat-card/stat-card-delta.d.ts.map +1 -1
- package/dist/types/stat-card/stat-card-parts.d.ts +3 -3
- package/dist/types/stat-card/stat-card-parts.d.ts.map +1 -1
- package/dist/types/stepper/stepper-parts.d.ts +11 -2
- package/dist/types/stepper/stepper-parts.d.ts.map +1 -1
- package/dist/types/stepper/stepper.d.ts.map +1 -1
- package/dist/types/timeline/timeline-parts.d.ts.map +1 -1
- package/dist/types/top-navigation/top-navigation.d.ts.map +1 -1
- package/dist/{wizard-4c0X7Bx_.js → wizard-Dfryz1id.js} +214 -214
- package/dist/wizard.js +1 -1
- package/package.json +6 -6
- package/dist/attachment-MqczA38F.js +0 -292
- package/dist/detail-panel-EImAtksY.js +0 -327
- package/dist/message-D1Dd6Y2k.js +0 -452
- package/dist/section-D_qOfdxR.js +0 -213
- package/dist/top-navigation-D8IHPOmm.js +0 -744
package/dist/docs/sparkline.md
CHANGED
|
@@ -11,10 +11,27 @@ import { Sparkline, SparklineDefaultsProvider } from '@slotted/react';
|
|
|
11
11
|
|
|
12
12
|
## Minimal example
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Example
|
|
15
15
|
|
|
16
16
|
```tsx
|
|
17
|
-
|
|
17
|
+
import { Sparkline } from '@slotted/react/sparkline';
|
|
18
|
+
import { Stack } from '@slotted/react/stack';
|
|
19
|
+
import { Text } from '@slotted/react/typography';
|
|
20
|
+
|
|
21
|
+
const FILL_RATE = [
|
|
22
|
+
0.929, 0.934, 0.931, 0.938, 0.942, 0.936, 0.945, 0.951, 0.948, 0.955, 0.958, 0.961,
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export default function SparklineBasic() {
|
|
26
|
+
return (
|
|
27
|
+
<Stack gap={1}>
|
|
28
|
+
<Text size="sm" tone="muted">
|
|
29
|
+
Fill rate, last 12 weeks
|
|
30
|
+
</Text>
|
|
31
|
+
<Sparkline data={FILL_RATE} label="Fill rate" />
|
|
32
|
+
</Stack>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
18
35
|
```
|
|
19
36
|
|
|
20
37
|
## Anatomy
|
|
@@ -34,27 +51,27 @@ Excerpt — not a complete module
|
|
|
34
51
|
|
|
35
52
|
| Name | Type | Default | Applies to | Description |
|
|
36
53
|
| --- | --- | --- | --- | --- |
|
|
37
|
-
| `data` | `(number \| null)[]` | — | Sparkline | The series, oldest first. null is a gap: the line breaks, the bar is not drawn, the summary ignores it |
|
|
38
|
-
| `type` | `'line' \| 'bar'` | line | Sparkline | A line through the points, or one bar per period |
|
|
39
|
-
| `size` | `'sm' \| 'md' \| 'lg'` | md | Sparkline | The height of the box: 20, 32 or 48 pixels |
|
|
40
|
-
| `curve` | `'linear' \| 'monotone'` | linear | Sparkline | Straight segments, or a monotone curve that never draws a value the series does not hold |
|
|
54
|
+
| `data` | `(number \| null)[]` | — | Sparkline | The series, oldest first. null is a gap: the line breaks, the bar is not drawn, the summary ignores it. |
|
|
55
|
+
| `type` | `'line' \| 'bar'` | line | Sparkline | A line through the points, or one bar per period. |
|
|
56
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | md | Sparkline | The height of the box: 20, 32 or 48 pixels. |
|
|
57
|
+
| `curve` | `'linear' \| 'monotone'` | linear | Sparkline | Straight segments, or a monotone curve that never draws a value the series does not hold. |
|
|
41
58
|
| `area` | `boolean` | false | Sparkline | The wash under a line |
|
|
42
59
|
| `marker` | `boolean` | true | Sparkline | A disc on the last real point |
|
|
43
|
-
| `reference` | `number` | — | Sparkline | A dashed hairline at this value. Widens the extent to hold it |
|
|
44
|
-
| `min` | `number` | — | Sparkline | The lowest value the extent must hold. The data widens the extent, never narrows it |
|
|
60
|
+
| `reference` | `number` | — | Sparkline | A dashed hairline at this value. Widens the extent to hold it. |
|
|
61
|
+
| `min` | `number` | — | Sparkline | The lowest value the extent must hold. The data widens the extent, never narrows it. |
|
|
45
62
|
| `max` | `number` | — | Sparkline | The highest value the extent must hold |
|
|
46
|
-
| `tone` | `'neutral' \| 'accent' \| 'secondary' \| 'info' \| 'success' \| 'warning' \| 'danger'` | — | Sparkline | How the series is doing. Wins over series; unset, a container may decide |
|
|
47
|
-
| `series` | `1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8` | — | Sparkline | Which series this is, as a slot of the data scale. Unset, a container decides, then slot 1 |
|
|
63
|
+
| `tone` | `'neutral' \| 'accent' \| 'secondary' \| 'info' \| 'success' \| 'warning' \| 'danger'` | — | Sparkline | How the series is doing. Wins over series; unset, a container may decide. |
|
|
64
|
+
| `series` | `1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8` | — | Sparkline | Which series this is, as a slot of the data scale. Unset, a container decides, then slot 1. |
|
|
48
65
|
| `label` | `string` | — | Sparkline | What the series is, said first in the description |
|
|
49
|
-
| `description` | `string` | — | Sparkline | The whole accessible name, in place of the generated one |
|
|
50
|
-
| `formatOptions` | `Intl.NumberFormatOptions` | — | Sparkline | How each number in the description is written |
|
|
51
|
-
| `valueFormatter` | `(value: number) => string` | — | Sparkline | A formatter of your own for the description, in place of Intl |
|
|
52
|
-
| `locale` | `string` | — | Sparkline | BCP 47, for the description’s numbers; the language in force when absent |
|
|
53
|
-
| `messages` | `Partial<SparklineMessages>` | — | Sparkline | Words laid over the language in force, key by key: up, down and flat with {last}, {change} and {first}, and noData |
|
|
54
|
-
| `render` | `(props) => ReactNode` | — | Sparkline | Substitutes the root element. The role, the name and every data attribute are handed to it |
|
|
55
|
-
| `ref` | `Ref<HTMLSpanElement>` | — | Sparkline | Reaches the root. Composed with the one the
|
|
56
|
-
| `--slotted-sparkline-color` | `custom property` | — | a container | What a sparkline with no tone and no series is drawn in. stat-card writes it on its trend from the delta’s tone |
|
|
57
|
-
| `SparklineDefaultsProvider` | `SparklineDefaults` | — | Application | Sets curve, area, marker and formatOptions once for everything below it; a prop still wins |
|
|
66
|
+
| `description` | `string` | — | Sparkline | The whole accessible name, in place of the generated one. |
|
|
67
|
+
| `formatOptions` | `Intl.NumberFormatOptions` | — | Sparkline | How each number in the description is written. |
|
|
68
|
+
| `valueFormatter` | `(value: number) => string` | — | Sparkline | A formatter of your own for the description, in place of Intl. |
|
|
69
|
+
| `locale` | `string` | — | Sparkline | BCP 47, for the description’s numbers; the language in force when absent. |
|
|
70
|
+
| `messages` | `Partial<SparklineMessages>` | — | Sparkline | Words laid over the language in force, key by key: up, down and flat with {last}, {change} and {first}, and noData. |
|
|
71
|
+
| `render` | `(props) => ReactNode` | — | Sparkline | Substitutes the root element. The role, the name and every data attribute are handed to it. |
|
|
72
|
+
| `ref` | `Ref<HTMLSpanElement>` | — | Sparkline | Reaches the root. Composed with the one the sparkline measures with, never replaced. |
|
|
73
|
+
| `--slotted-sparkline-color` | `custom property` | — | a container | What a sparkline with no tone and no series is drawn in. stat-card writes it on its trend from the delta’s tone. |
|
|
74
|
+
| `SparklineDefaultsProvider` | `SparklineDefaults` | — | Application | Sets curve, area, marker and formatOptions once for everything below it; a prop still wins. |
|
|
58
75
|
|
|
59
76
|
## Axes and defaults
|
|
60
77
|
|
|
@@ -81,105 +98,312 @@ Excerpt — not a complete module
|
|
|
81
98
|
|
|
82
99
|
## Examples
|
|
83
100
|
|
|
101
|
+
### Playground
|
|
102
|
+
|
|
103
|
+
One series, driven by the controls: the form, the curve, the wash and the marker.
|
|
104
|
+
|
|
105
|
+
Excerpt — not a complete module
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
<Sparkline data={fillRate} label="Fill rate, last 12 weeks" />;
|
|
109
|
+
```
|
|
110
|
+
|
|
84
111
|
### A line for a trend, bars for a count per period
|
|
85
112
|
|
|
86
113
|
The same twelve weeks four ways: a straight line, the line washed, the line smoothed with a monotone curve that never overshoots a point, and one bar per week with the current week at full color.
|
|
87
114
|
|
|
88
|
-
|
|
115
|
+
Example
|
|
89
116
|
|
|
90
117
|
```tsx
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
118
|
+
import { Sparkline } from '@slotted/react/sparkline';
|
|
119
|
+
import { Stack } from '@slotted/react/stack';
|
|
120
|
+
import { Text } from '@slotted/react/typography';
|
|
121
|
+
|
|
122
|
+
const ORDERS = [42, 48, 45, 53, 61, 58, 66, 72, 69, 77, 84, 91];
|
|
123
|
+
|
|
124
|
+
export default function SparklineTypes() {
|
|
125
|
+
return (
|
|
126
|
+
<Stack gap={4}>
|
|
127
|
+
<Stack gap={1}>
|
|
128
|
+
<Text size="sm" tone="muted">
|
|
129
|
+
Line
|
|
130
|
+
</Text>
|
|
131
|
+
<Sparkline data={ORDERS} label="Orders per week" />
|
|
132
|
+
</Stack>
|
|
133
|
+
<Stack gap={1}>
|
|
134
|
+
<Text size="sm" tone="muted">
|
|
135
|
+
Line with area
|
|
136
|
+
</Text>
|
|
137
|
+
<Sparkline area data={ORDERS} label="Orders per week" />
|
|
138
|
+
</Stack>
|
|
139
|
+
<Stack gap={1}>
|
|
140
|
+
<Text size="sm" tone="muted">
|
|
141
|
+
Monotone curve
|
|
142
|
+
</Text>
|
|
143
|
+
<Sparkline area curve="monotone" data={ORDERS} label="Orders per week" />
|
|
144
|
+
</Stack>
|
|
145
|
+
<Stack gap={1}>
|
|
146
|
+
<Text size="sm" tone="muted">
|
|
147
|
+
Bars
|
|
148
|
+
</Text>
|
|
149
|
+
<Sparkline data={ORDERS} label="Orders per week" type="bar" />
|
|
150
|
+
</Stack>
|
|
151
|
+
</Stack>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
95
154
|
```
|
|
96
155
|
|
|
97
156
|
### Three heights, and the width is the container’s
|
|
98
157
|
|
|
99
158
|
sm is twenty pixels tall for a table row, md thirty-two for a card, lg forty-eight for a card that leads a page. The stroke and the marker step down with sm; the width is always what the cell or the column gave.
|
|
100
159
|
|
|
101
|
-
|
|
160
|
+
Example
|
|
102
161
|
|
|
103
162
|
```tsx
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
163
|
+
import { Sparkline } from '@slotted/react/sparkline';
|
|
164
|
+
import { Stack } from '@slotted/react/stack';
|
|
165
|
+
import { Text } from '@slotted/react/typography';
|
|
166
|
+
|
|
167
|
+
const ORDERS = [42, 48, 45, 53, 61, 58, 66, 72, 69, 77, 84, 91];
|
|
168
|
+
|
|
169
|
+
export default function SparklineSizes() {
|
|
170
|
+
return (
|
|
171
|
+
<Stack gap={4}>
|
|
172
|
+
<Stack gap={1}>
|
|
173
|
+
<Text size="sm" tone="muted">
|
|
174
|
+
sm, 20 px, for a table row
|
|
175
|
+
</Text>
|
|
176
|
+
<Sparkline data={ORDERS} label="Orders per week" size="sm" />
|
|
177
|
+
</Stack>
|
|
178
|
+
<Stack gap={1}>
|
|
179
|
+
<Text size="sm" tone="muted">
|
|
180
|
+
md, 32 px, for a card
|
|
181
|
+
</Text>
|
|
182
|
+
<Sparkline data={ORDERS} label="Orders per week" size="md" />
|
|
183
|
+
</Stack>
|
|
184
|
+
<Stack gap={1}>
|
|
185
|
+
<Text size="sm" tone="muted">
|
|
186
|
+
lg, 48 px, for a card that leads a page
|
|
187
|
+
</Text>
|
|
188
|
+
<Sparkline data={ORDERS} label="Orders per week" size="lg" />
|
|
189
|
+
</Stack>
|
|
190
|
+
</Stack>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
107
193
|
```
|
|
108
194
|
|
|
109
195
|
### How the series is doing
|
|
110
196
|
|
|
111
197
|
A tone paints the line in the tone’s text color: success for an error rate that fell, danger for a lead time that grew, neutral for the comparison series behind a current one. Without a tone the line is the first slot of the data scale, the accent’s own hue.
|
|
112
198
|
|
|
113
|
-
|
|
199
|
+
Example
|
|
114
200
|
|
|
115
201
|
```tsx
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
202
|
+
import { Sparkline } from '@slotted/react/sparkline';
|
|
203
|
+
import { Stack } from '@slotted/react/stack';
|
|
204
|
+
import { Text } from '@slotted/react/typography';
|
|
205
|
+
|
|
206
|
+
const TREND_LINES = [
|
|
207
|
+
{ label: 'Last quarter', tone: 'neutral', data: [61, 64, 62, 66, 65, 68, 67, 70] },
|
|
208
|
+
{ label: 'Orders', tone: 'accent', data: [42, 48, 45, 53, 61, 58, 66, 72] },
|
|
209
|
+
{ label: 'Returns', tone: 'secondary', data: [14, 12, 15, 13, 16, 14, 17, 15] },
|
|
210
|
+
{ label: 'Inbound pallets', tone: 'info', data: [30, 34, 29, 38, 41, 36, 44, 47] },
|
|
211
|
+
{ label: 'Error rate', tone: 'success', data: [4.2, 3.9, 4.1, 3.4, 3.1, 2.8, 2.9, 2.4] },
|
|
212
|
+
{ label: 'Backorders', tone: 'warning', data: [18, 22, 19, 25, 24, 29, 27, 31] },
|
|
213
|
+
{ label: 'Lead time', tone: 'danger', data: [3.1, 3.3, 3.2, 3.8, 4.1, 4.6, 5.2, 5.9] },
|
|
214
|
+
] as const;
|
|
215
|
+
|
|
216
|
+
export default function SparklineTone() {
|
|
217
|
+
return (
|
|
218
|
+
<Stack gap={3}>
|
|
219
|
+
{TREND_LINES.map((line) => (
|
|
220
|
+
<Stack gap={1} key={line.tone}>
|
|
221
|
+
<Text size="sm" tone="muted">
|
|
222
|
+
{line.tone}
|
|
223
|
+
</Text>
|
|
224
|
+
<Sparkline data={line.data} label={line.label} tone={line.tone} />
|
|
225
|
+
</Stack>
|
|
226
|
+
))}
|
|
227
|
+
</Stack>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
119
230
|
```
|
|
120
231
|
|
|
121
232
|
### Which series this is
|
|
122
233
|
|
|
123
234
|
Eight slots of the data scale in a fixed order, so the sparklines of eight warehouses beside each other are eight colors a reader with deuteranopia still tells apart. A tone wins over a series where both are given.
|
|
124
235
|
|
|
125
|
-
|
|
236
|
+
Example
|
|
126
237
|
|
|
127
238
|
```tsx
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
239
|
+
import { Sparkline } from '@slotted/react/sparkline';
|
|
240
|
+
import { Stack } from '@slotted/react/stack';
|
|
241
|
+
import { Text } from '@slotted/react/typography';
|
|
242
|
+
|
|
243
|
+
const WAREHOUSES = [
|
|
244
|
+
{ name: 'Reno', series: 1, shipments: [210, 224, 218, 240, 236, 251, 262, 270] },
|
|
245
|
+
{ name: 'Columbus', series: 2, shipments: [180, 176, 190, 185, 199, 204, 198, 212] },
|
|
246
|
+
{ name: 'Savannah', series: 3, shipments: [150, 162, 158, 171, 166, 174, 181, 177] },
|
|
247
|
+
{ name: 'Dallas', series: 4, shipments: [240, 232, 245, 238, 251, 247, 258, 266] },
|
|
248
|
+
{ name: 'Memphis', series: 5, shipments: [120, 131, 127, 138, 142, 139, 147, 153] },
|
|
249
|
+
{ name: 'Phoenix', series: 6, shipments: [95, 102, 99, 108, 104, 113, 110, 119] },
|
|
250
|
+
{ name: 'Denver', series: 7, shipments: [135, 128, 140, 133, 129, 142, 138, 146] },
|
|
251
|
+
{ name: 'Atlanta', series: 8, shipments: [205, 211, 207, 219, 225, 221, 232, 238] },
|
|
252
|
+
] as const;
|
|
253
|
+
|
|
254
|
+
export default function SparklineSeriesExample() {
|
|
255
|
+
return (
|
|
256
|
+
<Stack gap={3}>
|
|
257
|
+
{WAREHOUSES.map((warehouse) => (
|
|
258
|
+
<Stack gap={1} key={warehouse.name}>
|
|
259
|
+
<Text size="sm" tone="muted">
|
|
260
|
+
{warehouse.name}, series {warehouse.series}
|
|
261
|
+
</Text>
|
|
262
|
+
<Sparkline
|
|
263
|
+
data={warehouse.shipments}
|
|
264
|
+
label={`${warehouse.name} shipments`}
|
|
265
|
+
series={warehouse.series}
|
|
266
|
+
/>
|
|
267
|
+
</Stack>
|
|
268
|
+
))}
|
|
269
|
+
</Stack>
|
|
270
|
+
);
|
|
271
|
+
}
|
|
138
272
|
```
|
|
139
273
|
|
|
140
274
|
### A line that is not data
|
|
141
275
|
|
|
142
276
|
The reference is dashed and neutral so it reads as a target before its color does, and it widens the extent when it lies outside the data: a target of 95% above a series that peaks at 91% is drawn above the line, not clipped.
|
|
143
277
|
|
|
144
|
-
|
|
278
|
+
Example
|
|
145
279
|
|
|
146
280
|
```tsx
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
281
|
+
import { Sparkline } from '@slotted/react/sparkline';
|
|
282
|
+
import { Stack } from '@slotted/react/stack';
|
|
283
|
+
import { Text } from '@slotted/react/typography';
|
|
284
|
+
|
|
285
|
+
const ON_TIME = [0.84, 0.86, 0.85, 0.88, 0.87, 0.89, 0.9, 0.88, 0.91, 0.9, 0.89, 0.91];
|
|
286
|
+
|
|
287
|
+
export default function SparklineReference() {
|
|
288
|
+
return (
|
|
289
|
+
<Stack gap={4}>
|
|
290
|
+
<Stack gap={1}>
|
|
291
|
+
<Text size="sm" tone="muted">
|
|
292
|
+
Target of 95%, above the data
|
|
293
|
+
</Text>
|
|
294
|
+
<Sparkline area data={ON_TIME} label="On-time delivery" reference={0.95} />
|
|
295
|
+
</Stack>
|
|
296
|
+
<Stack gap={1}>
|
|
297
|
+
<Text size="sm" tone="muted">
|
|
298
|
+
Bars drawn from 0 to 100%
|
|
299
|
+
</Text>
|
|
300
|
+
<Sparkline data={ON_TIME} label="On-time delivery" max={1} min={0} type="bar" />
|
|
301
|
+
</Stack>
|
|
302
|
+
</Stack>
|
|
303
|
+
);
|
|
304
|
+
}
|
|
151
305
|
```
|
|
152
306
|
|
|
153
307
|
### A gap is a gap, not a value
|
|
154
308
|
|
|
155
309
|
A null breaks the line and leaves the bar’s slot empty rather than being drawn as nought or bridged; a single point is a marker with no line; an empty series draws nothing and says so; a constant series runs through the middle.
|
|
156
310
|
|
|
157
|
-
|
|
311
|
+
Example
|
|
158
312
|
|
|
159
313
|
```tsx
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
314
|
+
import { Sparkline } from '@slotted/react/sparkline';
|
|
315
|
+
import { Stack } from '@slotted/react/stack';
|
|
316
|
+
import { Text } from '@slotted/react/typography';
|
|
317
|
+
|
|
318
|
+
const WEEKLY_RETURNS = [10, 12, null, null, 15, 14, 16, null, 18, 19];
|
|
319
|
+
|
|
320
|
+
export default function SparklineGaps() {
|
|
321
|
+
return (
|
|
322
|
+
<Stack gap={4}>
|
|
323
|
+
<Stack gap={1}>
|
|
324
|
+
<Text size="sm" tone="muted">
|
|
325
|
+
Line with missing weeks
|
|
326
|
+
</Text>
|
|
327
|
+
<Sparkline area data={WEEKLY_RETURNS} label="Returns" />
|
|
328
|
+
</Stack>
|
|
329
|
+
<Stack gap={1}>
|
|
330
|
+
<Text size="sm" tone="muted">
|
|
331
|
+
Bars with missing weeks
|
|
332
|
+
</Text>
|
|
333
|
+
<Sparkline data={WEEKLY_RETURNS} label="Returns" type="bar" />
|
|
334
|
+
</Stack>
|
|
335
|
+
<Stack gap={1}>
|
|
336
|
+
<Text size="sm" tone="muted">
|
|
337
|
+
One point
|
|
338
|
+
</Text>
|
|
339
|
+
<Sparkline data={[7]} label="Returns" />
|
|
340
|
+
</Stack>
|
|
341
|
+
<Stack gap={1}>
|
|
342
|
+
<Text size="sm" tone="muted">
|
|
343
|
+
Constant series
|
|
344
|
+
</Text>
|
|
345
|
+
<Sparkline data={[8, 8, 8, 8, 8, 8]} label="Returns" />
|
|
346
|
+
</Stack>
|
|
347
|
+
<Stack gap={1}>
|
|
348
|
+
<Text size="sm" tone="muted">
|
|
349
|
+
No data
|
|
350
|
+
</Text>
|
|
351
|
+
<Sparkline data={[]} label="Returns" />
|
|
352
|
+
</Stack>
|
|
353
|
+
</Stack>
|
|
354
|
+
);
|
|
355
|
+
}
|
|
164
356
|
```
|
|
165
357
|
|
|
166
|
-
###
|
|
358
|
+
### Dense, negative and mirrored data
|
|
167
359
|
|
|
168
360
|
Four hundred points in eighty pixels stay one path; bars with no room for a gap draw contiguous and never under a pixel; a series that crosses nought hangs its bars from a baseline inside the box; a right-to-left document reads the series from the right.
|
|
169
361
|
|
|
170
|
-
|
|
362
|
+
Example
|
|
171
363
|
|
|
172
364
|
```tsx
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
365
|
+
import { Sparkline } from '@slotted/react/sparkline';
|
|
366
|
+
import { Stack } from '@slotted/react/stack';
|
|
367
|
+
import { Text } from '@slotted/react/typography';
|
|
368
|
+
|
|
369
|
+
const REQUESTS_PER_MINUTE = Array.from(
|
|
370
|
+
{ length: 400 },
|
|
371
|
+
(_, index) => Math.round(120 + 40 * Math.sin(index / 12)) + (index % 9) * 3,
|
|
372
|
+
);
|
|
373
|
+
const NET_STOCK = [-12, 8, 15, -6, -20, 4, 18, 26, -9, 11, 22, 14];
|
|
374
|
+
const ORDERS = [42, 48, 45, 53, 61, 58, 66, 72, 69, 77, 84, 91];
|
|
375
|
+
|
|
376
|
+
export default function SparklineExtremes() {
|
|
377
|
+
return (
|
|
378
|
+
<Stack gap={4}>
|
|
379
|
+
<Stack gap={1}>
|
|
380
|
+
<Text size="sm" tone="muted">
|
|
381
|
+
400 points
|
|
382
|
+
</Text>
|
|
383
|
+
<Sparkline data={REQUESTS_PER_MINUTE} label="Requests per minute" />
|
|
384
|
+
</Stack>
|
|
385
|
+
<Stack gap={1}>
|
|
386
|
+
<Text size="sm" tone="muted">
|
|
387
|
+
Values below zero
|
|
388
|
+
</Text>
|
|
389
|
+
<Sparkline data={NET_STOCK} label="Net stock change" type="bar" />
|
|
390
|
+
</Stack>
|
|
391
|
+
<Stack gap={1}>
|
|
392
|
+
<Text size="sm" tone="muted">
|
|
393
|
+
Right to left
|
|
394
|
+
</Text>
|
|
395
|
+
<div dir="rtl">
|
|
396
|
+
<Sparkline data={ORDERS} label="Orders per week" />
|
|
397
|
+
</div>
|
|
398
|
+
</Stack>
|
|
399
|
+
</Stack>
|
|
400
|
+
);
|
|
401
|
+
}
|
|
178
402
|
```
|
|
179
403
|
|
|
180
404
|
### A trend column
|
|
181
405
|
|
|
182
|
-
|
|
406
|
+
A size="sm" line in a table cell takes the column’s width. The value it annotates sits in the column before it, and the accessible name carries the same numbers to a screen reader.
|
|
183
407
|
|
|
184
408
|
Excerpt — not a complete module
|
|
185
409
|
|
|
@@ -193,16 +417,168 @@ Excerpt — not a complete module
|
|
|
193
417
|
|
|
194
418
|
The root is an image named “Fill rate: 96.1%, up 3.2% since 92.9%” — last value, direction, change since the first, each number in the locale and format you give; description replaces the sentence, and messages replace its words.
|
|
195
419
|
|
|
196
|
-
|
|
420
|
+
Example
|
|
421
|
+
|
|
422
|
+
```tsx
|
|
423
|
+
import { Sparkline } from '@slotted/react/sparkline';
|
|
424
|
+
import { Stack } from '@slotted/react/stack';
|
|
425
|
+
import { Text } from '@slotted/react/typography';
|
|
426
|
+
|
|
427
|
+
const FILL_RATE = [
|
|
428
|
+
0.929, 0.934, 0.931, 0.938, 0.942, 0.936, 0.945, 0.951, 0.948, 0.955, 0.958, 0.961,
|
|
429
|
+
];
|
|
430
|
+
const PERCENT = { maximumFractionDigits: 1, style: 'percent' } as const;
|
|
431
|
+
|
|
432
|
+
export default function SparklineAccessibility() {
|
|
433
|
+
return (
|
|
434
|
+
<Stack gap={4}>
|
|
435
|
+
<Stack gap={1}>
|
|
436
|
+
<Text size="sm" tone="muted">
|
|
437
|
+
formatOptions, read as Fill rate: 96.1%, up 3.2% since 92.9%
|
|
438
|
+
</Text>
|
|
439
|
+
<Sparkline data={FILL_RATE} formatOptions={PERCENT} label="Fill rate" />
|
|
440
|
+
</Stack>
|
|
441
|
+
<Stack gap={1}>
|
|
442
|
+
<Text size="sm" tone="muted">
|
|
443
|
+
valueFormatter, numbers written in points
|
|
444
|
+
</Text>
|
|
445
|
+
<Sparkline
|
|
446
|
+
data={FILL_RATE}
|
|
447
|
+
label="Fill rate"
|
|
448
|
+
valueFormatter={(value) => `${(value * 100).toFixed(1)} pts`}
|
|
449
|
+
/>
|
|
450
|
+
</Stack>
|
|
451
|
+
<Stack gap={1}>
|
|
452
|
+
<Text size="sm" tone="muted">
|
|
453
|
+
locale, numbers written with a decimal comma
|
|
454
|
+
</Text>
|
|
455
|
+
<Sparkline data={FILL_RATE} formatOptions={PERCENT} label="Fill rate" locale="pt-BR" />
|
|
456
|
+
</Stack>
|
|
457
|
+
<Stack gap={1}>
|
|
458
|
+
<Text size="sm" tone="muted">
|
|
459
|
+
messages, the sentence for a rising series reworded
|
|
460
|
+
</Text>
|
|
461
|
+
<Sparkline
|
|
462
|
+
data={FILL_RATE}
|
|
463
|
+
formatOptions={PERCENT}
|
|
464
|
+
label="Fill rate"
|
|
465
|
+
messages={{ up: '{last}, rising {change} since {first}' }}
|
|
466
|
+
/>
|
|
467
|
+
</Stack>
|
|
468
|
+
<Stack gap={1}>
|
|
469
|
+
<Text size="sm" tone="muted">
|
|
470
|
+
description, the whole name replaced
|
|
471
|
+
</Text>
|
|
472
|
+
<Sparkline
|
|
473
|
+
data={FILL_RATE}
|
|
474
|
+
description="Fill rate held above 92% for twelve weeks"
|
|
475
|
+
label="Fill rate"
|
|
476
|
+
/>
|
|
477
|
+
</Stack>
|
|
478
|
+
</Stack>
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### defaults.tsx
|
|
484
|
+
|
|
485
|
+
Example
|
|
486
|
+
|
|
487
|
+
```tsx
|
|
488
|
+
import { Sparkline, SparklineDefaultsProvider } from '@slotted/react/sparkline';
|
|
489
|
+
import { Stack } from '@slotted/react/stack';
|
|
490
|
+
import { Text } from '@slotted/react/typography';
|
|
491
|
+
|
|
492
|
+
const ORDERS = [42, 48, 45, 53, 61, 58, 66, 72, 69, 77, 84, 91];
|
|
493
|
+
|
|
494
|
+
export default function SparklineDefaultsExample() {
|
|
495
|
+
return (
|
|
496
|
+
<SparklineDefaultsProvider area curve="monotone" marker={false}>
|
|
497
|
+
<Stack gap={4}>
|
|
498
|
+
<Stack gap={1}>
|
|
499
|
+
<Text size="sm" tone="muted">
|
|
500
|
+
Takes the defaults
|
|
501
|
+
</Text>
|
|
502
|
+
<Sparkline data={ORDERS} label="Orders per week" />
|
|
503
|
+
</Stack>
|
|
504
|
+
<Stack gap={1}>
|
|
505
|
+
<Text size="sm" tone="muted">
|
|
506
|
+
States curve, a straight line
|
|
507
|
+
</Text>
|
|
508
|
+
<Sparkline curve="linear" data={ORDERS} label="Orders per week" />
|
|
509
|
+
</Stack>
|
|
510
|
+
<Stack gap={1}>
|
|
511
|
+
<Text size="sm" tone="muted">
|
|
512
|
+
States marker, the disc back
|
|
513
|
+
</Text>
|
|
514
|
+
<Sparkline data={ORDERS} label="Orders per week" marker />
|
|
515
|
+
</Stack>
|
|
516
|
+
</Stack>
|
|
517
|
+
</SparklineDefaultsProvider>
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### table.tsx
|
|
523
|
+
|
|
524
|
+
Example
|
|
197
525
|
|
|
198
526
|
```tsx
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
527
|
+
import { Sparkline } from '@slotted/react/sparkline';
|
|
528
|
+
import {
|
|
529
|
+
Table,
|
|
530
|
+
TableBody,
|
|
531
|
+
TableCaption,
|
|
532
|
+
TableCell,
|
|
533
|
+
TableColumnHeader,
|
|
534
|
+
TableContent,
|
|
535
|
+
TableHead,
|
|
536
|
+
TableRow,
|
|
537
|
+
TableRowHeader,
|
|
538
|
+
} from '@slotted/react/table';
|
|
539
|
+
|
|
540
|
+
const PERCENT = new Intl.NumberFormat('en-US', { minimumFractionDigits: 1, style: 'percent' });
|
|
541
|
+
|
|
542
|
+
const LINES = [
|
|
543
|
+
{
|
|
544
|
+
name: 'Reno',
|
|
545
|
+
fillRate: [0.929, 0.934, 0.931, 0.938, 0.942, 0.936, 0.945, 0.951],
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
name: 'Columbus',
|
|
549
|
+
fillRate: [0.962, 0.958, 0.955, 0.951, 0.953, 0.947, 0.944, 0.941],
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
name: 'Savannah',
|
|
553
|
+
fillRate: [0.918, 0.921, 0.915, 0.924, 0.919, 0.922, 0.926, 0.923],
|
|
554
|
+
},
|
|
555
|
+
] as const;
|
|
556
|
+
|
|
557
|
+
export default function SparklineTable() {
|
|
558
|
+
return (
|
|
559
|
+
<Table columns={3}>
|
|
560
|
+
<TableContent>
|
|
561
|
+
<TableCaption>Fill rate by warehouse, last 8 weeks</TableCaption>
|
|
562
|
+
<TableHead>
|
|
563
|
+
<TableRow>
|
|
564
|
+
<TableColumnHeader>Warehouse</TableColumnHeader>
|
|
565
|
+
<TableColumnHeader numeric>Fill rate</TableColumnHeader>
|
|
566
|
+
<TableColumnHeader>Trend</TableColumnHeader>
|
|
567
|
+
</TableRow>
|
|
568
|
+
</TableHead>
|
|
569
|
+
<TableBody>
|
|
570
|
+
{LINES.map((line) => (
|
|
571
|
+
<TableRow key={line.name} value={line.name}>
|
|
572
|
+
<TableRowHeader text="nowrap">{line.name}</TableRowHeader>
|
|
573
|
+
<TableCell numeric>{PERCENT.format(line.fillRate.at(-1) ?? 0)}</TableCell>
|
|
574
|
+
<TableCell>
|
|
575
|
+
<Sparkline data={line.fillRate} label={`${line.name} fill rate`} size="sm" />
|
|
576
|
+
</TableCell>
|
|
577
|
+
</TableRow>
|
|
578
|
+
))}
|
|
579
|
+
</TableBody>
|
|
580
|
+
</TableContent>
|
|
581
|
+
</Table>
|
|
582
|
+
);
|
|
583
|
+
}
|
|
208
584
|
```
|