@tensor_1/react 2.55.2 → 2.56.0
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/README.md +42 -0
- package/component-inventory.json +44 -0
- package/dist/{ChartCore-BKK2HEfi.d.cts → ChartCore-CY5a4teJ.d.cts} +18 -2
- package/dist/GlanceCharts-Cb39RqDC.d.cts +88 -0
- package/dist/chart-analytic-guide.d.ts +1 -0
- package/dist/chart-analytic-guide.js +6 -1
- package/dist/chart-analytic.cjs +11 -1
- package/dist/chart-analytic.d.cts +2 -2
- package/dist/chart-glance.d.ts +65 -0
- package/dist/chart-glance.js +162 -0
- package/dist/chart-preset.cjs +337 -5
- package/dist/chart-preset.d.cts +9 -3
- package/dist/chart-preset.d.ts +8 -1
- package/dist/chart-preset.js +16 -1
- package/dist/chart-theme.d.ts +18 -2
- package/dist/chart-theme.js +6 -1
- package/dist/chart.cjs +337 -5
- package/dist/chart.d.cts +9 -3
- package/dist/chart.d.ts +3 -1
- package/dist/chart.js +9 -2
- package/dist/components/Arrive.d.ts +49 -0
- package/dist/components/Arrive.js +93 -0
- package/dist/components/Chart.d.ts +8 -1
- package/dist/components/Chart.js +16 -1
- package/dist/components/ChartCard.d.ts +34 -0
- package/dist/components/ChartCard.js +36 -0
- package/dist/components/ChartPanels.js +5 -0
- package/dist/components/Count.d.ts +10 -4
- package/dist/components/Count.js +35 -3
- package/dist/components/GlanceCharts.d.ts +37 -0
- package/dist/components/GlanceCharts.js +128 -0
- package/dist/components/GlanceMarks.d.ts +63 -0
- package/dist/components/GlanceMarks.js +59 -0
- package/dist/components/Meter.d.ts +12 -2
- package/dist/components/Meter.js +23 -13
- package/dist/components/StatusDot.d.ts +27 -0
- package/dist/components/StatusDot.js +16 -0
- package/dist/icons/Icon.d.ts +5 -5
- package/dist/index.cjs +2165 -1925
- package/dist/index.d.cts +173 -7
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -734,6 +734,48 @@ enumerateDateKeys({ start: '2026-10-11', end: '2026-10-12' }); // { d
|
|
|
734
734
|
- **Deprecated:** `zonedDateSpan` (end-inclusive, swaps inverted ends) and `enumerateDateSpan` (stops silently at
|
|
735
735
|
370) are unchanged in 2.x. Use `zonedDaySpan` and `enumerateDateKeys`.
|
|
736
736
|
|
|
737
|
+
### Calm kit: glance cards, quiet status and the arrival (2.56.0)
|
|
738
|
+
|
|
739
|
+
For a home page that greets before it warns: one question per card, red only for what is broken now, and motion once on the first paint. Phase 1 of the TENSOR calm-home proposal (2026-11-04).
|
|
740
|
+
|
|
741
|
+
**Status, quietly.** `StatusDot` is a dot and a word, no box: `neutral` (a fact, in ink), `info`, `warning`, `critical` (`danger` is an alias), and `success` for a service list. The word and the dot both wear the tone's text colour, so the dot clears 3:1 on the surface, the app background and the tone's own tint; `quiet` keeps the word in ink. The `critical` StatusPill is now the danger tint with the danger words (semibold) instead of a solid red fill; the destructive `Button variant="danger"` is the one solid red left.
|
|
742
|
+
|
|
743
|
+
```tsx
|
|
744
|
+
<StatusDot tone="critical">Läuft gerade</StatusDot>
|
|
745
|
+
<StatusDot tone="warning">SLA in 1 Std. 40 Min.</StatusDot>
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
**Glance cards.** `ChartCard` asks a question (`question`, a heading), answers it (`headline` large, `answer` short), holds one chart and a `note` line; `empty` replaces all of it with one sentence. The chart is one of:
|
|
749
|
+
|
|
750
|
+
- `GlanceLineChart` (`@tensor_1/react/chart` or `/chart/preset`): one series in `--uix-chart-series`, labelled at its end, an optional dashed `forecast`, three dashed gridlines, sans tabular axis digits and a dark tooltip with a crosshair. Builds a hidden data table from the data; pass `ariaLabel` and `categoryLabel`.
|
|
751
|
+
- `PairedBarChart` (same entries): per bucket the measure in blue beside its comparison in grey, up to 12 buckets (it warns above). Put the key in `note` with `ChartLegend`.
|
|
752
|
+
- `BarList`: label, bar, value per bucket; every value written out.
|
|
753
|
+
- `Meter target={95} targetLabel="Ziel 95 %"`: an ink mark at the goal, said after the value.
|
|
754
|
+
- `StatusStrip`: one cell per service and only the affected ones listed, critical first.
|
|
755
|
+
- `Sparkline`: an ink-grey line with a dot on the latest value; decoration unless you pass `label`.
|
|
756
|
+
|
|
757
|
+
The option builders are public for your own glance charts: `glanceLineOption`, `pairedBarsOption`, `uixGlanceBase` (pure functions of `uixChartTokens()`).
|
|
758
|
+
|
|
759
|
+
```tsx
|
|
760
|
+
<ChartCard question="Wächst der Rückstand?" headline={<Count value={85} arrive />} answer="offen, Prognose 140 bis 23. Nov."
|
|
761
|
+
note="Gestrichelt: Prognose." arriveIndex={5}>
|
|
762
|
+
<GlanceLineChart ariaLabel="Offener Rückstand, 12 Wochen" categoryLabel="Woche" name="offen"
|
|
763
|
+
categories={weeks} values={backlog} forecast={{ categories, values, name: 'erwartet', label: 'Prognose 140' }} />
|
|
764
|
+
</ChartCard>
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
**The arrival.** Wrap the page in `Arrive` and mark the cards in reading order with `ArriveItem index` (or `ChartCard arriveIndex`). On the first mount the cards fade and rise 8 px, 45 ms apart, over 420 ms; lines trace in (700 ms, 150 ms after their card), bars grow 25 ms apart (500 ms) and `Count arrive` counts up (600 ms). Then the stage rests: a re-render, a refetch or new data never replays it, and the resting state is the finished page. `name="home"` remembers it for the browser session (sessionStorage), so a reload or a route change back does not replay it either; `ready={!loading}` waits for the data. Under reduced motion each card only fades for 160 ms and the marks are drawn at once. `useArrive()` tells your own marks whether the stage is playing; plain markup opts in with `.uix-arrive__item`, `.uix-arrive__trace` (an SVG stroke with `pathLength="1"`), `.uix-arrive__grow` and `.uix-arrive__slide`.
|
|
768
|
+
|
|
769
|
+
```tsx
|
|
770
|
+
<Arrive name="home" ready={!loading}>
|
|
771
|
+
<ArriveItem index={0}><RunningNow /></ArriveItem>
|
|
772
|
+
<ArriveItem index={1}><Stat label="Warten auf Sie" value={<Count value={16} arrive />} /></ArriveItem>
|
|
773
|
+
…
|
|
774
|
+
</Arrive>
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
**Tokens.** The status families are softer in light and dark (fills, words, dots and tints; overdue follows danger), all AA. Palette v2: `--uix-chart-1..8` are blue (the series), teal, violet, green, plum, olive, cyan, moss, with no red and no amber slot; `--uix-chart-1` stays the brand blue (`#0455E6`, dark `#3280FC`); `--uix-chart-series` (= chart-1) and `--uix-chart-series-soft` are new. The arrival timings are `--uix-dur-arrive`, `--uix-stagger-arrive`, `--uix-delay-arrive-trace`, `--uix-dur-arrive-trace`, `--uix-dur-arrive-grow`, `--uix-stagger-arrive-grow`, `--uix-dur-arrive-count` and `--uix-arrive-rise`.
|
|
778
|
+
|
|
737
779
|
### Two-axis grids: MatrixInput and MatrixHeatmap
|
|
738
780
|
|
|
739
781
|
`MatrixInput` fills a grid of choices, one per row and column, from the keyboard alone. `MatrixHeatmap` shows how many items sit in each cell, each cell's named band, and a way to the items behind it. Neither has words of its own: `labels`, the axes, the options and the bands come from you.
|
package/component-inventory.json
CHANGED
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
"name": "AppShell",
|
|
14
14
|
"subpath": "."
|
|
15
15
|
},
|
|
16
|
+
{
|
|
17
|
+
"name": "Arrive",
|
|
18
|
+
"subpath": "."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "ArriveItem",
|
|
22
|
+
"subpath": "."
|
|
23
|
+
},
|
|
16
24
|
{
|
|
17
25
|
"name": "AsyncOperationStatus",
|
|
18
26
|
"subpath": "."
|
|
@@ -37,6 +45,10 @@
|
|
|
37
45
|
"name": "AvatarGroup",
|
|
38
46
|
"subpath": "."
|
|
39
47
|
},
|
|
48
|
+
{
|
|
49
|
+
"name": "BarList",
|
|
50
|
+
"subpath": "."
|
|
51
|
+
},
|
|
40
52
|
{
|
|
41
53
|
"name": "BrandProfileEditor",
|
|
42
54
|
"subpath": "."
|
|
@@ -97,6 +109,10 @@
|
|
|
97
109
|
"name": "ChangeHighlight",
|
|
98
110
|
"subpath": "."
|
|
99
111
|
},
|
|
112
|
+
{
|
|
113
|
+
"name": "ChartCard",
|
|
114
|
+
"subpath": "."
|
|
115
|
+
},
|
|
100
116
|
{
|
|
101
117
|
"name": "Checkbox",
|
|
102
118
|
"subpath": "."
|
|
@@ -673,6 +689,10 @@
|
|
|
673
689
|
"name": "SortableList",
|
|
674
690
|
"subpath": "."
|
|
675
691
|
},
|
|
692
|
+
{
|
|
693
|
+
"name": "Sparkline",
|
|
694
|
+
"subpath": "."
|
|
695
|
+
},
|
|
676
696
|
{
|
|
677
697
|
"name": "Spinner",
|
|
678
698
|
"subpath": "."
|
|
@@ -693,6 +713,10 @@
|
|
|
693
713
|
"name": "StatRow",
|
|
694
714
|
"subpath": "."
|
|
695
715
|
},
|
|
716
|
+
{
|
|
717
|
+
"name": "StatusDot",
|
|
718
|
+
"subpath": "."
|
|
719
|
+
},
|
|
696
720
|
{
|
|
697
721
|
"name": "StatusPill",
|
|
698
722
|
"subpath": "."
|
|
@@ -701,6 +725,10 @@
|
|
|
701
725
|
"name": "StatusRow",
|
|
702
726
|
"subpath": "."
|
|
703
727
|
},
|
|
728
|
+
{
|
|
729
|
+
"name": "StatusStrip",
|
|
730
|
+
"subpath": "."
|
|
731
|
+
},
|
|
704
732
|
{
|
|
705
733
|
"name": "Step",
|
|
706
734
|
"subpath": "."
|
|
@@ -829,6 +857,14 @@
|
|
|
829
857
|
"name": "ChartMetric",
|
|
830
858
|
"subpath": "./chart"
|
|
831
859
|
},
|
|
860
|
+
{
|
|
861
|
+
"name": "GlanceLineChart",
|
|
862
|
+
"subpath": "./chart"
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
"name": "PairedBarChart",
|
|
866
|
+
"subpath": "./chart"
|
|
867
|
+
},
|
|
832
868
|
{
|
|
833
869
|
"name": "Chart",
|
|
834
870
|
"subpath": "./chart/analytic"
|
|
@@ -869,6 +905,14 @@
|
|
|
869
905
|
"name": "ChartMetric",
|
|
870
906
|
"subpath": "./chart/preset"
|
|
871
907
|
},
|
|
908
|
+
{
|
|
909
|
+
"name": "GlanceLineChart",
|
|
910
|
+
"subpath": "./chart/preset"
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
"name": "PairedBarChart",
|
|
914
|
+
"subpath": "./chart/preset"
|
|
915
|
+
},
|
|
872
916
|
{
|
|
873
917
|
"name": "EmojiPicker",
|
|
874
918
|
"subpath": "./emoji"
|
|
@@ -4,9 +4,21 @@ import { EChartsOption, ECharts } from 'echarts';
|
|
|
4
4
|
|
|
5
5
|
/** Where tokens are read from: an element (its computed style), or a reader for tests and non-DOM use. */
|
|
6
6
|
type ChartTokenSource = Element | ((token: string) => string);
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* The analytic chart roles: reference lines, threshold zones, forecast bands, events, partial periods.
|
|
9
|
+
* The calm-kit fields (series, seriesSoft, categories, radius, shadow) are optional, so an object
|
|
10
|
+
* built for 2.55 still type-checks; `uixChartTokens()` always fills them, and the glance charts fall
|
|
11
|
+
* back to `palette[0]` when an object of your own leaves them out.
|
|
12
|
+
*/
|
|
8
13
|
interface UixChartTokens {
|
|
14
|
+
/** The categorical palette, --uix-chart-1..8 (v2, calm kit 2.56): no red slot and no amber slot. */
|
|
9
15
|
palette: string[];
|
|
16
|
+
/** THE series colour of a glance chart (--uix-chart-series, = chart-1). */
|
|
17
|
+
series?: string;
|
|
18
|
+
/** The series colour as a faint wash (an area under a glance line). */
|
|
19
|
+
seriesSoft?: string;
|
|
20
|
+
/** The three quiet category hues (blue, teal, violet) for a chart that truly needs more than one. */
|
|
21
|
+
categories?: string[];
|
|
10
22
|
neutral: string;
|
|
11
23
|
grid: string;
|
|
12
24
|
axis: string;
|
|
@@ -26,9 +38,13 @@ interface UixChartTokens {
|
|
|
26
38
|
border: string;
|
|
27
39
|
fontSans: string;
|
|
28
40
|
fontMono: string;
|
|
41
|
+
/** --uix-radius-md, for a glance tooltip. */
|
|
42
|
+
radius?: string;
|
|
43
|
+
/** --uix-shadow-popover, for a glance tooltip. */
|
|
44
|
+
shadow?: string;
|
|
29
45
|
}
|
|
30
46
|
/** Resolve the chart tokens once (current theme). */
|
|
31
|
-
declare function uixChartTokens(source?: ChartTokenSource): UixChartTokens
|
|
47
|
+
declare function uixChartTokens(source?: ChartTokenSource): UixChartTokens & Required<Pick<UixChartTokens, 'series' | 'seriesSoft' | 'categories' | 'radius' | 'shadow'>>;
|
|
32
48
|
/**
|
|
33
49
|
* The base option every UIx chart merges under the consumer's option (the consumer wins).
|
|
34
50
|
* Axis defaults apply to every x/y axis, whether the consumer passes one axis or an array.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { U as UixChartTokens, C as ChartLabels, c as ChartEventHandler } from './ChartCore-CY5a4teJ.cjs';
|
|
3
|
+
import { EChartsOption } from 'echarts';
|
|
4
|
+
|
|
5
|
+
/** How a glance chart draws in. `play: false` (the default) draws it at rest, with no animation. */
|
|
6
|
+
interface GlanceMotion {
|
|
7
|
+
play: boolean;
|
|
8
|
+
/** When the chart starts drawing, after its card started (ms). */
|
|
9
|
+
delay: number;
|
|
10
|
+
/** A line tracing in (ms). */
|
|
11
|
+
trace: number;
|
|
12
|
+
/** One bar growing (ms). */
|
|
13
|
+
grow: number;
|
|
14
|
+
/** The gap between one bucket starting to grow and the next (ms). */
|
|
15
|
+
stagger: number;
|
|
16
|
+
}
|
|
17
|
+
declare const GLANCE_AT_REST: GlanceMotion;
|
|
18
|
+
/** Formats a value for the tooltip and the end label. */
|
|
19
|
+
type GlanceFormat = (value: number) => string;
|
|
20
|
+
/** The shared frame: grid, dashed gridlines, sans axis digits and the dark tooltip. */
|
|
21
|
+
declare function uixGlanceBase(k: UixChartTokens, motion?: GlanceMotion): EChartsOption;
|
|
22
|
+
interface GlanceLineInput {
|
|
23
|
+
/** The x labels of the measured points (weeks, days). */
|
|
24
|
+
categories: string[];
|
|
25
|
+
values: number[];
|
|
26
|
+
/** The series name, for the tooltip ("offen"). */
|
|
27
|
+
name: string;
|
|
28
|
+
/** A dashed projection that continues from the last measured point. */
|
|
29
|
+
forecast?: {
|
|
30
|
+
categories: string[];
|
|
31
|
+
values: number[];
|
|
32
|
+
name: string;
|
|
33
|
+
label?: string;
|
|
34
|
+
};
|
|
35
|
+
/** Label the line at its end with its last value (default true). */
|
|
36
|
+
endLabel?: boolean;
|
|
37
|
+
/** A faint wash under the line (default true). */
|
|
38
|
+
area?: boolean;
|
|
39
|
+
format?: GlanceFormat;
|
|
40
|
+
/** The tooltip's title for an x label ("Woche ab 2. Nov."). Default the label itself. */
|
|
41
|
+
tooltipTitle?: (category: string) => string;
|
|
42
|
+
}
|
|
43
|
+
/** One line in the series blue, labelled at its end, optionally with a dashed forecast. */
|
|
44
|
+
declare function glanceLineOption(k: UixChartTokens, input: GlanceLineInput, motion?: GlanceMotion): EChartsOption;
|
|
45
|
+
interface PairedBarsInput {
|
|
46
|
+
/** The buckets (days, weeks); at most 12 read at a glance. */
|
|
47
|
+
categories: string[];
|
|
48
|
+
/** The measure, in the series blue ("eröffnet"). */
|
|
49
|
+
series: {
|
|
50
|
+
name: string;
|
|
51
|
+
values: number[];
|
|
52
|
+
};
|
|
53
|
+
/** The comparison, in grey ("gelöst"). */
|
|
54
|
+
comparison: {
|
|
55
|
+
name: string;
|
|
56
|
+
values: number[];
|
|
57
|
+
};
|
|
58
|
+
format?: GlanceFormat;
|
|
59
|
+
tooltipTitle?: (category: string) => string;
|
|
60
|
+
}
|
|
61
|
+
/** The most buckets a paired-bar glance chart should hold. */
|
|
62
|
+
declare const PAIRED_BARS_MAX_BUCKETS = 12;
|
|
63
|
+
/** Two bars per bucket: the measure in blue beside its comparison in grey. */
|
|
64
|
+
declare function pairedBarsOption(k: UixChartTokens, input: PairedBarsInput, motion?: GlanceMotion): EChartsOption;
|
|
65
|
+
|
|
66
|
+
/** The props every glance chart shares with Chart. */
|
|
67
|
+
interface GlanceChartBaseProps {
|
|
68
|
+
/** What the chart shows, in a sentence: its accessible name ("Offener Rückstand der letzten 12 Wochen …"). */
|
|
69
|
+
ariaLabel: string;
|
|
70
|
+
/** The header of the first column of the hidden data table ("Woche"). Default "Period". */
|
|
71
|
+
categoryLabel?: string;
|
|
72
|
+
/** Plot height in px. Default 150 (a line) or 140 (paired bars). */
|
|
73
|
+
height?: number;
|
|
74
|
+
className?: string;
|
|
75
|
+
style?: CSSProperties;
|
|
76
|
+
loading?: boolean;
|
|
77
|
+
empty?: ReactNode;
|
|
78
|
+
labels?: Partial<ChartLabels>;
|
|
79
|
+
/** Charts with the same group share one crosshair and tooltip. */
|
|
80
|
+
group?: string;
|
|
81
|
+
onEvents?: Record<string, ChartEventHandler>;
|
|
82
|
+
}
|
|
83
|
+
interface GlanceLineChartProps extends GlanceLineInput, GlanceChartBaseProps {
|
|
84
|
+
}
|
|
85
|
+
interface PairedBarChartProps extends PairedBarsInput, GlanceChartBaseProps {
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { type GlanceLineChartProps as G, type PairedBarChartProps as P, GLANCE_AT_REST as a, type GlanceChartBaseProps as b, type GlanceFormat as c, type GlanceLineInput as d, type GlanceMotion as e, PAIRED_BARS_MAX_BUCKETS as f, type PairedBarsInput as g, glanceLineOption as h, pairedBarsOption as p, uixGlanceBase as u };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { DEFAULT_CHART_PANELS_LABELS, chartPanelsModel } from './chart-panels-model.js';
|
|
2
2
|
export { DEFAULT_CORRELATION_SCATTER_LABELS, correlationScatterModel, formatCorrelation } from './correlation-scatter-model.js';
|
|
3
|
+
export { GLANCE_AT_REST, glanceLineOption, pairedBarsOption, uixGlanceBase } from './chart-glance.js';
|
|
3
4
|
import 'echarts';
|
|
4
5
|
import './chart-theme.js';
|
|
5
6
|
import './chart-analytic-model.js';
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { chartPanelsModel } from "./chart-panels-model.js";
|
|
2
2
|
import { correlationScatterModel, formatCorrelation, DEFAULT_CORRELATION_SCATTER_LABELS } from "./correlation-scatter-model.js";
|
|
3
3
|
import { DEFAULT_CHART_PANELS_LABELS } from "./chart-panels-model.js";
|
|
4
|
+
import { GLANCE_AT_REST, glanceLineOption, pairedBarsOption, uixGlanceBase } from "./chart-glance.js";
|
|
4
5
|
export {
|
|
5
6
|
DEFAULT_CHART_PANELS_LABELS,
|
|
6
7
|
DEFAULT_CORRELATION_SCATTER_LABELS,
|
|
8
|
+
GLANCE_AT_REST,
|
|
7
9
|
chartPanelsModel,
|
|
8
10
|
correlationScatterModel,
|
|
9
|
-
formatCorrelation
|
|
11
|
+
formatCorrelation,
|
|
12
|
+
glanceLineOption,
|
|
13
|
+
pairedBarsOption,
|
|
14
|
+
uixGlanceBase
|
|
10
15
|
};
|
package/dist/chart-analytic.cjs
CHANGED
|
@@ -93,6 +93,9 @@ function uixChartTokens(source) {
|
|
|
93
93
|
const unquote = (font) => font.replace(/"/g, "");
|
|
94
94
|
return {
|
|
95
95
|
palette: [1, 2, 3, 4, 5, 6, 7, 8].map((i) => t(`chart-${i}`)),
|
|
96
|
+
series: t("chart-series"),
|
|
97
|
+
seriesSoft: t("chart-series-soft"),
|
|
98
|
+
categories: [1, 2, 3].map((i) => t(`chart-${i}`)),
|
|
96
99
|
neutral: t("chart-neutral"),
|
|
97
100
|
grid: t("chart-grid"),
|
|
98
101
|
axis: t("chart-axis"),
|
|
@@ -110,7 +113,9 @@ function uixChartTokens(source) {
|
|
|
110
113
|
textMuted: t("text-muted"),
|
|
111
114
|
border: t("border-strong"),
|
|
112
115
|
fontSans: unquote(t("font-sans")),
|
|
113
|
-
fontMono: unquote(t("font-mono"))
|
|
116
|
+
fontMono: unquote(t("font-mono")),
|
|
117
|
+
radius: t("radius-md"),
|
|
118
|
+
shadow: t("shadow-popover")
|
|
114
119
|
};
|
|
115
120
|
}
|
|
116
121
|
function uixChartTheme(source) {
|
|
@@ -1162,6 +1167,11 @@ function correlationScatterModel(spec, tokens, labelOverrides) {
|
|
|
1162
1167
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1163
1168
|
var CSS_VAR_TOKENS = {
|
|
1164
1169
|
palette: [1, 2, 3, 4, 5, 6, 7, 8].map((i) => `var(--uix-chart-${i})`),
|
|
1170
|
+
series: "var(--uix-chart-series)",
|
|
1171
|
+
seriesSoft: "var(--uix-chart-series-soft)",
|
|
1172
|
+
categories: [1, 2, 3].map((i) => `var(--uix-chart-${i})`),
|
|
1173
|
+
radius: "var(--uix-radius-md)",
|
|
1174
|
+
shadow: "var(--uix-shadow-popover)",
|
|
1165
1175
|
neutral: "var(--uix-chart-neutral)",
|
|
1166
1176
|
grid: "var(--uix-chart-grid)",
|
|
1167
1177
|
axis: "var(--uix-chart-axis)",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { U as UixChartTokens, C as ChartLabels, a as ChartProps } from './ChartCore-
|
|
4
|
-
export { b as ChartEngine, c as ChartEventHandler, d as ChartLegend, e as ChartLegendItem, f as ChartLegendItemProps, g as ChartLegendProps, h as ChartMetric, i as ChartMetricProps, j as ChartOption, k as ChartTable, l as ChartTableRow, m as ChartTokenSource, D as DEFAULT_CHART_LABELS, n as mergeChartTheme, u as uixChartAreaGradient, o as uixChartPalette, p as uixChartTheme, q as uixChartTokens } from './ChartCore-
|
|
3
|
+
import { U as UixChartTokens, C as ChartLabels, a as ChartProps } from './ChartCore-CY5a4teJ.cjs';
|
|
4
|
+
export { b as ChartEngine, c as ChartEventHandler, d as ChartLegend, e as ChartLegendItem, f as ChartLegendItemProps, g as ChartLegendProps, h as ChartMetric, i as ChartMetricProps, j as ChartOption, k as ChartTable, l as ChartTableRow, m as ChartTokenSource, D as DEFAULT_CHART_LABELS, n as mergeChartTheme, u as uixChartAreaGradient, o as uixChartPalette, p as uixChartTheme, q as uixChartTokens } from './ChartCore-CY5a4teJ.cjs';
|
|
5
5
|
import { ScatterSeriesOption, MarkLineComponentOption, MarkAreaComponentOption, MarkPointComponentOption, LineSeriesOption, EChartsOption } from 'echarts';
|
|
6
6
|
import { L as LinearFit } from './chart-stats-o4zDhpVm.cjs';
|
|
7
7
|
export { C as ChartStatPoint, P as PredictionBandPoint, l as linearFit, n as normalQuantile, p as predictionBand, q as quantiles, s as studentTQuantile } from './chart-stats-o4zDhpVm.cjs';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { EChartsOption } from 'echarts';
|
|
2
|
+
import { UixChartTokens } from './chart-theme.js';
|
|
3
|
+
|
|
4
|
+
/** How a glance chart draws in. `play: false` (the default) draws it at rest, with no animation. */
|
|
5
|
+
interface GlanceMotion {
|
|
6
|
+
play: boolean;
|
|
7
|
+
/** When the chart starts drawing, after its card started (ms). */
|
|
8
|
+
delay: number;
|
|
9
|
+
/** A line tracing in (ms). */
|
|
10
|
+
trace: number;
|
|
11
|
+
/** One bar growing (ms). */
|
|
12
|
+
grow: number;
|
|
13
|
+
/** The gap between one bucket starting to grow and the next (ms). */
|
|
14
|
+
stagger: number;
|
|
15
|
+
}
|
|
16
|
+
declare const GLANCE_AT_REST: GlanceMotion;
|
|
17
|
+
/** Formats a value for the tooltip and the end label. */
|
|
18
|
+
type GlanceFormat = (value: number) => string;
|
|
19
|
+
/** The shared frame: grid, dashed gridlines, sans axis digits and the dark tooltip. */
|
|
20
|
+
declare function uixGlanceBase(k: UixChartTokens, motion?: GlanceMotion): EChartsOption;
|
|
21
|
+
interface GlanceLineInput {
|
|
22
|
+
/** The x labels of the measured points (weeks, days). */
|
|
23
|
+
categories: string[];
|
|
24
|
+
values: number[];
|
|
25
|
+
/** The series name, for the tooltip ("offen"). */
|
|
26
|
+
name: string;
|
|
27
|
+
/** A dashed projection that continues from the last measured point. */
|
|
28
|
+
forecast?: {
|
|
29
|
+
categories: string[];
|
|
30
|
+
values: number[];
|
|
31
|
+
name: string;
|
|
32
|
+
label?: string;
|
|
33
|
+
};
|
|
34
|
+
/** Label the line at its end with its last value (default true). */
|
|
35
|
+
endLabel?: boolean;
|
|
36
|
+
/** A faint wash under the line (default true). */
|
|
37
|
+
area?: boolean;
|
|
38
|
+
format?: GlanceFormat;
|
|
39
|
+
/** The tooltip's title for an x label ("Woche ab 2. Nov."). Default the label itself. */
|
|
40
|
+
tooltipTitle?: (category: string) => string;
|
|
41
|
+
}
|
|
42
|
+
/** One line in the series blue, labelled at its end, optionally with a dashed forecast. */
|
|
43
|
+
declare function glanceLineOption(k: UixChartTokens, input: GlanceLineInput, motion?: GlanceMotion): EChartsOption;
|
|
44
|
+
interface PairedBarsInput {
|
|
45
|
+
/** The buckets (days, weeks); at most 12 read at a glance. */
|
|
46
|
+
categories: string[];
|
|
47
|
+
/** The measure, in the series blue ("eröffnet"). */
|
|
48
|
+
series: {
|
|
49
|
+
name: string;
|
|
50
|
+
values: number[];
|
|
51
|
+
};
|
|
52
|
+
/** The comparison, in grey ("gelöst"). */
|
|
53
|
+
comparison: {
|
|
54
|
+
name: string;
|
|
55
|
+
values: number[];
|
|
56
|
+
};
|
|
57
|
+
format?: GlanceFormat;
|
|
58
|
+
tooltipTitle?: (category: string) => string;
|
|
59
|
+
}
|
|
60
|
+
/** The most buckets a paired-bar glance chart should hold. */
|
|
61
|
+
declare const PAIRED_BARS_MAX_BUCKETS = 12;
|
|
62
|
+
/** Two bars per bucket: the measure in blue beside its comparison in grey. */
|
|
63
|
+
declare function pairedBarsOption(k: UixChartTokens, input: PairedBarsInput, motion?: GlanceMotion): EChartsOption;
|
|
64
|
+
|
|
65
|
+
export { GLANCE_AT_REST, type GlanceFormat, type GlanceLineInput, type GlanceMotion, PAIRED_BARS_MAX_BUCKETS, type PairedBarsInput, glanceLineOption, pairedBarsOption, uixGlanceBase };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
const GLANCE_AT_REST = { play: false, delay: 0, trace: 0, grow: 0, stagger: 0 };
|
|
2
|
+
const escapeHtml = (value) => String(value).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
3
|
+
const plain = (value) => value.toLocaleString();
|
|
4
|
+
function tooltipHtml(title, rows) {
|
|
5
|
+
return `<div class="uix-glance-tooltip"><div class="uix-glance-tooltip__title">${escapeHtml(title)}</div>${rows.map((row) => `<div class="uix-glance-tooltip__row"><span class="uix-glance-tooltip__swatch" style="--swatch:${escapeHtml(row.color)}"></span>${escapeHtml(row.name)}<span class="uix-glance-tooltip__value">${escapeHtml(row.value)}</span></div>`).join("")}</div>`;
|
|
6
|
+
}
|
|
7
|
+
const seriesColor = (k) => k.series ?? k.palette[0] ?? "";
|
|
8
|
+
function uixGlanceBase(k, motion = GLANCE_AT_REST) {
|
|
9
|
+
return {
|
|
10
|
+
backgroundColor: "transparent",
|
|
11
|
+
animation: motion.play,
|
|
12
|
+
animationDurationUpdate: 0,
|
|
13
|
+
textStyle: { color: k.textMuted, fontFamily: k.fontSans, fontSize: 11 },
|
|
14
|
+
grid: { top: 10, right: 12, bottom: 4, left: 4, containLabel: true },
|
|
15
|
+
tooltip: {
|
|
16
|
+
trigger: "axis",
|
|
17
|
+
confine: true,
|
|
18
|
+
backgroundColor: k.text,
|
|
19
|
+
borderWidth: 0,
|
|
20
|
+
padding: [6, 10],
|
|
21
|
+
textStyle: { color: k.surface, fontFamily: k.fontSans, fontSize: 12 },
|
|
22
|
+
extraCssText: [k.radius ? `border-radius:${k.radius}` : "", k.shadow ? `box-shadow:${k.shadow}` : ""].filter(Boolean).join(";"),
|
|
23
|
+
transitionDuration: 0
|
|
24
|
+
},
|
|
25
|
+
xAxis: {
|
|
26
|
+
type: "category",
|
|
27
|
+
axisLine: { lineStyle: { color: k.axis } },
|
|
28
|
+
axisTick: { show: false },
|
|
29
|
+
axisLabel: { color: k.textMuted, fontFamily: k.fontSans, fontSize: 11, hideOverlap: true },
|
|
30
|
+
splitLine: { show: false }
|
|
31
|
+
},
|
|
32
|
+
yAxis: {
|
|
33
|
+
type: "value",
|
|
34
|
+
splitNumber: 3,
|
|
35
|
+
minInterval: 1,
|
|
36
|
+
axisLine: { show: false },
|
|
37
|
+
axisTick: { show: false },
|
|
38
|
+
axisLabel: { color: k.textMuted, fontFamily: k.fontSans, fontSize: 11 },
|
|
39
|
+
splitLine: { lineStyle: { color: k.axis, type: [3, 4], width: 1 } }
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function glanceLineOption(k, input, motion = GLANCE_AT_REST) {
|
|
44
|
+
const format = input.format ?? plain;
|
|
45
|
+
const last = input.values.length - 1;
|
|
46
|
+
const forecast = input.forecast;
|
|
47
|
+
const categories = [...input.categories, ...forecast?.categories ?? []];
|
|
48
|
+
const labelled = (value, text, color2, dot) => ({
|
|
49
|
+
value,
|
|
50
|
+
symbolSize: dot ? 8 : 0,
|
|
51
|
+
label: { show: true, position: "right", distance: 6, color: color2, fontFamily: k.fontSans, fontSize: 11, fontWeight: 600, formatter: () => text }
|
|
52
|
+
});
|
|
53
|
+
const showEnd = input.endLabel !== false && !forecast && last >= 0;
|
|
54
|
+
const measured = forecast ? [
|
|
55
|
+
...input.values.map((v, i) => i === last ? { value: v, symbolSize: 8 } : v),
|
|
56
|
+
...forecast.values.map(() => null)
|
|
57
|
+
] : [
|
|
58
|
+
...input.values.map((v, i) => showEnd && i === last ? labelled(v, format(v), k.text, true) : v)
|
|
59
|
+
];
|
|
60
|
+
const projected = forecast ? [...input.values.map((v, i) => i === last ? v : null), ...forecast.values.map((v, i) => i === forecast.values.length - 1 ? labelled(v, forecast.label ?? format(v), k.textMuted, false) : v)] : [];
|
|
61
|
+
const color = seriesColor(k);
|
|
62
|
+
const base = uixGlanceBase(k, motion);
|
|
63
|
+
const title = input.tooltipTitle ?? ((c) => c);
|
|
64
|
+
const endText = forecast ? forecast.label ?? format(forecast.values[forecast.values.length - 1] ?? 0) : showEnd ? format(input.values[last]) : "";
|
|
65
|
+
const series = [{
|
|
66
|
+
name: input.name,
|
|
67
|
+
type: "line",
|
|
68
|
+
data: measured,
|
|
69
|
+
color,
|
|
70
|
+
// symbols at size 0 so the last point can carry its dot and its label
|
|
71
|
+
showSymbol: true,
|
|
72
|
+
symbol: "circle",
|
|
73
|
+
symbolSize: 0,
|
|
74
|
+
lineStyle: { width: 2.2, cap: "round", join: "round" },
|
|
75
|
+
itemStyle: { color, borderColor: k.surface, borderWidth: 2 },
|
|
76
|
+
areaStyle: input.area === false ? void 0 : k.seriesSoft ? { color: k.seriesSoft, opacity: 1 } : { color, opacity: 0.14 },
|
|
77
|
+
emphasis: { disabled: true },
|
|
78
|
+
animationDuration: motion.trace,
|
|
79
|
+
animationDelay: motion.delay,
|
|
80
|
+
animationEasing: "cubicOut"
|
|
81
|
+
}];
|
|
82
|
+
if (forecast) {
|
|
83
|
+
series.push({
|
|
84
|
+
name: forecast.name,
|
|
85
|
+
type: "line",
|
|
86
|
+
data: projected,
|
|
87
|
+
color,
|
|
88
|
+
showSymbol: true,
|
|
89
|
+
symbolSize: 0,
|
|
90
|
+
connectNulls: false,
|
|
91
|
+
lineStyle: { width: 2, type: [4, 5], opacity: 0.75, cap: "round" },
|
|
92
|
+
itemStyle: { color },
|
|
93
|
+
emphasis: { disabled: true },
|
|
94
|
+
// the projection continues the measured line, at half its pace
|
|
95
|
+
animationDuration: Math.round(motion.trace / 2),
|
|
96
|
+
animationDelay: motion.delay + motion.trace,
|
|
97
|
+
animationEasing: "cubicOut"
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
...base,
|
|
102
|
+
// the gutter fits the end label ("Prognose 140"): about 6.5 px a character at 11 px
|
|
103
|
+
grid: { ...base.grid, right: endText ? Math.max(24, Math.ceil(endText.length * 6.5) + 14) : 12 },
|
|
104
|
+
tooltip: {
|
|
105
|
+
...base.tooltip,
|
|
106
|
+
axisPointer: { type: "line", lineStyle: { color: k.textMuted, type: [2, 3], width: 1 } },
|
|
107
|
+
formatter: (params) => {
|
|
108
|
+
const list = (Array.isArray(params) ? params : [params]).filter((p) => p.value != null);
|
|
109
|
+
if (!list.length) return "";
|
|
110
|
+
const point = list.find((p) => p.seriesIndex === 0) ?? list[0];
|
|
111
|
+
const value = typeof point.value === "object" && point.value !== null ? point.value.value : point.value;
|
|
112
|
+
return tooltipHtml(title(point.name), [{ color, name: point.seriesName, value: format(value) }]);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
xAxis: { ...base.xAxis, data: categories, boundaryGap: false },
|
|
116
|
+
series
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const PAIRED_BARS_MAX_BUCKETS = 12;
|
|
120
|
+
function pairedBarsOption(k, input, motion = GLANCE_AT_REST) {
|
|
121
|
+
const format = input.format ?? plain;
|
|
122
|
+
const base = uixGlanceBase(k, motion);
|
|
123
|
+
const title = input.tooltipTitle ?? ((c) => c);
|
|
124
|
+
const bar = (name, values, color, offset) => ({
|
|
125
|
+
name,
|
|
126
|
+
type: "bar",
|
|
127
|
+
data: values,
|
|
128
|
+
color,
|
|
129
|
+
barMaxWidth: 16,
|
|
130
|
+
barGap: "18%",
|
|
131
|
+
barCategoryGap: "38%",
|
|
132
|
+
itemStyle: { color, borderRadius: [3, 3, 0, 0] },
|
|
133
|
+
emphasis: { disabled: true },
|
|
134
|
+
animationDuration: motion.grow,
|
|
135
|
+
animationDelay: (index) => motion.delay + index * motion.stagger + offset,
|
|
136
|
+
animationEasing: "cubicOut"
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
...base,
|
|
140
|
+
tooltip: {
|
|
141
|
+
...base.tooltip,
|
|
142
|
+
axisPointer: { type: "shadow", shadowStyle: { color: k.forecastBand } },
|
|
143
|
+
formatter: (params) => {
|
|
144
|
+
const list = Array.isArray(params) ? params : [params];
|
|
145
|
+
if (!list.length) return "";
|
|
146
|
+
return tooltipHtml(title(list[0].name), list.map((p) => ({ color: p.color, name: p.seriesName, value: format(p.value) })));
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
xAxis: { ...base.xAxis, data: input.categories },
|
|
150
|
+
series: [
|
|
151
|
+
bar(input.series.name, input.series.values, seriesColor(k), 0),
|
|
152
|
+
bar(input.comparison.name, input.comparison.values, k.comparison, motion.stagger)
|
|
153
|
+
]
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
GLANCE_AT_REST,
|
|
158
|
+
PAIRED_BARS_MAX_BUCKETS,
|
|
159
|
+
glanceLineOption,
|
|
160
|
+
pairedBarsOption,
|
|
161
|
+
uixGlanceBase
|
|
162
|
+
};
|