@motifx-community/ui 0.1.0-beta.5 → 0.1.0-beta.6
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/CHANGELOG.md +87 -0
- package/README.md +7 -4
- package/dist/components/appbar/AppBar.d.ts +88 -0
- package/dist/components/appbar/app-bar-navigation-click-event-args.d.ts +9 -0
- package/dist/components/appbar/app-bar-navigation.d.ts +2 -0
- package/dist/components/appbar/app-bar-position.d.ts +2 -0
- package/dist/components/appbar/app-bar-props.d.ts +49 -0
- package/dist/components/appbar/app-bar-scroll-behavior.d.ts +2 -0
- package/dist/components/appbar/app-bar-title-align.d.ts +2 -0
- package/dist/components/appbar/app-bar-tone.d.ts +2 -0
- package/dist/components/appbar/index.d.ts +8 -0
- package/dist/components/barcode/Barcode.d.ts +62 -0
- package/dist/components/barcode/barcode-export-options.d.ts +9 -0
- package/dist/components/barcode/barcode-failed-event-args.d.ts +9 -0
- package/dist/components/barcode/barcode-props.d.ts +25 -0
- package/dist/components/barcode/index.d.ts +5 -0
- package/dist/components/bargauge/BarGauge.d.ts +120 -0
- package/dist/components/bargauge/bar-gauge-props.d.ts +38 -0
- package/dist/components/bargauge/index.d.ts +2 -0
- package/dist/components/bottomnavigation/BottomNavigation.d.ts +101 -0
- package/dist/components/bottomnavigation/bottom-navigation-item-click-event-args.d.ts +9 -0
- package/dist/components/bottomnavigation/bottom-navigation-item.d.ts +35 -0
- package/dist/components/bottomnavigation/bottom-navigation-label-mode.d.ts +2 -0
- package/dist/components/bottomnavigation/bottom-navigation-position.d.ts +2 -0
- package/dist/components/bottomnavigation/bottom-navigation-props.d.ts +31 -0
- package/dist/components/bottomnavigation/bottom-navigation-selecting-event-args.d.ts +5 -0
- package/dist/components/bottomnavigation/bottom-navigation-selection-changed-event-args.d.ts +11 -0
- package/dist/components/bottomnavigation/index.d.ts +8 -0
- package/dist/components/chart/Chart.d.ts +229 -0
- package/dist/components/chart/ChartLegend.d.ts +24 -0
- package/dist/components/chart/ChartPlot.d.ts +161 -0
- package/dist/components/chart/ChartTable.d.ts +68 -0
- package/dist/components/chart/ChartTooltip.d.ts +22 -0
- package/dist/components/chart/PartsPlot.d.ts +39 -0
- package/dist/components/chart/RadarPlot.d.ts +34 -0
- package/dist/components/chart/chart-axis-kind.d.ts +2 -0
- package/dist/components/chart/chart-axis.d.ts +31 -0
- package/dist/components/chart/chart-data-error-event-args.d.ts +7 -0
- package/dist/components/chart/chart-export-options.d.ts +7 -0
- package/dist/components/chart/chart-export.d.ts +12 -0
- package/dist/components/chart/chart-field.d.ts +2 -0
- package/dist/components/chart/chart-labels.d.ts +2 -0
- package/dist/components/chart/chart-legend-options.d.ts +10 -0
- package/dist/components/chart/chart-legend-position.d.ts +2 -0
- package/dist/components/chart/chart-look.d.ts +25 -0
- package/dist/components/chart/chart-mode-changed-event-args.d.ts +7 -0
- package/dist/components/chart/chart-mode.d.ts +2 -0
- package/dist/components/chart/chart-model.d.ts +105 -0
- package/dist/components/chart/chart-point-event-args.d.ts +9 -0
- package/dist/components/chart/chart-point-selection.d.ts +2 -0
- package/dist/components/chart/chart-point.d.ts +23 -0
- package/dist/components/chart/chart-props.d.ts +76 -0
- package/dist/components/chart/chart-reference.d.ts +12 -0
- package/dist/components/chart/chart-selection-changed-event-args.d.ts +8 -0
- package/dist/components/chart/chart-series-toggled-event-args.d.ts +10 -0
- package/dist/components/chart/chart-series-type.d.ts +6 -0
- package/dist/components/chart/chart-series.d.ts +55 -0
- package/dist/components/chart/chart-stacked.d.ts +2 -0
- package/dist/components/chart/chart-tooltip-context.d.ts +10 -0
- package/dist/components/chart/chart-tooltip-options.d.ts +10 -0
- package/dist/components/chart/chart-zoom-changed-event-args.d.ts +8 -0
- package/dist/components/chart/index.d.ts +21 -0
- package/dist/components/chart/legend-entry.d.ts +13 -0
- package/dist/components/chart/plot-text.d.ts +10 -0
- package/dist/components/chart/plot-view.d.ts +61 -0
- package/dist/components/datagrid/grid-settings.d.ts +3 -3
- package/dist/components/datagrid/model/GridData.d.ts +22 -3
- package/dist/components/gauge/Gauge.d.ts +179 -0
- package/dist/components/gauge/gauge-mark.d.ts +9 -0
- package/dist/components/gauge/gauge-marker.d.ts +2 -0
- package/dist/components/gauge/gauge-needle-shape.d.ts +2 -0
- package/dist/components/gauge/gauge-orientation.d.ts +2 -0
- package/dist/components/gauge/gauge-props.d.ts +58 -0
- package/dist/components/gauge/gauge-range.d.ts +11 -0
- package/dist/components/gauge/gauge-scale.d.ts +2 -0
- package/dist/components/gauge/gauge-shape.d.ts +43 -0
- package/dist/components/gauge/gauge-type.d.ts +2 -0
- package/dist/components/gauge/index.d.ts +9 -0
- package/dist/components/otpinput/OtpInput.d.ts +73 -0
- package/dist/components/otpinput/index.d.ts +4 -0
- package/dist/components/otpinput/otp-charset.d.ts +2 -0
- package/dist/components/otpinput/otp-completed-event-args.d.ts +8 -0
- package/dist/components/otpinput/otp-input-props.d.ts +32 -0
- package/dist/components/qrcode/QRCode.d.ts +58 -0
- package/dist/components/qrcode/index.d.ts +5 -0
- package/dist/components/qrcode/qr-code-export-options.d.ts +9 -0
- package/dist/components/qrcode/qr-code-failed-event-args.d.ts +7 -0
- package/dist/components/qrcode/qr-code-props.d.ts +23 -0
- package/dist/components/signature/Signature.d.ts +100 -0
- package/dist/components/signature/index.d.ts +5 -0
- package/dist/components/signature/signature-draw.d.ts +15 -0
- package/dist/components/signature/signature-export-options.d.ts +11 -0
- package/dist/components/signature/signature-props.d.ts +30 -0
- package/dist/components/signature/signature-stroke-event-args.d.ts +9 -0
- package/dist/components/signature/signature-stroke.d.ts +11 -0
- package/dist/components/sparkline/Sparkline.d.ts +85 -0
- package/dist/components/sparkline/index.d.ts +4 -0
- package/dist/components/sparkline/sparkline-highlight.d.ts +2 -0
- package/dist/components/sparkline/sparkline-props.d.ts +34 -0
- package/dist/components/sparkline/sparkline-type.d.ts +2 -0
- package/dist/components/validationsummary/ValidationSummary.d.ts +1 -0
- package/dist/core/fonts-loaded.d.ts +2 -0
- package/dist/core/scroll-watch.d.ts +13 -0
- package/dist/core/ui-strings.d.ts +38 -0
- package/dist/generated/tokens.d.ts +3023 -863
- package/dist/index.d.ts +10 -0
- package/dist/index.js +55999 -47313
- package/dist/index.js.map +1 -1
- package/dist/locales/en.json +37 -1
- package/dist/locales/tr.json +37 -1
- package/dist/parts/chart/chart-paths.d.ts +30 -0
- package/dist/parts/chart/chart-scale.d.ts +13 -0
- package/dist/parts/chart/chart-text.d.ts +12 -0
- package/dist/parts/chart/nice-ticks.d.ts +6 -0
- package/dist/parts/chart/svg-parts.d.ts +12 -0
- package/dist/parts/chart/thin-out.d.ts +6 -0
- package/dist/parts/chart/time-ticks.d.ts +7 -0
- package/dist/parts/chart/token-lengths.d.ts +16 -0
- package/dist/parts/chart/value-motion.d.ts +16 -0
- package/dist/parts/code/barcode-encode.d.ts +23 -0
- package/dist/parts/code/code-image.d.ts +35 -0
- package/dist/parts/code/qr-encode.d.ts +10 -0
- package/dist/parts/field/Field.d.ts +2 -0
- package/dist/styles.css +3043 -9
- package/dist/tokens/index.d.ts +3212 -967
- package/dist/tokens/index.js +3023 -863
- package/dist/tokens/index.js.map +1 -1
- package/dist/{tr-C5IXRzAH.js → tr-DhIFcH3c.js} +75 -3
- package/dist/{tr-C5IXRzAH.js.map → tr-DhIFcH3c.js.map} +1 -1
- package/docs/accordion.md +1 -1
- package/docs/actionsheet.md +1 -1
- package/docs/appbar.md +194 -0
- package/docs/avatar.md +1 -1
- package/docs/badge.md +1 -1
- package/docs/bar-gauge-angles.md +87 -0
- package/docs/bar-gauge-data.md +122 -0
- package/docs/bar-gauge-labels.md +78 -0
- package/docs/bar-gauge.md +98 -0
- package/docs/barcode.md +193 -0
- package/docs/bottomnavigation.md +258 -0
- package/docs/bottomsheet.md +1 -1
- package/docs/breadcrumb.md +1 -1
- package/docs/button.md +1 -1
- package/docs/buttongroup.md +1 -1
- package/docs/buttons.md +169 -0
- package/docs/calendar.md +1 -1
- package/docs/card.md +1 -1
- package/docs/chart-bars.md +142 -0
- package/docs/chart-candles.md +164 -0
- package/docs/chart-funnel.md +115 -0
- package/docs/chart-heatmap.md +93 -0
- package/docs/chart-lines.md +128 -0
- package/docs/chart-live.md +62 -0
- package/docs/chart-pie.md +125 -0
- package/docs/chart-radar.md +124 -0
- package/docs/chart-ranges.md +127 -0
- package/docs/chart-references.md +126 -0
- package/docs/chart-scatter.md +139 -0
- package/docs/chart-waterfall.md +111 -0
- package/docs/chart-zoom.md +95 -0
- package/docs/chart.md +427 -0
- package/docs/checkbox.md +1 -1
- package/docs/chip.md +1 -1
- package/docs/choice.md +151 -0
- package/docs/colorbox.md +1 -1
- package/docs/combobox.md +1 -1
- package/docs/control.md +1 -1
- package/docs/data.md +127 -0
- package/docs/datagrid-api.md +1 -1
- package/docs/datagrid-bands.md +1 -1
- package/docs/datagrid-drag-select.md +1 -1
- package/docs/datagrid-drag.md +1 -1
- package/docs/datagrid-editing.md +1 -1
- package/docs/datagrid-filtering.md +1 -1
- package/docs/datagrid-forms.md +1 -1
- package/docs/datagrid-grouping.md +62 -2
- package/docs/datagrid-layout.md +2 -2
- package/docs/datagrid-lookups.md +1 -1
- package/docs/datagrid-master-detail.md +1 -1
- package/docs/datagrid-scrolling.md +1 -1
- package/docs/datagrid-selection.md +1 -1
- package/docs/datagrid.md +1 -1
- package/docs/datebox.md +1 -1
- package/docs/daterangebox.md +1 -1
- package/docs/display.md +148 -0
- package/docs/draggable.md +1 -1
- package/docs/drawer.md +1 -1
- package/docs/dropdown.md +1 -1
- package/docs/editors.md +157 -0
- package/docs/feedback.md +138 -0
- package/docs/fileuploader.md +1 -1
- package/docs/filterbuilder.md +1 -1
- package/docs/formlayout.md +1 -1
- package/docs/foundations.md +79 -0
- package/docs/gallery.md +1 -1
- package/docs/gauge-base.md +78 -0
- package/docs/gauge-circular.md +101 -0
- package/docs/gauge-dashboards.md +134 -0
- package/docs/gauge-linear.md +84 -0
- package/docs/gauge-markers.md +135 -0
- package/docs/gauge-marks.md +108 -0
- package/docs/gauge-ranges.md +133 -0
- package/docs/gauge-scales.md +117 -0
- package/docs/gauge.md +152 -0
- package/docs/home.md +1 -1
- package/docs/keyboard.md +1 -1
- package/docs/language.md +1 -1
- package/docs/layout.md +1 -1
- package/docs/listbox.md +1 -1
- package/docs/loadpanel.md +1 -1
- package/docs/lookup.md +1 -1
- package/docs/menus.md +1 -1
- package/docs/multiview.md +1 -1
- package/docs/navigation.md +143 -0
- package/docs/numberbox.md +1 -1
- package/docs/otpinput.md +197 -0
- package/docs/pagination.md +1 -1
- package/docs/popover.md +1 -1
- package/docs/progress.md +1 -1
- package/docs/qrcode.md +179 -0
- package/docs/radiogroup.md +1 -1
- package/docs/rating.md +1 -1
- package/docs/resizable.md +1 -1
- package/docs/scheduler-agenda.md +1 -1
- package/docs/scheduler-big-data.md +1 -1
- package/docs/scheduler-editing.md +1 -1
- package/docs/scheduler-form.md +1 -1
- package/docs/scheduler-icalendar.md +1 -1
- package/docs/scheduler-mobile.md +1 -1
- package/docs/scheduler-recurrence.md +1 -1
- package/docs/scheduler-resources.md +1 -1
- package/docs/scheduler-timeline.md +1 -1
- package/docs/scheduler.md +1 -1
- package/docs/scrollview.md +1 -1
- package/docs/showcase-home.md +31 -0
- package/docs/showcase.md +1 -1
- package/docs/signature.md +208 -0
- package/docs/skeleton.md +1 -1
- package/docs/slider.md +1 -1
- package/docs/sortable.md +1 -1
- package/docs/sparkline.md +119 -0
- package/docs/speeddial.md +1 -1
- package/docs/splitter.md +1 -1
- package/docs/stepper.md +1 -1
- package/docs/switch.md +1 -1
- package/docs/tabdocs-dock.md +1 -1
- package/docs/tabdocs-drag.md +1 -1
- package/docs/tabdocs-menus.md +1 -1
- package/docs/tabdocs-mobile.md +1 -1
- package/docs/tabdocs-tabs.md +1 -1
- package/docs/tabdocs-windows.md +1 -1
- package/docs/tabdocs-workspace.md +1 -1
- package/docs/tabdocs.md +1 -1
- package/docs/tabs.md +1 -1
- package/docs/tagbox.md +1 -1
- package/docs/textarea.md +1 -1
- package/docs/textbox.md +1 -1
- package/docs/tileview.md +1 -1
- package/docs/timeline.md +1 -1
- package/docs/toast.md +1 -1
- package/docs/tokens.md +450 -1
- package/docs/toolbar.md +1 -1
- package/docs/tooltip.md +1 -1
- package/docs/treeview.md +1 -1
- package/docs/validationsummary.md +1 -1
- package/docs/window.md +1 -1
- package/docs/wizard.md +1 -1
- package/llms-full.txt +6724 -98
- package/llms.txt +50 -1
- package/package.json +5 -5
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Gauge: Base value
|
|
2
|
+
|
|
3
|
+
> Gauges · @motifx-community/ui 0.1.0-beta.6
|
|
4
|
+
|
|
5
|
+
The fill starts at the start of the scale, or at a base value inside it. A scale with values on both sides of a target then fills from the target, either way.
|
|
6
|
+
|
|
7
|
+
## Either way from a target
|
|
8
|
+
|
|
9
|
+
`baseValue` sets where the fill starts. A deviation fills from 0 to the left or to the right, on an arc and on a bar.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { reactive } from '@motifx/core';
|
|
13
|
+
import { Gauge, Slider, Stack } from '@motifx-community/ui';
|
|
14
|
+
|
|
15
|
+
const degrees = (v: number) => `${v}°`;
|
|
16
|
+
|
|
17
|
+
/** A deviation from the target: the fill grows from 0 to either side. */
|
|
18
|
+
export default function Deviation() {
|
|
19
|
+
const s = reactive({ angle: 20 });
|
|
20
|
+
return (
|
|
21
|
+
<Stack gap="md">
|
|
22
|
+
<Stack orientation="horizontal" gap="lg" wrap align="end">
|
|
23
|
+
<Gauge class="ga-base" angle={90} min={-45} max={45} baseValue={0} value={() => s.angle} scale="ticks" tickInterval={45} format={degrees}
|
|
24
|
+
label="Deviation" size={240} />
|
|
25
|
+
<Gauge class="ga-base-bar" type="linear" orientation="vertical" size={180} min={-45} max={45} baseValue={0} value={() => s.angle}
|
|
26
|
+
scale="ticks" tickInterval={15} format={degrees} label="Deviation" />
|
|
27
|
+
</Stack>
|
|
28
|
+
<Slider label="Deviation" x-model={() => s.angle} min={-45} max={45} />
|
|
29
|
+
</Stack>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Losses and profits
|
|
35
|
+
|
|
36
|
+
Bars in a list, each filling from 0: a loss to the left in the danger tone, a profit to the right in the good tone.
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { Gauge, Stack } from '@motifx-community/ui';
|
|
40
|
+
|
|
41
|
+
const MONTHS = [
|
|
42
|
+
{ name: 'January', change: 12 },
|
|
43
|
+
{ name: 'February', change: -7 },
|
|
44
|
+
{ name: 'March', change: 4 },
|
|
45
|
+
{ name: 'April', change: -15 }
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const RESULT = [
|
|
49
|
+
{ from: -20, to: 0, tone: 'danger' as const, label: 'loss' },
|
|
50
|
+
{ from: 0, to: 20, tone: 'good' as const, label: 'profit' }
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
/** Changes against last year, one bar each: a loss fills to the left of 0, a profit to the right. */
|
|
54
|
+
export default function Balance() {
|
|
55
|
+
return (
|
|
56
|
+
<Stack class="ga-balance" gap="md" style="inline-size: 100%">
|
|
57
|
+
{MONTHS.map(m => (
|
|
58
|
+
<Gauge type="linear" value={m.change} min={-20} max={20} baseValue={0} label={m.name} ranges={RESULT} scale="ticks" tickInterval={10}
|
|
59
|
+
format={{ style: 'unit', unit: 'percent', signDisplay: 'exceptZero' }} />
|
|
60
|
+
))}
|
|
61
|
+
</Stack>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Props on this page
|
|
67
|
+
|
|
68
|
+
| Prop | Type | Default | Description |
|
|
69
|
+
| --- | --- | --- | --- |
|
|
70
|
+
| `baseValue` | `Bind<number \| null>` | The start of the scale | Where the fill starts. |
|
|
71
|
+
| `fill` | `Bind<boolean>` | `true` | Fills the track from `baseValue` to the value. |
|
|
72
|
+
| `ranges` | `Bind<GaugeRange[]>` | `[]` | Stretches of the scale: `from`, `to`, `tone` or `color`, and a `label` read with the value. A range with neither a tone nor a color takes the next chart color. |
|
|
73
|
+
|
|
74
|
+
Every other prop, and the types of ranges and marks, are on the [Overview](gauge.md#api).
|
|
75
|
+
|
|
76
|
+
## Feedback
|
|
77
|
+
|
|
78
|
+
Loading issues…
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Gauge: Circular
|
|
2
|
+
|
|
3
|
+
> Gauges · @motifx-community/ui 0.1.0-beta.6
|
|
4
|
+
|
|
5
|
+
A circular gauge shows its value on an arc or a whole circle, with the value written in the middle. It reads best for one value whose scale the reader knows, such as a speed or a share.
|
|
6
|
+
|
|
7
|
+
## Arc and circle
|
|
8
|
+
|
|
9
|
+
`type` draws an open arc, `'arc'`, or a whole circle, `'circle'`. `angle` sets how far an arc goes round: 240 degrees by default, open at the bottom.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { Gauge, Stack } from '@motifx-community/ui';
|
|
13
|
+
|
|
14
|
+
/** The default arc of 240 degrees, a wider one of 300, and a whole circle. */
|
|
15
|
+
export default function ArcCircle() {
|
|
16
|
+
return (
|
|
17
|
+
<Stack orientation="horizontal" gap="lg" wrap align="end">
|
|
18
|
+
<Gauge class="ga-arc" value={72} label="Arc" />
|
|
19
|
+
<Gauge angle={300} value={72} label="Wide arc" />
|
|
20
|
+
<Gauge class="ga-circle" type="circle" value={72} label="Circle" />
|
|
21
|
+
</Stack>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Half and quarter
|
|
27
|
+
|
|
28
|
+
`angle` of 180 draws a half and 90 a quarter; `rotation` turns the arc, here to each corner. A quarter has little room inside, so its value is better left out with `showValue`.
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { Gauge, Stack } from '@motifx-community/ui';
|
|
32
|
+
|
|
33
|
+
/** A half, and a quarter turned to each corner. A quarter has little room inside, so its value is left out. */
|
|
34
|
+
export default function HalfQuarter() {
|
|
35
|
+
return (
|
|
36
|
+
<Stack orientation="horizontal" gap="lg" wrap align="end">
|
|
37
|
+
<Gauge class="ga-half" angle={180} value={72} label="Half" />
|
|
38
|
+
<Gauge class="ga-quarter" angle={90} rotation={-45} value={80} label="Upper left" showValue={false} scale="ticks" tickInterval={50} />
|
|
39
|
+
<Gauge angle={90} rotation={45} value={75} label="Upper right" showValue={false} scale="ticks" tickInterval={50} />
|
|
40
|
+
<Gauge angle={90} rotation={135} value={70} label="Lower right" showValue={false} scale="ticks" tickInterval={50} />
|
|
41
|
+
<Gauge angle={90} rotation={-135} value={68} label="Lower left" showValue={false} scale="ticks" tickInterval={50} />
|
|
42
|
+
</Stack>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Size
|
|
48
|
+
|
|
49
|
+
`size` sets the width of the arc's whole circle, with its ranges. Ticks, their values and marks go around it, so a scale never makes the arc smaller.
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { Gauge, Stack } from '@motifx-community/ui';
|
|
53
|
+
|
|
54
|
+
/** The same gauge at three sizes. The track keeps the thickness of the design language. */
|
|
55
|
+
export default function Sizes() {
|
|
56
|
+
return (
|
|
57
|
+
<Stack orientation="horizontal" gap="lg" wrap align="end">
|
|
58
|
+
<Gauge class="ga-small" size={120} value={40} label="120 px" />
|
|
59
|
+
<Gauge value={40} label="Design language" />
|
|
60
|
+
<Gauge class="ga-large" size={220} value={40} label="220 px" scale="ticks" tickInterval={10} />
|
|
61
|
+
</Stack>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Value and label
|
|
67
|
+
|
|
68
|
+
The value is written in the middle with `format`, and `label` under it. `showValue` leaves the value out. With a needle, the value moves under the arc to keep the middle clear.
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import { Gauge, Stack } from '@motifx-community/ui';
|
|
72
|
+
|
|
73
|
+
/** The value in the middle with a unit, a gauge that shows only its fill, and a needle that moves the value under the arc. */
|
|
74
|
+
export default function ValueLabel() {
|
|
75
|
+
return (
|
|
76
|
+
<Stack orientation="horizontal" gap="lg" wrap align="end">
|
|
77
|
+
<Gauge value={21.5} label="Room" format={{ style: 'unit', unit: 'celsius', maximumFractionDigits: 1 }} />
|
|
78
|
+
<Gauge value={21.5} max={40} label="Room" showValue={false} />
|
|
79
|
+
<Gauge class="ga-needle-value" value={21.5} max={40} label="Room" marker="needle" format={{ style: 'unit', unit: 'celsius', maximumFractionDigits: 1 }} />
|
|
80
|
+
</Stack>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Props on this page
|
|
86
|
+
|
|
87
|
+
| Prop | Type | Default | Description |
|
|
88
|
+
| --- | --- | --- | --- |
|
|
89
|
+
| `type` | `Bind<'arc' \| 'circle' \| 'linear'>` | `'arc'` | How it draws. |
|
|
90
|
+
| `angle` | `Bind<number>` | `240` | How far an arc goes round, in degrees. |
|
|
91
|
+
| `rotation` | `Bind<number>` | `0` | How far the middle of an arc is turned from the top, clockwise, in degrees. |
|
|
92
|
+
| `size` | `Bind<number \| null>` | From the design language | The width of an arc's whole circle, or the length of an upright gauge, in pixels. |
|
|
93
|
+
| `showValue` | `Bind<boolean>` | `true` | Shows the value in the middle. |
|
|
94
|
+
| `label` | `Bind<string>` | `''` | What it measures, shown under the value and read as its name. |
|
|
95
|
+
| `format` | `Bind<ChartFormat \| null>` | The language's numbers | How the values read: options of the browser's number format, or a function of your own. |
|
|
96
|
+
|
|
97
|
+
Every other prop, and the types of ranges and marks, are on the [Overview](gauge.md#api).
|
|
98
|
+
|
|
99
|
+
## Feedback
|
|
100
|
+
|
|
101
|
+
Loading issues…
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Gauge: Dashboards
|
|
2
|
+
|
|
3
|
+
> Gauges · @motifx-community/ui 0.1.0-beta.6
|
|
4
|
+
|
|
5
|
+
Gauges of different kinds put together, all following the same values. Each gauge keeps its own scale, so readers compare values by their meaning, not by size alone.
|
|
6
|
+
|
|
7
|
+
## Upright gauges side by side
|
|
8
|
+
|
|
9
|
+
Three upright gauges, each showing its value its own way, follow the city chosen: a fill from 0, a rhombus, and a circle among ranges.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { reactive } from '@motifx/core';
|
|
13
|
+
import { DropDown, Gauge, Stack } from '@motifx-community/ui';
|
|
14
|
+
|
|
15
|
+
const CITIES = [
|
|
16
|
+
{ name: 'Ankara', temperature: 14, humidity: 48, pressure: 1016 },
|
|
17
|
+
{ name: 'Lisbon', temperature: 21, humidity: 67, pressure: 1021 },
|
|
18
|
+
{ name: 'Oslo', temperature: -6, humidity: 81, pressure: 994 },
|
|
19
|
+
{ name: 'Cairo', temperature: 33, humidity: 22, pressure: 1009 }
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const PRESSURE = [
|
|
23
|
+
{ from: 900, to: 1000, label: 'low' },
|
|
24
|
+
{ from: 1000, to: 1020, label: 'normal' },
|
|
25
|
+
{ from: 1020, to: 1100, label: 'high' }
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
/** Three upright gauges, each showing its value its own way: a fill from 0, a rhombus, a circle among ranges. */
|
|
29
|
+
export default function Weather() {
|
|
30
|
+
const s = reactive({ city: 'Ankara' as string | null });
|
|
31
|
+
const city = () => CITIES.find(c => c.name === s.city) ?? CITIES[0];
|
|
32
|
+
return (
|
|
33
|
+
<Stack gap="lg" align="center">
|
|
34
|
+
<Stack orientation="horizontal" gap="xl" wrap justify="center">
|
|
35
|
+
<Gauge class="ga-weather" type="linear" orientation="vertical" size={220} min={-40} max={40} baseValue={0} scale="ticks" tickInterval={20}
|
|
36
|
+
value={() => city().temperature} label="Temperature (°C)" />
|
|
37
|
+
<Gauge class="ga-weather" type="linear" orientation="vertical" size={220} scale="ticks" tickInterval={10} fill={false} marker="rhombus"
|
|
38
|
+
value={() => city().humidity} label="Humidity (%)" />
|
|
39
|
+
<Gauge class="ga-weather" type="linear" orientation="vertical" size={220} min={900} max={1100} scale="ticks" ticks={[900, 1000, 1020, 1100]}
|
|
40
|
+
fill={false} marker="circle" value={() => city().pressure} label="Pressure (hPa)" ranges={PRESSURE} />
|
|
41
|
+
</Stack>
|
|
42
|
+
<DropDown label="City" items={CITIES} textField="name" valueField="name" x-model={() => s.city} />
|
|
43
|
+
</Stack>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## A dashboard
|
|
49
|
+
|
|
50
|
+
A speedometer with a needle, four quarter gauges around it, and a fuel bar, all driven by one slider.
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { reactive } from '@motifx/core';
|
|
54
|
+
import { Gauge, Slider, Stack } from '@motifx-community/ui';
|
|
55
|
+
|
|
56
|
+
/** Gauges put together: a speedometer, four quarter gauges around it and a fuel bar, all driven by one slider. */
|
|
57
|
+
export default function Dashboard() {
|
|
58
|
+
const s = reactive({ speed: 80 });
|
|
59
|
+
const quarter = (rotation: number, label: string, value: () => number) => (
|
|
60
|
+
<Gauge class="ga-dash-quarter" angle={90} rotation={rotation} size={130} value={value} label={label} showValue={false} scale="ticks" tickInterval={50} />
|
|
61
|
+
);
|
|
62
|
+
return (
|
|
63
|
+
<Stack gap="lg" align="center">
|
|
64
|
+
<Stack orientation="horizontal" gap="md" align="center" wrap justify="center">
|
|
65
|
+
<Stack gap="md">
|
|
66
|
+
{quarter(-45, 'Oil', () => s.speed / 2)}
|
|
67
|
+
{quarter(-135, 'Water', () => 100 - s.speed / 2)}
|
|
68
|
+
</Stack>
|
|
69
|
+
<Gauge class="ga-speed" value={() => s.speed} max={200} size={220} angle={270} scale="ticks" tickInterval={20} minorTicks={1}
|
|
70
|
+
marker="needle" label="km/h" ranges={[{ from: 160, to: 200, tone: 'danger' }]} />
|
|
71
|
+
<Stack gap="md">
|
|
72
|
+
{quarter(45, 'Load', () => s.speed / 2)}
|
|
73
|
+
{quarter(135, 'Charge', () => 100 - s.speed / 2)}
|
|
74
|
+
</Stack>
|
|
75
|
+
</Stack>
|
|
76
|
+
<Gauge class="ga-fuel" type="linear" value={() => 50 - s.speed * 0.2} max={50} scale="ticks" tickInterval={25} minorTicks={1}
|
|
77
|
+
format={{ maximumFractionDigits: 0 }} label="Fuel (l)" />
|
|
78
|
+
<Slider label="Speed" x-model={() => s.speed} min={0} max={200} />
|
|
79
|
+
</Stack>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Live values
|
|
85
|
+
|
|
86
|
+
New values every second. Each change moves over the motion of the design language, and values that come quicker than it are drawn at once.
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { reactive } from '@motifx/core';
|
|
90
|
+
import { Button, Gauge, Stack } from '@motifx-community/ui';
|
|
91
|
+
|
|
92
|
+
const LOAD = [
|
|
93
|
+
{ from: 0, to: 70, tone: 'good' as const, label: 'normal' },
|
|
94
|
+
{ from: 70, to: 90, tone: 'warning' as const, label: 'high' },
|
|
95
|
+
{ from: 90, to: 100, tone: 'danger' as const, label: 'critical' }
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
const walk = (v: number, step: number) => Math.max(2, Math.min(98, v + Math.round(Math.random() * step * 2 - step)));
|
|
99
|
+
|
|
100
|
+
/** New values every second. Each change moves over the motion of the design language. */
|
|
101
|
+
export default function ServerLoad() {
|
|
102
|
+
const s = reactive({ running: true, cpu: 46, memory: 62, disk: 31 });
|
|
103
|
+
const timer = setInterval(() => {
|
|
104
|
+
if (!s.running) return;
|
|
105
|
+
s.cpu = walk(s.cpu, 12);
|
|
106
|
+
s.memory = walk(s.memory, 4);
|
|
107
|
+
s.disk = walk(s.disk, 8);
|
|
108
|
+
}, 1000);
|
|
109
|
+
return (
|
|
110
|
+
<Stack gap="md" align="start" onDisposing={() => clearInterval(timer)}>
|
|
111
|
+
<Stack orientation="horizontal" gap="lg" wrap align="end">
|
|
112
|
+
<Gauge class="ga-live" value={() => s.cpu} ranges={LOAD} label="Processor" format={{ style: 'unit', unit: 'percent' }} />
|
|
113
|
+
<Gauge value={() => s.memory} ranges={LOAD} marker="needle" fill={false} scale="ticks" tickInterval={25} label="Memory" format={{ style: 'unit', unit: 'percent' }} />
|
|
114
|
+
<Gauge type="linear" orientation="vertical" size={160} value={() => s.disk} ranges={LOAD} scale="ticks" tickInterval={25} label="Disk" />
|
|
115
|
+
</Stack>
|
|
116
|
+
<Button text={() => (s.running ? 'Pause' : 'Go on')} variant="outline" onclick={() => (s.running = !s.running)} />
|
|
117
|
+
</Stack>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Props on this page
|
|
123
|
+
|
|
124
|
+
| Prop | Type | Default | Description |
|
|
125
|
+
| --- | --- | --- | --- |
|
|
126
|
+
| `value` | `Bind<number \| null>` | `null` | The value. |
|
|
127
|
+
| `marker` | `Bind<'needle' \| 'triangle' \| 'circle' \| 'rhombus' \| 'line' \| 'text' \| null>` | `null` | A shape that points at the value. On a straight gauge a needle is a triangle. |
|
|
128
|
+
| `ranges` | `Bind<GaugeRange[]>` | `[]` | Stretches of the scale: `from`, `to`, `tone` or `color`, and a `label` read with the value. A range with neither a tone nor a color takes the next chart color. |
|
|
129
|
+
|
|
130
|
+
Every other prop, and the types of ranges and marks, are on the [Overview](gauge.md#api).
|
|
131
|
+
|
|
132
|
+
## Feedback
|
|
133
|
+
|
|
134
|
+
Loading issues…
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Gauge: Linear
|
|
2
|
+
|
|
3
|
+
> Gauges · @motifx-community/ui 0.1.0-beta.6
|
|
4
|
+
|
|
5
|
+
A linear gauge shows its value on a straight bar, across or upright. Bars fit in narrow places, line up in lists, and compare well side by side.
|
|
6
|
+
|
|
7
|
+
## Across
|
|
8
|
+
|
|
9
|
+
`type: 'linear'` draws a bar across the width it is given. The label and the value sit above it; the ends of the scale sit under its ends, or ticks with `scale`.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { Gauge, Stack } from '@motifx-community/ui';
|
|
13
|
+
|
|
14
|
+
/** A bar across with the ends of its scale under its ends, and one with ticks. The label and the value sit above. */
|
|
15
|
+
export default function Across() {
|
|
16
|
+
return (
|
|
17
|
+
<Stack gap="lg" style="inline-size: 100%">
|
|
18
|
+
<Gauge class="ga-linear" type="linear" value={72} label="Storage" format={{ style: 'unit', unit: 'gigabyte' }} max={128} />
|
|
19
|
+
<Gauge type="linear" value={4.3} max={5} scale="ticks" tickInterval={1} minorTicks={3} label="Rating" format={{ maximumFractionDigits: 1 }} />
|
|
20
|
+
</Stack>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Upright
|
|
26
|
+
|
|
27
|
+
`orientation: 'vertical'` stands the bar upright, and `size` sets its length. The label sits above and the value under it.
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { Gauge, Stack } from '@motifx-community/ui';
|
|
31
|
+
|
|
32
|
+
/** Upright gauges: `size` sets their length. The label sits above and the value under them. */
|
|
33
|
+
export default function Upright() {
|
|
34
|
+
return (
|
|
35
|
+
<Stack orientation="horizontal" gap="xl" wrap align="end">
|
|
36
|
+
<Gauge class="ga-upright" type="linear" orientation="vertical" size={160} value={72} label="Tank" scale="ticks" />
|
|
37
|
+
<Gauge type="linear" orientation="vertical" size={220} value={35} max={50} label="Fuel (l)" scale="ticks" tickInterval={10} minorTicks={1} />
|
|
38
|
+
<Gauge type="linear" orientation="vertical" size={120} value={0.8} max={1} label="Load" format={{ style: 'percent' }} />
|
|
39
|
+
</Stack>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## In a list
|
|
45
|
+
|
|
46
|
+
Bars one under another read as a list. Here a range marks the last tenth of each drive, and its tone shows when a drive is almost full.
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { Gauge, Stack } from '@motifx-community/ui';
|
|
50
|
+
|
|
51
|
+
const DRIVES = [
|
|
52
|
+
{ name: 'System', used: 212, size: 256 },
|
|
53
|
+
{ name: 'Projects', used: 640, size: 1000 },
|
|
54
|
+
{ name: 'Backup', used: 1880, size: 2000 }
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
/** Bars in a list, one for each drive. A drive more than 90 percent full takes the danger tone. */
|
|
58
|
+
export default function Drives() {
|
|
59
|
+
return (
|
|
60
|
+
<Stack class="ga-drives" gap="md" style="inline-size: 100%">
|
|
61
|
+
{DRIVES.map(d => (
|
|
62
|
+
<Gauge type="linear" value={d.used} max={d.size} label={d.name} format={{ style: 'unit', unit: 'gigabyte' }}
|
|
63
|
+
ranges={[{ from: d.size * 0.9, to: d.size, tone: 'danger', label: 'almost full' }]} />
|
|
64
|
+
))}
|
|
65
|
+
</Stack>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Props on this page
|
|
71
|
+
|
|
72
|
+
| Prop | Type | Default | Description |
|
|
73
|
+
| --- | --- | --- | --- |
|
|
74
|
+
| `type` | `Bind<'arc' \| 'circle' \| 'linear'>` | `'arc'` | How it draws. |
|
|
75
|
+
| `orientation` | `Bind<'horizontal' \| 'vertical'>` | `'horizontal'` | Which way a straight gauge runs. |
|
|
76
|
+
| `size` | `Bind<number \| null>` | From the design language | The width of an arc's whole circle, or the length of an upright gauge, in pixels. |
|
|
77
|
+
| `label` | `Bind<string>` | `''` | What it measures, shown under the value and read as its name. |
|
|
78
|
+
| `format` | `Bind<ChartFormat \| null>` | The language's numbers | How the values read: options of the browser's number format, or a function of your own. |
|
|
79
|
+
|
|
80
|
+
Every other prop, and the types of ranges and marks, are on the [Overview](gauge.md#api).
|
|
81
|
+
|
|
82
|
+
## Feedback
|
|
83
|
+
|
|
84
|
+
Loading issues…
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Gauge: Markers
|
|
2
|
+
|
|
3
|
+
> Gauges · @motifx-community/ui 0.1.0-beta.6
|
|
4
|
+
|
|
5
|
+
A marker points at the value: a needle from the middle of an arc, a shape on or beside the track, or a callout that writes the value.
|
|
6
|
+
|
|
7
|
+
## Needles
|
|
8
|
+
|
|
9
|
+
`marker: 'needle'` draws a needle from the middle, and `needleShape` sets how: narrowing to its tip, straight, or straight with its tip in the color of the value's range.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { Gauge, Stack, type GaugeNeedleShape } from '@motifx-community/ui';
|
|
13
|
+
|
|
14
|
+
const NEEDLES: { shape: GaugeNeedleShape; value: number; label: string }[] = [
|
|
15
|
+
{ shape: 'tapered', value: 75, label: 'Tapered' },
|
|
16
|
+
{ shape: 'straight', value: 62, label: 'Straight' },
|
|
17
|
+
{ shape: 'two-tone', value: 80, label: 'Two-tone' }
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/** The three needles, on a half arc without a fill. A two-tone needle's tip takes the color of the value's range. */
|
|
21
|
+
export default function Needles() {
|
|
22
|
+
return (
|
|
23
|
+
<Stack orientation="horizontal" gap="lg" wrap align="end">
|
|
24
|
+
{NEEDLES.map(n => (
|
|
25
|
+
<Gauge class="ga-marker" angle={180} fill={false} scale="ticks" tickInterval={50} marker="needle" needleShape={n.shape} value={n.value} label={n.label}
|
|
26
|
+
ranges={[{ from: 80, to: 100, tone: 'danger' }]} />
|
|
27
|
+
))}
|
|
28
|
+
</Stack>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Shapes on the track
|
|
34
|
+
|
|
35
|
+
A triangle points at the value from outside the track; a circle, a rhombus and a line sit on it. Turn `fill` off to show the value with the marker alone.
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { Gauge, Stack, type GaugeMarker } from '@motifx-community/ui';
|
|
39
|
+
|
|
40
|
+
const SHAPES: { marker: GaugeMarker; value: number; label: string }[] = [
|
|
41
|
+
{ marker: 'triangle', value: 85, label: 'Triangle' },
|
|
42
|
+
{ marker: 'circle', value: 65, label: 'Circle' },
|
|
43
|
+
{ marker: 'rhombus', value: 80, label: 'Rhombus' },
|
|
44
|
+
{ marker: 'line', value: 75, label: 'Line' }
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
/** A triangle outside the track, and a circle, a rhombus and a line on it. */
|
|
48
|
+
export default function TrackShapes() {
|
|
49
|
+
return (
|
|
50
|
+
<Stack orientation="horizontal" gap="lg" wrap align="end">
|
|
51
|
+
{SHAPES.map(s => (
|
|
52
|
+
<Gauge class="ga-track-marker" angle={180} fill={false} scale="ticks" tickInterval={50} marker={s.marker} value={s.value} label={s.label} />
|
|
53
|
+
))}
|
|
54
|
+
</Stack>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Callout
|
|
60
|
+
|
|
61
|
+
`marker: 'text'` writes the value in a callout that points at it: inside an arc, beside a bar. The value in the middle is then left out.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Gauge, Stack } from '@motifx-community/ui';
|
|
65
|
+
|
|
66
|
+
/** The value written in a callout that points at it: inside an arc, beside a bar. */
|
|
67
|
+
export default function Callout() {
|
|
68
|
+
return (
|
|
69
|
+
<Stack orientation="horizontal" gap="xl" wrap align="end">
|
|
70
|
+
<Gauge class="ga-callout" angle={180} fill={false} scale="ticks" tickInterval={50} marker="text" value={70} label="Arc" />
|
|
71
|
+
<Gauge type="linear" fill={false} scale="ticks" tickInterval={25} marker="text" value={70} label="Bar" style="flex: 1 1 16rem" />
|
|
72
|
+
</Stack>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## On a bar
|
|
78
|
+
|
|
79
|
+
Every marker works on a straight gauge too; a needle is drawn there as a triangle.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import { Gauge, Stack, type GaugeMarker } from '@motifx-community/ui';
|
|
83
|
+
|
|
84
|
+
const BARS: { marker: GaugeMarker; value: number; label: string }[] = [
|
|
85
|
+
{ marker: 'triangle', value: 85, label: 'Triangle' },
|
|
86
|
+
{ marker: 'circle', value: 65, label: 'Circle' },
|
|
87
|
+
{ marker: 'rhombus', value: 80, label: 'Rhombus' },
|
|
88
|
+
{ marker: 'line', value: 75, label: 'Line' },
|
|
89
|
+
{ marker: 'text', value: 70, label: 'Callout' }
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
/** Each marker on a bar across. On a straight gauge a needle is drawn as a triangle. */
|
|
93
|
+
export default function BarMarkers() {
|
|
94
|
+
return (
|
|
95
|
+
<Stack gap="md" style="inline-size: 100%">
|
|
96
|
+
{BARS.map(b => (
|
|
97
|
+
<Gauge class="ga-bar-marker" type="linear" fill={false} scale="ticks" tickInterval={25} marker={b.marker} value={b.value} label={b.label} />
|
|
98
|
+
))}
|
|
99
|
+
</Stack>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Marker and fill together
|
|
105
|
+
|
|
106
|
+
A marker over the fill keeps the value easy to find on a long scale.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { Gauge, Stack } from '@motifx-community/ui';
|
|
110
|
+
|
|
111
|
+
/** A fill with a needle over it, and a fill with a triangle that keeps the value easy to find. */
|
|
112
|
+
export default function FillAndMarker() {
|
|
113
|
+
return (
|
|
114
|
+
<Stack orientation="horizontal" gap="lg" wrap align="end">
|
|
115
|
+
<Gauge value={128} max={240} marker="needle" scale="ticks" tickInterval={40} label="km/h" />
|
|
116
|
+
<Gauge value={62} marker="triangle" scale="ticks" tickInterval={25} label="Progress" format={{ style: 'unit', unit: 'percent' }} />
|
|
117
|
+
<Gauge type="linear" orientation="vertical" size={180} value={62} marker="triangle" scale="ticks" tickInterval={25} label="Level" />
|
|
118
|
+
</Stack>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Props on this page
|
|
124
|
+
|
|
125
|
+
| Prop | Type | Default | Description |
|
|
126
|
+
| --- | --- | --- | --- |
|
|
127
|
+
| `marker` | `Bind<'needle' \| 'triangle' \| 'circle' \| 'rhombus' \| 'line' \| 'text' \| null>` | `null` | A shape that points at the value. On a straight gauge a needle is a triangle. |
|
|
128
|
+
| `needleShape` | `Bind<'tapered' \| 'straight' \| 'two-tone'>` | `'tapered'` | How a needle is drawn. |
|
|
129
|
+
| `fill` | `Bind<boolean>` | `true` | Fills the track from `baseValue` to the value. |
|
|
130
|
+
|
|
131
|
+
Every other prop, and the types of ranges and marks, are on the [Overview](gauge.md#api).
|
|
132
|
+
|
|
133
|
+
## Feedback
|
|
134
|
+
|
|
135
|
+
Loading issues…
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Gauge: Marks
|
|
2
|
+
|
|
3
|
+
> Gauges · @motifx-community/ui 0.1.0-beta.6
|
|
4
|
+
|
|
5
|
+
Marks show other values on the scale besides the gauge's own, such as a target, a limit, or the lowest and highest expected.
|
|
6
|
+
|
|
7
|
+
## Targets and limits
|
|
8
|
+
|
|
9
|
+
`marks` takes values with a `label`. Each label is read with the gauge's value, and shows when the pointer is over its mark.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { Gauge } from '@motifx-community/ui';
|
|
13
|
+
|
|
14
|
+
const EXPECTED = [
|
|
15
|
+
{ value: 40, label: 'Lowest expected' },
|
|
16
|
+
{ value: 90, label: 'Highest expected' }
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const SOLD = [
|
|
20
|
+
{ from: 0, to: 30, tone: 'danger' as const },
|
|
21
|
+
{ from: 30, to: 70, tone: 'warning' as const },
|
|
22
|
+
{ from: 70, to: 100, tone: 'good' as const }
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
/** The lowest and highest expected values marked on the scale. Point at a mark to see its name. */
|
|
26
|
+
export default function Targets() {
|
|
27
|
+
return <Gauge class="ga-marks" value={85} scale="ticks" tickInterval={10} marks={EXPECTED} ranges={SOLD} label="Tickets sold (%)" size={200} />;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Shapes of marks
|
|
32
|
+
|
|
33
|
+
`markShape` sets the shape of every mark, and a mark's own `shape` wins over it. A callout writes the mark's value.
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { Gauge, Stack } from '@motifx-community/ui';
|
|
37
|
+
|
|
38
|
+
/** Marks as lines for every mark, and a mark with a callout of its own beside a needle. */
|
|
39
|
+
export default function MarkShapes() {
|
|
40
|
+
return (
|
|
41
|
+
<Stack orientation="horizontal" gap="xl" wrap align="end">
|
|
42
|
+
<Gauge value={62} markShape="line" marks={[{ value: 30, label: 'Low' }, { value: 80, label: 'High' }]} scale="ticks" tickInterval={25} label="Lines" />
|
|
43
|
+
<Gauge class="ga-mark-text" value={2200} max={3000} scale="ticks" tickInterval={500} marker="needle" fill={false}
|
|
44
|
+
marks={[{ value: 2700, label: 'Recommended', shape: 'text' }]} label="Oven (°C)" />
|
|
45
|
+
<Gauge value={55} marks={[{ value: 20, shape: 'circle' }, { value: 45, shape: 'rhombus' }, { value: 90 }]} scale="ticks" tickInterval={25} label="Mixed" />
|
|
46
|
+
</Stack>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Marks that change
|
|
52
|
+
|
|
53
|
+
A function as `marks` is followed: the marks move when the values they read change.
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { reactive } from '@motifx/core';
|
|
57
|
+
import { Gauge, NumberBox, Stack } from '@motifx-community/ui';
|
|
58
|
+
|
|
59
|
+
/** Marks that follow the data: change the target and the limit, and the marks move. */
|
|
60
|
+
export default function MovingMarks() {
|
|
61
|
+
const s = reactive({ value: 34, target: 23, limit: 38 });
|
|
62
|
+
return (
|
|
63
|
+
<Stack orientation="horizontal" gap="xl" wrap align="center">
|
|
64
|
+
<Gauge class="ga-moving-marks" value={() => s.value} min={10} max={40} scale="ticks" tickInterval={5} label="Voltage (kV)"
|
|
65
|
+
marks={() => [{ value: s.target, label: 'Target' }, { value: s.limit, label: 'Limit', shape: 'line' }]} />
|
|
66
|
+
<Stack gap="sm">
|
|
67
|
+
<NumberBox label="Value" x-model={() => s.value} min={10} max={40} />
|
|
68
|
+
<NumberBox label="Target" x-model={() => s.target} min={10} max={40} />
|
|
69
|
+
<NumberBox label="Limit" x-model={() => s.limit} min={10} max={40} />
|
|
70
|
+
</Stack>
|
|
71
|
+
</Stack>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## On a bar
|
|
77
|
+
|
|
78
|
+
Marks work the same on a straight gauge.
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { Gauge, Stack } from '@motifx-community/ui';
|
|
82
|
+
|
|
83
|
+
/** Marks on bars: the lowest and highest expected, and a price between its low and high of the day. */
|
|
84
|
+
export default function BarMarks() {
|
|
85
|
+
return (
|
|
86
|
+
<Stack gap="md" style="inline-size: 100%">
|
|
87
|
+
<Gauge class="ga-bar-marks" type="linear" value={17} max={30} scale="ticks" tickInterval={5} marks={[{ value: 5, label: 'Lowest' }, { value: 25, label: 'Highest' }]}
|
|
88
|
+
label="Issues closed" />
|
|
89
|
+
<Gauge type="linear" value={28} min={10} max={50} scale="ticks" tickInterval={10} fill={false} marker="circle" markShape="line"
|
|
90
|
+
marks={[{ value: 18, label: 'Low' }, { value: 43, label: 'High' }]} format={{ style: 'currency', currency: 'USD', maximumFractionDigits: 0 }} label="Price" />
|
|
91
|
+
</Stack>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Props on this page
|
|
97
|
+
|
|
98
|
+
| Prop | Type | Default | Description |
|
|
99
|
+
| --- | --- | --- | --- |
|
|
100
|
+
| `marks` | `Bind<GaugeMark[]>` | `[]` | Other values marked on the scale: `value`, a `label`, and a `shape` of their own. |
|
|
101
|
+
| `markShape` | `Bind<GaugeMarker>` | `'triangle'` | The shape of the marks, unless a mark has its own. |
|
|
102
|
+
| `tooltip` | `Bind<boolean>` | `true` | Shows the value or the mark under the pointer. |
|
|
103
|
+
|
|
104
|
+
Every other prop, and the types of ranges and marks, are on the [Overview](gauge.md#api).
|
|
105
|
+
|
|
106
|
+
## Feedback
|
|
107
|
+
|
|
108
|
+
Loading issues…
|