@altertable/data-app-react 0.78.0 → 0.80.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/dist/chunks/{SectionHeading-BKvi7HVv.js → SectionHeading-DR8RX7YZ.js} +205 -693
- package/dist/chunks/SectionHeading-DR8RX7YZ.js.map +1 -0
- package/dist/index.js +699 -7
- package/dist/index.js.map +1 -1
- package/dist/types/chunks/DateTimeRangePicker.d.ts +5 -146
- package/dist/types/index.d.ts +199 -14
- package/dist/types/ui/index.d.ts +4 -16
- package/dist/ui/index.js +605 -427
- package/dist/ui/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/SectionHeading-BKvi7HVv.js.map +0 -1
package/dist/ui/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as DimensionPicker, A as LiveControl, B as isPlainKeyEvent, Bt as TabList, C as DataAppFrame, F as MenuSeparator, G as useDeclaredResult, Gt as Sheet, Ht as TabPanels, I as MenuTrigger, It as AboutData, J as SearchTypeahead, K as FilterActions, Kt as GradientScroll, M as MenuItem, Mt as ShimmerText, N as MenuPopover, P as MenuSection, Pt as DataAppProvider, Q as NumberRangeField, Qt as TooltipSurface, St as HelpPopover, Ut as Tabs, V as createDataHooks, Vt as TabPanel, Wt as useViewTab, X as NumberFilterPicker, Xt as TooltipProvider, Y as SearchField, Yt as Tooltip, Z as NumberField, Zt as ChartTooltip$1, a as DataTable, an as Button$1, b as Notice, bt as DateDisplay, c as DataTableTimestamp, ct as dateTimeRangeFilter, d as explorationMenuEvents, dn as injectDataAppStyles, et as FilterBar, f as getPrimaryExplorationAction, ft as matchSearchText, h as DataWidget, it as ChoicePicker, j as Menu, k as PresentStory, l as ExplorationActionControl, ln as useDateFormatting, lt as dateTimeRangePresets, m as useChartActions, n as createDataContext, nt as Select, o as DataTableEmptyRow, on as PressButton, ot as SelectionMark, p as openExplorationMenu, pt as searchItems, q as ControlBar, r as chartBarFill, rn as AppIcon, s as DataTableShare, sn as classNames, st as SearchMatch, t as SectionHeading, tt as DateTimeRangePicker, u as ExplorationActionMenu, ut as useAppFilters, zt as Tab } from "../chunks/SectionHeading-DR8RX7YZ.js";
|
|
2
2
|
import { KEY_SEPARATOR, invariant, validateChoiceOptions } from "@altertable/data-app/internal";
|
|
3
|
-
import { Children, Fragment, cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
|
+
import { Children, Fragment, cloneElement, createContext, isValidElement, memo, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import { Label, Radio as Radio$1, RadioGroup as RadioGroup$1 } from "react-aria-components";
|
|
5
5
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { formatDate, formatDateTime, formatMetric, formatNumber, formatPercent, parseDateTime } from "@altertable/data-app/format";
|
|
@@ -210,6 +210,7 @@ function chartAxisKey(axis, id) {
|
|
|
210
210
|
return `${axis}:${typeof id}:${id}`;
|
|
211
211
|
}
|
|
212
212
|
const ChartInteractionContext = createContext(null);
|
|
213
|
+
const ChartActiveSampleContext = createContext(null);
|
|
213
214
|
const ChartRegistrationContext = createContext(null);
|
|
214
215
|
function isChartSeriesActive(interaction, seriesId) {
|
|
215
216
|
return !interaction?.isPointerInspection || interaction.seriesCount === 1 || interaction.activeSeriesId === seriesId;
|
|
@@ -863,27 +864,37 @@ function useChartCursorGroup() {
|
|
|
863
864
|
const [group] = useState(createGroup);
|
|
864
865
|
return group;
|
|
865
866
|
}
|
|
866
|
-
function emptySnapshot() {
|
|
867
|
-
return null;
|
|
868
|
-
}
|
|
869
867
|
function emptySubscribe() {
|
|
870
868
|
return () => {};
|
|
871
869
|
}
|
|
870
|
+
const noLinkedChartCursor = {
|
|
871
|
+
setTime: () => {},
|
|
872
|
+
reset: () => {},
|
|
873
|
+
subscribe: emptySubscribe,
|
|
874
|
+
peerTime: () => void 0
|
|
875
|
+
};
|
|
872
876
|
function useLinkedChartCursor(group) {
|
|
873
877
|
const store = group == null ? void 0 : stores.get(group);
|
|
874
|
-
const cursor = useSyncExternalStore(store?.subscribe ?? emptySubscribe, store?.snapshot ?? emptySnapshot, emptySnapshot);
|
|
875
878
|
const id = useId();
|
|
876
|
-
const
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
879
|
+
const cursor = useMemo(() => store ? {
|
|
880
|
+
setTime: (time) => {
|
|
881
|
+
if (time != null) store.publish(id, time);
|
|
882
|
+
else store.clear(id);
|
|
883
|
+
},
|
|
884
|
+
reset: () => store.clear(id),
|
|
885
|
+
subscribe: store.subscribe,
|
|
886
|
+
peerTime: () => {
|
|
887
|
+
const current = store.snapshot();
|
|
888
|
+
return current?.source !== id ? current?.time : void 0;
|
|
889
|
+
}
|
|
890
|
+
} : noLinkedChartCursor, [store, id]);
|
|
891
|
+
useEffect(() => cursor.reset, [cursor]);
|
|
892
|
+
return cursor;
|
|
893
|
+
}
|
|
894
|
+
/** Subscribes to a derived peer cursor value. Return a primitive so only the
|
|
895
|
+
* marks whose value changes re-render while the pointer moves. */
|
|
896
|
+
function useLinkedCursorValue(cursor, select) {
|
|
897
|
+
return useSyncExternalStore(cursor.subscribe, () => select(cursor.peerTime()), () => select(void 0));
|
|
887
898
|
}
|
|
888
899
|
const ChartCursorChartContext = createContext(null);
|
|
889
900
|
//#endregion
|
|
@@ -910,7 +921,7 @@ function ChartDateAxes({ data, children }) {
|
|
|
910
921
|
return next;
|
|
911
922
|
});
|
|
912
923
|
}, []);
|
|
913
|
-
return /* @__PURE__ */ jsx(ChartDateAxesContext
|
|
924
|
+
return /* @__PURE__ */ jsx(ChartDateAxesContext, {
|
|
914
925
|
value: {
|
|
915
926
|
data,
|
|
916
927
|
formatters,
|
|
@@ -943,24 +954,25 @@ function LinkedTimeCursor({ times, axisId }) {
|
|
|
943
954
|
const scale = useXAxisScale(axisId);
|
|
944
955
|
const plot = usePlotArea();
|
|
945
956
|
const mouseHover = context?.mouseHover;
|
|
946
|
-
const
|
|
947
|
-
const reset =
|
|
957
|
+
const cursor = context?.cursor ?? noLinkedChartCursor;
|
|
958
|
+
const { setTime, reset } = cursor;
|
|
959
|
+
const timeSet = useMemo(() => new Set(times), [times]);
|
|
948
960
|
useEffect(() => {
|
|
949
|
-
if (!mouseHover || !active) reset
|
|
961
|
+
if (!mouseHover || !active) reset();
|
|
950
962
|
else {
|
|
951
963
|
const time = chartTimestamp(label, true);
|
|
952
|
-
if (time != null &&
|
|
964
|
+
if (time != null && timeSet.has(time)) setTime(time);
|
|
953
965
|
}
|
|
954
966
|
}, [
|
|
955
967
|
mouseHover,
|
|
956
968
|
active,
|
|
957
969
|
label,
|
|
958
|
-
|
|
970
|
+
timeSet,
|
|
959
971
|
setTime,
|
|
960
972
|
reset
|
|
961
973
|
]);
|
|
962
|
-
const time =
|
|
963
|
-
if (time == null
|
|
974
|
+
const time = useLinkedCursorValue(cursor, (peerTime) => peerTime != null && timeSet.has(peerTime) ? peerTime : void 0);
|
|
975
|
+
if (time == null) return null;
|
|
964
976
|
const x = scale?.(time);
|
|
965
977
|
if (!plot || x == null || !Number.isFinite(x) || x < plot.x || x > plot.x + plot.width) return null;
|
|
966
978
|
return /* @__PURE__ */ jsx("line", {
|
|
@@ -1344,19 +1356,23 @@ function renderBarShape(option, props) {
|
|
|
1344
1356
|
});
|
|
1345
1357
|
return /* @__PURE__ */ jsx(Rectangle, { ...props });
|
|
1346
1358
|
}
|
|
1347
|
-
function InspectedBarVisual(
|
|
1359
|
+
function InspectedBarVisual(inspected) {
|
|
1348
1360
|
const interaction = useContext(ChartInteractionContext);
|
|
1349
|
-
const
|
|
1350
|
-
const
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1361
|
+
const activeBar = useContext(ChartActiveSampleContext)?.activeBar;
|
|
1362
|
+
const selected = Boolean(interaction?.isPointerInspection && activeBar?.seriesId === inspected.seriesId && activeBar.index === inspected.originalDataIndex);
|
|
1363
|
+
return useMemo(() => {
|
|
1364
|
+
const { seriesId: _, shape, activeShape, dimmed, ...props } = inspected;
|
|
1365
|
+
const renderedProps = {
|
|
1366
|
+
...props,
|
|
1367
|
+
isActive: selected || Boolean(props.isActive),
|
|
1368
|
+
opacity: dimmed ? void 0 : selected ? .75 : props.opacity
|
|
1369
|
+
};
|
|
1370
|
+
const rendered = renderBarShape(selected && activeShape && activeShape !== true ? activeShape : shape, renderedProps);
|
|
1371
|
+
return dimmed ? /* @__PURE__ */ jsx("g", {
|
|
1372
|
+
opacity: .2,
|
|
1373
|
+
children: rendered
|
|
1374
|
+
}) : rendered;
|
|
1375
|
+
}, [inspected, selected]);
|
|
1360
1376
|
}
|
|
1361
1377
|
/** Shared series defaults; native props override every authored choice. */
|
|
1362
1378
|
function InspectedBarShape({ seriesId, shape, activeShape, dimmed, ...props }) {
|
|
@@ -1678,6 +1694,7 @@ function barTooltipPosition(bar, plot, size) {
|
|
|
1678
1694
|
function ChartTooltip(props) {
|
|
1679
1695
|
const dateLabel = useDateAxisLabel(props.axisId);
|
|
1680
1696
|
const interaction = useContext(ChartInteractionContext);
|
|
1697
|
+
const sample = useContext(ChartActiveSampleContext);
|
|
1681
1698
|
const legendInteraction = useContext(ChartLegendInteractionContext);
|
|
1682
1699
|
const plot = usePlotArea();
|
|
1683
1700
|
const [tooltipSize, setTooltipSize] = useState({
|
|
@@ -1691,8 +1708,8 @@ function ChartTooltip(props) {
|
|
|
1691
1708
|
});
|
|
1692
1709
|
}, []);
|
|
1693
1710
|
const { content: authoredContent, ...tooltipProps } = props;
|
|
1694
|
-
const activeBar = interaction?.isPointerInspection ?
|
|
1695
|
-
const position = activeBar && plot && tooltipSize.width && tooltipSize.height ? barTooltipPosition(activeBar, plot, tooltipSize) : interaction?.isPointerInspection &&
|
|
1711
|
+
const activeBar = interaction?.isPointerInspection ? sample?.activeBar ?? null : null;
|
|
1712
|
+
const position = activeBar && plot && tooltipSize.width && tooltipSize.height ? barTooltipPosition(activeBar, plot, tooltipSize) : interaction?.isPointerInspection && sample?.activePoint ? { y: sample.activePoint.y } : void 0;
|
|
1696
1713
|
return /* @__PURE__ */ jsx(Tooltip$1, {
|
|
1697
1714
|
labelFormatter: dateLabel,
|
|
1698
1715
|
position,
|
|
@@ -1745,26 +1762,207 @@ function useChartScrollToEnd(items, enabled = true) {
|
|
|
1745
1762
|
}
|
|
1746
1763
|
//#endregion
|
|
1747
1764
|
//#region src/ui/TrendChart.tsx
|
|
1765
|
+
const HighlightedSampleContext = createContext(void 0);
|
|
1766
|
+
/** Reads the highlighted index itself, so moving between samples skips the plot. */
|
|
1767
|
+
function TrendSample({ index, cx, cy }) {
|
|
1768
|
+
const highlighted = useContext(HighlightedSampleContext) === index;
|
|
1769
|
+
return /* @__PURE__ */ jsx("g", {
|
|
1770
|
+
"data-atbl-internal-sample": index,
|
|
1771
|
+
transform: `translate(${cx}, ${cy})`,
|
|
1772
|
+
children: highlighted && /* @__PURE__ */ jsx(ChartDot, {
|
|
1773
|
+
cx: 0,
|
|
1774
|
+
cy: 0,
|
|
1775
|
+
active: true
|
|
1776
|
+
})
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
function LinkedTrendCursor({ cursor, items }) {
|
|
1780
|
+
const id = useLinkedCursorValue(cursor, (time) => time == null ? void 0 : items.find((item) => item.time === time)?.id);
|
|
1781
|
+
return id == null ? null : /* @__PURE__ */ jsx(ReferenceLine, {
|
|
1782
|
+
x: id,
|
|
1783
|
+
stroke: "var(--atbl-muted)",
|
|
1784
|
+
strokeOpacity: .3,
|
|
1785
|
+
pointerEvents: "none",
|
|
1786
|
+
"data-atbl-internal-linked-cursor": "true"
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
/** Hit targets and tooltips stay mounted while the pointer moves between samples. */
|
|
1790
|
+
const TrendChartItems = memo(function TrendChartItems({ items, unit, formatValue, itemActions, actions: chartActions, setActiveIndex, onInspectAction, "aria-describedby": describedBy }) {
|
|
1791
|
+
const menuTriggers = useRef(/* @__PURE__ */ new Map());
|
|
1792
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1793
|
+
className: "altertable-trend-points",
|
|
1794
|
+
"aria-describedby": describedBy,
|
|
1795
|
+
onClickCapture: onInspectAction,
|
|
1796
|
+
onContextMenuCapture: onInspectAction,
|
|
1797
|
+
children: items.map((item, index) => {
|
|
1798
|
+
const declaredActions = itemActions?.(item) ?? [];
|
|
1799
|
+
const actions = chartActions(declaredActions, item.label, `${formatValue(item.value)} ${unit}`);
|
|
1800
|
+
const action = getPrimaryExplorationAction(actions);
|
|
1801
|
+
const menuTrigger = { get current() {
|
|
1802
|
+
return menuTriggers.current.get(item.id) ?? null;
|
|
1803
|
+
} };
|
|
1804
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", {
|
|
1805
|
+
className: "altertable-chart-item-actions",
|
|
1806
|
+
children: [/* @__PURE__ */ jsx(ChartTooltip$1, {
|
|
1807
|
+
variant: "chart",
|
|
1808
|
+
mouseHover: false,
|
|
1809
|
+
followCursor: false,
|
|
1810
|
+
onOpenChange: (open) => setActiveIndex((current) => open ? index : current === index ? void 0 : current),
|
|
1811
|
+
content: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("strong", { children: item.label }), /* @__PURE__ */ jsxs("span", { children: [
|
|
1812
|
+
formatValue(item.value),
|
|
1813
|
+
" ",
|
|
1814
|
+
unit
|
|
1815
|
+
] })] }),
|
|
1816
|
+
className: "altertable-chart-column",
|
|
1817
|
+
children: action ? /* @__PURE__ */ jsxs("button", {
|
|
1818
|
+
"data-atbl-focus": "ring",
|
|
1819
|
+
"data-atbl-control": "action",
|
|
1820
|
+
type: "button",
|
|
1821
|
+
className: "altertable-trend-point",
|
|
1822
|
+
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. ${action.label}`,
|
|
1823
|
+
...explorationMenuEvents(menuTrigger),
|
|
1824
|
+
onClick: (event) => action.onSelect(event.currentTarget),
|
|
1825
|
+
children: [/* @__PURE__ */ jsx("span", { className: "altertable-trend-hit" }), /* @__PURE__ */ jsx("span", {
|
|
1826
|
+
className: "altertable-trend-label",
|
|
1827
|
+
children: item.label
|
|
1828
|
+
})]
|
|
1829
|
+
}) : actions.length > 1 ? /* @__PURE__ */ jsxs(MenuTrigger, { children: [/* @__PURE__ */ jsxs(PressButton, {
|
|
1830
|
+
...explorationMenuEvents(menuTrigger),
|
|
1831
|
+
ref: (element) => {
|
|
1832
|
+
if (element) menuTriggers.current.set(item.id, element);
|
|
1833
|
+
else menuTriggers.current.delete(item.id);
|
|
1834
|
+
},
|
|
1835
|
+
className: "altertable-trend-point",
|
|
1836
|
+
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. Actions`,
|
|
1837
|
+
children: [/* @__PURE__ */ jsx("span", { className: "altertable-trend-hit" }), /* @__PURE__ */ jsx("span", {
|
|
1838
|
+
className: "altertable-trend-label",
|
|
1839
|
+
children: item.label
|
|
1840
|
+
})]
|
|
1841
|
+
}), /* @__PURE__ */ jsx(ExplorationActionMenu, {
|
|
1842
|
+
actions,
|
|
1843
|
+
ariaLabel: `${item.label} actions`,
|
|
1844
|
+
triggerRef: menuTrigger
|
|
1845
|
+
})] }) : /* @__PURE__ */ jsxs("button", {
|
|
1846
|
+
"data-atbl-focus": "ring",
|
|
1847
|
+
"data-atbl-control": "default",
|
|
1848
|
+
type: "button",
|
|
1849
|
+
tabIndex: -1,
|
|
1850
|
+
className: "altertable-trend-point",
|
|
1851
|
+
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}`,
|
|
1852
|
+
children: [/* @__PURE__ */ jsx("span", { className: "altertable-trend-hit" }), /* @__PURE__ */ jsx("span", {
|
|
1853
|
+
className: "altertable-trend-label",
|
|
1854
|
+
children: item.label
|
|
1855
|
+
})]
|
|
1856
|
+
})
|
|
1857
|
+
}), action && /* @__PURE__ */ jsx(ExplorationActionControl, {
|
|
1858
|
+
contextOnly: declaredActions.length === 1,
|
|
1859
|
+
indicator: "chevron",
|
|
1860
|
+
ref: (element) => {
|
|
1861
|
+
if (element) menuTriggers.current.set(item.id, element);
|
|
1862
|
+
else menuTriggers.current.delete(item.id);
|
|
1863
|
+
},
|
|
1864
|
+
actions,
|
|
1865
|
+
ariaLabel: `${item.label} actions`,
|
|
1866
|
+
hidePrimary: Boolean(action)
|
|
1867
|
+
})]
|
|
1868
|
+
}) }, item.id);
|
|
1869
|
+
})
|
|
1870
|
+
});
|
|
1871
|
+
});
|
|
1748
1872
|
/** Ordered, equally spaced samples; negative values share an explicit zero baseline. */
|
|
1749
1873
|
function TrendChart({ items, unit, ariaLabel, formatValue = formatNumber, kind, itemActions, cursorGroup, horizontalGrid = true }) {
|
|
1750
1874
|
validateValueChartItems(kind, items);
|
|
1751
1875
|
const Plot = kind === "area" ? AreaChart$1 : LineChart$1;
|
|
1752
1876
|
const chartActions = useChartActions();
|
|
1753
1877
|
const cursor = useLinkedChartCursor(cursorGroup);
|
|
1754
|
-
const linkedItem = items.find((item) => item.time === cursor.time && cursor.time != null);
|
|
1755
1878
|
const [activeIndex, setActiveIndex] = useState();
|
|
1756
1879
|
const [nearestIndex, setNearestIndex] = useState();
|
|
1757
1880
|
const [mouseVisible, setMouseVisible] = useState(false);
|
|
1881
|
+
const mouseVisibleRef = useRef(false);
|
|
1758
1882
|
const nearest = useRef(void 0);
|
|
1759
1883
|
const points = useRef(/* @__PURE__ */ new Map());
|
|
1760
1884
|
const plotRef = useRef(null);
|
|
1761
1885
|
const canvasRef = useRef(null);
|
|
1762
1886
|
const highlightedIndex = mouseVisible ? nearestIndex : activeIndex;
|
|
1763
1887
|
const scrollport = useChartScrollToEnd(items);
|
|
1764
|
-
const
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1888
|
+
const { data, low, high } = useMemo(() => {
|
|
1889
|
+
const magnitude = items.reduce((max, item) => Math.max(max, Math.abs(item.value)), 1);
|
|
1890
|
+
return {
|
|
1891
|
+
data: items.map((item) => ({
|
|
1892
|
+
...item,
|
|
1893
|
+
plotValue: item.value / magnitude
|
|
1894
|
+
})),
|
|
1895
|
+
low: items.reduce((min, item) => Math.min(min, item.value / magnitude), 0),
|
|
1896
|
+
high: items.reduce((max, item) => Math.max(max, item.value / magnitude), 0)
|
|
1897
|
+
};
|
|
1898
|
+
}, [items]);
|
|
1899
|
+
const renderSample = useCallback(({ cx, cy, index }) => {
|
|
1900
|
+
if (index != null && cx != null && cy != null) points.current.set(index, {
|
|
1901
|
+
x: cx,
|
|
1902
|
+
y: cy
|
|
1903
|
+
});
|
|
1904
|
+
return /* @__PURE__ */ jsx(TrendSample, {
|
|
1905
|
+
index,
|
|
1906
|
+
cx,
|
|
1907
|
+
cy
|
|
1908
|
+
});
|
|
1909
|
+
}, []);
|
|
1910
|
+
const plot = useMemo(() => /* @__PURE__ */ jsxs(Plot, {
|
|
1911
|
+
data,
|
|
1912
|
+
responsive: true,
|
|
1913
|
+
width: "100%",
|
|
1914
|
+
height: 220,
|
|
1915
|
+
margin: {
|
|
1916
|
+
top: 12,
|
|
1917
|
+
right: 0,
|
|
1918
|
+
bottom: 12,
|
|
1919
|
+
left: 0
|
|
1920
|
+
},
|
|
1921
|
+
accessibilityLayer: false,
|
|
1922
|
+
tabIndex: -1,
|
|
1923
|
+
children: [
|
|
1924
|
+
/* @__PURE__ */ jsx(ChartXAxis, {
|
|
1925
|
+
hide: true,
|
|
1926
|
+
dataKey: "id",
|
|
1927
|
+
scale: "band"
|
|
1928
|
+
}),
|
|
1929
|
+
/* @__PURE__ */ jsx(ChartYAxis, {
|
|
1930
|
+
hide: true,
|
|
1931
|
+
domain: [low, high === low ? low + 1 : high]
|
|
1932
|
+
}),
|
|
1933
|
+
/* @__PURE__ */ jsx(ReferenceLine, {
|
|
1934
|
+
y: 0,
|
|
1935
|
+
stroke: "var(--atbl-border)"
|
|
1936
|
+
}),
|
|
1937
|
+
horizontalGrid && /* @__PURE__ */ jsx(ChartGrid, {}),
|
|
1938
|
+
kind === "area" && /* @__PURE__ */ jsx(ChartArea, {
|
|
1939
|
+
dataKey: "plotValue",
|
|
1940
|
+
stroke: "none",
|
|
1941
|
+
fill: "var(--atbl-chart-1)",
|
|
1942
|
+
dot: false,
|
|
1943
|
+
activeDot: false
|
|
1944
|
+
}),
|
|
1945
|
+
/* @__PURE__ */ jsx(ChartLine, {
|
|
1946
|
+
dataKey: "plotValue",
|
|
1947
|
+
dot: renderSample,
|
|
1948
|
+
activeDot: false
|
|
1949
|
+
}),
|
|
1950
|
+
/* @__PURE__ */ jsx(LinkedTrendCursor, {
|
|
1951
|
+
cursor,
|
|
1952
|
+
items
|
|
1953
|
+
})
|
|
1954
|
+
]
|
|
1955
|
+
}), [
|
|
1956
|
+
Plot,
|
|
1957
|
+
data,
|
|
1958
|
+
low,
|
|
1959
|
+
high,
|
|
1960
|
+
horizontalGrid,
|
|
1961
|
+
kind,
|
|
1962
|
+
renderSample,
|
|
1963
|
+
cursor,
|
|
1964
|
+
items
|
|
1965
|
+
]);
|
|
1768
1966
|
function screenPoint(index) {
|
|
1769
1967
|
if (index == null) return null;
|
|
1770
1968
|
const point = points.current.get(index);
|
|
@@ -1794,8 +1992,8 @@ function TrendChart({ items, unit, ariaLabel, formatValue = formatNumber, kind,
|
|
|
1794
1992
|
setNearestIndex(selected);
|
|
1795
1993
|
cursor.setTime(selected == null ? void 0 : items[selected]?.time);
|
|
1796
1994
|
}
|
|
1797
|
-
|
|
1798
|
-
if (!
|
|
1995
|
+
const inspectAction = useCallback((event) => {
|
|
1996
|
+
if (!mouseVisibleRef.current || nearest.current == null || !(event.target instanceof Element)) return;
|
|
1799
1997
|
if (event.clientY >= (plotRef.current?.getBoundingClientRect().top ?? 0) + 220) return;
|
|
1800
1998
|
if (event.type === "click" && event.detail === 0) return;
|
|
1801
1999
|
if (event.type === "contextmenu" && event.clientX === 0 && event.clientY === 0) return;
|
|
@@ -1812,7 +2010,7 @@ function TrendChart({ items, unit, ariaLabel, formatValue = formatNumber, kind,
|
|
|
1812
2010
|
clientX: event.clientX,
|
|
1813
2011
|
clientY: event.clientY
|
|
1814
2012
|
}));
|
|
1815
|
-
}
|
|
2013
|
+
}, []);
|
|
1816
2014
|
return /* @__PURE__ */ jsxs("section", {
|
|
1817
2015
|
className: "altertable-trend-chart",
|
|
1818
2016
|
"aria-label": ariaLabel,
|
|
@@ -1834,71 +2032,9 @@ function TrendChart({ items, unit, ariaLabel, formatValue = formatNumber, kind,
|
|
|
1834
2032
|
className: "altertable-chart-canvas",
|
|
1835
2033
|
"aria-hidden": "true",
|
|
1836
2034
|
ref: canvasRef,
|
|
1837
|
-
children: /* @__PURE__ */
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
plotValue: item.value / magnitude
|
|
1841
|
-
})),
|
|
1842
|
-
responsive: true,
|
|
1843
|
-
width: "100%",
|
|
1844
|
-
height: 220,
|
|
1845
|
-
margin: {
|
|
1846
|
-
top: 12,
|
|
1847
|
-
right: 0,
|
|
1848
|
-
bottom: 12,
|
|
1849
|
-
left: 0
|
|
1850
|
-
},
|
|
1851
|
-
accessibilityLayer: false,
|
|
1852
|
-
tabIndex: -1,
|
|
1853
|
-
children: [
|
|
1854
|
-
/* @__PURE__ */ jsx(ChartXAxis, {
|
|
1855
|
-
hide: true,
|
|
1856
|
-
dataKey: "id",
|
|
1857
|
-
scale: "band"
|
|
1858
|
-
}),
|
|
1859
|
-
/* @__PURE__ */ jsx(ChartYAxis, {
|
|
1860
|
-
hide: true,
|
|
1861
|
-
domain: [low, high === low ? low + 1 : high]
|
|
1862
|
-
}),
|
|
1863
|
-
/* @__PURE__ */ jsx(ReferenceLine, {
|
|
1864
|
-
y: 0,
|
|
1865
|
-
stroke: "var(--atbl-border)"
|
|
1866
|
-
}),
|
|
1867
|
-
horizontalGrid && /* @__PURE__ */ jsx(ChartGrid, {}),
|
|
1868
|
-
kind === "area" && /* @__PURE__ */ jsx(ChartArea, {
|
|
1869
|
-
dataKey: "plotValue",
|
|
1870
|
-
stroke: "none",
|
|
1871
|
-
fill: "var(--atbl-chart-1)",
|
|
1872
|
-
dot: false,
|
|
1873
|
-
activeDot: false
|
|
1874
|
-
}),
|
|
1875
|
-
/* @__PURE__ */ jsx(ChartLine, {
|
|
1876
|
-
dataKey: "plotValue",
|
|
1877
|
-
dot: ({ cx, cy, index }) => {
|
|
1878
|
-
if (index != null && cx != null && cy != null) points.current.set(index, {
|
|
1879
|
-
x: cx,
|
|
1880
|
-
y: cy
|
|
1881
|
-
});
|
|
1882
|
-
return /* @__PURE__ */ jsx("g", {
|
|
1883
|
-
"data-atbl-internal-sample": index,
|
|
1884
|
-
transform: `translate(${cx}, ${cy})`,
|
|
1885
|
-
children: index === highlightedIndex && /* @__PURE__ */ jsx(ChartDot, {
|
|
1886
|
-
cx: 0,
|
|
1887
|
-
cy: 0,
|
|
1888
|
-
active: true
|
|
1889
|
-
})
|
|
1890
|
-
});
|
|
1891
|
-
},
|
|
1892
|
-
activeDot: false
|
|
1893
|
-
}),
|
|
1894
|
-
linkedItem && /* @__PURE__ */ jsx(ReferenceLine, {
|
|
1895
|
-
x: linkedItem.id,
|
|
1896
|
-
stroke: "var(--atbl-muted)",
|
|
1897
|
-
strokeOpacity: .3,
|
|
1898
|
-
pointerEvents: "none",
|
|
1899
|
-
"data-atbl-internal-linked-cursor": "true"
|
|
1900
|
-
})
|
|
1901
|
-
]
|
|
2035
|
+
children: /* @__PURE__ */ jsx(HighlightedSampleContext, {
|
|
2036
|
+
value: highlightedIndex,
|
|
2037
|
+
children: plot
|
|
1902
2038
|
})
|
|
1903
2039
|
}), /* @__PURE__ */ jsx(ChartTooltip$1, {
|
|
1904
2040
|
variant: "chart",
|
|
@@ -1907,7 +2043,10 @@ function TrendChart({ items, unit, ariaLabel, formatValue = formatNumber, kind,
|
|
|
1907
2043
|
onPointerEnter: inspectNearest,
|
|
1908
2044
|
onPointerMove: inspectNearest,
|
|
1909
2045
|
onPointerLeave: cursor.reset,
|
|
1910
|
-
onOpenChange:
|
|
2046
|
+
onOpenChange: (open) => {
|
|
2047
|
+
mouseVisibleRef.current = open;
|
|
2048
|
+
setMouseVisible(open);
|
|
2049
|
+
},
|
|
1911
2050
|
anchorRect: () => {
|
|
1912
2051
|
const point = screenPoint(nearest.current);
|
|
1913
2052
|
return point ? new DOMRect(point.x, point.y, 0, 0) : null;
|
|
@@ -1917,83 +2056,14 @@ function TrendChart({ items, unit, ariaLabel, formatValue = formatNumber, kind,
|
|
|
1917
2056
|
" ",
|
|
1918
2057
|
unit
|
|
1919
2058
|
] })] }),
|
|
1920
|
-
children: /* @__PURE__ */ jsx(
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
const menuTrigger = { get current() {
|
|
1929
|
-
return menuTriggers.current.get(item.id) ?? null;
|
|
1930
|
-
} };
|
|
1931
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", {
|
|
1932
|
-
className: "altertable-chart-item-actions",
|
|
1933
|
-
children: [/* @__PURE__ */ jsx(ChartTooltip$1, {
|
|
1934
|
-
variant: "chart",
|
|
1935
|
-
mouseHover: false,
|
|
1936
|
-
followCursor: false,
|
|
1937
|
-
onOpenChange: (open) => setActiveIndex((current) => open ? index : current === index ? void 0 : current),
|
|
1938
|
-
content: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("strong", { children: item.label }), /* @__PURE__ */ jsxs("span", { children: [
|
|
1939
|
-
formatValue(item.value),
|
|
1940
|
-
" ",
|
|
1941
|
-
unit
|
|
1942
|
-
] })] }),
|
|
1943
|
-
className: "altertable-chart-column",
|
|
1944
|
-
children: action ? /* @__PURE__ */ jsxs("button", {
|
|
1945
|
-
"data-atbl-focus": "ring",
|
|
1946
|
-
"data-atbl-control": "action",
|
|
1947
|
-
type: "button",
|
|
1948
|
-
className: "altertable-trend-point",
|
|
1949
|
-
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. ${action.label}`,
|
|
1950
|
-
...explorationMenuEvents(menuTrigger),
|
|
1951
|
-
onClick: (event) => action.onSelect(event.currentTarget),
|
|
1952
|
-
children: [/* @__PURE__ */ jsx("span", { className: "altertable-trend-hit" }), /* @__PURE__ */ jsx("span", {
|
|
1953
|
-
className: "altertable-trend-label",
|
|
1954
|
-
children: item.label
|
|
1955
|
-
})]
|
|
1956
|
-
}) : actions.length > 1 ? /* @__PURE__ */ jsxs(MenuTrigger, { children: [/* @__PURE__ */ jsxs(PressButton, {
|
|
1957
|
-
...explorationMenuEvents(menuTrigger),
|
|
1958
|
-
ref: (element) => {
|
|
1959
|
-
if (element) menuTriggers.current.set(item.id, element);
|
|
1960
|
-
else menuTriggers.current.delete(item.id);
|
|
1961
|
-
},
|
|
1962
|
-
className: "altertable-trend-point",
|
|
1963
|
-
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. Actions`,
|
|
1964
|
-
children: [/* @__PURE__ */ jsx("span", { className: "altertable-trend-hit" }), /* @__PURE__ */ jsx("span", {
|
|
1965
|
-
className: "altertable-trend-label",
|
|
1966
|
-
children: item.label
|
|
1967
|
-
})]
|
|
1968
|
-
}), /* @__PURE__ */ jsx(ExplorationActionMenu, {
|
|
1969
|
-
actions,
|
|
1970
|
-
ariaLabel: `${item.label} actions`,
|
|
1971
|
-
triggerRef: menuTrigger
|
|
1972
|
-
})] }) : /* @__PURE__ */ jsxs("button", {
|
|
1973
|
-
"data-atbl-focus": "ring",
|
|
1974
|
-
"data-atbl-control": "default",
|
|
1975
|
-
type: "button",
|
|
1976
|
-
tabIndex: -1,
|
|
1977
|
-
className: "altertable-trend-point",
|
|
1978
|
-
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}`,
|
|
1979
|
-
children: [/* @__PURE__ */ jsx("span", { className: "altertable-trend-hit" }), /* @__PURE__ */ jsx("span", {
|
|
1980
|
-
className: "altertable-trend-label",
|
|
1981
|
-
children: item.label
|
|
1982
|
-
})]
|
|
1983
|
-
})
|
|
1984
|
-
}), action && /* @__PURE__ */ jsx(ExplorationActionControl, {
|
|
1985
|
-
contextOnly: declaredActions.length === 1,
|
|
1986
|
-
indicator: "chevron",
|
|
1987
|
-
ref: (element) => {
|
|
1988
|
-
if (element) menuTriggers.current.set(item.id, element);
|
|
1989
|
-
else menuTriggers.current.delete(item.id);
|
|
1990
|
-
},
|
|
1991
|
-
actions,
|
|
1992
|
-
ariaLabel: `${item.label} actions`,
|
|
1993
|
-
hidePrimary: Boolean(action)
|
|
1994
|
-
})]
|
|
1995
|
-
}) }, item.id);
|
|
1996
|
-
})
|
|
2059
|
+
children: /* @__PURE__ */ jsx(TrendChartItems, {
|
|
2060
|
+
items,
|
|
2061
|
+
unit,
|
|
2062
|
+
formatValue,
|
|
2063
|
+
itemActions,
|
|
2064
|
+
actions: chartActions.actions,
|
|
2065
|
+
setActiveIndex,
|
|
2066
|
+
onInspectAction: inspectAction
|
|
1997
2067
|
})
|
|
1998
2068
|
})]
|
|
1999
2069
|
})
|
|
@@ -2375,45 +2445,244 @@ function timeTickIndices(items, width) {
|
|
|
2375
2445
|
function PlotBoundsObserver({ overlayRef }) {
|
|
2376
2446
|
const plot = usePlotArea();
|
|
2377
2447
|
const left = plot?.x;
|
|
2448
|
+
const top = plot?.y;
|
|
2378
2449
|
const width = plot?.width;
|
|
2379
2450
|
useLayoutEffect(() => {
|
|
2380
|
-
if (left === void 0 || width === void 0 || !Number.isFinite(left) || !Number.isFinite(width) || !overlayRef.current) return;
|
|
2451
|
+
if (left === void 0 || top === void 0 || width === void 0 || !Number.isFinite(left) || !Number.isFinite(top) || !Number.isFinite(width) || !overlayRef.current) return;
|
|
2381
2452
|
const overlay = overlayRef.current;
|
|
2453
|
+
overlay.style.top = `${top}px`;
|
|
2382
2454
|
overlay.style.marginLeft = `${left}px`;
|
|
2383
2455
|
overlay.style.width = `${width}px`;
|
|
2384
2456
|
return () => {
|
|
2457
|
+
overlay.style.top = "";
|
|
2385
2458
|
overlay.style.marginLeft = "";
|
|
2386
2459
|
overlay.style.width = "";
|
|
2387
2460
|
};
|
|
2388
2461
|
}, [
|
|
2389
2462
|
overlayRef,
|
|
2390
2463
|
left,
|
|
2464
|
+
top,
|
|
2391
2465
|
width
|
|
2392
2466
|
]);
|
|
2393
2467
|
return null;
|
|
2394
2468
|
}
|
|
2469
|
+
const ActiveBarIdContext = createContext(void 0);
|
|
2470
|
+
/** Reads the hovered id itself, so moving between bars redraws two bars, not the plot. */
|
|
2471
|
+
function HighlightedBar(props) {
|
|
2472
|
+
const id = props["data-atbl-internal-bar-id"];
|
|
2473
|
+
const active = useContext(ActiveBarIdContext) === id;
|
|
2474
|
+
return useMemo(() => /* @__PURE__ */ jsx(Rectangle, {
|
|
2475
|
+
...props,
|
|
2476
|
+
opacity: active ? .75 : 1
|
|
2477
|
+
}), [props, active]);
|
|
2478
|
+
}
|
|
2479
|
+
function renderHighlightedBar(props) {
|
|
2480
|
+
return /* @__PURE__ */ jsx(HighlightedBar, { ...props });
|
|
2481
|
+
}
|
|
2482
|
+
function minimumBarSize(value) {
|
|
2483
|
+
return (value ?? 0) > 0 ? 7 : 0;
|
|
2484
|
+
}
|
|
2485
|
+
/** Subscribes per bar, so a peer cursor repaints two backgrounds instead of the chart. */
|
|
2486
|
+
function LinkedBarBackground({ cursor, time, x, y, width, height }) {
|
|
2487
|
+
const linked = useLinkedCursorValue(cursor, (peerTime) => time != null && peerTime === time);
|
|
2488
|
+
return /* @__PURE__ */ jsx("g", { children: linked && /* @__PURE__ */ jsx("rect", {
|
|
2489
|
+
x,
|
|
2490
|
+
y,
|
|
2491
|
+
width,
|
|
2492
|
+
height,
|
|
2493
|
+
fill: "var(--atbl-muted)",
|
|
2494
|
+
fillOpacity: .14,
|
|
2495
|
+
pointerEvents: "none",
|
|
2496
|
+
"aria-hidden": "true",
|
|
2497
|
+
"data-atbl-internal-linked-cursor": "true"
|
|
2498
|
+
}) });
|
|
2499
|
+
}
|
|
2500
|
+
/** Hit targets and tooltips stay mounted while the plot highlights a bar. */
|
|
2501
|
+
const BarChartItems = memo(function BarChartItems({ items, unit, formatValue, itemActions, actions: chartActions, cursor, ticks, setActiveId, plotRef, canvasRef, scrollport }) {
|
|
2502
|
+
const menuTriggers = useRef(/* @__PURE__ */ new Map());
|
|
2503
|
+
return items.map((item, index) => {
|
|
2504
|
+
const actions = chartActions(itemActions?.(item) ?? [], item.label, `${formatValue(item.value)} ${unit}`);
|
|
2505
|
+
const action = getPrimaryExplorationAction(actions);
|
|
2506
|
+
const menuTrigger = { get current() {
|
|
2507
|
+
return menuTriggers.current.get(item.id) ?? null;
|
|
2508
|
+
} };
|
|
2509
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", {
|
|
2510
|
+
className: "altertable-chart-item-actions",
|
|
2511
|
+
onPointerMove: (event) => {
|
|
2512
|
+
if (event.pointerType === "mouse") cursor.setTime(item.time);
|
|
2513
|
+
},
|
|
2514
|
+
children: [/* @__PURE__ */ jsx(ChartTooltip$1, {
|
|
2515
|
+
variant: "chart",
|
|
2516
|
+
followCursor: false,
|
|
2517
|
+
boundaryRefs: [canvasRef, scrollport],
|
|
2518
|
+
anchorRect: (trigger) => {
|
|
2519
|
+
const bar = plotRef.current?.querySelector(`[data-atbl-internal-bar-id="${CSS.escape(item.id)}"]`);
|
|
2520
|
+
const bounds = bar?.getBoundingClientRect() ?? trigger?.getBoundingClientRect();
|
|
2521
|
+
if (!bounds) return null;
|
|
2522
|
+
const top = bar ? bounds.top : bounds.top + 220;
|
|
2523
|
+
return new DOMRect(bounds.left + bounds.width / 2, top, 0, 0);
|
|
2524
|
+
},
|
|
2525
|
+
onOpenChange: (open) => setActiveId((current) => open ? item.id : current === item.id ? void 0 : current),
|
|
2526
|
+
content: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("strong", { children: item.label }), /* @__PURE__ */ jsxs("span", { children: [
|
|
2527
|
+
formatValue(item.value),
|
|
2528
|
+
" ",
|
|
2529
|
+
unit
|
|
2530
|
+
] })] }),
|
|
2531
|
+
className: "altertable-chart-column",
|
|
2532
|
+
children: action ? /* @__PURE__ */ jsx("button", {
|
|
2533
|
+
"data-atbl-focus": "ring",
|
|
2534
|
+
"data-atbl-control": "action",
|
|
2535
|
+
type: "button",
|
|
2536
|
+
className: "altertable-selectable-bars-item",
|
|
2537
|
+
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. ${action.label}`,
|
|
2538
|
+
...explorationMenuEvents(menuTrigger),
|
|
2539
|
+
onClick: (event) => action.onSelect(event.currentTarget),
|
|
2540
|
+
children: /* @__PURE__ */ jsx("span", { className: "altertable-selectable-bars-area" })
|
|
2541
|
+
}) : actions.length ? /* @__PURE__ */ jsx("button", {
|
|
2542
|
+
type: "button",
|
|
2543
|
+
"data-atbl-focus": "ring",
|
|
2544
|
+
"data-atbl-control": "action",
|
|
2545
|
+
className: "altertable-selectable-bars-item",
|
|
2546
|
+
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. Actions`,
|
|
2547
|
+
...explorationMenuEvents(menuTrigger),
|
|
2548
|
+
onClick: (event) => openExplorationMenu(menuTrigger, event),
|
|
2549
|
+
children: /* @__PURE__ */ jsx("span", { className: "altertable-selectable-bars-area" })
|
|
2550
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
2551
|
+
"data-atbl-focus": "ring",
|
|
2552
|
+
"data-atbl-control": "default",
|
|
2553
|
+
type: "button",
|
|
2554
|
+
tabIndex: -1,
|
|
2555
|
+
className: "altertable-selectable-bars-item",
|
|
2556
|
+
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}`,
|
|
2557
|
+
children: /* @__PURE__ */ jsx("span", { className: "altertable-selectable-bars-area" })
|
|
2558
|
+
})
|
|
2559
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
2560
|
+
className: "altertable-chart-item-label-row",
|
|
2561
|
+
"data-time-tick": ticks?.has(index) || void 0,
|
|
2562
|
+
children: actions.length ? /* @__PURE__ */ jsxs(MenuTrigger, { children: [/* @__PURE__ */ jsxs(PressButton, {
|
|
2563
|
+
className: "altertable-selectable-bars-label",
|
|
2564
|
+
variant: "ghost",
|
|
2565
|
+
size: "compact",
|
|
2566
|
+
...explorationMenuEvents(menuTrigger),
|
|
2567
|
+
ref: (element) => {
|
|
2568
|
+
if (element) menuTriggers.current.set(item.id, element);
|
|
2569
|
+
else menuTriggers.current.delete(item.id);
|
|
2570
|
+
},
|
|
2571
|
+
"aria-label": `${item.label}: Actions`,
|
|
2572
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2573
|
+
title: item.label,
|
|
2574
|
+
children: item.label
|
|
2575
|
+
}), /* @__PURE__ */ jsx(AppIcon, {
|
|
2576
|
+
name: "disclosure",
|
|
2577
|
+
size: 12
|
|
2578
|
+
})]
|
|
2579
|
+
}), /* @__PURE__ */ jsx(ExplorationActionMenu, {
|
|
2580
|
+
actions,
|
|
2581
|
+
ariaLabel: item.label,
|
|
2582
|
+
triggerRef: menuTrigger,
|
|
2583
|
+
placement: "bottom"
|
|
2584
|
+
})] }) : /* @__PURE__ */ jsx("span", {
|
|
2585
|
+
className: "altertable-selectable-bars-label",
|
|
2586
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
2587
|
+
title: item.label,
|
|
2588
|
+
children: item.label
|
|
2589
|
+
})
|
|
2590
|
+
})
|
|
2591
|
+
})]
|
|
2592
|
+
}) }, item.id);
|
|
2593
|
+
});
|
|
2594
|
+
});
|
|
2395
2595
|
/** Nonnegative category values. Compose inside VisualizationWidget for a titled panel.
|
|
2396
2596
|
* Owns hover/touch tooltips; no selection state or keyboard navigation. */
|
|
2397
2597
|
function BarChart({ items, unit, ariaLabel, formatValue: authoredFormatValue, itemActions, cursorGroup, horizontalGrid = true, showYAxis = false, scrollToEnd = true, valueFormat }) {
|
|
2398
|
-
const formatValue = authoredFormatValue ?? (valueFormat ? (value) => formatMetric(value, valueFormat) : formatNumber);
|
|
2598
|
+
const formatValue = useMemo(() => authoredFormatValue ?? (valueFormat ? (value) => formatMetric(value, valueFormat) : formatNumber), [authoredFormatValue, valueFormat]);
|
|
2399
2599
|
const axisLabelSpace = showYAxis ? 10 : 0;
|
|
2400
2600
|
validateValueChartItems("bar", items);
|
|
2401
2601
|
const chartActions = useChartActions();
|
|
2402
2602
|
const cursor = useLinkedChartCursor(cursorGroup);
|
|
2403
|
-
const linkedItem = items.find((item) => item.time === cursor.time && cursor.time != null);
|
|
2404
2603
|
const [activeId, setActiveId] = useState();
|
|
2405
2604
|
const [viewportWidth, setViewportWidth] = useState(0);
|
|
2406
2605
|
const plotRef = useRef(null);
|
|
2407
2606
|
const canvasRef = useRef(null);
|
|
2408
2607
|
const itemOverlayRef = useRef(null);
|
|
2409
|
-
const
|
|
2410
|
-
|
|
2608
|
+
const data = useMemo(() => {
|
|
2609
|
+
if (showYAxis) return items;
|
|
2610
|
+
const maximum = items.reduce((max, item) => Math.max(max, item.value), 0) || 1;
|
|
2611
|
+
return items.map((item) => ({
|
|
2612
|
+
...item,
|
|
2613
|
+
plotValue: item.value / maximum
|
|
2614
|
+
}));
|
|
2615
|
+
}, [items, showYAxis]);
|
|
2411
2616
|
const hasTimeAxis = items.length > 0 && items.every((item, index) => typeof item.time === "number" && Number.isFinite(item.time) && (index === 0 || item.time > items[index - 1].time));
|
|
2412
2617
|
const scrollport = useChartScrollToEnd(items, scrollToEnd);
|
|
2413
2618
|
const compactTimeAxis = hasTimeAxis && !itemActions;
|
|
2414
2619
|
const minimumSlotWidth = compactTimeAxis ? 3.5 : 120;
|
|
2415
2620
|
const plotWidth = Math.max(viewportWidth, items.length * minimumSlotWidth);
|
|
2416
|
-
const ticks = compactTimeAxis ? timeTickIndices(items, plotWidth) : null
|
|
2621
|
+
const ticks = useMemo(() => compactTimeAxis ? timeTickIndices(items, plotWidth) : null, [
|
|
2622
|
+
compactTimeAxis,
|
|
2623
|
+
items,
|
|
2624
|
+
plotWidth
|
|
2625
|
+
]);
|
|
2626
|
+
const linkedBackground = useCallback(({ originalDataIndex, x, y, width, height }) => /* @__PURE__ */ jsx(LinkedBarBackground, {
|
|
2627
|
+
cursor,
|
|
2628
|
+
time: items[originalDataIndex]?.time,
|
|
2629
|
+
x,
|
|
2630
|
+
y,
|
|
2631
|
+
width,
|
|
2632
|
+
height
|
|
2633
|
+
}), [cursor, items]);
|
|
2634
|
+
const linked = cursorGroup != null;
|
|
2635
|
+
const plot = useMemo(() => /* @__PURE__ */ jsx(ChartValueFormat, {
|
|
2636
|
+
value: valueFormat,
|
|
2637
|
+
children: /* @__PURE__ */ jsxs(BarChart$1, {
|
|
2638
|
+
data,
|
|
2639
|
+
responsive: true,
|
|
2640
|
+
width: "100%",
|
|
2641
|
+
height: 220 + 2 * axisLabelSpace,
|
|
2642
|
+
margin: {
|
|
2643
|
+
top: axisLabelSpace,
|
|
2644
|
+
right: 0,
|
|
2645
|
+
bottom: axisLabelSpace,
|
|
2646
|
+
left: 0
|
|
2647
|
+
},
|
|
2648
|
+
accessibilityLayer: false,
|
|
2649
|
+
tabIndex: -1,
|
|
2650
|
+
barCategoryGap: "24%",
|
|
2651
|
+
children: [
|
|
2652
|
+
showYAxis && /* @__PURE__ */ jsx(PlotBoundsObserver, { overlayRef: itemOverlayRef }),
|
|
2653
|
+
/* @__PURE__ */ jsx(ChartXAxis, {
|
|
2654
|
+
hide: true,
|
|
2655
|
+
dataKey: "id",
|
|
2656
|
+
scale: "band"
|
|
2657
|
+
}),
|
|
2658
|
+
showYAxis ? /* @__PURE__ */ jsx(ChartYAxis, { domain: [0, "auto"] }) : /* @__PURE__ */ jsx(ChartYAxis, {
|
|
2659
|
+
hide: true,
|
|
2660
|
+
domain: [0, 1],
|
|
2661
|
+
allowDataOverflow: true
|
|
2662
|
+
}),
|
|
2663
|
+
horizontalGrid && /* @__PURE__ */ jsx(ChartGrid, {}),
|
|
2664
|
+
/* @__PURE__ */ jsx(ChartBar, {
|
|
2665
|
+
dataKey: showYAxis ? "value" : "plotValue",
|
|
2666
|
+
minPointSize: minimumBarSize,
|
|
2667
|
+
background: linked ? linkedBackground : false,
|
|
2668
|
+
shape: renderHighlightedBar,
|
|
2669
|
+
children: items.map((item) => /* @__PURE__ */ jsx(Cell, {
|
|
2670
|
+
fill: chartBarFill,
|
|
2671
|
+
"data-atbl-internal-bar-id": item.id
|
|
2672
|
+
}, item.id))
|
|
2673
|
+
})
|
|
2674
|
+
]
|
|
2675
|
+
})
|
|
2676
|
+
}), [
|
|
2677
|
+
valueFormat,
|
|
2678
|
+
data,
|
|
2679
|
+
axisLabelSpace,
|
|
2680
|
+
showYAxis,
|
|
2681
|
+
horizontalGrid,
|
|
2682
|
+
linked,
|
|
2683
|
+
linkedBackground,
|
|
2684
|
+
items
|
|
2685
|
+
]);
|
|
2417
2686
|
useLayoutEffect(() => {
|
|
2418
2687
|
const element = scrollport.current;
|
|
2419
2688
|
if (!element) return;
|
|
@@ -2440,6 +2709,7 @@ function BarChart({ items, unit, ariaLabel, formatValue: authoredFormatValue, it
|
|
|
2440
2709
|
/* @__PURE__ */ jsx("div", {
|
|
2441
2710
|
className: "altertable-selectable-bars-scroll",
|
|
2442
2711
|
"data-time-axis": compactTimeAxis || void 0,
|
|
2712
|
+
style: { "--atbl-internal-bar-axis-space": `${axisLabelSpace}px` },
|
|
2443
2713
|
ref: scrollport,
|
|
2444
2714
|
children: /* @__PURE__ */ jsxs("div", {
|
|
2445
2715
|
className: "altertable-selectable-bars-plot",
|
|
@@ -2449,154 +2719,25 @@ function BarChart({ items, unit, ariaLabel, formatValue: authoredFormatValue, it
|
|
|
2449
2719
|
className: "altertable-chart-canvas",
|
|
2450
2720
|
"aria-hidden": "true",
|
|
2451
2721
|
ref: canvasRef,
|
|
2452
|
-
children: /* @__PURE__ */ jsx(
|
|
2453
|
-
value:
|
|
2454
|
-
children:
|
|
2455
|
-
data: showYAxis ? items : items.map((item) => ({
|
|
2456
|
-
...item,
|
|
2457
|
-
plotValue: item.value / maximum
|
|
2458
|
-
})),
|
|
2459
|
-
responsive: true,
|
|
2460
|
-
width: "100%",
|
|
2461
|
-
height: 220 + axisLabelSpace,
|
|
2462
|
-
margin: {
|
|
2463
|
-
top: 0,
|
|
2464
|
-
right: 0,
|
|
2465
|
-
bottom: axisLabelSpace,
|
|
2466
|
-
left: 0
|
|
2467
|
-
},
|
|
2468
|
-
accessibilityLayer: false,
|
|
2469
|
-
tabIndex: -1,
|
|
2470
|
-
barCategoryGap: "24%",
|
|
2471
|
-
children: [
|
|
2472
|
-
showYAxis && /* @__PURE__ */ jsx(PlotBoundsObserver, { overlayRef: itemOverlayRef }),
|
|
2473
|
-
/* @__PURE__ */ jsx(ChartXAxis, {
|
|
2474
|
-
hide: true,
|
|
2475
|
-
dataKey: "id",
|
|
2476
|
-
scale: "band"
|
|
2477
|
-
}),
|
|
2478
|
-
showYAxis ? /* @__PURE__ */ jsx(ChartYAxis, { domain: [0, "auto"] }) : /* @__PURE__ */ jsx(ChartYAxis, {
|
|
2479
|
-
hide: true,
|
|
2480
|
-
domain: [0, 1],
|
|
2481
|
-
allowDataOverflow: true
|
|
2482
|
-
}),
|
|
2483
|
-
horizontalGrid && /* @__PURE__ */ jsx(ChartGrid, {}),
|
|
2484
|
-
/* @__PURE__ */ jsx(ChartBar, {
|
|
2485
|
-
dataKey: showYAxis ? "value" : "plotValue",
|
|
2486
|
-
minPointSize: (value) => (value ?? 0) > 0 ? 7 : 0,
|
|
2487
|
-
background: linkedItem ? ({ index, x, y, width, height }) => /* @__PURE__ */ jsx("g", { children: items[index]?.id === linkedItem.id && /* @__PURE__ */ jsx("rect", {
|
|
2488
|
-
x,
|
|
2489
|
-
y,
|
|
2490
|
-
width,
|
|
2491
|
-
height,
|
|
2492
|
-
fill: "var(--atbl-muted)",
|
|
2493
|
-
fillOpacity: .14,
|
|
2494
|
-
pointerEvents: "none",
|
|
2495
|
-
"aria-hidden": "true",
|
|
2496
|
-
"data-atbl-internal-linked-cursor": "true"
|
|
2497
|
-
}) }) : false,
|
|
2498
|
-
children: items.map((item) => /* @__PURE__ */ jsx(Cell, {
|
|
2499
|
-
fill: chartBarFill,
|
|
2500
|
-
opacity: activeId === item.id ? .75 : 1,
|
|
2501
|
-
"data-atbl-internal-bar-id": item.id
|
|
2502
|
-
}, item.id))
|
|
2503
|
-
})
|
|
2504
|
-
]
|
|
2505
|
-
})
|
|
2722
|
+
children: /* @__PURE__ */ jsx(ActiveBarIdContext, {
|
|
2723
|
+
value: activeId,
|
|
2724
|
+
children: plot
|
|
2506
2725
|
})
|
|
2507
2726
|
}), /* @__PURE__ */ jsx("div", {
|
|
2508
2727
|
className: "altertable-selectable-bars-items",
|
|
2509
2728
|
ref: itemOverlayRef,
|
|
2510
|
-
children:
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
variant: "chart",
|
|
2523
|
-
followCursor: false,
|
|
2524
|
-
boundaryRefs: [canvasRef, scrollport],
|
|
2525
|
-
anchorRect: (trigger) => {
|
|
2526
|
-
const bar = plotRef.current?.querySelector(`[data-atbl-internal-bar-id="${CSS.escape(item.id)}"]`);
|
|
2527
|
-
const bounds = bar?.getBoundingClientRect() ?? trigger?.getBoundingClientRect();
|
|
2528
|
-
if (!bounds) return null;
|
|
2529
|
-
const top = bar ? bounds.top : bounds.top + 220;
|
|
2530
|
-
return new DOMRect(bounds.left + bounds.width / 2, top, 0, 0);
|
|
2531
|
-
},
|
|
2532
|
-
onOpenChange: (open) => setActiveId((current) => open ? item.id : current === item.id ? void 0 : current),
|
|
2533
|
-
content: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("strong", { children: item.label }), /* @__PURE__ */ jsxs("span", { children: [
|
|
2534
|
-
formatValue(item.value),
|
|
2535
|
-
" ",
|
|
2536
|
-
unit
|
|
2537
|
-
] })] }),
|
|
2538
|
-
className: "altertable-chart-column",
|
|
2539
|
-
children: action ? /* @__PURE__ */ jsx("button", {
|
|
2540
|
-
"data-atbl-focus": "ring",
|
|
2541
|
-
"data-atbl-control": "action",
|
|
2542
|
-
type: "button",
|
|
2543
|
-
className: "altertable-selectable-bars-item",
|
|
2544
|
-
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. ${action.label}`,
|
|
2545
|
-
...explorationMenuEvents(menuTrigger),
|
|
2546
|
-
onClick: (event) => action.onSelect(event.currentTarget),
|
|
2547
|
-
children: /* @__PURE__ */ jsx("span", { className: "altertable-selectable-bars-area" })
|
|
2548
|
-
}) : actions.length ? /* @__PURE__ */ jsx("button", {
|
|
2549
|
-
type: "button",
|
|
2550
|
-
"data-atbl-focus": "ring",
|
|
2551
|
-
"data-atbl-control": "action",
|
|
2552
|
-
className: "altertable-selectable-bars-item",
|
|
2553
|
-
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. Actions`,
|
|
2554
|
-
...explorationMenuEvents(menuTrigger),
|
|
2555
|
-
onClick: (event) => openExplorationMenu(menuTrigger, event),
|
|
2556
|
-
children: /* @__PURE__ */ jsx("span", { className: "altertable-selectable-bars-area" })
|
|
2557
|
-
}) : /* @__PURE__ */ jsx("button", {
|
|
2558
|
-
"data-atbl-focus": "ring",
|
|
2559
|
-
"data-atbl-control": "default",
|
|
2560
|
-
type: "button",
|
|
2561
|
-
tabIndex: -1,
|
|
2562
|
-
className: "altertable-selectable-bars-item",
|
|
2563
|
-
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}`,
|
|
2564
|
-
children: /* @__PURE__ */ jsx("span", { className: "altertable-selectable-bars-area" })
|
|
2565
|
-
})
|
|
2566
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
2567
|
-
className: "altertable-chart-item-label-row",
|
|
2568
|
-
"data-time-tick": ticks?.has(index) || void 0,
|
|
2569
|
-
children: actions.length ? /* @__PURE__ */ jsxs(MenuTrigger, { children: [/* @__PURE__ */ jsxs(PressButton, {
|
|
2570
|
-
className: "altertable-selectable-bars-label",
|
|
2571
|
-
variant: "ghost",
|
|
2572
|
-
size: "compact",
|
|
2573
|
-
...explorationMenuEvents(menuTrigger),
|
|
2574
|
-
ref: (element) => {
|
|
2575
|
-
if (element) menuTriggers.current.set(item.id, element);
|
|
2576
|
-
else menuTriggers.current.delete(item.id);
|
|
2577
|
-
},
|
|
2578
|
-
"aria-label": `${item.label}: Actions`,
|
|
2579
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
2580
|
-
title: item.label,
|
|
2581
|
-
children: item.label
|
|
2582
|
-
}), /* @__PURE__ */ jsx(AppIcon, {
|
|
2583
|
-
name: "disclosure",
|
|
2584
|
-
size: 12
|
|
2585
|
-
})]
|
|
2586
|
-
}), /* @__PURE__ */ jsx(ExplorationActionMenu, {
|
|
2587
|
-
actions,
|
|
2588
|
-
ariaLabel: item.label,
|
|
2589
|
-
triggerRef: menuTrigger,
|
|
2590
|
-
placement: "bottom"
|
|
2591
|
-
})] }) : /* @__PURE__ */ jsx("span", {
|
|
2592
|
-
className: "altertable-selectable-bars-label",
|
|
2593
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
2594
|
-
title: item.label,
|
|
2595
|
-
children: item.label
|
|
2596
|
-
})
|
|
2597
|
-
})
|
|
2598
|
-
})]
|
|
2599
|
-
}) }, item.id);
|
|
2729
|
+
children: /* @__PURE__ */ jsx(BarChartItems, {
|
|
2730
|
+
items,
|
|
2731
|
+
unit,
|
|
2732
|
+
formatValue,
|
|
2733
|
+
itemActions,
|
|
2734
|
+
actions: chartActions.actions,
|
|
2735
|
+
cursor,
|
|
2736
|
+
ticks,
|
|
2737
|
+
setActiveId,
|
|
2738
|
+
plotRef,
|
|
2739
|
+
canvasRef,
|
|
2740
|
+
scrollport
|
|
2600
2741
|
})
|
|
2601
2742
|
})]
|
|
2602
2743
|
})
|
|
@@ -2962,6 +3103,40 @@ function PlotOffsets({ onChange }) {
|
|
|
2962
3103
|
]);
|
|
2963
3104
|
return null;
|
|
2964
3105
|
}
|
|
3106
|
+
/** Pointer inspection reaches marks through context, so the Recharts tree
|
|
3107
|
+
* re-renders only for new chart props or legend state. */
|
|
3108
|
+
const ComposedChartPlot = memo(function ComposedChartPlot({ chartProps, registration, focusedLegendKeys, legendHoveredKey, suppressPlotInspection, barAxisByKey, fullAxisSpace, trackPlotOffsets }) {
|
|
3109
|
+
const { data, ariaLabel, valueFormat, cursorGroup: _cursorGroup, horizontalGrid = true, children, width = "100%", height = 300, responsive = true, layout = "horizontal", className: _className, ...rechartsProps } = chartProps;
|
|
3110
|
+
const valueAxis = layout === "vertical" ? "x" : "y";
|
|
3111
|
+
const axisLayout = inspectAxisLayout(children);
|
|
3112
|
+
const nativeKeyCounts = countNativeSeriesKeys(children);
|
|
3113
|
+
const visibleBarAxisIds = collectVisibleNativeBarAxisIds(children, focusedLegendKeys, valueAxis, nativeKeyCounts);
|
|
3114
|
+
for (const [key, axisId] of barAxisByKey) if (!focusedLegendKeys || focusedLegendKeys.has(key)) visibleBarAxisIds.add(axisId);
|
|
3115
|
+
return /* @__PURE__ */ jsx(ChartValueFormat, {
|
|
3116
|
+
value: valueFormat,
|
|
3117
|
+
children: /* @__PURE__ */ jsx(ChartDateAxes, {
|
|
3118
|
+
data,
|
|
3119
|
+
children: /* @__PURE__ */ jsx(ChartRegistrationContext, {
|
|
3120
|
+
value: registration,
|
|
3121
|
+
children: /* @__PURE__ */ jsxs(ComposedChart$1, {
|
|
3122
|
+
"data-atbl-focus": "inset",
|
|
3123
|
+
...rechartsProps,
|
|
3124
|
+
data,
|
|
3125
|
+
width,
|
|
3126
|
+
height,
|
|
3127
|
+
responsive,
|
|
3128
|
+
layout,
|
|
3129
|
+
"aria-label": ariaLabel,
|
|
3130
|
+
children: [
|
|
3131
|
+
valueAxis === "y" && axisLayout.autoYAxis && axisLayout.interactiveLegend && /* @__PURE__ */ jsx(PlotOffsets, { onChange: trackPlotOffsets }),
|
|
3132
|
+
horizontalGrid && !hasAuthoredGrid(children) && /* @__PURE__ */ jsx(ChartGrid, {}),
|
|
3133
|
+
applyNativeLegendInteraction(children, focusedLegendKeys, legendHoveredKey, suppressPlotInspection, valueAxis, visibleBarAxisIds, fullAxisSpace, axisLayout, nativeKeyCounts)
|
|
3134
|
+
]
|
|
3135
|
+
})
|
|
3136
|
+
})
|
|
3137
|
+
})
|
|
3138
|
+
});
|
|
3139
|
+
});
|
|
2965
3140
|
/** Compose Cartesian series inside VisualizationWidget. Defaults to responsive
|
|
2966
3141
|
* full width and 300px height. Children retain native Recharts props and behavior,
|
|
2967
3142
|
* including stacking, numeric/time axes, missing values, tooltips, and keyboard
|
|
@@ -2969,7 +3144,8 @@ function PlotOffsets({ onChange }) {
|
|
|
2969
3144
|
* for stacks. Preserve missing measures as null and choose connectNulls deliberately.
|
|
2970
3145
|
* Use public chart tokens for series colors. Dataset bindings own
|
|
2971
3146
|
* loading, empty results, evidence, and CSV; this primitive owns only the plot. */
|
|
2972
|
-
function ComposedChartRoot(
|
|
3147
|
+
function ComposedChartRoot(props) {
|
|
3148
|
+
const { ariaLabel, cursorGroup, children, layout = "horizontal", className } = props;
|
|
2973
3149
|
const cursor = useLinkedChartCursor(cursorGroup);
|
|
2974
3150
|
const [mouseHover, setMouseHover] = useState(false);
|
|
2975
3151
|
const [hasPointerFocus, setHasPointerFocus] = useState(false);
|
|
@@ -3098,7 +3274,6 @@ function ComposedChartRoot({ data, ariaLabel, valueFormat, cursorGroup, horizont
|
|
|
3098
3274
|
return next;
|
|
3099
3275
|
});
|
|
3100
3276
|
}, []);
|
|
3101
|
-
const valueAxis = layout === "vertical" ? "x" : "y";
|
|
3102
3277
|
const [fullAxisSpace, setFullAxisSpace] = useState(null);
|
|
3103
3278
|
const trackPlotOffsets = useCallback((left, right) => {
|
|
3104
3279
|
if (focusedLegendKeys) return;
|
|
@@ -3107,10 +3282,6 @@ function ComposedChartRoot({ data, ariaLabel, valueFormat, cursorGroup, horizont
|
|
|
3107
3282
|
right
|
|
3108
3283
|
});
|
|
3109
3284
|
}, [focusedLegendKeys]);
|
|
3110
|
-
const axisLayout = inspectAxisLayout(children);
|
|
3111
|
-
const nativeKeyCounts = countNativeSeriesKeys(children);
|
|
3112
|
-
const visibleBarAxisIds = collectVisibleNativeBarAxisIds(children, focusedLegendKeys, valueAxis, nativeKeyCounts);
|
|
3113
|
-
for (const [key, axisId] of barAxisByKey) if (!focusedLegendKeys || focusedLegendKeys.has(key)) visibleBarAxisIds.add(axisId);
|
|
3114
3285
|
const reconcileLegendKeys = useCallback((keys) => {
|
|
3115
3286
|
setFocusedLegendKeys((current) => reconcileLegendFocus(current, keys));
|
|
3116
3287
|
}, []);
|
|
@@ -3130,80 +3301,95 @@ function ComposedChartRoot({ data, ariaLabel, valueFormat, cursorGroup, horizont
|
|
|
3130
3301
|
registerSeries,
|
|
3131
3302
|
registerCategoryAxis
|
|
3132
3303
|
]);
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3304
|
+
const cursorContext = useMemo(() => ({
|
|
3305
|
+
cursor,
|
|
3306
|
+
mouseHover
|
|
3307
|
+
}), [cursor, mouseHover]);
|
|
3308
|
+
const hoverLegendKey = useCallback((key) => {
|
|
3309
|
+
setLegendHoveredKey(key);
|
|
3310
|
+
if (key) setSuppressPlotInspection(true);
|
|
3311
|
+
}, []);
|
|
3312
|
+
const legendContext = useMemo(() => ({
|
|
3313
|
+
hoveredKey: legendHoveredKey,
|
|
3314
|
+
focusedKeys: focusedLegendKeys,
|
|
3315
|
+
suppressPlotInspection,
|
|
3316
|
+
hover: hoverLegendKey,
|
|
3317
|
+
toggle: toggleLegendKey,
|
|
3318
|
+
reconcile: reconcileLegendKeys,
|
|
3319
|
+
registerBarAxis
|
|
3320
|
+
}), [
|
|
3321
|
+
legendHoveredKey,
|
|
3322
|
+
focusedLegendKeys,
|
|
3323
|
+
suppressPlotInspection,
|
|
3324
|
+
hoverLegendKey,
|
|
3325
|
+
toggleLegendKey,
|
|
3326
|
+
reconcileLegendKeys,
|
|
3327
|
+
registerBarAxis
|
|
3328
|
+
]);
|
|
3329
|
+
const getCategoryDataKey = useCallback((axisId) => categoryAxisKeys.get(chartAxisKey(layout === "horizontal" ? "x" : "y", axisId)) ?? categoryDataKey(children, layout, axisId), [
|
|
3330
|
+
categoryAxisKeys,
|
|
3331
|
+
layout,
|
|
3332
|
+
children
|
|
3333
|
+
]);
|
|
3334
|
+
const seriesCount = seriesIds.size;
|
|
3335
|
+
const interactionContext = useMemo(() => ({
|
|
3336
|
+
isPointerInspection,
|
|
3337
|
+
activeSeriesId,
|
|
3338
|
+
getCategoryDataKey,
|
|
3339
|
+
seriesCount
|
|
3340
|
+
}), [
|
|
3341
|
+
isPointerInspection,
|
|
3342
|
+
activeSeriesId,
|
|
3343
|
+
getCategoryDataKey,
|
|
3344
|
+
seriesCount
|
|
3345
|
+
]);
|
|
3346
|
+
const activePoint = activeSeriesId == null ? void 0 : points.get(activeSeriesId);
|
|
3347
|
+
const activeSampleContext = useMemo(() => ({
|
|
3348
|
+
activePoint,
|
|
3349
|
+
activeBar
|
|
3350
|
+
}), [activePoint, activeBar]);
|
|
3351
|
+
return /* @__PURE__ */ jsx(ChartCursorChartContext, {
|
|
3352
|
+
value: cursorContext,
|
|
3353
|
+
children: /* @__PURE__ */ jsx(ChartLegendInteractionContext, {
|
|
3354
|
+
value: legendContext,
|
|
3355
|
+
children: /* @__PURE__ */ jsx(ChartInteractionContext, {
|
|
3356
|
+
value: interactionContext,
|
|
3357
|
+
children: /* @__PURE__ */ jsx(ChartActiveSampleContext, {
|
|
3358
|
+
value: activeSampleContext,
|
|
3359
|
+
children: /* @__PURE__ */ jsx("section", {
|
|
3360
|
+
className: classNames("altertable-composed-chart", className),
|
|
3361
|
+
"aria-label": ariaLabel,
|
|
3362
|
+
"data-atbl-internal-pointer-focus": hasPointerFocus || void 0,
|
|
3363
|
+
onPointerDownCapture: (event) => {
|
|
3364
|
+
setHasPointerFocus(trackPointer(event));
|
|
3365
|
+
},
|
|
3366
|
+
onPointerOverCapture: trackPointer,
|
|
3367
|
+
onPointerMoveCapture: trackPointer,
|
|
3368
|
+
onPointerLeave: (event) => {
|
|
3369
|
+
if (event.pointerType !== "touch") resetPointerInspection();
|
|
3370
|
+
},
|
|
3371
|
+
onKeyDownCapture: () => {
|
|
3181
3372
|
setHasPointerFocus(false);
|
|
3182
3373
|
resetPointerInspection();
|
|
3183
|
-
}
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
horizontalGrid && !hasAuthoredGrid(children) && /* @__PURE__ */ jsx(ChartGrid, {}),
|
|
3203
|
-
applyNativeLegendInteraction(children, focusedLegendKeys, legendHoveredKey, suppressPlotInspection, valueAxis, visibleBarAxisIds, fullAxisSpace, axisLayout, nativeKeyCounts)
|
|
3204
|
-
]
|
|
3205
|
-
})
|
|
3206
|
-
})
|
|
3374
|
+
},
|
|
3375
|
+
onFocusCapture: (event) => {
|
|
3376
|
+
if (event.currentTarget.querySelector("svg[role=\"application\"]")?.contains(event.target)) setSuppressPlotInspection(false);
|
|
3377
|
+
},
|
|
3378
|
+
onBlurCapture: (event) => {
|
|
3379
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
3380
|
+
setHasPointerFocus(false);
|
|
3381
|
+
resetPointerInspection();
|
|
3382
|
+
}
|
|
3383
|
+
},
|
|
3384
|
+
children: /* @__PURE__ */ jsx(ComposedChartPlot, {
|
|
3385
|
+
chartProps: props,
|
|
3386
|
+
registration,
|
|
3387
|
+
focusedLegendKeys,
|
|
3388
|
+
legendHoveredKey,
|
|
3389
|
+
suppressPlotInspection,
|
|
3390
|
+
barAxisByKey,
|
|
3391
|
+
fullAxisSpace,
|
|
3392
|
+
trackPlotOffsets
|
|
3207
3393
|
})
|
|
3208
3394
|
})
|
|
3209
3395
|
})
|
|
@@ -3994,14 +4180,6 @@ function JourneyFlow({ paths, unit, formatValue }) {
|
|
|
3994
4180
|
});
|
|
3995
4181
|
}
|
|
3996
4182
|
//#endregion
|
|
3997
|
-
|
|
3998
|
-
/** Direct UI composition and static screens. Requests use declared views from /react. */
|
|
3999
|
-
const TextWidget = withWidgetBoundary(TextWidget$1);
|
|
4000
|
-
/** Compose an unframed visual with the shared heading and inspection. */
|
|
4001
|
-
const VisualizationWidget = withWidgetBoundary(VisualizationWidget$1);
|
|
4002
|
-
const TableWidget = withWidgetBoundary(TableWidget$1);
|
|
4003
|
-
const MetricWidget = withWidgetBoundary(MetricWidget$1);
|
|
4004
|
-
//#endregion
|
|
4005
|
-
export { AboutData, AppIcon, AreaChart, BarChart, ChartLegend, Checkbox, CheckboxGroup, ChoicePicker, ComposedChart, ControlBar, DataApp, DataAppProvider, DataTable, DataTableEmptyRow, DataTableShare, DataTableTimestamp, DataValue, DataWidget, DateDisplay, DateTimeRangePicker, DimensionPicker, ExplorationActionControl, FilterActions, FilterBar, FunnelChart, GettingStarted, GlossaryDefinition, GlossaryExplanation, GradientScroll, HelpPopover, JourneyChart, LineChart, LiveControl, Menu, PressButton as MenuButton, MenuItem, MenuPopover, MenuSection, MenuSeparator, MenuTrigger, MetricWidget, Notice, NumberField, NumberFilterPicker, NumberRangeField, PieChart, PresentStory, Radio, RadioGroup, RetentionChart, ScatterChart, SearchField, SearchMatch, SearchTypeahead, SectionHeading, SegmentedControl, Select, Sheet, ShimmerText, Tab, TabList, TabPanel, TabPanels, TableWidget, Tabs, TextWidget, Tooltip, TooltipProvider, VisualizationWidget, dateTimeRangeFilter, dateTimeRangePresets, injectDataAppStyles, isPlainKeyEvent, matchSearchText, searchItems, useAppFilters, useChartCursorGroup, useDateFormatting, useSvgId, useViewTab };
|
|
4183
|
+
export { AboutData, AppIcon, AreaChart, BarChart, ChartLegend, Checkbox, CheckboxGroup, ChoicePicker, ComposedChart, ControlBar, DataAppProvider, DataTable, DataTableEmptyRow, DataTableShare, DataTableTimestamp, DataWidget, DateDisplay, DateTimeRangePicker, DimensionPicker, ExplorationActionControl, FilterActions, FilterBar, FunnelChart, GettingStarted, GlossaryDefinition, GlossaryExplanation, GradientScroll, HelpPopover, JourneyChart, LineChart, LiveControl, Menu, PressButton as MenuButton, MenuItem, MenuPopover, MenuSection, MenuSeparator, MenuTrigger, Notice, NumberField, NumberFilterPicker, NumberRangeField, PieChart, PresentStory, Radio, RadioGroup, RetentionChart, ScatterChart, SearchField, SearchMatch, SearchTypeahead, SectionHeading, SegmentedControl, Select, Sheet, ShimmerText, Tab, TabList, TabPanel, TabPanels, Tabs, Tooltip, TooltipProvider, dateTimeRangeFilter, dateTimeRangePresets, injectDataAppStyles, isPlainKeyEvent, matchSearchText, searchItems, useAppFilters, useChartCursorGroup, useDateFormatting, useSvgId, useViewTab };
|
|
4006
4184
|
|
|
4007
4185
|
//# sourceMappingURL=index.js.map
|