@altertable/data-app-react 0.78.0 → 0.79.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-BAZB-Fnf.js} +131 -643
- package/dist/chunks/SectionHeading-BAZB-Fnf.js.map +1 -0
- package/dist/index.js +483 -4
- package/dist/index.js.map +1 -1
- package/dist/types/chunks/DateTimeRangePicker.d.ts +2 -143
- package/dist/types/index.d.ts +187 -13
- package/dist/types/ui/index.d.ts +3 -15
- package/dist/ui/index.js +599 -426
- 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 ChoicePicker, A as MenuSeparator, B as useDeclaredResult, Bt as Tooltip, D as MenuItem, Dt as DataAppProvider, E as Menu, F as isPlainKeyEvent, Ft as TabPanels, G as NumberFilterPicker, H as ControlBar, Ht as ChartTooltip$1, I as createDataHooks, It as Tabs, J as DimensionPicker, Jt as AppIcon, K as NumberField, Lt as useViewTab, Mt as Tab, Nt as TabList, O as MenuPopover, Pt as TabPanel, Qt as classNames, Rt as Sheet, T as LiveControl, Tt as ShimmerText, U as SearchTypeahead, Ut as TooltipSurface, V as FilterActions, Vt as TooltipProvider, W as SearchField, X as DateTimeRangePicker, Xt as Button$1, Y as FilterBar, Z as Select, Zt as PressButton, _t as HelpPopover, a as DataTable, at as useAppFilters, b as Notice, c as DataTableTimestamp, ct as searchItems, d as explorationMenuEvents, en as useDateFormatting, f as getPrimaryExplorationAction, h as DataWidget, ht as DateDisplay, it as dateTimeRangePresets, j as MenuTrigger, k as MenuSection, kt as AboutData, l as ExplorationActionControl, m as useChartActions, n as createDataContext, nn as injectDataAppStyles, nt as SearchMatch, o as DataTableEmptyRow, p as openExplorationMenu, q as NumberRangeField, r as chartBarFill, rt as dateTimeRangeFilter, s as DataTableShare, st as matchSearchText, t as SectionHeading, tt as SelectionMark, u as ExplorationActionMenu, w as PresentStory, x as DataAppFrame, zt as GradientScroll } from "../chunks/SectionHeading-BAZB-Fnf.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
|
})
|
|
@@ -2392,28 +2462,223 @@ function PlotBoundsObserver({ overlayRef }) {
|
|
|
2392
2462
|
]);
|
|
2393
2463
|
return null;
|
|
2394
2464
|
}
|
|
2465
|
+
const ActiveBarIdContext = createContext(void 0);
|
|
2466
|
+
/** Reads the hovered id itself, so moving between bars redraws two bars, not the plot. */
|
|
2467
|
+
function HighlightedBar(props) {
|
|
2468
|
+
const id = props["data-atbl-internal-bar-id"];
|
|
2469
|
+
const active = useContext(ActiveBarIdContext) === id;
|
|
2470
|
+
return useMemo(() => /* @__PURE__ */ jsx(Rectangle, {
|
|
2471
|
+
...props,
|
|
2472
|
+
opacity: active ? .75 : 1
|
|
2473
|
+
}), [props, active]);
|
|
2474
|
+
}
|
|
2475
|
+
function renderHighlightedBar(props) {
|
|
2476
|
+
return /* @__PURE__ */ jsx(HighlightedBar, { ...props });
|
|
2477
|
+
}
|
|
2478
|
+
function minimumBarSize(value) {
|
|
2479
|
+
return (value ?? 0) > 0 ? 7 : 0;
|
|
2480
|
+
}
|
|
2481
|
+
/** Subscribes per bar, so a peer cursor repaints two backgrounds instead of the chart. */
|
|
2482
|
+
function LinkedBarBackground({ cursor, time, x, y, width, height }) {
|
|
2483
|
+
const linked = useLinkedCursorValue(cursor, (peerTime) => time != null && peerTime === time);
|
|
2484
|
+
return /* @__PURE__ */ jsx("g", { children: linked && /* @__PURE__ */ jsx("rect", {
|
|
2485
|
+
x,
|
|
2486
|
+
y,
|
|
2487
|
+
width,
|
|
2488
|
+
height,
|
|
2489
|
+
fill: "var(--atbl-muted)",
|
|
2490
|
+
fillOpacity: .14,
|
|
2491
|
+
pointerEvents: "none",
|
|
2492
|
+
"aria-hidden": "true",
|
|
2493
|
+
"data-atbl-internal-linked-cursor": "true"
|
|
2494
|
+
}) });
|
|
2495
|
+
}
|
|
2496
|
+
/** Hit targets and tooltips stay mounted while the plot highlights a bar. */
|
|
2497
|
+
const BarChartItems = memo(function BarChartItems({ items, unit, formatValue, itemActions, actions: chartActions, cursor, ticks, setActiveId, plotRef, canvasRef, scrollport }) {
|
|
2498
|
+
const menuTriggers = useRef(/* @__PURE__ */ new Map());
|
|
2499
|
+
return items.map((item, index) => {
|
|
2500
|
+
const actions = chartActions(itemActions?.(item) ?? [], item.label, `${formatValue(item.value)} ${unit}`);
|
|
2501
|
+
const action = getPrimaryExplorationAction(actions);
|
|
2502
|
+
const menuTrigger = { get current() {
|
|
2503
|
+
return menuTriggers.current.get(item.id) ?? null;
|
|
2504
|
+
} };
|
|
2505
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", {
|
|
2506
|
+
className: "altertable-chart-item-actions",
|
|
2507
|
+
onPointerMove: (event) => {
|
|
2508
|
+
if (event.pointerType === "mouse") cursor.setTime(item.time);
|
|
2509
|
+
},
|
|
2510
|
+
children: [/* @__PURE__ */ jsx(ChartTooltip$1, {
|
|
2511
|
+
variant: "chart",
|
|
2512
|
+
followCursor: false,
|
|
2513
|
+
boundaryRefs: [canvasRef, scrollport],
|
|
2514
|
+
anchorRect: (trigger) => {
|
|
2515
|
+
const bar = plotRef.current?.querySelector(`[data-atbl-internal-bar-id="${CSS.escape(item.id)}"]`);
|
|
2516
|
+
const bounds = bar?.getBoundingClientRect() ?? trigger?.getBoundingClientRect();
|
|
2517
|
+
if (!bounds) return null;
|
|
2518
|
+
const top = bar ? bounds.top : bounds.top + 220;
|
|
2519
|
+
return new DOMRect(bounds.left + bounds.width / 2, top, 0, 0);
|
|
2520
|
+
},
|
|
2521
|
+
onOpenChange: (open) => setActiveId((current) => open ? item.id : current === item.id ? void 0 : current),
|
|
2522
|
+
content: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("strong", { children: item.label }), /* @__PURE__ */ jsxs("span", { children: [
|
|
2523
|
+
formatValue(item.value),
|
|
2524
|
+
" ",
|
|
2525
|
+
unit
|
|
2526
|
+
] })] }),
|
|
2527
|
+
className: "altertable-chart-column",
|
|
2528
|
+
children: action ? /* @__PURE__ */ jsx("button", {
|
|
2529
|
+
"data-atbl-focus": "ring",
|
|
2530
|
+
"data-atbl-control": "action",
|
|
2531
|
+
type: "button",
|
|
2532
|
+
className: "altertable-selectable-bars-item",
|
|
2533
|
+
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. ${action.label}`,
|
|
2534
|
+
...explorationMenuEvents(menuTrigger),
|
|
2535
|
+
onClick: (event) => action.onSelect(event.currentTarget),
|
|
2536
|
+
children: /* @__PURE__ */ jsx("span", { className: "altertable-selectable-bars-area" })
|
|
2537
|
+
}) : actions.length ? /* @__PURE__ */ jsx("button", {
|
|
2538
|
+
type: "button",
|
|
2539
|
+
"data-atbl-focus": "ring",
|
|
2540
|
+
"data-atbl-control": "action",
|
|
2541
|
+
className: "altertable-selectable-bars-item",
|
|
2542
|
+
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}. Actions`,
|
|
2543
|
+
...explorationMenuEvents(menuTrigger),
|
|
2544
|
+
onClick: (event) => openExplorationMenu(menuTrigger, event),
|
|
2545
|
+
children: /* @__PURE__ */ jsx("span", { className: "altertable-selectable-bars-area" })
|
|
2546
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
2547
|
+
"data-atbl-focus": "ring",
|
|
2548
|
+
"data-atbl-control": "default",
|
|
2549
|
+
type: "button",
|
|
2550
|
+
tabIndex: -1,
|
|
2551
|
+
className: "altertable-selectable-bars-item",
|
|
2552
|
+
"aria-label": `${item.label}: ${formatValue(item.value)} ${unit}`,
|
|
2553
|
+
children: /* @__PURE__ */ jsx("span", { className: "altertable-selectable-bars-area" })
|
|
2554
|
+
})
|
|
2555
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
2556
|
+
className: "altertable-chart-item-label-row",
|
|
2557
|
+
"data-time-tick": ticks?.has(index) || void 0,
|
|
2558
|
+
children: actions.length ? /* @__PURE__ */ jsxs(MenuTrigger, { children: [/* @__PURE__ */ jsxs(PressButton, {
|
|
2559
|
+
className: "altertable-selectable-bars-label",
|
|
2560
|
+
variant: "ghost",
|
|
2561
|
+
size: "compact",
|
|
2562
|
+
...explorationMenuEvents(menuTrigger),
|
|
2563
|
+
ref: (element) => {
|
|
2564
|
+
if (element) menuTriggers.current.set(item.id, element);
|
|
2565
|
+
else menuTriggers.current.delete(item.id);
|
|
2566
|
+
},
|
|
2567
|
+
"aria-label": `${item.label}: Actions`,
|
|
2568
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2569
|
+
title: item.label,
|
|
2570
|
+
children: item.label
|
|
2571
|
+
}), /* @__PURE__ */ jsx(AppIcon, {
|
|
2572
|
+
name: "disclosure",
|
|
2573
|
+
size: 12
|
|
2574
|
+
})]
|
|
2575
|
+
}), /* @__PURE__ */ jsx(ExplorationActionMenu, {
|
|
2576
|
+
actions,
|
|
2577
|
+
ariaLabel: item.label,
|
|
2578
|
+
triggerRef: menuTrigger,
|
|
2579
|
+
placement: "bottom"
|
|
2580
|
+
})] }) : /* @__PURE__ */ jsx("span", {
|
|
2581
|
+
className: "altertable-selectable-bars-label",
|
|
2582
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
2583
|
+
title: item.label,
|
|
2584
|
+
children: item.label
|
|
2585
|
+
})
|
|
2586
|
+
})
|
|
2587
|
+
})]
|
|
2588
|
+
}) }, item.id);
|
|
2589
|
+
});
|
|
2590
|
+
});
|
|
2395
2591
|
/** Nonnegative category values. Compose inside VisualizationWidget for a titled panel.
|
|
2396
2592
|
* Owns hover/touch tooltips; no selection state or keyboard navigation. */
|
|
2397
2593
|
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);
|
|
2594
|
+
const formatValue = useMemo(() => authoredFormatValue ?? (valueFormat ? (value) => formatMetric(value, valueFormat) : formatNumber), [authoredFormatValue, valueFormat]);
|
|
2399
2595
|
const axisLabelSpace = showYAxis ? 10 : 0;
|
|
2400
2596
|
validateValueChartItems("bar", items);
|
|
2401
2597
|
const chartActions = useChartActions();
|
|
2402
2598
|
const cursor = useLinkedChartCursor(cursorGroup);
|
|
2403
|
-
const linkedItem = items.find((item) => item.time === cursor.time && cursor.time != null);
|
|
2404
2599
|
const [activeId, setActiveId] = useState();
|
|
2405
2600
|
const [viewportWidth, setViewportWidth] = useState(0);
|
|
2406
2601
|
const plotRef = useRef(null);
|
|
2407
2602
|
const canvasRef = useRef(null);
|
|
2408
2603
|
const itemOverlayRef = useRef(null);
|
|
2409
|
-
const
|
|
2410
|
-
|
|
2604
|
+
const data = useMemo(() => {
|
|
2605
|
+
if (showYAxis) return items;
|
|
2606
|
+
const maximum = items.reduce((max, item) => Math.max(max, item.value), 0) || 1;
|
|
2607
|
+
return items.map((item) => ({
|
|
2608
|
+
...item,
|
|
2609
|
+
plotValue: item.value / maximum
|
|
2610
|
+
}));
|
|
2611
|
+
}, [items, showYAxis]);
|
|
2411
2612
|
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
2613
|
const scrollport = useChartScrollToEnd(items, scrollToEnd);
|
|
2413
2614
|
const compactTimeAxis = hasTimeAxis && !itemActions;
|
|
2414
2615
|
const minimumSlotWidth = compactTimeAxis ? 3.5 : 120;
|
|
2415
2616
|
const plotWidth = Math.max(viewportWidth, items.length * minimumSlotWidth);
|
|
2416
|
-
const ticks = compactTimeAxis ? timeTickIndices(items, plotWidth) : null
|
|
2617
|
+
const ticks = useMemo(() => compactTimeAxis ? timeTickIndices(items, plotWidth) : null, [
|
|
2618
|
+
compactTimeAxis,
|
|
2619
|
+
items,
|
|
2620
|
+
plotWidth
|
|
2621
|
+
]);
|
|
2622
|
+
const linkedBackground = useCallback(({ originalDataIndex, x, y, width, height }) => /* @__PURE__ */ jsx(LinkedBarBackground, {
|
|
2623
|
+
cursor,
|
|
2624
|
+
time: items[originalDataIndex]?.time,
|
|
2625
|
+
x,
|
|
2626
|
+
y,
|
|
2627
|
+
width,
|
|
2628
|
+
height
|
|
2629
|
+
}), [cursor, items]);
|
|
2630
|
+
const linked = cursorGroup != null;
|
|
2631
|
+
const plot = useMemo(() => /* @__PURE__ */ jsx(ChartValueFormat, {
|
|
2632
|
+
value: valueFormat,
|
|
2633
|
+
children: /* @__PURE__ */ jsxs(BarChart$1, {
|
|
2634
|
+
data,
|
|
2635
|
+
responsive: true,
|
|
2636
|
+
width: "100%",
|
|
2637
|
+
height: 220 + axisLabelSpace,
|
|
2638
|
+
margin: {
|
|
2639
|
+
top: 0,
|
|
2640
|
+
right: 0,
|
|
2641
|
+
bottom: axisLabelSpace,
|
|
2642
|
+
left: 0
|
|
2643
|
+
},
|
|
2644
|
+
accessibilityLayer: false,
|
|
2645
|
+
tabIndex: -1,
|
|
2646
|
+
barCategoryGap: "24%",
|
|
2647
|
+
children: [
|
|
2648
|
+
showYAxis && /* @__PURE__ */ jsx(PlotBoundsObserver, { overlayRef: itemOverlayRef }),
|
|
2649
|
+
/* @__PURE__ */ jsx(ChartXAxis, {
|
|
2650
|
+
hide: true,
|
|
2651
|
+
dataKey: "id",
|
|
2652
|
+
scale: "band"
|
|
2653
|
+
}),
|
|
2654
|
+
showYAxis ? /* @__PURE__ */ jsx(ChartYAxis, { domain: [0, "auto"] }) : /* @__PURE__ */ jsx(ChartYAxis, {
|
|
2655
|
+
hide: true,
|
|
2656
|
+
domain: [0, 1],
|
|
2657
|
+
allowDataOverflow: true
|
|
2658
|
+
}),
|
|
2659
|
+
horizontalGrid && /* @__PURE__ */ jsx(ChartGrid, {}),
|
|
2660
|
+
/* @__PURE__ */ jsx(ChartBar, {
|
|
2661
|
+
dataKey: showYAxis ? "value" : "plotValue",
|
|
2662
|
+
minPointSize: minimumBarSize,
|
|
2663
|
+
background: linked ? linkedBackground : false,
|
|
2664
|
+
shape: renderHighlightedBar,
|
|
2665
|
+
children: items.map((item) => /* @__PURE__ */ jsx(Cell, {
|
|
2666
|
+
fill: chartBarFill,
|
|
2667
|
+
"data-atbl-internal-bar-id": item.id
|
|
2668
|
+
}, item.id))
|
|
2669
|
+
})
|
|
2670
|
+
]
|
|
2671
|
+
})
|
|
2672
|
+
}), [
|
|
2673
|
+
valueFormat,
|
|
2674
|
+
data,
|
|
2675
|
+
axisLabelSpace,
|
|
2676
|
+
showYAxis,
|
|
2677
|
+
horizontalGrid,
|
|
2678
|
+
linked,
|
|
2679
|
+
linkedBackground,
|
|
2680
|
+
items
|
|
2681
|
+
]);
|
|
2417
2682
|
useLayoutEffect(() => {
|
|
2418
2683
|
const element = scrollport.current;
|
|
2419
2684
|
if (!element) return;
|
|
@@ -2449,154 +2714,25 @@ function BarChart({ items, unit, ariaLabel, formatValue: authoredFormatValue, it
|
|
|
2449
2714
|
className: "altertable-chart-canvas",
|
|
2450
2715
|
"aria-hidden": "true",
|
|
2451
2716
|
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
|
-
})
|
|
2717
|
+
children: /* @__PURE__ */ jsx(ActiveBarIdContext, {
|
|
2718
|
+
value: activeId,
|
|
2719
|
+
children: plot
|
|
2506
2720
|
})
|
|
2507
2721
|
}), /* @__PURE__ */ jsx("div", {
|
|
2508
2722
|
className: "altertable-selectable-bars-items",
|
|
2509
2723
|
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);
|
|
2724
|
+
children: /* @__PURE__ */ jsx(BarChartItems, {
|
|
2725
|
+
items,
|
|
2726
|
+
unit,
|
|
2727
|
+
formatValue,
|
|
2728
|
+
itemActions,
|
|
2729
|
+
actions: chartActions.actions,
|
|
2730
|
+
cursor,
|
|
2731
|
+
ticks,
|
|
2732
|
+
setActiveId,
|
|
2733
|
+
plotRef,
|
|
2734
|
+
canvasRef,
|
|
2735
|
+
scrollport
|
|
2600
2736
|
})
|
|
2601
2737
|
})]
|
|
2602
2738
|
})
|
|
@@ -2962,6 +3098,40 @@ function PlotOffsets({ onChange }) {
|
|
|
2962
3098
|
]);
|
|
2963
3099
|
return null;
|
|
2964
3100
|
}
|
|
3101
|
+
/** Pointer inspection reaches marks through context, so the Recharts tree
|
|
3102
|
+
* re-renders only for new chart props or legend state. */
|
|
3103
|
+
const ComposedChartPlot = memo(function ComposedChartPlot({ chartProps, registration, focusedLegendKeys, legendHoveredKey, suppressPlotInspection, barAxisByKey, fullAxisSpace, trackPlotOffsets }) {
|
|
3104
|
+
const { data, ariaLabel, valueFormat, cursorGroup: _cursorGroup, horizontalGrid = true, children, width = "100%", height = 300, responsive = true, layout = "horizontal", className: _className, ...rechartsProps } = chartProps;
|
|
3105
|
+
const valueAxis = layout === "vertical" ? "x" : "y";
|
|
3106
|
+
const axisLayout = inspectAxisLayout(children);
|
|
3107
|
+
const nativeKeyCounts = countNativeSeriesKeys(children);
|
|
3108
|
+
const visibleBarAxisIds = collectVisibleNativeBarAxisIds(children, focusedLegendKeys, valueAxis, nativeKeyCounts);
|
|
3109
|
+
for (const [key, axisId] of barAxisByKey) if (!focusedLegendKeys || focusedLegendKeys.has(key)) visibleBarAxisIds.add(axisId);
|
|
3110
|
+
return /* @__PURE__ */ jsx(ChartValueFormat, {
|
|
3111
|
+
value: valueFormat,
|
|
3112
|
+
children: /* @__PURE__ */ jsx(ChartDateAxes, {
|
|
3113
|
+
data,
|
|
3114
|
+
children: /* @__PURE__ */ jsx(ChartRegistrationContext, {
|
|
3115
|
+
value: registration,
|
|
3116
|
+
children: /* @__PURE__ */ jsxs(ComposedChart$1, {
|
|
3117
|
+
"data-atbl-focus": "inset",
|
|
3118
|
+
...rechartsProps,
|
|
3119
|
+
data,
|
|
3120
|
+
width,
|
|
3121
|
+
height,
|
|
3122
|
+
responsive,
|
|
3123
|
+
layout,
|
|
3124
|
+
"aria-label": ariaLabel,
|
|
3125
|
+
children: [
|
|
3126
|
+
valueAxis === "y" && axisLayout.autoYAxis && axisLayout.interactiveLegend && /* @__PURE__ */ jsx(PlotOffsets, { onChange: trackPlotOffsets }),
|
|
3127
|
+
horizontalGrid && !hasAuthoredGrid(children) && /* @__PURE__ */ jsx(ChartGrid, {}),
|
|
3128
|
+
applyNativeLegendInteraction(children, focusedLegendKeys, legendHoveredKey, suppressPlotInspection, valueAxis, visibleBarAxisIds, fullAxisSpace, axisLayout, nativeKeyCounts)
|
|
3129
|
+
]
|
|
3130
|
+
})
|
|
3131
|
+
})
|
|
3132
|
+
})
|
|
3133
|
+
});
|
|
3134
|
+
});
|
|
2965
3135
|
/** Compose Cartesian series inside VisualizationWidget. Defaults to responsive
|
|
2966
3136
|
* full width and 300px height. Children retain native Recharts props and behavior,
|
|
2967
3137
|
* including stacking, numeric/time axes, missing values, tooltips, and keyboard
|
|
@@ -2969,7 +3139,8 @@ function PlotOffsets({ onChange }) {
|
|
|
2969
3139
|
* for stacks. Preserve missing measures as null and choose connectNulls deliberately.
|
|
2970
3140
|
* Use public chart tokens for series colors. Dataset bindings own
|
|
2971
3141
|
* loading, empty results, evidence, and CSV; this primitive owns only the plot. */
|
|
2972
|
-
function ComposedChartRoot(
|
|
3142
|
+
function ComposedChartRoot(props) {
|
|
3143
|
+
const { ariaLabel, cursorGroup, children, layout = "horizontal", className } = props;
|
|
2973
3144
|
const cursor = useLinkedChartCursor(cursorGroup);
|
|
2974
3145
|
const [mouseHover, setMouseHover] = useState(false);
|
|
2975
3146
|
const [hasPointerFocus, setHasPointerFocus] = useState(false);
|
|
@@ -3098,7 +3269,6 @@ function ComposedChartRoot({ data, ariaLabel, valueFormat, cursorGroup, horizont
|
|
|
3098
3269
|
return next;
|
|
3099
3270
|
});
|
|
3100
3271
|
}, []);
|
|
3101
|
-
const valueAxis = layout === "vertical" ? "x" : "y";
|
|
3102
3272
|
const [fullAxisSpace, setFullAxisSpace] = useState(null);
|
|
3103
3273
|
const trackPlotOffsets = useCallback((left, right) => {
|
|
3104
3274
|
if (focusedLegendKeys) return;
|
|
@@ -3107,10 +3277,6 @@ function ComposedChartRoot({ data, ariaLabel, valueFormat, cursorGroup, horizont
|
|
|
3107
3277
|
right
|
|
3108
3278
|
});
|
|
3109
3279
|
}, [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
3280
|
const reconcileLegendKeys = useCallback((keys) => {
|
|
3115
3281
|
setFocusedLegendKeys((current) => reconcileLegendFocus(current, keys));
|
|
3116
3282
|
}, []);
|
|
@@ -3130,80 +3296,95 @@ function ComposedChartRoot({ data, ariaLabel, valueFormat, cursorGroup, horizont
|
|
|
3130
3296
|
registerSeries,
|
|
3131
3297
|
registerCategoryAxis
|
|
3132
3298
|
]);
|
|
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
|
-
|
|
3299
|
+
const cursorContext = useMemo(() => ({
|
|
3300
|
+
cursor,
|
|
3301
|
+
mouseHover
|
|
3302
|
+
}), [cursor, mouseHover]);
|
|
3303
|
+
const hoverLegendKey = useCallback((key) => {
|
|
3304
|
+
setLegendHoveredKey(key);
|
|
3305
|
+
if (key) setSuppressPlotInspection(true);
|
|
3306
|
+
}, []);
|
|
3307
|
+
const legendContext = useMemo(() => ({
|
|
3308
|
+
hoveredKey: legendHoveredKey,
|
|
3309
|
+
focusedKeys: focusedLegendKeys,
|
|
3310
|
+
suppressPlotInspection,
|
|
3311
|
+
hover: hoverLegendKey,
|
|
3312
|
+
toggle: toggleLegendKey,
|
|
3313
|
+
reconcile: reconcileLegendKeys,
|
|
3314
|
+
registerBarAxis
|
|
3315
|
+
}), [
|
|
3316
|
+
legendHoveredKey,
|
|
3317
|
+
focusedLegendKeys,
|
|
3318
|
+
suppressPlotInspection,
|
|
3319
|
+
hoverLegendKey,
|
|
3320
|
+
toggleLegendKey,
|
|
3321
|
+
reconcileLegendKeys,
|
|
3322
|
+
registerBarAxis
|
|
3323
|
+
]);
|
|
3324
|
+
const getCategoryDataKey = useCallback((axisId) => categoryAxisKeys.get(chartAxisKey(layout === "horizontal" ? "x" : "y", axisId)) ?? categoryDataKey(children, layout, axisId), [
|
|
3325
|
+
categoryAxisKeys,
|
|
3326
|
+
layout,
|
|
3327
|
+
children
|
|
3328
|
+
]);
|
|
3329
|
+
const seriesCount = seriesIds.size;
|
|
3330
|
+
const interactionContext = useMemo(() => ({
|
|
3331
|
+
isPointerInspection,
|
|
3332
|
+
activeSeriesId,
|
|
3333
|
+
getCategoryDataKey,
|
|
3334
|
+
seriesCount
|
|
3335
|
+
}), [
|
|
3336
|
+
isPointerInspection,
|
|
3337
|
+
activeSeriesId,
|
|
3338
|
+
getCategoryDataKey,
|
|
3339
|
+
seriesCount
|
|
3340
|
+
]);
|
|
3341
|
+
const activePoint = activeSeriesId == null ? void 0 : points.get(activeSeriesId);
|
|
3342
|
+
const activeSampleContext = useMemo(() => ({
|
|
3343
|
+
activePoint,
|
|
3344
|
+
activeBar
|
|
3345
|
+
}), [activePoint, activeBar]);
|
|
3346
|
+
return /* @__PURE__ */ jsx(ChartCursorChartContext, {
|
|
3347
|
+
value: cursorContext,
|
|
3348
|
+
children: /* @__PURE__ */ jsx(ChartLegendInteractionContext, {
|
|
3349
|
+
value: legendContext,
|
|
3350
|
+
children: /* @__PURE__ */ jsx(ChartInteractionContext, {
|
|
3351
|
+
value: interactionContext,
|
|
3352
|
+
children: /* @__PURE__ */ jsx(ChartActiveSampleContext, {
|
|
3353
|
+
value: activeSampleContext,
|
|
3354
|
+
children: /* @__PURE__ */ jsx("section", {
|
|
3355
|
+
className: classNames("altertable-composed-chart", className),
|
|
3356
|
+
"aria-label": ariaLabel,
|
|
3357
|
+
"data-atbl-internal-pointer-focus": hasPointerFocus || void 0,
|
|
3358
|
+
onPointerDownCapture: (event) => {
|
|
3359
|
+
setHasPointerFocus(trackPointer(event));
|
|
3360
|
+
},
|
|
3361
|
+
onPointerOverCapture: trackPointer,
|
|
3362
|
+
onPointerMoveCapture: trackPointer,
|
|
3363
|
+
onPointerLeave: (event) => {
|
|
3364
|
+
if (event.pointerType !== "touch") resetPointerInspection();
|
|
3365
|
+
},
|
|
3366
|
+
onKeyDownCapture: () => {
|
|
3181
3367
|
setHasPointerFocus(false);
|
|
3182
3368
|
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
|
-
})
|
|
3369
|
+
},
|
|
3370
|
+
onFocusCapture: (event) => {
|
|
3371
|
+
if (event.currentTarget.querySelector("svg[role=\"application\"]")?.contains(event.target)) setSuppressPlotInspection(false);
|
|
3372
|
+
},
|
|
3373
|
+
onBlurCapture: (event) => {
|
|
3374
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
3375
|
+
setHasPointerFocus(false);
|
|
3376
|
+
resetPointerInspection();
|
|
3377
|
+
}
|
|
3378
|
+
},
|
|
3379
|
+
children: /* @__PURE__ */ jsx(ComposedChartPlot, {
|
|
3380
|
+
chartProps: props,
|
|
3381
|
+
registration,
|
|
3382
|
+
focusedLegendKeys,
|
|
3383
|
+
legendHoveredKey,
|
|
3384
|
+
suppressPlotInspection,
|
|
3385
|
+
barAxisByKey,
|
|
3386
|
+
fullAxisSpace,
|
|
3387
|
+
trackPlotOffsets
|
|
3207
3388
|
})
|
|
3208
3389
|
})
|
|
3209
3390
|
})
|
|
@@ -3994,14 +4175,6 @@ function JourneyFlow({ paths, unit, formatValue }) {
|
|
|
3994
4175
|
});
|
|
3995
4176
|
}
|
|
3996
4177
|
//#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 };
|
|
4178
|
+
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
4179
|
|
|
4007
4180
|
//# sourceMappingURL=index.js.map
|