@apliteni/apliteni-ui 0.181.0 → 0.184.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/docs/components.md +26 -9
- package/package.json +1 -1
- package/react/README.md +8 -2
- package/react/dist/index.d.ts +16 -5
- package/react/dist/index.js +172 -61
- package/src/styles/chart.css +33 -21
package/docs/components.md
CHANGED
|
@@ -1209,10 +1209,10 @@ chart has the title. `format` prints exact values in the readout, the live regio
|
|
|
1209
1209
|
|
|
1210
1210
|
| `variant` | Data | `look` values | Default look |
|
|
1211
1211
|
| --- | --- | --- | --- |
|
|
1212
|
-
| `months` | `periods`, `series` | none:
|
|
1212
|
+
| `months` | `periods`, `series` | none: columns per period with a line across them, fitted to the card | |
|
|
1213
1213
|
| `bridge` | `steps` | none: one period from a start total to a result | |
|
|
1214
1214
|
| `spark` | `periods`, `series` | none: one series at text size, for a stat band `trend` | |
|
|
1215
|
-
| `line` | `periods`, `series` | `thin`; `points`, a point on each value; `labels`, the last value at the line's end
|
|
1215
|
+
| `line` | `periods`, `series` | `thin`; `points`, a point on each value; `labels`, the last value at the line's end | `thin` |
|
|
1216
1216
|
| `area` | `periods`, `series` | `flat`, each series from zero; `curves`, each series from zero as a smooth curve with a point on each value; `stacked`; `share`, each column is 100% | `stacked` |
|
|
1217
1217
|
| `stacked` | `periods`, `series` | `columns`; `share`, each column is 100%; `rows`, a bar for each period | `columns` |
|
|
1218
1218
|
| `donut` | `slices` | `thin`, the total in the centre; `table`, a list of the shares beside the ring; `labels`, the name, value and share at each slice | `table` |
|
|
@@ -1232,17 +1232,34 @@ values and hangs them under the line.
|
|
|
1232
1232
|
`good`, `bad` and `neutral`. The product accent does not change them. Each full tone is at least
|
|
1233
1233
|
3:1 on the card and the page in both themes.
|
|
1234
1234
|
|
|
1235
|
-
**What the user sees.**
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1235
|
+
**What the user sees.** In `months`, every period shares the card's width, so the plot never
|
|
1236
|
+
scrolls. A bar is one flat fill of its tone. It takes two thirds of its column, and at most 48px.
|
|
1237
|
+
Where the period labels do not fit, the chart prints every second, third or later label, counted
|
|
1238
|
+
from the first period that is not final, or from the latest period. Set `values` to print each
|
|
1239
|
+
bar's value past its end, in `formatAxis`: over a bar that grows up from zero, and under a bar
|
|
1240
|
+
that grows down. A value takes at most half the space to the next value,
|
|
1241
|
+
at the 12px text size, and stays inside the plot. A value that does not fit there is left out.
|
|
1242
|
+
The readout and the table always show it. A chart that prints no value gives that room to its
|
|
1243
|
+
bars. `legend`
|
|
1244
|
+
shows the legend. A period with `estimated` keeps its solid mark in the series
|
|
1245
|
+
ink. Set `estimated` to `'incomplete'` for the period that is still running, to `'projected'` for a
|
|
1246
|
+
future period, or to `true` for any other estimate. In `months`, one solid line stands before the
|
|
1247
|
+
first period that is not final, and the words "Not final" stand over that group. Put the periods
|
|
1248
|
+
that are not final last. The hover and keyboard readout and each table row say "Incomplete",
|
|
1249
|
+
"Projected" or "Estimated", followed by the `note`. The readout of a period also compares it with
|
|
1250
|
+
the period before it. Set `compare: false` on a period to show its value with no comparison text.
|
|
1251
|
+
A switch at the top right
|
|
1252
|
+
shows the same numbers as a chart or as a table. In a titled `Card`, the switch stands in the
|
|
1253
|
+
card's title row. `table={false}` removes the switch and the table. `selectable` with `selected`
|
|
1254
|
+
and `onSelect` lets the user pick a column, which gets a band behind it. In the other variants, at
|
|
1255
|
+
phone widths the plot scrolls and the value axis stays. A chart of periods that is wider than its
|
|
1256
|
+
card opens at its latest period. A bridge opens at its opening total.
|
|
1241
1257
|
|
|
1242
1258
|
**Keyboard and screen reader.** The switch is the first Tab stop and the chart is the second. Left,
|
|
1243
1259
|
Right, Home and End move between columns and announce each one. Enter picks a column when
|
|
1244
1260
|
`selectable` is set. A plot that scrolls adds one more Tab stop for the scroll box. On a touch
|
|
1245
|
-
screen, the first tap on a mark opens its readout and does not call `onSelect`.
|
|
1261
|
+
screen, the first tap on a mark opens its readout and does not call `onSelect`. After Escape, a
|
|
1262
|
+
new tap on the same mark opens its readout again. Every value is
|
|
1246
1263
|
reachable at full strength by pointer or keyboard.
|
|
1247
1264
|
|
|
1248
1265
|
### Table values
|
package/package.json
CHANGED
package/react/README.md
CHANGED
|
@@ -938,8 +938,14 @@ one series at text size with no axis, for a stat band's `trend` slot.
|
|
|
938
938
|
The numbers are yours and so is the wording. `format` prints exact values in the readout, the
|
|
939
939
|
live region and the table; `formatAxis` prints the ticks, which are whole units, and defaults
|
|
940
940
|
to `format`. A `bars-below` series takes positive magnitudes and is drawn under the zero line.
|
|
941
|
-
A period marked `estimated` keeps its
|
|
942
|
-
|
|
941
|
+
A period marked `estimated` keeps its solid mark in the series ink. `estimated: 'incomplete'` marks
|
|
942
|
+
the period that is still running, `'projected'` a future period, and `true` any other estimate.
|
|
943
|
+
A months chart draws one solid line before the first period that is not final, with "Not final"
|
|
944
|
+
over that group. The readout and the optional table say "Incomplete", "Projected" or
|
|
945
|
+
"Estimated", followed by the `note`. A period with `compare: false` shows its value in the
|
|
946
|
+
readout with no comparison. A months chart fits its card and does not scroll: it prints fewer
|
|
947
|
+
period labels where they do not fit, and `values` prints each bar's value where it fits. Any
|
|
948
|
+
other chart of periods that is wider than its card opens at its latest period.
|
|
943
949
|
|
|
944
950
|
A bar series names a tone. Each tone has its own hue: `accent` is blue and `accent-soft` is
|
|
945
951
|
cyan, so two series read apart by hue. `good` and `bad` say which way
|
package/react/dist/index.d.ts
CHANGED
|
@@ -1207,11 +1207,18 @@ type ChartPeriod = {
|
|
|
1207
1207
|
label: string;
|
|
1208
1208
|
/** The period as the axis names it. Defaults to `label`'s first word. */
|
|
1209
1209
|
short?: string;
|
|
1210
|
-
/**
|
|
1211
|
-
|
|
1212
|
-
|
|
1210
|
+
/**
|
|
1211
|
+
* The period is not final. `incomplete` is the period still running,
|
|
1212
|
+
* `projected` a future one, and `true` any other estimate. The readout and
|
|
1213
|
+
* the table name the state; the chart at rest prints none.
|
|
1214
|
+
*/
|
|
1215
|
+
estimated?: ChartEstimate;
|
|
1216
|
+
/** Why it is not final. Printed in the readout and in the table. */
|
|
1213
1217
|
note?: string;
|
|
1218
|
+
/** `false` prints the period's value in the readout with no comparison text. */
|
|
1219
|
+
compare?: boolean;
|
|
1214
1220
|
};
|
|
1221
|
+
type ChartEstimate = boolean | 'incomplete' | 'projected';
|
|
1215
1222
|
type ChartSeries = {
|
|
1216
1223
|
id: string;
|
|
1217
1224
|
name: string;
|
|
@@ -1239,7 +1246,7 @@ type ChartBridgeStep = {
|
|
|
1239
1246
|
kind?: 'total' | 'change';
|
|
1240
1247
|
/** A change's amount. A `total` without one takes the running total. */
|
|
1241
1248
|
value?: number;
|
|
1242
|
-
estimated?:
|
|
1249
|
+
estimated?: ChartEstimate;
|
|
1243
1250
|
note?: string;
|
|
1244
1251
|
};
|
|
1245
1252
|
type ChartBridgeTones = {
|
|
@@ -1278,6 +1285,10 @@ type ChartProps = ChartCommon & ({
|
|
|
1278
1285
|
variant?: 'months';
|
|
1279
1286
|
periods: readonly ChartPeriod[];
|
|
1280
1287
|
series: readonly ChartSeries[];
|
|
1288
|
+
/** Print each bar's value past its end, in `formatAxis`: over a bar that grows
|
|
1289
|
+
* up from zero, under one that grows down. A value that does not
|
|
1290
|
+
* fit its bar's room is left out; the readout and the table keep it. */
|
|
1291
|
+
values?: boolean;
|
|
1281
1292
|
} | {
|
|
1282
1293
|
variant: 'spark';
|
|
1283
1294
|
periods: readonly ChartPeriod[];
|
|
@@ -1484,4 +1495,4 @@ declare const PAGE_SIZES: readonly number[];
|
|
|
1484
1495
|
declare const DEFAULT_PAGE_SIZE: number;
|
|
1485
1496
|
|
|
1486
1497
|
export { AccentPicker, AccountMenu, AccountWindow, AppShell, AuthShell, Avatar, BackLink, Badge, BusyRegion, Button, Callout, Card, Chart, CheckList, Checkbox, CommandPalette, Confirm, DEFAULT_PAGE_SIZE, DataTable, DatePicker, DeltaValue, Denied, Drawer, DrawerSection, Dropdown, EmptyState, Feedback, Field, FileDrop, FileField, FilterBar, Footer, Icon, KeyValueList, Modal, NavTabs, NumericValue, PAGE_SIZES, Pagination, Pill, RowIdentity, SearchField, Segmented, SelectField, SidebarNav, Skeleton, SkeletonTable, Snippet, StatBand, StatusDot, Success, SuccessCheck, SuccessPanel, Switch, THEME_INIT_SCRIPT, Tabs, TextArea, TextField, ThemeChoice, ThemeToggle, Timeline, Toast, Tooltip, TopBar, VersionSwitcher, ViewSwitch, sortTableRows, useToast };
|
|
1487
|
-
export type { Accent, AccentPickerProps, AccountMenuProps, AccountReader, AccountSection, AccountWindowProps, AddFilter, AppShellGroup, AppShellLink, AppShellProps, AppShellSection, AuthShellProps, AvatarProps, BackLinkOwnProps, BackLinkProps, BusyRegionProps, ButtonLinkProps, ButtonProps, CalloutProps, CalloutVariant, ChartAreaLook, ChartBridgeStep, ChartBridgeTones, ChartDonutLook, ChartLineLook, ChartLookSeries, ChartPeriod, ChartProps, ChartSeries, ChartSlice, ChartStackedLook, ChartTone, CheckListProps, CheckboxProps, Column, CommandGroup, CommandItem, CommandPaletteProps, ConfirmProps, DataTableProps, DatePickerMode, DatePickerPreset, DatePickerProps, DatePickerRange, DeltaValueProps, DeniedProps, DrawerProps, DrawerSectionProps, DropdownAvatar, DropdownBadge, DropdownEntry, DropdownItem, DropdownProps, DropdownRowProps, DropdownSearch, DropdownSection, DropdownSeparator, EmptyStateProps, EmptyStateVariant, FeedbackPayload, FeedbackProps, FeedbackResult, FeedbackSection, FieldControlProps, FieldProps, FileDropFile, FileDropProps, FileDropStatus, FileFieldProps, Filter, FilterBarProps, FooterColumn, FooterLink, FooterProps, FooterSocial, KeyValueListProps, KeyValueRow, ModalProps, NativeButtonProps, NavTabBadge, NavTabItem, NavTabsProps, NumericValueProps, PaginationProps, PillProps, RowIdentityProps, SearchFieldProps, SegmentOption, SegmentedProps, SelectFieldProps, SidebarNavBadge, SidebarNavBlock, SidebarNavGroup, SidebarNavItem, SidebarNavLeaf, SidebarNavProps, SidebarNavRow, SidebarNavSection, SidebarNavSections, SkeletonProps, SkeletonTableProps, SnippetProps, StatBandProps, StatDelta, StatFigure, StatTone, StatVariant, StatusDotProps, SuccessCheckProps, SuccessCountdown, SuccessPanelProps, SuccessProps, SwitchProps, TabItem, TableSort, TabsProps, TextAreaProps, TextFieldProps, ThemeChoiceProps, ThemeToggleProps, TimelineEvent, TimelineEventKind, TimelineProps, ToastNotice, ToastProps, TooltipProps, TopBarProps, Version, VersionSwitcherProps, ViewSwitchItem, ViewSwitchProps };
|
|
1498
|
+
export type { Accent, AccentPickerProps, AccountMenuProps, AccountReader, AccountSection, AccountWindowProps, AddFilter, AppShellGroup, AppShellLink, AppShellProps, AppShellSection, AuthShellProps, AvatarProps, BackLinkOwnProps, BackLinkProps, BusyRegionProps, ButtonLinkProps, ButtonProps, CalloutProps, CalloutVariant, ChartAreaLook, ChartBridgeStep, ChartBridgeTones, ChartDonutLook, ChartEstimate, ChartLineLook, ChartLookSeries, ChartPeriod, ChartProps, ChartSeries, ChartSlice, ChartStackedLook, ChartTone, CheckListProps, CheckboxProps, Column, CommandGroup, CommandItem, CommandPaletteProps, ConfirmProps, DataTableProps, DatePickerMode, DatePickerPreset, DatePickerProps, DatePickerRange, DeltaValueProps, DeniedProps, DrawerProps, DrawerSectionProps, DropdownAvatar, DropdownBadge, DropdownEntry, DropdownItem, DropdownProps, DropdownRowProps, DropdownSearch, DropdownSection, DropdownSeparator, EmptyStateProps, EmptyStateVariant, FeedbackPayload, FeedbackProps, FeedbackResult, FeedbackSection, FieldControlProps, FieldProps, FileDropFile, FileDropProps, FileDropStatus, FileFieldProps, Filter, FilterBarProps, FooterColumn, FooterLink, FooterProps, FooterSocial, KeyValueListProps, KeyValueRow, ModalProps, NativeButtonProps, NavTabBadge, NavTabItem, NavTabsProps, NumericValueProps, PaginationProps, PillProps, RowIdentityProps, SearchFieldProps, SegmentOption, SegmentedProps, SelectFieldProps, SidebarNavBadge, SidebarNavBlock, SidebarNavGroup, SidebarNavItem, SidebarNavLeaf, SidebarNavProps, SidebarNavRow, SidebarNavSection, SidebarNavSections, SkeletonProps, SkeletonTableProps, SnippetProps, StatBandProps, StatDelta, StatFigure, StatTone, StatVariant, StatusDotProps, SuccessCheckProps, SuccessCountdown, SuccessPanelProps, SuccessProps, SwitchProps, TabItem, TableSort, TabsProps, TextAreaProps, TextFieldProps, ThemeChoiceProps, ThemeToggleProps, TimelineEvent, TimelineEventKind, TimelineProps, ToastNotice, ToastProps, TooltipProps, TopBarProps, Version, VersionSwitcherProps, ViewSwitchItem, ViewSwitchProps };
|
package/react/dist/index.js
CHANGED
|
@@ -477,7 +477,7 @@ import { useId as useId4 } from "react";
|
|
|
477
477
|
|
|
478
478
|
// src/tip.ts
|
|
479
479
|
var TIP_GAP = 8;
|
|
480
|
-
function placeTip(host, mark, tip,
|
|
480
|
+
function placeTip(host, mark, tip, placement = "top") {
|
|
481
481
|
const mrect = mark.getBoundingClientRect();
|
|
482
482
|
const view = host.ownerDocument.documentElement;
|
|
483
483
|
const declared = parseFloat(getComputedStyle(tip).getPropertyValue("--ui-tip-gap"));
|
|
@@ -496,13 +496,6 @@ function placeTip(host, mark, tip, bound, placement = "top") {
|
|
|
496
496
|
clip.right = Math.min(clip.right, left2 + el.clientWidth);
|
|
497
497
|
clip.bottom = Math.min(clip.bottom, top + el.clientHeight);
|
|
498
498
|
}
|
|
499
|
-
if (bound) {
|
|
500
|
-
const edge = bound.getBoundingClientRect();
|
|
501
|
-
clip.top = Math.max(clip.top, edge.top);
|
|
502
|
-
clip.left = Math.max(clip.left, edge.left);
|
|
503
|
-
clip.right = Math.min(clip.right, edge.right);
|
|
504
|
-
clip.bottom = Math.min(clip.bottom, edge.bottom);
|
|
505
|
-
}
|
|
506
499
|
const above = mrect.top - clip.top;
|
|
507
500
|
const below = clip.bottom - mrect.bottom;
|
|
508
501
|
const prefersBelow = placement === "bottom";
|
|
@@ -619,7 +612,7 @@ function Tooltip({ text: text2, label = text2, value, detail: detail2, placement
|
|
|
619
612
|
const target = active.current;
|
|
620
613
|
if (!h || !t || !target) return;
|
|
621
614
|
const anchor = target.querySelector("[data-tip-anchor]") || target;
|
|
622
|
-
placeTip(h, anchor, t,
|
|
615
|
+
placeTip(h, anchor, t, placement);
|
|
623
616
|
}
|
|
624
617
|
useLayoutEffect2(() => {
|
|
625
618
|
const t = tip.current;
|
|
@@ -6105,6 +6098,17 @@ var FALLBACK_COL = 48;
|
|
|
6105
6098
|
var BAR_SHARE = 0.5;
|
|
6106
6099
|
var BAR_MAX = 12;
|
|
6107
6100
|
var BAR_MAX_BRIDGE = 22;
|
|
6101
|
+
var FIT_SHARE = 2 / 3;
|
|
6102
|
+
var FIT_MAX = 48;
|
|
6103
|
+
var FIT_CORNER = 6;
|
|
6104
|
+
var TEXT_GAP = 4;
|
|
6105
|
+
var LABEL_GAP = 8;
|
|
6106
|
+
var TEXT_SIZE = 12;
|
|
6107
|
+
var VALUE_ROOM = Math.ceil(TEXT_SIZE * 1.45) + TEXT_GAP;
|
|
6108
|
+
var GROUP_ROOM = 32;
|
|
6109
|
+
var GROUP_BASELINE = 16;
|
|
6110
|
+
var BOUNDARY_TOP = 24;
|
|
6111
|
+
var GROUP_WORDS = "Not final";
|
|
6108
6112
|
var LANE_GAP = 2;
|
|
6109
6113
|
var MISSING2 = "\u2014";
|
|
6110
6114
|
function fadeOf(uid, m, bridge) {
|
|
@@ -6114,19 +6118,22 @@ function fadeOf(uid, m, bridge) {
|
|
|
6114
6118
|
}
|
|
6115
6119
|
var cx9 = (...parts) => parts.filter(Boolean).join(" ");
|
|
6116
6120
|
var px2 = (n) => Math.round(n * 10) / 10;
|
|
6121
|
+
var STATE_WORD = { incomplete: "Incomplete", projected: "Projected" };
|
|
6117
6122
|
var columnOf = (p, fallback) => ({
|
|
6118
6123
|
label: p.label,
|
|
6119
6124
|
short: p.short || fallback,
|
|
6120
6125
|
estimated: Boolean(p.estimated),
|
|
6121
|
-
note: p.note
|
|
6126
|
+
note: p.note,
|
|
6127
|
+
compare: !("compare" in p) || p.compare !== false,
|
|
6128
|
+
state: !p.estimated ? void 0 : p.estimated === true ? "Estimated" : STATE_WORD[p.estimated]
|
|
6122
6129
|
});
|
|
6123
6130
|
function onPrevious(value, previous, when) {
|
|
6124
6131
|
if (previous === void 0 || previous === 0 || !Number.isFinite(previous) || !when) return "";
|
|
6125
6132
|
const pct2 = (value - previous) / Math.abs(previous) * 100;
|
|
6126
6133
|
return `${pct2 < 0 ? "\u2212" : "+"}${Math.abs(pct2).toFixed(1)}% on ${when}`;
|
|
6127
6134
|
}
|
|
6128
|
-
function barPath(m) {
|
|
6129
|
-
const r = Math.min(m.w / 2, m.h / (m.foot ? 1 : 4));
|
|
6135
|
+
function barPath(m, corner = m.w / 2) {
|
|
6136
|
+
const r = Math.min(corner, m.w / 2, m.h / (m.foot ? 1 : 4));
|
|
6130
6137
|
const { x, y: top, w, h } = m;
|
|
6131
6138
|
const bottom = top + h;
|
|
6132
6139
|
const arc2 = (dx, dy, sweep) => `a${px2(r)} ${px2(r)} 0 0 ${sweep} ${px2(dx)} ${px2(dy)}`;
|
|
@@ -6147,9 +6154,42 @@ function useTapFloor() {
|
|
|
6147
6154
|
}, []);
|
|
6148
6155
|
return floor;
|
|
6149
6156
|
}
|
|
6157
|
+
function useTextWidth(host) {
|
|
6158
|
+
const [face, setFace] = useState21(null);
|
|
6159
|
+
const [loaded, setLoaded] = useState21(0);
|
|
6160
|
+
useEffect21(() => {
|
|
6161
|
+
const el = host.current;
|
|
6162
|
+
if (!el || typeof OffscreenCanvas === "undefined") return;
|
|
6163
|
+
const style = getComputedStyle(el);
|
|
6164
|
+
const font = (weight) => `${weight} ${TEXT_SIZE}px ${style.fontFamily}`;
|
|
6165
|
+
setFace({ regular: font(style.fontWeight), medium: font(style.getPropertyValue("--weight-medium").trim() || "500") });
|
|
6166
|
+
let live = true;
|
|
6167
|
+
el.ownerDocument.fonts?.ready.then(() => {
|
|
6168
|
+
if (live) setLoaded((n) => n + 1);
|
|
6169
|
+
});
|
|
6170
|
+
return () => {
|
|
6171
|
+
live = false;
|
|
6172
|
+
};
|
|
6173
|
+
}, [host]);
|
|
6174
|
+
return useMemo6(() => {
|
|
6175
|
+
void loaded;
|
|
6176
|
+
const ctx = face ? new OffscreenCanvas(1, 1).getContext("2d") : null;
|
|
6177
|
+
return (text2, medium = false) => {
|
|
6178
|
+
if (!ctx || !face) return text2.length * TEXT_SIZE * 0.62;
|
|
6179
|
+
ctx.font = medium ? face.medium : face.regular;
|
|
6180
|
+
return Math.ceil(ctx.measureText(text2).width);
|
|
6181
|
+
};
|
|
6182
|
+
}, [face, loaded]);
|
|
6183
|
+
}
|
|
6184
|
+
function barValue(bar) {
|
|
6185
|
+
return bar.band === "down" ? bar.from - bar.to : bar.to - bar.from;
|
|
6186
|
+
}
|
|
6187
|
+
function printsBelow(bar) {
|
|
6188
|
+
return bar.to < bar.from;
|
|
6189
|
+
}
|
|
6150
6190
|
function stateOf(column) {
|
|
6151
|
-
if (!column?.
|
|
6152
|
-
return column.note ?
|
|
6191
|
+
if (!column?.state) return "";
|
|
6192
|
+
return column.note ? `${column.state} \u2014 ${column.note}` : column.state;
|
|
6153
6193
|
}
|
|
6154
6194
|
function seriesFrame(periods, series, spark, format) {
|
|
6155
6195
|
const columns = periods.map((p) => columnOf(p, p.label.split(" ")[0]));
|
|
@@ -6182,7 +6222,7 @@ function seriesFrame(periods, series, spark, format) {
|
|
|
6182
6222
|
column: i,
|
|
6183
6223
|
from: 0,
|
|
6184
6224
|
to: below ? -value : value,
|
|
6185
|
-
detail: onPrevious(value, s.values[i - 1], columns[i - 1]?.short ?? ""),
|
|
6225
|
+
detail: columns[i].compare ? onPrevious(value, s.values[i - 1], columns[i - 1]?.short ?? "") : "",
|
|
6186
6226
|
band,
|
|
6187
6227
|
lane,
|
|
6188
6228
|
lanes
|
|
@@ -6315,7 +6355,7 @@ function donutFrame(look, slices, totalLabel, format) {
|
|
|
6315
6355
|
to: [total > 0 ? at / total : 0]
|
|
6316
6356
|
};
|
|
6317
6357
|
});
|
|
6318
|
-
const columns = slices.map((s) => ({ label: s.name, short: s.name, estimated: false }));
|
|
6358
|
+
const columns = slices.map((s) => ({ label: s.name, short: s.name, estimated: false, compare: false }));
|
|
6319
6359
|
return {
|
|
6320
6360
|
columns,
|
|
6321
6361
|
scale: { min: 0, max: 1, step: 1, ticks: [] },
|
|
@@ -6370,6 +6410,8 @@ function Chart(props) {
|
|
|
6370
6410
|
} = props;
|
|
6371
6411
|
const variant = props.variant ?? "months";
|
|
6372
6412
|
const spark = variant === "spark";
|
|
6413
|
+
const fit = variant === "months";
|
|
6414
|
+
const showValues = fit && "values" in props && props.values === true;
|
|
6373
6415
|
const plotHeight = height ?? HEIGHT[variant];
|
|
6374
6416
|
const showTable = table ?? !spark;
|
|
6375
6417
|
const [view, setView] = useState21("chart");
|
|
@@ -6390,7 +6432,9 @@ function Chart(props) {
|
|
|
6390
6432
|
const opening = useRef25(false);
|
|
6391
6433
|
const pointerFocus = useRef25(false);
|
|
6392
6434
|
const floor = useTapFloor();
|
|
6435
|
+
const textWidth = useTextWidth(frameEl);
|
|
6393
6436
|
const [width, setWidth] = useState21(0);
|
|
6437
|
+
const [boxWidth, setBoxWidth] = useState21(0);
|
|
6394
6438
|
const [overflows, setOverflows] = useState21(false);
|
|
6395
6439
|
const [openId, setOpenId] = useState21(null);
|
|
6396
6440
|
const [rawCursor, setCursor] = useState21(0);
|
|
@@ -6419,20 +6463,33 @@ function Chart(props) {
|
|
|
6419
6463
|
const boxHeight = Math.max(plotHeight, floor);
|
|
6420
6464
|
const boxTop = -(boxHeight - plotHeight) / 2;
|
|
6421
6465
|
const span = scale.max - scale.min || 1;
|
|
6466
|
+
const groupFrom = fit ? columns.findIndex((c) => c.estimated) : -1;
|
|
6467
|
+
const lanes = Math.max(1, ...frame.bars.map((b) => b.lanes));
|
|
6468
|
+
const cap = fit ? FIT_MAX : variant === "bridge" ? BAR_MAX_BRIDGE : BAR_MAX;
|
|
6469
|
+
const groupWidth = fit ? Math.max(lanes * 2, Math.min(colWidth * FIT_SHARE, cap * lanes + LANE_GAP * (lanes - 1))) : Math.max(4, Math.min(colWidth * BAR_SHARE, colWidth - 6, cap * lanes + LANE_GAP * (lanes - 1)));
|
|
6470
|
+
const barWidth = Math.max(1, (groupWidth - LANE_GAP * (lanes - 1)) / lanes);
|
|
6471
|
+
const centre = useCallback8((column) => column * colWidth + colWidth / 2, [colWidth]);
|
|
6472
|
+
const barX = useCallback8((bar) => centre(bar.column) - (bar.lanes * barWidth + LANE_GAP * (bar.lanes - 1)) / 2 + bar.lane * (barWidth + LANE_GAP), [centre, barWidth]);
|
|
6473
|
+
const under = useMemo6(() => new Set(frame.bars.filter(printsBelow).map((b) => b.id)), [frame.bars]);
|
|
6474
|
+
const printed = useMemo6(() => {
|
|
6475
|
+
const out = /* @__PURE__ */ new Set();
|
|
6476
|
+
if (!showValues) return out;
|
|
6477
|
+
const at = frame.bars.map((bar) => ({ bar, x: barX(bar) + barWidth / 2 }));
|
|
6478
|
+
for (const { bar, x } of at) {
|
|
6479
|
+
const side = at.filter((o) => o.bar !== bar && under.has(o.bar.id) === under.has(bar.id));
|
|
6480
|
+
const left = Math.min(2 * x, ...side.filter((o) => o.x <= x).map((o) => x - o.x));
|
|
6481
|
+
const right = Math.min(2 * (plotWidth - x), ...side.filter((o) => o.x > x).map((o) => o.x - x));
|
|
6482
|
+
if (textWidth(formatAxis(barValue(bar))) + TEXT_GAP <= Math.min(left, right)) out.add(bar.id);
|
|
6483
|
+
}
|
|
6484
|
+
return out;
|
|
6485
|
+
}, [showValues, frame.bars, under, barX, barWidth, plotWidth, textWidth, formatAxis]);
|
|
6486
|
+
const roomTop = (groupFrom >= 0 ? GROUP_ROOM : 0) + ([...printed].some((id) => !under.has(id)) ? VALUE_ROOM : 0);
|
|
6487
|
+
const roomBottom = [...printed].some((id) => under.has(id)) ? VALUE_ROOM : 0;
|
|
6422
6488
|
const y = useCallback8(
|
|
6423
|
-
(value) => PAD + (scale.max - value) / span * (plotHeight - PAD * 2),
|
|
6424
|
-
[scale.max, span, plotHeight]
|
|
6489
|
+
(value) => PAD + roomTop + (scale.max - value) / span * (plotHeight - PAD * 2 - roomTop - roomBottom),
|
|
6490
|
+
[scale.max, span, plotHeight, roomTop, roomBottom]
|
|
6425
6491
|
);
|
|
6426
6492
|
const zero = y(Math.min(Math.max(0, scale.min), scale.max));
|
|
6427
|
-
const lanes = Math.max(1, ...frame.bars.map((b) => b.lanes));
|
|
6428
|
-
const cap = variant === "bridge" ? BAR_MAX_BRIDGE : BAR_MAX;
|
|
6429
|
-
const groupWidth = Math.max(4, Math.min(
|
|
6430
|
-
colWidth * BAR_SHARE,
|
|
6431
|
-
colWidth - 6,
|
|
6432
|
-
cap * lanes + LANE_GAP * (lanes - 1)
|
|
6433
|
-
));
|
|
6434
|
-
const barWidth = (groupWidth - LANE_GAP * (lanes - 1)) / lanes;
|
|
6435
|
-
const centre = useCallback8((column) => column * colWidth + colWidth / 2, [colWidth]);
|
|
6436
6493
|
const axisFormat = look?.share ? pct : formatAxis;
|
|
6437
6494
|
const geometry = useMemo6(() => look ? {
|
|
6438
6495
|
look,
|
|
@@ -6472,7 +6529,7 @@ function Chart(props) {
|
|
|
6472
6529
|
column: bar.column,
|
|
6473
6530
|
name: bar.name,
|
|
6474
6531
|
tone: bar.tone,
|
|
6475
|
-
value: bar
|
|
6532
|
+
value: barValue(bar),
|
|
6476
6533
|
detail: bar.detail,
|
|
6477
6534
|
kind: "bar",
|
|
6478
6535
|
band: bar.band,
|
|
@@ -6483,7 +6540,7 @@ function Chart(props) {
|
|
|
6483
6540
|
// the lanes it actually has: a chart with two series above the line and
|
|
6484
6541
|
// one below puts the single one in the middle of its column rather than
|
|
6485
6542
|
// in the left half of a group it does not fill.
|
|
6486
|
-
x:
|
|
6543
|
+
x: barX(bar),
|
|
6487
6544
|
y: top,
|
|
6488
6545
|
w: barWidth,
|
|
6489
6546
|
h: Math.max(bottom - top, 1),
|
|
@@ -6500,7 +6557,7 @@ function Chart(props) {
|
|
|
6500
6557
|
name: keys.find((k) => k.id === line.id)?.name ?? line.id,
|
|
6501
6558
|
tone: line.tone,
|
|
6502
6559
|
value,
|
|
6503
|
-
detail: onPrevious(value, line.values[i - 1], columns[i - 1]?.short ?? ""),
|
|
6560
|
+
detail: columns[i]?.compare ? onPrevious(value, line.values[i - 1], columns[i - 1]?.short ?? "") : "",
|
|
6504
6561
|
kind: "dot",
|
|
6505
6562
|
band: "full",
|
|
6506
6563
|
foot: null,
|
|
@@ -6523,9 +6580,10 @@ function Chart(props) {
|
|
|
6523
6580
|
);
|
|
6524
6581
|
}
|
|
6525
6582
|
return [...out, ...dots];
|
|
6526
|
-
}, [geometry, frame, lines, keys, columns, centre, barWidth, groupWidth, y, floor, colWidth, plotWidth, boxTop, boxHeight]);
|
|
6583
|
+
}, [geometry, frame, lines, keys, columns, centre, barX, barWidth, groupWidth, y, floor, colWidth, plotWidth, boxTop, boxHeight]);
|
|
6527
6584
|
const byId = useMemo6(() => new Map(marks.map((m) => [m.id, m])), [marks]);
|
|
6528
|
-
const
|
|
6585
|
+
const fadeFor = useCallback8((m) => fit ? null : fadeOf(uid, m, variant === "bridge"), [fit, uid, variant]);
|
|
6586
|
+
const fades = useMemo6(() => new Map(marks.filter((m) => m.kind === "bar").map(fadeFor).filter((f) => f !== null).map((f) => [f.id, f])), [marks, fadeFor]);
|
|
6529
6587
|
const lead = useCallback8((column) => marks.find((m) => m.column === column), [marks]);
|
|
6530
6588
|
const open = openId ? byId.get(openId) : void 0;
|
|
6531
6589
|
useEffect21(() => {
|
|
@@ -6534,6 +6592,7 @@ function Chart(props) {
|
|
|
6534
6592
|
if (!el || !box2) return;
|
|
6535
6593
|
const read = () => {
|
|
6536
6594
|
setWidth(el.clientWidth);
|
|
6595
|
+
setBoxWidth(box2.clientWidth);
|
|
6537
6596
|
setOverflows(box2.scrollWidth > box2.clientWidth);
|
|
6538
6597
|
};
|
|
6539
6598
|
read();
|
|
@@ -6543,15 +6602,15 @@ function Chart(props) {
|
|
|
6543
6602
|
observer.observe(box2);
|
|
6544
6603
|
return () => observer.disconnect();
|
|
6545
6604
|
}, []);
|
|
6546
|
-
const opensAtEnd =
|
|
6605
|
+
const opensAtEnd = Boolean(periods);
|
|
6547
6606
|
useLayoutEffect5(() => {
|
|
6548
6607
|
const el = scroller.current;
|
|
6549
6608
|
if (opensAtEnd && el) el.scrollLeft = el.scrollWidth - el.clientWidth;
|
|
6550
|
-
}, [opensAtEnd, plotWidth, count]);
|
|
6609
|
+
}, [opensAtEnd, plotWidth, boxWidth, count]);
|
|
6551
6610
|
useLayoutEffect5(() => {
|
|
6552
6611
|
if (!openId || !frameEl.current || !tipEl.current || !svgEl.current) return;
|
|
6553
|
-
const
|
|
6554
|
-
if (
|
|
6612
|
+
const anchor2 = [...svgEl.current.querySelectorAll("[data-anchor]")].find((el) => el.getAttribute("data-anchor") === openId);
|
|
6613
|
+
if (anchor2) placeTip(frameEl.current, anchor2, tipEl.current);
|
|
6555
6614
|
}, [openId, plotWidth, plotHeight]);
|
|
6556
6615
|
useEffect21(() => {
|
|
6557
6616
|
if (!openId) return;
|
|
@@ -6592,6 +6651,16 @@ function Chart(props) {
|
|
|
6592
6651
|
const state = stateOf(where);
|
|
6593
6652
|
setSaid(`${where.label}. ${values}.${state ? ` ${state}.` : ""}${picked === column ? " Selected." : ""}`);
|
|
6594
6653
|
}, [columns, marks, format, pick, totalLabel]);
|
|
6654
|
+
const inView = (column) => {
|
|
6655
|
+
const el = scroller.current;
|
|
6656
|
+
if (!el || el.scrollWidth <= el.clientWidth || !colWidth) return column;
|
|
6657
|
+
const first = Math.min(count - 1, Math.max(0, Math.ceil(el.scrollLeft / colWidth - 0.01)));
|
|
6658
|
+
const last = Math.max(first, Math.min(
|
|
6659
|
+
count - 1,
|
|
6660
|
+
Math.floor((el.scrollLeft + el.clientWidth) / colWidth + 0.01) - 1
|
|
6661
|
+
));
|
|
6662
|
+
return Math.min(Math.max(column, first), last);
|
|
6663
|
+
};
|
|
6595
6664
|
const step = (next) => {
|
|
6596
6665
|
const column = Math.max(0, Math.min(next, count - 1));
|
|
6597
6666
|
setCursor(column);
|
|
@@ -6626,20 +6695,12 @@ function Chart(props) {
|
|
|
6626
6695
|
announce(cursor, cursor);
|
|
6627
6696
|
}
|
|
6628
6697
|
};
|
|
6629
|
-
const estimated = columns.filter((c) => c.estimated);
|
|
6630
|
-
const estimatedTone = marks.find((m) => m.estimated && m.kind === "bar")?.tone ?? keys[0]?.tone ?? "neutral";
|
|
6631
6698
|
const hitBand = (band) => band === "up" ? { y: PAD, h: Math.max(zero - PAD, TARGET) } : band === "down" ? { y: zero, h: Math.max(plotHeight - PAD - zero, TARGET) } : { y: PAD, h: Math.max(plotHeight - PAD * 2, TARGET) };
|
|
6632
6699
|
const legendFirst = !(look?.variant === "donut" && look.look !== "labels");
|
|
6633
|
-
const legend = keyed && !asTable && keys.length > 0 && !(look?.variant === "donut" && look.look === "table") && /* @__PURE__ */
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
] }, key.id)),
|
|
6638
|
-
estimated.length > 0 && /* @__PURE__ */ jsxs43("li", { className: cx9("ui-chart__key", `ui-chart__tone--${estimatedTone}`), children: [
|
|
6639
|
-
/* @__PURE__ */ jsx47("svg", { className: "ui-chart__key-mark", width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", children: /* @__PURE__ */ jsx47("rect", { className: "ui-chart__key-estimated", x: "1.5", y: "1.5", width: "9", height: "9", rx: "2.5" }) }),
|
|
6640
|
-
"Estimated"
|
|
6641
|
-
] })
|
|
6642
|
-
] });
|
|
6700
|
+
const legend = keyed && !asTable && keys.length > 0 && !(look?.variant === "donut" && look.look === "table") && /* @__PURE__ */ jsx47("ul", { className: "ui-chart__legend", children: keys.map((key) => /* @__PURE__ */ jsxs43("li", { className: cx9("ui-chart__key", `ui-chart__tone--${key.tone}`), children: [
|
|
6701
|
+
/* @__PURE__ */ jsx47(KeyMark, { shape: key.shape }),
|
|
6702
|
+
key.name
|
|
6703
|
+
] }, key.id)) });
|
|
6643
6704
|
const viewSwitch = showTable && /* @__PURE__ */ jsx47(
|
|
6644
6705
|
Segmented,
|
|
6645
6706
|
{
|
|
@@ -6654,6 +6715,15 @@ function Chart(props) {
|
|
|
6654
6715
|
}
|
|
6655
6716
|
);
|
|
6656
6717
|
const noun = look?.layout === "ring" ? "slices" : look?.layout === "rows" ? "rows" : "columns";
|
|
6718
|
+
const labelRoom = Math.max(0, ...columns.map((c) => textWidth(c.short))) + LABEL_GAP;
|
|
6719
|
+
const every = labelRoom > colWidth ? Math.ceil(labelRoom / colWidth) : 1;
|
|
6720
|
+
const anchor = groupFrom >= 0 ? groupFrom : count - 1;
|
|
6721
|
+
const labelled = (i) => ((anchor - i) % every + every) % every === 0;
|
|
6722
|
+
const edgeOf = (i) => {
|
|
6723
|
+
const half = textWidth(columns[i].short) / 2;
|
|
6724
|
+
return centre(i) - half < 0 ? "is-start" : centre(i) + half > plotWidth ? "is-end" : null;
|
|
6725
|
+
};
|
|
6726
|
+
const groupX = groupFrom >= 0 ? Math.min(Math.max(groupFrom * colWidth, 1), plotWidth - 1) : 0;
|
|
6657
6727
|
return /* @__PURE__ */ jsxs43(
|
|
6658
6728
|
"div",
|
|
6659
6729
|
{
|
|
@@ -6668,7 +6738,9 @@ function Chart(props) {
|
|
|
6668
6738
|
"--ui-chart-h": `${plotHeight}px`,
|
|
6669
6739
|
"--ui-chart-box": `${px2(boxHeight)}px`,
|
|
6670
6740
|
"--ui-chart-cols": count,
|
|
6671
|
-
"--ui-chart-pad": `${PAD}px
|
|
6741
|
+
"--ui-chart-pad": `${PAD}px`,
|
|
6742
|
+
"--ui-chart-top": `${PAD + roomTop}px`,
|
|
6743
|
+
"--ui-chart-bottom": `${PAD + roomBottom}px`
|
|
6672
6744
|
},
|
|
6673
6745
|
children: [
|
|
6674
6746
|
toCard && createPortal8(viewSwitch, toCard),
|
|
@@ -6692,11 +6764,14 @@ function Chart(props) {
|
|
|
6692
6764
|
pointerFocus.current = false;
|
|
6693
6765
|
return;
|
|
6694
6766
|
}
|
|
6695
|
-
|
|
6696
|
-
|
|
6767
|
+
const column = inView(cursor);
|
|
6768
|
+
setCursor(column);
|
|
6769
|
+
show(lead(column)?.id);
|
|
6770
|
+
announce(column);
|
|
6697
6771
|
},
|
|
6698
6772
|
onBlur: (event) => {
|
|
6699
6773
|
if (event.target !== event.currentTarget) return;
|
|
6774
|
+
if (pointerFocus.current) return;
|
|
6700
6775
|
setOpenId(null);
|
|
6701
6776
|
setSaid("");
|
|
6702
6777
|
},
|
|
@@ -6711,12 +6786,12 @@ function Chart(props) {
|
|
|
6711
6786
|
role: overflows ? "region" : void 0,
|
|
6712
6787
|
"aria-label": overflows ? `${title}. Scroll for more ${noun}.` : void 0,
|
|
6713
6788
|
onScroll: () => {
|
|
6714
|
-
const
|
|
6715
|
-
if (!
|
|
6716
|
-
const mark =
|
|
6789
|
+
const anchor2 = [...svgEl.current?.querySelectorAll("[data-anchor]") ?? []].find((el) => el.getAttribute("data-anchor") === openId);
|
|
6790
|
+
if (!anchor2 || !scroller.current || !frameEl.current || !tipEl.current) return;
|
|
6791
|
+
const mark = anchor2.getBoundingClientRect();
|
|
6717
6792
|
const view2 = scroller.current.getBoundingClientRect();
|
|
6718
6793
|
if (mark.right <= view2.left || mark.left >= view2.right) setOpenId(null);
|
|
6719
|
-
else placeTip(frameEl.current,
|
|
6794
|
+
else placeTip(frameEl.current, anchor2, tipEl.current);
|
|
6720
6795
|
},
|
|
6721
6796
|
children: /* @__PURE__ */ jsxs43("div", { ref: plot, className: "ui-chart__plot", children: [
|
|
6722
6797
|
/* @__PURE__ */ jsxs43(
|
|
@@ -6757,7 +6832,8 @@ function Chart(props) {
|
|
|
6757
6832
|
opening.current = false;
|
|
6758
6833
|
setOpenId(null);
|
|
6759
6834
|
} else {
|
|
6760
|
-
|
|
6835
|
+
dismissed.current = null;
|
|
6836
|
+
opening.current = Boolean(id);
|
|
6761
6837
|
show(id);
|
|
6762
6838
|
}
|
|
6763
6839
|
},
|
|
@@ -6826,6 +6902,27 @@ function Chart(props) {
|
|
|
6826
6902
|
y2: px2(y(0))
|
|
6827
6903
|
}
|
|
6828
6904
|
),
|
|
6905
|
+
groupFrom >= 0 && /* @__PURE__ */ jsxs43(Fragment21, { children: [
|
|
6906
|
+
/* @__PURE__ */ jsx47(
|
|
6907
|
+
"line",
|
|
6908
|
+
{
|
|
6909
|
+
className: "ui-chart__boundary",
|
|
6910
|
+
x1: px2(groupX),
|
|
6911
|
+
x2: px2(groupX),
|
|
6912
|
+
y1: BOUNDARY_TOP,
|
|
6913
|
+
y2: px2(plotHeight - PAD)
|
|
6914
|
+
}
|
|
6915
|
+
),
|
|
6916
|
+
/* @__PURE__ */ jsx47(
|
|
6917
|
+
"text",
|
|
6918
|
+
{
|
|
6919
|
+
className: "ui-chart__text ui-chart__group",
|
|
6920
|
+
y: GROUP_BASELINE,
|
|
6921
|
+
x: px2(Math.max(0, Math.min(groupX + TEXT_GAP, plotWidth - textWidth(GROUP_WORDS, true)))),
|
|
6922
|
+
children: GROUP_WORDS
|
|
6923
|
+
}
|
|
6924
|
+
)
|
|
6925
|
+
] }),
|
|
6829
6926
|
fades.size > 0 && /* @__PURE__ */ jsx47("defs", { children: [...fades.values()].map((fade) => /* @__PURE__ */ jsxs43(
|
|
6830
6927
|
"linearGradient",
|
|
6831
6928
|
{
|
|
@@ -6843,7 +6940,7 @@ function Chart(props) {
|
|
|
6843
6940
|
fade.id
|
|
6844
6941
|
)) }),
|
|
6845
6942
|
marks.filter((m) => m.kind === "bar").map((mark) => {
|
|
6846
|
-
const fade =
|
|
6943
|
+
const fade = fadeFor(mark);
|
|
6847
6944
|
return /* @__PURE__ */ jsx47(
|
|
6848
6945
|
"path",
|
|
6849
6946
|
{
|
|
@@ -6853,11 +6950,25 @@ function Chart(props) {
|
|
|
6853
6950
|
mark.estimated && "is-estimated"
|
|
6854
6951
|
),
|
|
6855
6952
|
style: fade ? { "--ui-chart-paint": `url(#${fade.id})` } : void 0,
|
|
6856
|
-
d: barPath(mark)
|
|
6953
|
+
d: fit ? barPath(mark, px2(Math.min(FIT_CORNER, mark.w / 4))) : barPath(mark)
|
|
6857
6954
|
},
|
|
6858
6955
|
`bar-${mark.id}`
|
|
6859
6956
|
);
|
|
6860
6957
|
}),
|
|
6958
|
+
marks.filter((m) => m.kind === "bar" && printed.has(m.id)).map((mark) => {
|
|
6959
|
+
const text2 = formatAxis(mark.value);
|
|
6960
|
+
const below = under.has(mark.id);
|
|
6961
|
+
return /* @__PURE__ */ jsx47(
|
|
6962
|
+
"text",
|
|
6963
|
+
{
|
|
6964
|
+
className: cx9("ui-chart__text", "ui-chart__value", below && "ui-chart__value--below"),
|
|
6965
|
+
x: px2(mark.x + mark.w / 2),
|
|
6966
|
+
y: px2(below ? mark.y + mark.h + TEXT_GAP : mark.y - TEXT_GAP),
|
|
6967
|
+
children: text2
|
|
6968
|
+
},
|
|
6969
|
+
`value-${mark.id}`
|
|
6970
|
+
);
|
|
6971
|
+
}),
|
|
6861
6972
|
["casing", "stroke"].map((layer) => lines.flatMap(
|
|
6862
6973
|
(line) => line.values.slice(1).map((value, i) => Number.isFinite(value) && Number.isFinite(line.values[i]) ? /* @__PURE__ */ jsx47(
|
|
6863
6974
|
"line",
|
|
@@ -6922,11 +7033,11 @@ function Chart(props) {
|
|
|
6922
7033
|
}
|
|
6923
7034
|
),
|
|
6924
7035
|
look?.variant === "donut" && look.look === "table" && /* @__PURE__ */ jsx47(Shares, { look, format, swatch: /* @__PURE__ */ jsx47(KeyMark, { shape: "fill" }) }),
|
|
6925
|
-
!spark && columnsLayout && /* @__PURE__ */ jsx47("div", { className: "ui-chart__periods", "aria-hidden": "true", children: columns.map((column, i) => /* @__PURE__ */ jsx47(
|
|
7036
|
+
!spark && columnsLayout && /* @__PURE__ */ jsx47("div", { className: cx9("ui-chart__periods", every > 1 && "ui-chart__periods--step"), "aria-hidden": "true", children: columns.map((column, i) => /* @__PURE__ */ jsx47(
|
|
6926
7037
|
"span",
|
|
6927
7038
|
{
|
|
6928
|
-
className: cx9("ui-chart__period", pick === i && "is-selected"),
|
|
6929
|
-
children: column.short
|
|
7039
|
+
className: cx9("ui-chart__period", pick === i && "is-selected", every > 1 && edgeOf(i)),
|
|
7040
|
+
children: labelled(i) ? column.short : null
|
|
6930
7041
|
},
|
|
6931
7042
|
`${column.label}-${i}`
|
|
6932
7043
|
)) })
|
package/src/styles/chart.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* ============================================================================
|
|
2
2
|
* Chart — .ui-chart, the shapes a money dashboard keeps redrawing.
|
|
3
3
|
* .ui-chart__head the opt-in legend and the chart and table switch
|
|
4
|
-
* .ui-chart__legend one key per series
|
|
4
|
+
* .ui-chart__legend one key per series
|
|
5
5
|
* .ui-chart__frame the tab stop; the value axis beside the scroller
|
|
6
6
|
* .ui-chart__scroll the scroller
|
|
7
7
|
* .ui-chart__plot the drawing and its column labels
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
.ui-chart {
|
|
14
14
|
--ui-chart-col: var(--space-12);
|
|
15
|
-
/* The ground the marks are drawn on, so
|
|
16
|
-
|
|
15
|
+
/* The ground the marks are drawn on, so a point and the rim the line is
|
|
16
|
+
carried on read as cut out of it. A chart outside a card names its
|
|
17
17
|
own. */
|
|
18
18
|
--ui-chart-ground: var(--surface);
|
|
19
19
|
/* The tick's own line box. The axis spans the band the gridlines are drawn
|
|
@@ -65,12 +65,6 @@
|
|
|
65
65
|
.ui-chart__key-mark { flex: none; }
|
|
66
66
|
.ui-chart__key-swatch { fill: var(--ui-chart-tone); }
|
|
67
67
|
.ui-chart__key-line { fill: none; stroke: var(--ui-chart-tone); stroke-width: 2; stroke-linecap: round; }
|
|
68
|
-
.ui-chart__key-estimated {
|
|
69
|
-
fill: var(--ui-chart-tone);
|
|
70
|
-
stroke: var(--ui-chart-ground);
|
|
71
|
-
stroke-width: 1;
|
|
72
|
-
stroke-dasharray: 2 2;
|
|
73
|
-
}
|
|
74
68
|
|
|
75
69
|
/* -- the frame ------------------------------------------------------------- */
|
|
76
70
|
|
|
@@ -94,8 +88,12 @@
|
|
|
94
88
|
display: flex;
|
|
95
89
|
flex-direction: column;
|
|
96
90
|
justify-content: space-between;
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
/* The component sets the band's top and bottom edges past the room that the
|
|
92
|
+
group label and the bars' values take. */
|
|
93
|
+
height: calc(var(--ui-chart-h) - var(--ui-chart-top, var(--ui-chart-pad))
|
|
94
|
+
- var(--ui-chart-bottom, var(--ui-chart-pad)) + var(--ui-chart-tick));
|
|
95
|
+
margin-block: calc(var(--ui-chart-top, var(--ui-chart-pad)) - var(--ui-chart-tick) / 2)
|
|
96
|
+
calc(var(--ui-chart-bottom, var(--ui-chart-pad)) - var(--ui-chart-tick) / 2);
|
|
99
97
|
text-align: right;
|
|
100
98
|
font-variant-numeric: tabular-nums;
|
|
101
99
|
}
|
|
@@ -110,6 +108,8 @@
|
|
|
110
108
|
}
|
|
111
109
|
|
|
112
110
|
.ui-chart__plot { min-width: calc(var(--ui-chart-col) * var(--ui-chart-cols, 1)); }
|
|
111
|
+
/* The months chart's periods share the card's width, so it never scrolls. */
|
|
112
|
+
.ui-chart--months .ui-chart__plot { min-width: 0; }
|
|
113
113
|
.ui-chart__svg { display: block; }
|
|
114
114
|
|
|
115
115
|
.ui-chart__periods {
|
|
@@ -133,6 +133,17 @@
|
|
|
133
133
|
weight a reader who separates no colours still reads. Selection is otherwise
|
|
134
134
|
the band behind the column and the band alone — the outline the chart draws
|
|
135
135
|
belongs to focus. */
|
|
136
|
+
/* Where the labels do not fit, the component prints every n-th one. A printed
|
|
137
|
+
label keeps one line, centred on its column, or on the plot's edge. */
|
|
138
|
+
.ui-chart__periods--step { grid-template-columns: repeat(var(--ui-chart-cols, 1), minmax(0, 1fr)); }
|
|
139
|
+
.ui-chart__periods--step .ui-chart__period {
|
|
140
|
+
justify-self: center;
|
|
141
|
+
width: max-content;
|
|
142
|
+
padding-inline: 0;
|
|
143
|
+
white-space: nowrap;
|
|
144
|
+
}
|
|
145
|
+
.ui-chart__periods--step .ui-chart__period.is-start { justify-self: start; }
|
|
146
|
+
.ui-chart__periods--step .ui-chart__period.is-end { justify-self: end; }
|
|
136
147
|
.ui-chart__period.is-selected {
|
|
137
148
|
color: var(--strong);
|
|
138
149
|
font-weight: 600;
|
|
@@ -172,13 +183,6 @@
|
|
|
172
183
|
/* The ramp's two stops. Each reads the tone of the gradient that holds it. */
|
|
173
184
|
.ui-chart__fade-base { stop-color: var(--ui-chart-fade); }
|
|
174
185
|
.ui-chart__fade-end { stop-color: var(--ui-chart-tone); }
|
|
175
|
-
/* Keep each series' fill. Ground-coloured dashes mark unfinished data
|
|
176
|
-
without joining the mirrored bars across the zero channel. */
|
|
177
|
-
.ui-chart__bar.is-estimated {
|
|
178
|
-
stroke: var(--ui-chart-ground);
|
|
179
|
-
stroke-width: 1;
|
|
180
|
-
stroke-dasharray: 3 2;
|
|
181
|
-
}
|
|
182
186
|
|
|
183
187
|
/* An isolated value has no segment to draw it. Connected points need no dot. */
|
|
184
188
|
.ui-chart__isolated { fill: var(--ui-chart-tone); stroke: var(--ui-chart-ground); stroke-width: 1; }
|
|
@@ -189,7 +193,6 @@
|
|
|
189
193
|
stroke-width: 2;
|
|
190
194
|
stroke-linecap: round;
|
|
191
195
|
}
|
|
192
|
-
.ui-chart__line.is-estimated { stroke-dasharray: 5 3; }
|
|
193
196
|
|
|
194
197
|
/* The ground carried under the line. The line crosses bars of its own family,
|
|
195
198
|
where hue alone separates them and luminance does not: a stroke of the ground
|
|
@@ -243,7 +246,7 @@
|
|
|
243
246
|
/* The rule under the column the reader is on. It is the zero rule's weight: a
|
|
244
247
|
line read across, not a mark. */
|
|
245
248
|
.ui-chart__cross { stroke: var(--border-strong); stroke-width: 1; }
|
|
246
|
-
/* A point, cut out of the ground
|
|
249
|
+
/* A point, cut out of the ground, so two lines that
|
|
247
250
|
meet still show both points. */
|
|
248
251
|
.ui-chart__dot { fill: var(--ui-chart-tone); stroke: var(--ui-chart-ground); stroke-width: 2; }
|
|
249
252
|
.ui-chart--line-thin .ui-chart__line { stroke-width: 1.5; }
|
|
@@ -266,10 +269,16 @@
|
|
|
266
269
|
stroke-width: 2;
|
|
267
270
|
stroke-linejoin: round;
|
|
268
271
|
}
|
|
269
|
-
.ui-chart__segment.is-estimated { stroke-dasharray: 3 2; }
|
|
270
272
|
/* Words drawn in the plot: a value at a line's end, a row's total, a slice's
|
|
271
273
|
name. They are the chart's own figures, so they take the body ink. */
|
|
272
274
|
.ui-chart__text { fill: var(--text); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
|
|
275
|
+
.ui-chart__value { text-anchor: middle; }
|
|
276
|
+
.ui-chart__value--below { dominant-baseline: hanging; }
|
|
277
|
+
/* The boundary before the first period that is not final, and the words over
|
|
278
|
+
that group. The line is the focus ring's width in the neutral chart tone, and
|
|
279
|
+
solid: a dash would read as a mark of its own. */
|
|
280
|
+
.ui-chart__boundary { stroke: var(--chart-neutral); stroke-width: var(--ring-width); }
|
|
281
|
+
.ui-chart__group { font-weight: var(--weight-medium); }
|
|
273
282
|
.ui-chart__text--strong { fill: var(--strong); font-weight: var(--weight-semibold); }
|
|
274
283
|
.ui-chart__total {
|
|
275
284
|
fill: var(--strong);
|
|
@@ -352,6 +361,9 @@
|
|
|
352
361
|
their height would hide the last period behind a second scrollbar. */
|
|
353
362
|
.ui-chart__data .ui-table-scroll { --ui-table-height: none; }
|
|
354
363
|
.ui-chart__data .ui-table { margin: 0; }
|
|
364
|
+
/* A period that is not final keeps its solid mark in the series ink: the
|
|
365
|
+
readout and the table name its state. */
|
|
366
|
+
|
|
355
367
|
/* Why a period is not final is a sentence, not a label, so it wraps under the
|
|
356
368
|
period it qualifies instead of carrying the money columns another two hundred
|
|
357
369
|
pixels to the right of a 390px card. */
|