@arbidocs/blocks 0.5.157 → 0.5.158
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/{ConnectedCallDock-TGI43VKB.cjs → ConnectedCallDock-ML4ZTABN.cjs} +27 -27
- package/dist/{ConnectedCallDock-TGI43VKB.cjs.map → ConnectedCallDock-ML4ZTABN.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-FBTDSG3N.cjs → ConnectedCallRoom-GBTP2LT2.cjs} +19 -19
- package/dist/{ConnectedCallRoom-FBTDSG3N.cjs.map → ConnectedCallRoom-GBTP2LT2.cjs.map} +1 -1
- package/dist/{ConnectedMailInviteCard-LV2VARX3.cjs → ConnectedMailInviteCard-VMFTQ5PW.cjs} +5 -5
- package/dist/{ConnectedMailInviteCard-LV2VARX3.cjs.map → ConnectedMailInviteCard-VMFTQ5PW.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-7VD4ZIHO.cjs → ConnectedNativeDocxComparison-JB77U5MF.cjs} +23 -23
- package/dist/{ConnectedNativeDocxComparison-7VD4ZIHO.cjs.map → ConnectedNativeDocxComparison-JB77U5MF.cjs.map} +1 -1
- package/dist/{ConnectedPresentation-FDYO2TSX.cjs → ConnectedPresentation-SQZJG6ZG.cjs} +22 -22
- package/dist/{ConnectedPresentation-FDYO2TSX.cjs.map → ConnectedPresentation-SQZJG6ZG.cjs.map} +1 -1
- package/dist/{ConnectedProductionSetDialog-4N7R7SFZ.cjs → ConnectedProductionSetDialog-7J4T3L6U.cjs} +3 -3
- package/dist/{ConnectedProductionSetDialog-4N7R7SFZ.cjs.map → ConnectedProductionSetDialog-7J4T3L6U.cjs.map} +1 -1
- package/dist/{ConnectedSlidesTab-NM2UEE77.cjs → ConnectedSlidesTab-VLRDE7YI.cjs} +18 -18
- package/dist/{ConnectedSlidesTab-NM2UEE77.cjs.map → ConnectedSlidesTab-VLRDE7YI.cjs.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-ISLZLV4V.cjs → ConnectedStreamedWordArtifact-HL7PQWLF.cjs} +23 -23
- package/dist/{ConnectedStreamedWordArtifact-ISLZLV4V.cjs.map → ConnectedStreamedWordArtifact-HL7PQWLF.cjs.map} +1 -1
- package/dist/{DocumentReviewCard-5CVWGOZQ.cjs → DocumentReviewCard-KYC4PXXF.cjs} +28 -28
- package/dist/{DocumentReviewCard-5CVWGOZQ.cjs.map → DocumentReviewCard-KYC4PXXF.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-PXUXYTPK.cjs → FilesViewerDialog-SHS35TMG.cjs} +63 -63
- package/dist/{FilesViewerDialog-PXUXYTPK.cjs.map → FilesViewerDialog-SHS35TMG.cjs.map} +1 -1
- package/dist/RechartsRenderer-KFHFIEIQ.cjs +347 -0
- package/dist/RechartsRenderer-KFHFIEIQ.cjs.map +1 -0
- package/dist/TimeSeriesDrawing-UHDFZPYG.cjs +166 -0
- package/dist/TimeSeriesDrawing-UHDFZPYG.cjs.map +1 -0
- package/dist/{WorkspaceTableView-HR4KTFSX.cjs → WorkspaceTableView-BO3N2NYC.cjs} +14 -14
- package/dist/{WorkspaceTableView-HR4KTFSX.cjs.map → WorkspaceTableView-BO3N2NYC.cjs.map} +1 -1
- package/dist/agents/index.cjs +385 -385
- package/dist/agents/tasks/WorkflowsTable.js +10 -6
- package/dist/agents/tasks/WorkflowsTable.js.map +2 -2
- package/dist/{ai-HME7CNDE.cjs → ai-NFZHPSS2.cjs} +28 -28
- package/dist/ai-NFZHPSS2.cjs.map +1 -0
- package/dist/auth/index.cjs +2 -2
- package/dist/calendar/index.cjs +106 -106
- package/dist/calls/index.cjs +155 -155
- package/dist/chat/index.cjs +22 -22
- package/dist/{chunk-ST5EZE2O.cjs → chunk-2I7Z3XFC.cjs} +12 -12
- package/dist/{chunk-ST5EZE2O.cjs.map → chunk-2I7Z3XFC.cjs.map} +1 -1
- package/dist/{chunk-NGATAD62.cjs → chunk-2P7VH2SK.cjs} +3 -3
- package/dist/{chunk-NGATAD62.cjs.map → chunk-2P7VH2SK.cjs.map} +1 -1
- package/dist/{chunk-BAZZTZW5.cjs → chunk-2XHJVYNY.cjs} +6 -6
- package/dist/{chunk-BAZZTZW5.cjs.map → chunk-2XHJVYNY.cjs.map} +1 -1
- package/dist/{chunk-PFGRONAI.cjs → chunk-3GQQUR27.cjs} +4 -4
- package/dist/{chunk-PFGRONAI.cjs.map → chunk-3GQQUR27.cjs.map} +1 -1
- package/dist/{chunk-N362DFM4.cjs → chunk-3RAW2ZH5.cjs} +3 -3
- package/dist/{chunk-N362DFM4.cjs.map → chunk-3RAW2ZH5.cjs.map} +1 -1
- package/dist/{chunk-HJDMKDAE.cjs → chunk-4GT4JLKS.cjs} +7 -7
- package/dist/{chunk-HJDMKDAE.cjs.map → chunk-4GT4JLKS.cjs.map} +1 -1
- package/dist/{chunk-KL7R2IBY.cjs → chunk-4M3OIBIS.cjs} +2 -2
- package/dist/{chunk-KL7R2IBY.cjs.map → chunk-4M3OIBIS.cjs.map} +1 -1
- package/dist/{chunk-JUOGNUQR.cjs → chunk-4RR7ZZPD.cjs} +50 -8
- package/dist/chunk-4RR7ZZPD.cjs.map +1 -0
- package/dist/{chunk-GQIH6ALC.cjs → chunk-5AQHL4E3.cjs} +742 -742
- package/dist/chunk-5AQHL4E3.cjs.map +1 -0
- package/dist/{chunk-LZZSCW7D.cjs → chunk-5HPUGSTJ.cjs} +18 -17
- package/dist/chunk-5HPUGSTJ.cjs.map +1 -0
- package/dist/{chunk-5NWTA4Y4.cjs → chunk-6AFAYGJW.cjs} +5 -5
- package/dist/{chunk-5NWTA4Y4.cjs.map → chunk-6AFAYGJW.cjs.map} +1 -1
- package/dist/{chunk-AVXJSCRN.cjs → chunk-AEAK3ZBS.cjs} +60 -8
- package/dist/chunk-AEAK3ZBS.cjs.map +1 -0
- package/dist/{chunk-IDV6I7GX.cjs → chunk-ATHPGGUH.cjs} +51 -51
- package/dist/{chunk-IDV6I7GX.cjs.map → chunk-ATHPGGUH.cjs.map} +1 -1
- package/dist/{chunk-WQ2KG4LS.cjs → chunk-BCU65RJM.cjs} +3 -3
- package/dist/{chunk-WQ2KG4LS.cjs.map → chunk-BCU65RJM.cjs.map} +1 -1
- package/dist/{chunk-KZFE65SA.cjs → chunk-C6EMTQHQ.cjs} +12 -12
- package/dist/{chunk-KZFE65SA.cjs.map → chunk-C6EMTQHQ.cjs.map} +1 -1
- package/dist/{chunk-4ZC6YLVQ.cjs → chunk-CMPCSONE.cjs} +4 -4
- package/dist/{chunk-4ZC6YLVQ.cjs.map → chunk-CMPCSONE.cjs.map} +1 -1
- package/dist/{chunk-L2Q2UHRY.cjs → chunk-CULUTYOD.cjs} +4 -4
- package/dist/{chunk-L2Q2UHRY.cjs.map → chunk-CULUTYOD.cjs.map} +1 -1
- package/dist/{chunk-K4SFQPOF.cjs → chunk-D4SJT3NG.cjs} +3 -3
- package/dist/{chunk-K4SFQPOF.cjs.map → chunk-D4SJT3NG.cjs.map} +1 -1
- package/dist/{chunk-7WENPOCP.cjs → chunk-DN6VM5M5.cjs} +6 -6
- package/dist/{chunk-7WENPOCP.cjs.map → chunk-DN6VM5M5.cjs.map} +1 -1
- package/dist/{chunk-U4YOVI5D.cjs → chunk-FDIZWCYF.cjs} +6 -6
- package/dist/{chunk-U4YOVI5D.cjs.map → chunk-FDIZWCYF.cjs.map} +1 -1
- package/dist/{chunk-UYBTXYYW.cjs → chunk-FX5TZ6JU.cjs} +16 -12
- package/dist/chunk-FX5TZ6JU.cjs.map +1 -0
- package/dist/{chunk-LFO3HNBX.cjs → chunk-GHPLRXB4.cjs} +34 -34
- package/dist/{chunk-LFO3HNBX.cjs.map → chunk-GHPLRXB4.cjs.map} +1 -1
- package/dist/{chunk-KIXB7V7A.cjs → chunk-GOKS55KC.cjs} +28 -28
- package/dist/{chunk-KIXB7V7A.cjs.map → chunk-GOKS55KC.cjs.map} +1 -1
- package/dist/{chunk-C4JRUDAY.cjs → chunk-GP4UC2K4.cjs} +12 -12
- package/dist/{chunk-C4JRUDAY.cjs.map → chunk-GP4UC2K4.cjs.map} +1 -1
- package/dist/{chunk-WKIESVWJ.cjs → chunk-HKKNHHBB.cjs} +6 -6
- package/dist/{chunk-WKIESVWJ.cjs.map → chunk-HKKNHHBB.cjs.map} +1 -1
- package/dist/{chunk-YPNGDJLX.cjs → chunk-IO3MNT4N.cjs} +4 -4
- package/dist/{chunk-YPNGDJLX.cjs.map → chunk-IO3MNT4N.cjs.map} +1 -1
- package/dist/{chunk-FQXZZXS2.cjs → chunk-JEHGTPS2.cjs} +5 -5
- package/dist/{chunk-FQXZZXS2.cjs.map → chunk-JEHGTPS2.cjs.map} +1 -1
- package/dist/{chunk-KJ65QZJI.cjs → chunk-KAKEFIDS.cjs} +13 -13
- package/dist/{chunk-KJ65QZJI.cjs.map → chunk-KAKEFIDS.cjs.map} +1 -1
- package/dist/{chunk-JXKUWLFZ.cjs → chunk-KMMKGJPX.cjs} +4 -4
- package/dist/{chunk-JXKUWLFZ.cjs.map → chunk-KMMKGJPX.cjs.map} +1 -1
- package/dist/{chunk-UYTFPMEA.cjs → chunk-LK4TQBV6.cjs} +9 -9
- package/dist/{chunk-UYTFPMEA.cjs.map → chunk-LK4TQBV6.cjs.map} +1 -1
- package/dist/{chunk-BCCMCR2U.cjs → chunk-MQS2PCCN.cjs} +67 -67
- package/dist/{chunk-BCCMCR2U.cjs.map → chunk-MQS2PCCN.cjs.map} +1 -1
- package/dist/{chunk-Q6ASMKFN.cjs → chunk-N2YOVDEN.cjs} +19 -19
- package/dist/{chunk-Q6ASMKFN.cjs.map → chunk-N2YOVDEN.cjs.map} +1 -1
- package/dist/{chunk-CZCSDIQY.cjs → chunk-NBKYVMAK.cjs} +4 -4
- package/dist/{chunk-CZCSDIQY.cjs.map → chunk-NBKYVMAK.cjs.map} +1 -1
- package/dist/{chunk-PA5CCOBU.cjs → chunk-NGM4HIPP.cjs} +140 -140
- package/dist/chunk-NGM4HIPP.cjs.map +1 -0
- package/dist/{chunk-GTWCDGXH.cjs → chunk-NPY5XQSN.cjs} +4 -4
- package/dist/{chunk-GTWCDGXH.cjs.map → chunk-NPY5XQSN.cjs.map} +1 -1
- package/dist/{chunk-7SJXYEZI.cjs → chunk-OAIOOVFN.cjs} +36 -36
- package/dist/chunk-OAIOOVFN.cjs.map +1 -0
- package/dist/{chunk-LBYJUPMV.cjs → chunk-P4KNRU7Y.cjs} +71 -71
- package/dist/{chunk-LBYJUPMV.cjs.map → chunk-P4KNRU7Y.cjs.map} +1 -1
- package/dist/{chunk-ZJ4P5QE5.cjs → chunk-PC2ZGCSX.cjs} +37 -37
- package/dist/{chunk-ZJ4P5QE5.cjs.map → chunk-PC2ZGCSX.cjs.map} +1 -1
- package/dist/{chunk-QA2MTHMN.cjs → chunk-QAPDDRE4.cjs} +80 -80
- package/dist/{chunk-QA2MTHMN.cjs.map → chunk-QAPDDRE4.cjs.map} +1 -1
- package/dist/{chunk-PBPO54KZ.cjs → chunk-QEMGGJB6.cjs} +97 -5
- package/dist/chunk-QEMGGJB6.cjs.map +1 -0
- package/dist/chunk-S3UNLRVM.cjs +87 -0
- package/dist/chunk-S3UNLRVM.cjs.map +1 -0
- package/dist/{chunk-PDDC5JOE.cjs → chunk-SGYURQ23.cjs} +10 -10
- package/dist/{chunk-PDDC5JOE.cjs.map → chunk-SGYURQ23.cjs.map} +1 -1
- package/dist/{chunk-RLRDQICM.cjs → chunk-SH7W4WVI.cjs} +103 -104
- package/dist/chunk-SH7W4WVI.cjs.map +1 -0
- package/dist/{chunk-C2VVBU7K.cjs → chunk-SLCH5JRI.cjs} +3 -3
- package/dist/{chunk-C2VVBU7K.cjs.map → chunk-SLCH5JRI.cjs.map} +1 -1
- package/dist/{chunk-RI367OOL.cjs → chunk-UEQNTXWV.cjs} +3 -3
- package/dist/{chunk-RI367OOL.cjs.map → chunk-UEQNTXWV.cjs.map} +1 -1
- package/dist/{chunk-PIWXX2M4.cjs → chunk-UOE6VC36.cjs} +11 -11
- package/dist/{chunk-PIWXX2M4.cjs.map → chunk-UOE6VC36.cjs.map} +1 -1
- package/dist/{chunk-DYIZ7W4P.cjs → chunk-VBSEYTRN.cjs} +3 -3
- package/dist/{chunk-DYIZ7W4P.cjs.map → chunk-VBSEYTRN.cjs.map} +1 -1
- package/dist/{chunk-LLVE5TST.cjs → chunk-VJRO6J37.cjs} +3 -3
- package/dist/{chunk-LLVE5TST.cjs.map → chunk-VJRO6J37.cjs.map} +1 -1
- package/dist/{chunk-I3GFGJSX.cjs → chunk-XBZP5J24.cjs} +7 -7
- package/dist/{chunk-I3GFGJSX.cjs.map → chunk-XBZP5J24.cjs.map} +1 -1
- package/dist/{chunk-JARBYN6Z.cjs → chunk-Y3OI7ZP7.cjs} +3 -3
- package/dist/{chunk-JARBYN6Z.cjs.map → chunk-Y3OI7ZP7.cjs.map} +1 -1
- package/dist/{chunk-JB26AJ2L.cjs → chunk-YFO2VHYQ.cjs} +139 -48
- package/dist/chunk-YFO2VHYQ.cjs.map +1 -0
- package/dist/{chunk-FV6AKSI7.cjs → chunk-YHXJWYOF.cjs} +4 -4
- package/dist/{chunk-FV6AKSI7.cjs.map → chunk-YHXJWYOF.cjs.map} +1 -1
- package/dist/collaboration/index.cjs +13 -13
- package/dist/connect/docx.cjs +26 -26
- package/dist/connect/index.cjs +1461 -1532
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/viewer.cjs +51 -51
- package/dist/connection/dashboards/DashboardPanel.js +1 -1
- package/dist/connection/dashboards/DashboardPanel.js.map +2 -2
- package/dist/connection/dashboards/PanelEditor.d.ts +4 -0
- package/dist/connection/dashboards/PanelEditor.js +45 -3
- package/dist/connection/dashboards/PanelEditor.js.map +2 -2
- package/dist/connection/export/ConnectedExportPanel.js +12 -7
- package/dist/connection/export/ConnectedExportPanel.js.map +2 -2
- package/dist/connection/export/transfer-text.d.ts +5 -0
- package/dist/connection/export/transfer-text.js +6 -1
- package/dist/connection/export/transfer-text.js.map +2 -2
- package/dist/connection/pages/PageTransferDialog.js +19 -2
- package/dist/connection/pages/PageTransferDialog.js.map +2 -2
- package/dist/dashboards/ChartRenderer.js +3 -2
- package/dist/dashboards/ChartRenderer.js.map +2 -2
- package/dist/dashboards/RechartsRenderer.js +171 -2
- package/dist/dashboards/RechartsRenderer.js.map +2 -2
- package/dist/dashboards/chartModel.d.ts +52 -2
- package/dist/dashboards/chartModel.js +95 -3
- package/dist/dashboards/chartModel.js.map +2 -2
- package/dist/dashboards/index.cjs +774 -25
- package/dist/dashboards/index.cjs.map +1 -1
- package/dist/dashboards/index.d.ts +3 -2
- package/dist/dashboards/index.js +9 -2
- package/dist/dashboards/index.js.map +2 -2
- package/dist/dashboards/monitor/LogViewer.d.ts +47 -0
- package/dist/dashboards/monitor/LogViewer.js +279 -0
- package/dist/dashboards/monitor/LogViewer.js.map +7 -0
- package/dist/dashboards/monitor/RequestTimeline.d.ts +68 -0
- package/dist/dashboards/monitor/RequestTimeline.js +228 -0
- package/dist/dashboards/monitor/RequestTimeline.js.map +7 -0
- package/dist/dashboards/monitor/StackedBar.d.ts +41 -0
- package/dist/dashboards/monitor/StackedBar.js +131 -0
- package/dist/dashboards/monitor/StackedBar.js.map +7 -0
- package/dist/dashboards/monitor/TimeSeriesChart.d.ts +60 -0
- package/dist/dashboards/monitor/TimeSeriesChart.js +116 -0
- package/dist/dashboards/monitor/TimeSeriesChart.js.map +7 -0
- package/dist/dashboards/monitor/TimeSeriesDrawing.d.ts +14 -0
- package/dist/dashboards/monitor/TimeSeriesDrawing.js +173 -0
- package/dist/dashboards/monitor/TimeSeriesDrawing.js.map +7 -0
- package/dist/dashboards/monitor/index.d.ts +10 -0
- package/dist/dashboards/monitor/index.js +44 -0
- package/dist/dashboards/monitor/index.js.map +7 -0
- package/dist/dashboards/monitor/units.d.ts +30 -0
- package/dist/dashboards/monitor/units.js +85 -0
- package/dist/dashboards/monitor/units.js.map +7 -0
- package/dist/document-tools/index.cjs +21 -21
- package/dist/embed/index.cjs +55 -55
- package/dist/facts/index.cjs +65 -65
- package/dist/files/TransferParts.d.ts +18 -1
- package/dist/files/TransferParts.js +55 -3
- package/dist/files/TransferParts.js.map +2 -2
- package/dist/files/index.cjs +235 -231
- package/dist/files/index.d.ts +1 -1
- package/dist/files/index.js +2 -0
- package/dist/files/index.js.map +2 -2
- package/dist/home/index.cjs +24 -24
- package/dist/index.cjs +1869 -1869
- package/dist/pages/index.cjs +66 -51
- package/dist/pages/index.cjs.map +1 -1
- package/dist/settings/index.cjs +141 -141
- package/dist/shell/index.cjs +81 -81
- package/dist/site/index.cjs +5 -5
- package/dist/studio/index.cjs +44 -44
- package/dist/studio/index.cjs.map +1 -1
- package/dist/studio/widgets.js +1 -1
- package/dist/studio/widgets.js.map +2 -2
- package/dist/styles.css +1 -1
- package/dist/workflow-canvas/index.cjs +77 -77
- package/dist/workspaces/index.cjs +9 -9
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/dist/RechartsRenderer-EPVL5QZA.cjs +0 -186
- package/dist/RechartsRenderer-EPVL5QZA.cjs.map +0 -1
- package/dist/ai-HME7CNDE.cjs.map +0 -1
- package/dist/chunk-7SJXYEZI.cjs.map +0 -1
- package/dist/chunk-AVXJSCRN.cjs.map +0 -1
- package/dist/chunk-GQIH6ALC.cjs.map +0 -1
- package/dist/chunk-JB26AJ2L.cjs.map +0 -1
- package/dist/chunk-JUOGNUQR.cjs.map +0 -1
- package/dist/chunk-LZZSCW7D.cjs.map +0 -1
- package/dist/chunk-PA5CCOBU.cjs.map +0 -1
- package/dist/chunk-PBPO54KZ.cjs.map +0 -1
- package/dist/chunk-RLRDQICM.cjs.map +0 -1
- package/dist/chunk-UYBTXYYW.cjs.map +0 -1
|
@@ -9,13 +9,21 @@ import {
|
|
|
9
9
|
Cell,
|
|
10
10
|
Line,
|
|
11
11
|
LineChart,
|
|
12
|
+
LabelList,
|
|
12
13
|
Pie,
|
|
13
14
|
PieChart,
|
|
15
|
+
ReferenceLine,
|
|
16
|
+
Scatter,
|
|
17
|
+
ScatterChart,
|
|
14
18
|
Tooltip,
|
|
15
19
|
XAxis,
|
|
16
20
|
YAxis
|
|
17
21
|
} from "recharts";
|
|
18
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
HIGHLIGHT_COLOR,
|
|
24
|
+
sliceColors,
|
|
25
|
+
valueAxisWidth
|
|
26
|
+
} from "./chartModel.js";
|
|
19
27
|
const AXIS_TICK = { fill: "hsl(var(--muted-foreground))", fontSize: 11 };
|
|
20
28
|
const MARGIN = { top: 8, right: 8, bottom: 0, left: 0 };
|
|
21
29
|
function ChartTooltip({
|
|
@@ -41,6 +49,163 @@ function ChartTooltip({
|
|
|
41
49
|
] }, i))
|
|
42
50
|
] });
|
|
43
51
|
}
|
|
52
|
+
function PointTooltip({
|
|
53
|
+
active,
|
|
54
|
+
payload,
|
|
55
|
+
model,
|
|
56
|
+
scatter
|
|
57
|
+
}) {
|
|
58
|
+
const point = payload?.[0]?.payload;
|
|
59
|
+
if (!active || !point) return null;
|
|
60
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground shadow-md", children: [
|
|
61
|
+
/* @__PURE__ */ jsx("div", { className: "mb-0.5 font-medium", children: point.label }),
|
|
62
|
+
[
|
|
63
|
+
[model.xLabel, scatter.formatX(point.x)],
|
|
64
|
+
[model.valueLabel, model.format(point.y)]
|
|
65
|
+
].map(([name, value]) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
66
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: name }),
|
|
67
|
+
/* @__PURE__ */ jsx("span", { className: "ml-auto pl-2 font-medium tabular-nums", children: value })
|
|
68
|
+
] }, name))
|
|
69
|
+
] });
|
|
70
|
+
}
|
|
71
|
+
const MAX_LABELLED_POINTS = 15;
|
|
72
|
+
function ScatterPlot({
|
|
73
|
+
model,
|
|
74
|
+
scatter,
|
|
75
|
+
ariaLabel,
|
|
76
|
+
style
|
|
77
|
+
}) {
|
|
78
|
+
const all = scatter.points.length <= MAX_LABELLED_POINTS;
|
|
79
|
+
const data = scatter.points.map((p) => ({
|
|
80
|
+
...p,
|
|
81
|
+
shown: all || p.highlighted || p.frontier ? p.label : ""
|
|
82
|
+
}));
|
|
83
|
+
const frontierColor = "hsl(var(--foreground))";
|
|
84
|
+
return /* @__PURE__ */ jsxs(
|
|
85
|
+
ScatterChart,
|
|
86
|
+
{
|
|
87
|
+
responsive: true,
|
|
88
|
+
style,
|
|
89
|
+
margin: { top: 16, right: 56, bottom: 16, left: 0 },
|
|
90
|
+
accessibilityLayer: true,
|
|
91
|
+
title: ariaLabel,
|
|
92
|
+
desc: ariaLabel,
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ jsx(CartesianGrid, { stroke: "hsl(var(--border))", strokeDasharray: "2 2" }),
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
XAxis,
|
|
97
|
+
{
|
|
98
|
+
type: "number",
|
|
99
|
+
dataKey: "x",
|
|
100
|
+
name: model.xLabel,
|
|
101
|
+
scale: scatter.xScale,
|
|
102
|
+
domain: scatter.xDomain ?? [0, "auto"],
|
|
103
|
+
ticks: scatter.xTicks ?? void 0,
|
|
104
|
+
allowDataOverflow: false,
|
|
105
|
+
tick: AXIS_TICK,
|
|
106
|
+
tickLine: false,
|
|
107
|
+
axisLine: { stroke: "hsl(var(--border))" },
|
|
108
|
+
tickFormatter: (v) => scatter.formatXTick(v),
|
|
109
|
+
label: {
|
|
110
|
+
value: model.xLabel,
|
|
111
|
+
position: "insideBottom",
|
|
112
|
+
offset: -12,
|
|
113
|
+
fill: "hsl(var(--muted-foreground))",
|
|
114
|
+
fontSize: 11
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ jsx(
|
|
119
|
+
YAxis,
|
|
120
|
+
{
|
|
121
|
+
type: "number",
|
|
122
|
+
dataKey: "y",
|
|
123
|
+
name: model.valueLabel,
|
|
124
|
+
tick: AXIS_TICK,
|
|
125
|
+
tickLine: false,
|
|
126
|
+
axisLine: false,
|
|
127
|
+
width: valueAxisWidth(model),
|
|
128
|
+
allowDecimals: !model.integer,
|
|
129
|
+
tickFormatter: (v) => model.formatTick(v),
|
|
130
|
+
label: {
|
|
131
|
+
value: model.valueLabel,
|
|
132
|
+
angle: -90,
|
|
133
|
+
position: "insideLeft",
|
|
134
|
+
fill: "hsl(var(--muted-foreground))",
|
|
135
|
+
fontSize: 11
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
scatter.quadrants && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
ReferenceLine,
|
|
142
|
+
{
|
|
143
|
+
x: scatter.quadrants.x,
|
|
144
|
+
stroke: "hsl(var(--muted-foreground))",
|
|
145
|
+
strokeDasharray: "4 4",
|
|
146
|
+
strokeOpacity: 0.6
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
/* @__PURE__ */ jsx(
|
|
150
|
+
ReferenceLine,
|
|
151
|
+
{
|
|
152
|
+
y: scatter.quadrants.y,
|
|
153
|
+
stroke: "hsl(var(--muted-foreground))",
|
|
154
|
+
strokeDasharray: "4 4",
|
|
155
|
+
strokeOpacity: 0.6
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
] }),
|
|
159
|
+
/* @__PURE__ */ jsx(
|
|
160
|
+
Tooltip,
|
|
161
|
+
{
|
|
162
|
+
cursor: false,
|
|
163
|
+
content: ({ active, payload }) => /* @__PURE__ */ jsx(
|
|
164
|
+
PointTooltip,
|
|
165
|
+
{
|
|
166
|
+
active,
|
|
167
|
+
payload,
|
|
168
|
+
model,
|
|
169
|
+
scatter
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
),
|
|
174
|
+
scatter.frontier.length > 1 && /* @__PURE__ */ jsx(
|
|
175
|
+
Scatter,
|
|
176
|
+
{
|
|
177
|
+
data: scatter.frontier,
|
|
178
|
+
line: { stroke: frontierColor, strokeWidth: 1.5, strokeOpacity: 0.7 },
|
|
179
|
+
shape: () => /* @__PURE__ */ jsx("g", {}),
|
|
180
|
+
legendType: "none",
|
|
181
|
+
tooltipType: "none",
|
|
182
|
+
isAnimationActive: false
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
/* @__PURE__ */ jsxs(Scatter, { data, isAnimationActive: false, children: [
|
|
186
|
+
data.map((p) => /* @__PURE__ */ jsx(
|
|
187
|
+
Cell,
|
|
188
|
+
{
|
|
189
|
+
fill: p.highlighted ? HIGHLIGHT_COLOR : model.series[1]?.color ?? HIGHLIGHT_COLOR,
|
|
190
|
+
stroke: p.frontier ? frontierColor : "none",
|
|
191
|
+
strokeWidth: p.frontier ? 1.5 : 0
|
|
192
|
+
},
|
|
193
|
+
p.label
|
|
194
|
+
)),
|
|
195
|
+
/* @__PURE__ */ jsx(
|
|
196
|
+
LabelList,
|
|
197
|
+
{
|
|
198
|
+
dataKey: "shown",
|
|
199
|
+
position: "top",
|
|
200
|
+
fill: "hsl(var(--muted-foreground))",
|
|
201
|
+
fontSize: 10
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
] })
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
}
|
|
44
209
|
function RechartsRenderer({
|
|
45
210
|
model,
|
|
46
211
|
ariaLabel,
|
|
@@ -68,6 +233,9 @@ function RechartsRenderer({
|
|
|
68
233
|
}
|
|
69
234
|
)
|
|
70
235
|
);
|
|
236
|
+
if (model.type === "scatter" && model.scatter) {
|
|
237
|
+
return /* @__PURE__ */ jsx(ScatterPlot, { model, scatter: model.scatter, ariaLabel, style });
|
|
238
|
+
}
|
|
71
239
|
if (model.type === "pie" || model.type === "donut") {
|
|
72
240
|
const colors = sliceColors(model, otherLabel);
|
|
73
241
|
const data2 = model.categories.map((name, i) => ({
|
|
@@ -147,7 +315,8 @@ function RechartsRenderer({
|
|
|
147
315
|
stackId,
|
|
148
316
|
radius: model.stacked ? 0 : [3, 3, 0, 0],
|
|
149
317
|
maxBarSize: 48,
|
|
150
|
-
isAnimationActive: false
|
|
318
|
+
isAnimationActive: false,
|
|
319
|
+
children: model.highlighted?.map((on, i) => /* @__PURE__ */ jsx(Cell, { fill: on ? HIGHLIGHT_COLOR : s.color }, i))
|
|
151
320
|
},
|
|
152
321
|
s.id
|
|
153
322
|
))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/dashboards/RechartsRenderer.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * The renderer adapter's second half: a `ChartModel` drawn with Recharts (MIT). Loaded on demand\n * (`ChartRenderer` imports it lazily), so the library is fetched only when a chart is shown. Nothing\n * of Recharts leaves this file: the props are the package's own `ChartModel`.\n *\n * Colours are the theme's `--chart-1..5` tokens and the axes, grid and tooltip use the theme's\n * surface and text tokens, so a chart follows the host theme in light and dark. Recharts'\n * accessibility layer makes the plot focusable: the arrow keys move the tooltip between categories.\n */\nimport {\n Area,\n AreaChart,\n Bar,\n BarChart,\n CartesianGrid,\n Cell,\n Line,\n LineChart,\n Pie,\n PieChart,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts'\nimport { sliceColors, valueAxisWidth, type ChartModel } from './chartModel'\n\nexport interface RechartsRendererProps {\n model: ChartModel\n ariaLabel: string\n /** In px, or a CSS length (`100%`: the box it is drawn in). */\n height: number | string\n otherLabel?: string\n}\n\nconst AXIS_TICK = { fill: 'hsl(var(--muted-foreground))', fontSize: 11 }\nconst MARGIN = { top: 8, right: 8, bottom: 0, left: 0 }\n\ninterface TooltipEntry {\n name?: string | number\n value?: unknown\n color?: string\n payload?: { fill?: string }\n}\n\n/** What the library hands a tooltip's content (the part this renderer reads). */\ninterface TooltipContent {\n active?: boolean\n label?: unknown\n payload?: readonly unknown[]\n}\n\n/** The tooltip, in the theme's popover colours (never the library's white box in dark mode). */\nfunction ChartTooltip({\n active,\n label,\n payload,\n format,\n}: {\n active?: boolean\n label?: unknown\n payload?: readonly TooltipEntry[]\n format: (v: number) => string\n}) {\n if (!active || !payload?.length) return null\n return (\n <div className=\"rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground shadow-md\">\n {label !== undefined && label !== '' && (\n <div className=\"mb-0.5 font-medium\">{String(label)}</div>\n )}\n {payload.map((entry, i) => (\n <div key={i} className=\"flex items-center gap-1.5\">\n <span\n aria-hidden=\"true\"\n className=\"inline-block size-2 rounded-full\"\n style={{ background: entry.color ?? entry.payload?.fill }}\n />\n <span className=\"text-muted-foreground\">{String(entry.name ?? '')}</span>\n <span className=\"ml-auto pl-2 font-medium tabular-nums\">\n {typeof entry.value === 'number' ? format(entry.value) : '\u2013'}\n </span>\n </div>\n ))}\n </div>\n )\n}\n\nexport default function RechartsRenderer({\n model,\n ariaLabel,\n height,\n otherLabel,\n}: RechartsRendererProps) {\n const style = { width: '100%', height }\n const tooltip = (\n // No hover cursor: a chart is read, not clicked, so the band behind the hovered category (a\n // shaded, dash-outlined cut-out) only suggested an action that is not there. The tooltip and\n // a line's active dot still show the value.\n <Tooltip\n cursor={false}\n content={({ active, label, payload }: TooltipContent) => (\n <ChartTooltip\n active={active}\n label={label}\n payload={payload as readonly TooltipEntry[] | undefined}\n format={model.format}\n />\n )}\n />\n )\n\n if (model.type === 'pie' || model.type === 'donut') {\n const colors = sliceColors(model, otherLabel)\n const data = model.categories.map((name, i) => ({\n name,\n value: Math.max(model.series[0]?.values[i] ?? 0, 0),\n }))\n return (\n <PieChart responsive style={style} accessibilityLayer title={ariaLabel} desc={ariaLabel}>\n <Pie\n data={data}\n dataKey=\"value\"\n nameKey=\"name\"\n innerRadius={model.type === 'donut' ? '55%' : 0}\n outerRadius=\"85%\"\n stroke=\"hsl(var(--card))\"\n strokeWidth={2}\n isAnimationActive={false}\n >\n {data.map((d, i) => (\n <Cell key={d.name} fill={colors[i]} />\n ))}\n </Pie>\n {tooltip}\n </PieChart>\n )\n }\n\n // Series keys are positional: labels may hold dots, which the library reads as paths.\n const data = model.categories.map((category, i) => {\n const row: Record<string, string | number | null> = { category }\n model.series.forEach((s, si) => {\n row[`s${si}`] = s.values[i]\n })\n return row\n })\n const stackId = model.stacked ? 'stack' : undefined\n const axes = (\n <>\n <CartesianGrid vertical={false} stroke=\"hsl(var(--border))\" strokeDasharray=\"2 2\" />\n <XAxis\n dataKey=\"category\"\n tick={AXIS_TICK}\n tickLine={false}\n axisLine={{ stroke: 'hsl(var(--border))' }}\n interval=\"preserveStartEnd\"\n minTickGap={8}\n />\n <YAxis\n tick={AXIS_TICK}\n tickLine={false}\n axisLine={false}\n width={valueAxisWidth(model)}\n allowDecimals={!model.integer}\n tickFormatter={(v: number) => model.formatTick(v)}\n />\n {tooltip}\n </>\n )\n const common = {\n data,\n responsive: true,\n style,\n margin: MARGIN,\n accessibilityLayer: true,\n title: ariaLabel,\n desc: ariaLabel,\n }\n\n if (model.type === 'bar') {\n return (\n <BarChart {...common}>\n {axes}\n {model.series.map((s, si) => (\n <Bar\n key={s.id}\n dataKey={`s${si}`}\n name={s.label}\n fill={s.color}\n stackId={stackId}\n radius={model.stacked ? 0 : [3, 3, 0, 0]}\n maxBarSize={48}\n isAnimationActive={false}\n />\n ))}\n </BarChart>\n )\n }\n if (model.type === 'area') {\n return (\n <AreaChart {...common}>\n {axes}\n {model.series.map((s, si) => (\n <Area\n key={s.id}\n type=\"monotone\"\n dataKey={`s${si}`}\n name={s.label}\n stroke={s.color}\n fill={s.color}\n fillOpacity={model.stacked ? 0.55 : 0.2}\n strokeWidth={2}\n stackId={stackId}\n isAnimationActive={false}\n />\n ))}\n </AreaChart>\n )\n }\n return (\n <LineChart {...common}>\n {axes}\n {model.series.map((s, si) => (\n <Line\n key={s.id}\n type=\"monotone\"\n dataKey={`s${si}`}\n name={s.label}\n stroke={s.color}\n strokeWidth={2}\n dot={model.categories.length <= 12 ? { r: 3, fill: s.color, strokeWidth: 0 } : false}\n activeDot={{ r: 4 }}\n isAnimationActive={false}\n />\n ))}\n </LineChart>\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * The renderer adapter's second half: a `ChartModel` drawn with Recharts (MIT). Loaded on demand\n * (`ChartRenderer` imports it lazily), so the library is fetched only when a chart is shown. Nothing\n * of Recharts leaves this file: the props are the package's own `ChartModel`.\n *\n * Colours are the theme's `--chart-1..5` tokens and the axes, grid and tooltip use the theme's\n * surface and text tokens, so a chart follows the host theme in light and dark. Recharts'\n * accessibility layer makes the plot focusable: the arrow keys move the tooltip between categories.\n */\nimport {\n Area,\n AreaChart,\n Bar,\n BarChart,\n CartesianGrid,\n Cell,\n Line,\n LineChart,\n LabelList,\n Pie,\n PieChart,\n ReferenceLine,\n Scatter,\n ScatterChart,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts'\nimport {\n HIGHLIGHT_COLOR,\n sliceColors,\n valueAxisWidth,\n type ChartModel,\n type ChartPoint,\n type ScatterModel,\n} from './chartModel'\n\nexport interface RechartsRendererProps {\n model: ChartModel\n ariaLabel: string\n /** In px, or a CSS length (`100%`: the box it is drawn in). */\n height: number | string\n otherLabel?: string\n}\n\nconst AXIS_TICK = { fill: 'hsl(var(--muted-foreground))', fontSize: 11 }\nconst MARGIN = { top: 8, right: 8, bottom: 0, left: 0 }\n\ninterface TooltipEntry {\n name?: string | number\n value?: unknown\n color?: string\n payload?: { fill?: string }\n}\n\n/** What the library hands a tooltip's content (the part this renderer reads). */\ninterface TooltipContent {\n active?: boolean\n label?: unknown\n payload?: readonly unknown[]\n}\n\n/** The tooltip, in the theme's popover colours (never the library's white box in dark mode). */\nfunction ChartTooltip({\n active,\n label,\n payload,\n format,\n}: {\n active?: boolean\n label?: unknown\n payload?: readonly TooltipEntry[]\n format: (v: number) => string\n}) {\n if (!active || !payload?.length) return null\n return (\n <div className=\"rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground shadow-md\">\n {label !== undefined && label !== '' && (\n <div className=\"mb-0.5 font-medium\">{String(label)}</div>\n )}\n {payload.map((entry, i) => (\n <div key={i} className=\"flex items-center gap-1.5\">\n <span\n aria-hidden=\"true\"\n className=\"inline-block size-2 rounded-full\"\n style={{ background: entry.color ?? entry.payload?.fill }}\n />\n <span className=\"text-muted-foreground\">{String(entry.name ?? '')}</span>\n <span className=\"ml-auto pl-2 font-medium tabular-nums\">\n {typeof entry.value === 'number' ? format(entry.value) : '\u2013'}\n </span>\n </div>\n ))}\n </div>\n )\n}\n\n/** A scatter point's tooltip: its label, then x and y in their own formats. */\nfunction PointTooltip({\n active,\n payload,\n model,\n scatter,\n}: {\n active?: boolean\n payload?: readonly { payload?: unknown }[]\n model: ChartModel\n scatter: ScatterModel\n}) {\n const point = payload?.[0]?.payload as ChartPoint | undefined\n if (!active || !point) return null\n return (\n <div className=\"rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground shadow-md\">\n <div className=\"mb-0.5 font-medium\">{point.label}</div>\n {(\n [\n [model.xLabel, scatter.formatX(point.x)],\n [model.valueLabel, model.format(point.y)],\n ] as const\n ).map(([name, value]) => (\n <div key={name} className=\"flex items-center gap-1.5\">\n <span className=\"text-muted-foreground\">{name}</span>\n <span className=\"ml-auto pl-2 font-medium tabular-nums\">{value}</span>\n </div>\n ))}\n </div>\n )\n}\n\n/** Points are labelled when there are few; otherwise only highlighted and frontier points are. */\nconst MAX_LABELLED_POINTS = 15\n\nfunction ScatterPlot({\n model,\n scatter,\n ariaLabel,\n style,\n}: {\n model: ChartModel\n scatter: ScatterModel\n ariaLabel: string\n style: { width: string; height: number | string }\n}) {\n const all = scatter.points.length <= MAX_LABELLED_POINTS\n const data = scatter.points.map((p) => ({\n ...p,\n shown: all || p.highlighted || p.frontier ? p.label : '',\n }))\n const frontierColor = 'hsl(var(--foreground))'\n return (\n <ScatterChart\n responsive\n style={style}\n // Room on the right for the labels of the rightmost points.\n margin={{ top: 16, right: 56, bottom: 16, left: 0 }}\n accessibilityLayer\n title={ariaLabel}\n desc={ariaLabel}\n >\n <CartesianGrid stroke=\"hsl(var(--border))\" strokeDasharray=\"2 2\" />\n <XAxis\n type=\"number\"\n dataKey=\"x\"\n name={model.xLabel}\n scale={scatter.xScale}\n domain={scatter.xDomain ?? [0, 'auto']}\n ticks={scatter.xTicks ?? undefined}\n allowDataOverflow={false}\n tick={AXIS_TICK}\n tickLine={false}\n axisLine={{ stroke: 'hsl(var(--border))' }}\n tickFormatter={(v: number) => scatter.formatXTick(v)}\n label={{\n value: model.xLabel,\n position: 'insideBottom',\n offset: -12,\n fill: 'hsl(var(--muted-foreground))',\n fontSize: 11,\n }}\n />\n <YAxis\n type=\"number\"\n dataKey=\"y\"\n name={model.valueLabel}\n tick={AXIS_TICK}\n tickLine={false}\n axisLine={false}\n width={valueAxisWidth(model)}\n allowDecimals={!model.integer}\n tickFormatter={(v: number) => model.formatTick(v)}\n label={{\n value: model.valueLabel,\n angle: -90,\n position: 'insideLeft',\n fill: 'hsl(var(--muted-foreground))',\n fontSize: 11,\n }}\n />\n {scatter.quadrants && (\n <>\n <ReferenceLine\n x={scatter.quadrants.x}\n stroke=\"hsl(var(--muted-foreground))\"\n strokeDasharray=\"4 4\"\n strokeOpacity={0.6}\n />\n <ReferenceLine\n y={scatter.quadrants.y}\n stroke=\"hsl(var(--muted-foreground))\"\n strokeDasharray=\"4 4\"\n strokeOpacity={0.6}\n />\n </>\n )}\n <Tooltip\n cursor={false}\n content={({ active, payload }: TooltipContent) => (\n <PointTooltip\n active={active}\n payload={payload as readonly { payload?: unknown }[] | undefined}\n model={model}\n scatter={scatter}\n />\n )}\n />\n {scatter.frontier.length > 1 && (\n <Scatter\n data={scatter.frontier}\n line={{ stroke: frontierColor, strokeWidth: 1.5, strokeOpacity: 0.7 }}\n shape={() => <g />}\n legendType=\"none\"\n tooltipType=\"none\"\n isAnimationActive={false}\n />\n )}\n <Scatter data={data} isAnimationActive={false}>\n {data.map((p) => (\n <Cell\n key={p.label}\n fill={p.highlighted ? HIGHLIGHT_COLOR : (model.series[1]?.color ?? HIGHLIGHT_COLOR)}\n stroke={p.frontier ? frontierColor : 'none'}\n strokeWidth={p.frontier ? 1.5 : 0}\n />\n ))}\n <LabelList\n dataKey=\"shown\"\n position=\"top\"\n fill=\"hsl(var(--muted-foreground))\"\n fontSize={10}\n />\n </Scatter>\n </ScatterChart>\n )\n}\n\nexport default function RechartsRenderer({\n model,\n ariaLabel,\n height,\n otherLabel,\n}: RechartsRendererProps) {\n const style = { width: '100%', height }\n const tooltip = (\n // No hover cursor: a chart is read, not clicked, so the band behind the hovered category (a\n // shaded, dash-outlined cut-out) only suggested an action that is not there. The tooltip and\n // a line's active dot still show the value.\n <Tooltip\n cursor={false}\n content={({ active, label, payload }: TooltipContent) => (\n <ChartTooltip\n active={active}\n label={label}\n payload={payload as readonly TooltipEntry[] | undefined}\n format={model.format}\n />\n )}\n />\n )\n\n if (model.type === 'scatter' && model.scatter) {\n return <ScatterPlot model={model} scatter={model.scatter} ariaLabel={ariaLabel} style={style} />\n }\n\n if (model.type === 'pie' || model.type === 'donut') {\n const colors = sliceColors(model, otherLabel)\n const data = model.categories.map((name, i) => ({\n name,\n value: Math.max(model.series[0]?.values[i] ?? 0, 0),\n }))\n return (\n <PieChart responsive style={style} accessibilityLayer title={ariaLabel} desc={ariaLabel}>\n <Pie\n data={data}\n dataKey=\"value\"\n nameKey=\"name\"\n innerRadius={model.type === 'donut' ? '55%' : 0}\n outerRadius=\"85%\"\n stroke=\"hsl(var(--card))\"\n strokeWidth={2}\n isAnimationActive={false}\n >\n {data.map((d, i) => (\n <Cell key={d.name} fill={colors[i]} />\n ))}\n </Pie>\n {tooltip}\n </PieChart>\n )\n }\n\n // Series keys are positional: labels may hold dots, which the library reads as paths.\n const data = model.categories.map((category, i) => {\n const row: Record<string, string | number | null> = { category }\n model.series.forEach((s, si) => {\n row[`s${si}`] = s.values[i]\n })\n return row\n })\n const stackId = model.stacked ? 'stack' : undefined\n const axes = (\n <>\n <CartesianGrid vertical={false} stroke=\"hsl(var(--border))\" strokeDasharray=\"2 2\" />\n <XAxis\n dataKey=\"category\"\n tick={AXIS_TICK}\n tickLine={false}\n axisLine={{ stroke: 'hsl(var(--border))' }}\n interval=\"preserveStartEnd\"\n minTickGap={8}\n />\n <YAxis\n tick={AXIS_TICK}\n tickLine={false}\n axisLine={false}\n width={valueAxisWidth(model)}\n allowDecimals={!model.integer}\n tickFormatter={(v: number) => model.formatTick(v)}\n />\n {tooltip}\n </>\n )\n const common = {\n data,\n responsive: true,\n style,\n margin: MARGIN,\n accessibilityLayer: true,\n title: ariaLabel,\n desc: ariaLabel,\n }\n\n if (model.type === 'bar') {\n return (\n <BarChart {...common}>\n {axes}\n {model.series.map((s, si) => (\n <Bar\n key={s.id}\n dataKey={`s${si}`}\n name={s.label}\n fill={s.color}\n stackId={stackId}\n radius={model.stacked ? 0 : [3, 3, 0, 0]}\n maxBarSize={48}\n isAnimationActive={false}\n >\n {model.highlighted?.map((on, i) => (\n <Cell key={i} fill={on ? HIGHLIGHT_COLOR : s.color} />\n ))}\n </Bar>\n ))}\n </BarChart>\n )\n }\n if (model.type === 'area') {\n return (\n <AreaChart {...common}>\n {axes}\n {model.series.map((s, si) => (\n <Area\n key={s.id}\n type=\"monotone\"\n dataKey={`s${si}`}\n name={s.label}\n stroke={s.color}\n fill={s.color}\n fillOpacity={model.stacked ? 0.55 : 0.2}\n strokeWidth={2}\n stackId={stackId}\n isAnimationActive={false}\n />\n ))}\n </AreaChart>\n )\n }\n return (\n <LineChart {...common}>\n {axes}\n {model.series.map((s, si) => (\n <Line\n key={s.id}\n type=\"monotone\"\n dataKey={`s${si}`}\n name={s.label}\n stroke={s.color}\n strokeWidth={2}\n dot={model.categories.length <= 12 ? { r: 3, fill: s.color, strokeWidth: 0 } : false}\n activeDot={{ r: 4 }}\n isAnimationActive={false}\n />\n ))}\n </LineChart>\n )\n}\n"],
|
|
5
|
+
"mappings": ";A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,QACR,QAAQ,EAAE;AAAA,QACV,aAAa;AAAA,QACb,KAAK,MAAM,WAAW,UAAU,KAAK,EAAE,GAAG,GAAG,MAAM,EAAE,OAAO,aAAa,EAAE,IAAI;AAAA,QAC/E,WAAW,EAAE,GAAG,EAAE;AAAA,QAClB,mBAAmB;AAAA;AAAA,MARd,EAAE;AAAA,IAST,CACD;AAAA,KACH;AAEJ;",
|
|
6
6
|
"names": ["data"]
|
|
7
7
|
}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* per group and series) become a `ChartModel`, the categories and series a drawing component plots.
|
|
4
4
|
* Nothing here knows the drawing library, so it can change without touching specs or sources.
|
|
5
5
|
*/
|
|
6
|
-
import type { ChartSpec, Dataset, DatasetField, TimeBucket } from '@arbidocs/react';
|
|
6
|
+
import type { ChartSpec, Dataset, DatasetField, FrontierGoal, TimeBucket } from '@arbidocs/react';
|
|
7
7
|
/** The drawing types (a metric and a table are not drawn). */
|
|
8
|
-
export type DrawnChartType = 'bar' | 'line' | 'area' | 'pie' | 'donut';
|
|
8
|
+
export type DrawnChartType = 'bar' | 'line' | 'area' | 'pie' | 'donut' | 'scatter';
|
|
9
9
|
export interface ChartModelSeries {
|
|
10
10
|
id: string;
|
|
11
11
|
label: string;
|
|
@@ -13,6 +13,37 @@ export interface ChartModelSeries {
|
|
|
13
13
|
values: (number | null)[];
|
|
14
14
|
/** The series' colour as a CSS value (a theme token). */
|
|
15
15
|
color: string;
|
|
16
|
+
/** Formats this series' values when it is not the chart's value (a scatter's x column). */
|
|
17
|
+
format?: (value: number) => string;
|
|
18
|
+
}
|
|
19
|
+
/** One point of a scatter. */
|
|
20
|
+
export interface ChartPoint {
|
|
21
|
+
label: string;
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
/** Named in the spec's `highlight`: drawn in the accent colour. */
|
|
25
|
+
highlighted: boolean;
|
|
26
|
+
/** On the Pareto frontier. */
|
|
27
|
+
frontier: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** What a scatter plots besides the shared fields. */
|
|
30
|
+
export interface ScatterModel {
|
|
31
|
+
points: ChartPoint[];
|
|
32
|
+
/** The frontier's points in x order (a line through them), or empty. */
|
|
33
|
+
frontier: ChartPoint[];
|
|
34
|
+
/** The median x and y (the quadrant guides), or null. */
|
|
35
|
+
quadrants: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
} | null;
|
|
39
|
+
/** The name of the field that labels the points. */
|
|
40
|
+
labelName: string;
|
|
41
|
+
formatX: (value: number) => string;
|
|
42
|
+
formatXTick: (value: number) => string;
|
|
43
|
+
xScale: 'linear' | 'log';
|
|
44
|
+
/** A log axis's range (the points with a margin) and its ticks (1, 2, 5 × a power of ten). */
|
|
45
|
+
xDomain: [number, number] | null;
|
|
46
|
+
xTicks: number[] | null;
|
|
16
47
|
}
|
|
17
48
|
/** What a chart plots, library-free. */
|
|
18
49
|
export interface ChartModel {
|
|
@@ -31,12 +62,18 @@ export interface ChartModel {
|
|
|
31
62
|
formatTick: (value: number) => string;
|
|
32
63
|
/** Every value is a whole number (a count, a sum of counts): the value axis has no 0.5 ticks. */
|
|
33
64
|
integer: boolean;
|
|
65
|
+
/** Per category, whether the spec's `highlight` names it (bar, line, area); absent: none. */
|
|
66
|
+
highlighted?: boolean[];
|
|
67
|
+
/** A scatter's points, frontier and guides. */
|
|
68
|
+
scatter?: ScatterModel;
|
|
34
69
|
}
|
|
35
70
|
/** Formats by unit (`gbp`, `bytes`, `tokens`, …); a host passes its own (the SDK's £ formatter). */
|
|
36
71
|
export type UnitFormatters = Readonly<Record<string, (value: number) => string>>;
|
|
37
72
|
/** The theme's series colours, then a muted "Other". */
|
|
38
73
|
export declare const SERIES_COLORS: string[];
|
|
39
74
|
export declare const OTHER_COLOR = "hsl(var(--muted-foreground))";
|
|
75
|
+
/** Highlighted categories and points. */
|
|
76
|
+
export declare const HIGHLIGHT_COLOR: string;
|
|
40
77
|
/** A date bucket key as people read it: "12 Jun 2026", "W24 2026", "Jun 2026", "Q2 2026", "2026". */
|
|
41
78
|
export declare function formatBucketLabel(key: string, bucket?: TimeBucket): string;
|
|
42
79
|
/** The default formatters: £ with pence, bytes in KB/MB/GB, tokens compact. */
|
|
@@ -64,6 +101,19 @@ export interface ChartModelOptions {
|
|
|
64
101
|
export declare function chartModelOf(spec: ChartSpec & {
|
|
65
102
|
type: DrawnChartType;
|
|
66
103
|
}, dataset: Dataset, options?: ChartModelOptions): ChartModel;
|
|
104
|
+
/** Ticks for a log axis over [min, max]: 1, 2 and 5 times each power of ten inside it. */
|
|
105
|
+
export declare function logTicks(min: number, max: number): number[];
|
|
106
|
+
/**
|
|
107
|
+
* The Pareto frontier: the points no other point beats on both axes (at least as good on each,
|
|
108
|
+
* better on one), in x order. `goal` says which way is better on each axis.
|
|
109
|
+
*/
|
|
110
|
+
export declare function paretoFrontier<P extends {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
}>(points: readonly P[], goal: {
|
|
114
|
+
x: FrontierGoal;
|
|
115
|
+
y: FrontierGoal;
|
|
116
|
+
}): P[];
|
|
67
117
|
/**
|
|
68
118
|
* The value axis's width: room for its longest tick (at 11px, about 6.5px a character), at least
|
|
69
119
|
* 48px. Ticks fall within the largest value (a stack's total), so its fractions stand for them.
|
|
@@ -7,6 +7,7 @@ const F = {
|
|
|
7
7
|
};
|
|
8
8
|
const SERIES_COLORS = [1, 2, 3, 4, 5].map((i) => `hsl(var(--chart-${i}))`);
|
|
9
9
|
const OTHER_COLOR = "hsl(var(--muted-foreground))";
|
|
10
|
+
const HIGHLIGHT_COLOR = SERIES_COLORS[1];
|
|
10
11
|
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
11
12
|
function formatBucketLabel(key, bucket = "month") {
|
|
12
13
|
let m;
|
|
@@ -57,6 +58,7 @@ const MAX_COLORED = SERIES_COLORS.length;
|
|
|
57
58
|
const additive = (spec) => (spec.aggregate ?? "count") === "count" || spec.aggregate === "sum";
|
|
58
59
|
const num = (v) => typeof v === "number" ? v : null;
|
|
59
60
|
function chartModelOf(spec, dataset, options = {}) {
|
|
61
|
+
if (spec.type === "scatter") return scatterModelOf(spec, dataset, options);
|
|
60
62
|
const other = options.otherLabel ?? "Other";
|
|
61
63
|
const valueField = dataset.fields.find((f) => f.id === F.value);
|
|
62
64
|
const xField = options.fields?.find((f) => f.id === spec.x);
|
|
@@ -128,13 +130,100 @@ function chartModelOf(spec, dataset, options = {}) {
|
|
|
128
130
|
xLabel: xField?.label ?? "",
|
|
129
131
|
valueLabel,
|
|
130
132
|
format,
|
|
131
|
-
formatTick: valueField
|
|
132
|
-
integer: series.every((s) => s.values.every((v) => v === null || Number.isInteger(v)))
|
|
133
|
+
formatTick: tickFormatterOf(valueField, format),
|
|
134
|
+
integer: series.every((s) => s.values.every((v) => v === null || Number.isInteger(v))),
|
|
135
|
+
...spec.highlight?.length ? { highlighted: categories.map((c) => spec.highlight?.includes(c) ?? false) } : {}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function tickFormatterOf(field, format) {
|
|
139
|
+
return field?.unit === "gbp" ? formatGbpTick : field?.unit === "bytes" ? format : formatCompact;
|
|
140
|
+
}
|
|
141
|
+
const median = (values) => {
|
|
142
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
143
|
+
const mid = Math.floor(sorted.length / 2);
|
|
144
|
+
return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
145
|
+
};
|
|
146
|
+
function logTicks(min, max) {
|
|
147
|
+
if (!(min > 0) || !(max >= min)) return [];
|
|
148
|
+
const ticks = [];
|
|
149
|
+
for (let k = Math.floor(Math.log10(min)); k <= Math.ceil(Math.log10(max)); k++) {
|
|
150
|
+
for (const m of [1, 2, 5]) {
|
|
151
|
+
const v = Number((m * 10 ** k).toPrecision(12));
|
|
152
|
+
if (v >= min && v <= max) ticks.push(v);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return ticks;
|
|
156
|
+
}
|
|
157
|
+
function paretoFrontier(points, goal) {
|
|
158
|
+
const better = (a, b, g) => g === "max" ? a > b : a < b;
|
|
159
|
+
const atLeast = (a, b, g) => g === "max" ? a >= b : a <= b;
|
|
160
|
+
return points.filter(
|
|
161
|
+
(p) => !points.some(
|
|
162
|
+
(q) => q !== p && atLeast(q.x, p.x, goal.x) && atLeast(q.y, p.y, goal.y) && (better(q.x, p.x, goal.x) || better(q.y, p.y, goal.y))
|
|
163
|
+
)
|
|
164
|
+
).sort((a, b) => a.x - b.x || a.y - b.y);
|
|
165
|
+
}
|
|
166
|
+
function scatterModelOf(spec, dataset, options) {
|
|
167
|
+
const fieldOf = (id) => id ? dataset.fields.find((f) => f.id === id) ?? options.fields?.find((f) => f.id === id) : void 0;
|
|
168
|
+
const xField = fieldOf(spec.x);
|
|
169
|
+
const yField = fieldOf(spec.y);
|
|
170
|
+
const labelField = fieldOf(spec.label);
|
|
171
|
+
const xScale = spec.xScale === "log" ? "log" : "linear";
|
|
172
|
+
const highlight = new Set(spec.highlight ?? []);
|
|
173
|
+
const points = [];
|
|
174
|
+
dataset.rows.forEach((row, i) => {
|
|
175
|
+
const x = spec.x ? num(row[spec.x]) : null;
|
|
176
|
+
const y = spec.y ? num(row[spec.y]) : null;
|
|
177
|
+
if (x === null || y === null || !Number.isFinite(x) || !Number.isFinite(y)) return;
|
|
178
|
+
if (xScale === "log" && x <= 0) return;
|
|
179
|
+
const raw = spec.label ? row[spec.label] : void 0;
|
|
180
|
+
const label = raw === void 0 || raw === null ? String(i + 1) : String(raw);
|
|
181
|
+
points.push({ label, x, y, highlighted: highlight.has(label), frontier: false });
|
|
182
|
+
});
|
|
183
|
+
const frontier = spec.frontier ? paretoFrontier(points, spec.frontier) : [];
|
|
184
|
+
for (const p of frontier) p.frontier = true;
|
|
185
|
+
const format = formatterOf(yField, options.formatters);
|
|
186
|
+
const formatX = formatterOf(xField, options.formatters);
|
|
187
|
+
const xLabel = xField?.label ?? spec.x ?? "";
|
|
188
|
+
const xs = points.map((p) => p.x);
|
|
189
|
+
const xDomain = xScale === "log" && xs.length ? [Math.min(...xs) / 1.6, Math.max(...xs) * 1.6] : null;
|
|
190
|
+
const valueLabel = yField?.label ?? spec.y ?? "";
|
|
191
|
+
return {
|
|
192
|
+
type: "scatter",
|
|
193
|
+
stacked: false,
|
|
194
|
+
categories: points.map((p) => p.label),
|
|
195
|
+
series: [
|
|
196
|
+
{
|
|
197
|
+
id: "x",
|
|
198
|
+
label: xLabel,
|
|
199
|
+
values: points.map((p) => p.x),
|
|
200
|
+
color: SERIES_COLORS[0],
|
|
201
|
+
format: formatX
|
|
202
|
+
},
|
|
203
|
+
{ id: "y", label: valueLabel, values: points.map((p) => p.y), color: SERIES_COLORS[0] }
|
|
204
|
+
],
|
|
205
|
+
xLabel,
|
|
206
|
+
valueLabel,
|
|
207
|
+
format,
|
|
208
|
+
formatTick: tickFormatterOf(yField, format),
|
|
209
|
+
integer: points.every((p) => Number.isInteger(p.y)),
|
|
210
|
+
scatter: {
|
|
211
|
+
points,
|
|
212
|
+
frontier,
|
|
213
|
+
quadrants: spec.quadrants && points.length > 1 ? { x: median(points.map((p) => p.x)), y: median(points.map((p) => p.y)) } : null,
|
|
214
|
+
labelName: labelField?.label ?? "",
|
|
215
|
+
formatX,
|
|
216
|
+
formatXTick: tickFormatterOf(xField, formatX),
|
|
217
|
+
xScale,
|
|
218
|
+
xDomain,
|
|
219
|
+
xTicks: xDomain ? logTicks(...xDomain) : null
|
|
220
|
+
}
|
|
133
221
|
};
|
|
134
222
|
}
|
|
135
223
|
function valueAxisWidth(model) {
|
|
224
|
+
const values = model.scatter ? model.series.filter((s) => s.id === "y") : model.series;
|
|
136
225
|
const totals = model.categories.map(
|
|
137
|
-
(_, i) => model.stacked ?
|
|
226
|
+
(_, i) => model.stacked ? values.reduce((sum, s) => sum + Math.abs(s.values[i] ?? 0), 0) : Math.max(0, ...values.map((s) => Math.abs(s.values[i] ?? 0)))
|
|
138
227
|
);
|
|
139
228
|
const max = Math.max(0, ...totals);
|
|
140
229
|
const longest = Math.max(
|
|
@@ -156,6 +245,7 @@ function metricValueOf(dataset) {
|
|
|
156
245
|
}
|
|
157
246
|
export {
|
|
158
247
|
DEFAULT_UNIT_FORMATTERS,
|
|
248
|
+
HIGHLIGHT_COLOR,
|
|
159
249
|
MAX_COLORED,
|
|
160
250
|
OTHER_COLOR,
|
|
161
251
|
SERIES_COLORS,
|
|
@@ -163,7 +253,9 @@ export {
|
|
|
163
253
|
formatBucketLabel,
|
|
164
254
|
formatGbpTick,
|
|
165
255
|
formatterOf,
|
|
256
|
+
logTicks,
|
|
166
257
|
metricValueOf,
|
|
258
|
+
paretoFrontier,
|
|
167
259
|
sliceColors,
|
|
168
260
|
valueAxisWidth
|
|
169
261
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/dashboards/chartModel.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The renderer adapter's first half: a `ChartSpec` and its aggregated `Dataset` (long form: a row\n * per group and series) become a `ChartModel`, the categories and series a drawing component plots.\n * Nothing here knows the drawing library, so it can change without touching specs or sources.\n */\nimport type {\n AGGREGATE_FIELDS,\n ChartSpec,\n Dataset,\n DatasetField,\n DatasetValue,\n TimeBucket,\n} from '@arbidocs/react'\n\n/** The aggregated dataset's field ids (`@arbidocs/react`'s `AGGREGATE_FIELDS`, checked). */\nconst F = {\n group: 'group',\n key: 'key',\n series: 'series',\n value: 'value',\n} as const satisfies typeof AGGREGATE_FIELDS\n\n/** The drawing types (a metric and a table are not drawn). */\nexport type DrawnChartType = 'bar' | 'line' | 'area' | 'pie' | 'donut'\n\nexport interface ChartModelSeries {\n id: string\n label: string\n /** One per category; `null` where the group has no value. */\n values: (number | null)[]\n /** The series' colour as a CSS value (a theme token). */\n color: string\n}\n\n/** What a chart plots, library-free. */\nexport interface ChartModel {\n type: DrawnChartType\n stacked: boolean\n /** Category labels, in order (x axis, or pie slices). */\n categories: string[]\n series: ChartModelSeries[]\n /** The x axis's name (the grouped field). */\n xLabel: string\n /** The value's name (\"count\", \"sum of Fee\"). */\n valueLabel: string\n /** Formats a value for ticks, the tooltip and the table. */\n format: (value: number) => string\n /** Short form of `format` for axis ticks. */\n formatTick: (value: number) => string\n /** Every value is a whole number (a count, a sum of counts): the value axis has no 0.5 ticks. */\n integer: boolean\n}\n\n/** Formats by unit (`gbp`, `bytes`, `tokens`, \u2026); a host passes its own (the SDK's \u00A3 formatter). */\nexport type UnitFormatters = Readonly<Record<string, (value: number) => string>>\n\n/** The theme's series colours, then a muted \"Other\". */\nexport const SERIES_COLORS = [1, 2, 3, 4, 5].map((i) => `hsl(var(--chart-${i}))`)\nexport const OTHER_COLOR = 'hsl(var(--muted-foreground))'\n\nconst MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']\n\n/** A date bucket key as people read it: \"12 Jun 2026\", \"W24 2026\", \"Jun 2026\", \"Q2 2026\", \"2026\". */\nexport function formatBucketLabel(key: string, bucket: TimeBucket = 'month'): string {\n let m: RegExpMatchArray | null\n if (bucket === 'day' && (m = key.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/)))\n return `${Number(m[3])} ${MONTHS[Number(m[2]) - 1]} ${m[1]}`\n if (bucket === 'week' && (m = key.match(/^(\\d{4})-W(\\d{2})$/))) return `W${Number(m[2])} ${m[1]}`\n if (bucket === 'month' && (m = key.match(/^(\\d{4})-(\\d{2})$/)))\n return `${MONTHS[Number(m[2]) - 1]} ${m[1]}`\n if (bucket === 'quarter' && (m = key.match(/^(\\d{4})-Q(\\d)$/))) return `Q${m[2]} ${m[1]}`\n return key\n}\n\nconst plain = new Intl.NumberFormat('en-GB', { maximumFractionDigits: 2 })\nconst oneDecimal = new Intl.NumberFormat('en-GB', { maximumFractionDigits: 1 })\nconst COMPACT_UNITS: readonly [number, string][] = [\n [1e12, 'T'],\n [1e9, 'B'],\n [1e6, 'M'],\n [1e3, 'K'],\n]\n\n/**\n * A number in fixed suffixes (950, 1.2K, 1.5M, 3B), the same in every browser and runtime:\n * `Intl`'s compact notation follows the ICU data, which writes \"1.5m\" in some versions.\n */\nfunction formatCompact(value: number): string {\n const size = Math.abs(value)\n const at = COMPACT_UNITS.findIndex(([divisor]) => size >= divisor)\n if (at === -1) return oneDecimal.format(value)\n // 999,950 rounds to \"1000K\": the next suffix up reads it.\n const [divisor, suffix] =\n at > 0 && Math.round((size / COMPACT_UNITS[at][0]) * 10) / 10 >= 1000\n ? COMPACT_UNITS[at - 1]\n : COMPACT_UNITS[at]\n return `${oneDecimal.format(value / divisor)}${suffix}`\n}\n\n/** The default formatters: \u00A3 with pence, bytes in KB/MB/GB, tokens compact. */\nexport const DEFAULT_UNIT_FORMATTERS: UnitFormatters = {\n gbp: (v) =>\n `${v < 0 ? '-' : ''}\u00A3${Math.abs(v).toLocaleString('en-GB', {\n minimumFractionDigits: Number.isInteger(v) ? 0 : 2,\n maximumFractionDigits: 2,\n })}`,\n bytes: (v) =>\n v < 1024\n ? `${v} B`\n : v < 1024 ** 2\n ? `${(v / 1024).toFixed(1)} KB`\n : v < 1024 ** 3\n ? `${(v / 1024 ** 2).toFixed(1)} MB`\n : `${(v / 1024 ** 3).toFixed(1)} GB`,\n tokens: formatCompact,\n}\n\n/**\n * A \u00A3 axis tick with the pence it needs: \u00A30.0025 where every amount is under a penny (where the\n * display form says \"<\u00A30.01\" on every tick), \u00A312.5 and \u00A31.2K above.\n */\nexport function formatGbpTick(value: number): string {\n const abs = Math.abs(value)\n if (abs >= 1000) return `${value < 0 ? '-' : ''}\u00A3${formatCompact(abs)}`\n const digits =\n abs === 0 || abs >= 1 ? 2 : Math.min(6, Math.max(2, -Math.floor(Math.log10(abs)) + 1))\n return `${value < 0 ? '-' : ''}\u00A3${abs.toLocaleString('en-GB', { maximumFractionDigits: digits })}`\n}\n\n/** The formatter of a value field: by its unit, a suffix for any other unit, else a number. */\nexport function formatterOf(\n field: Pick<DatasetField, 'unit'> | undefined,\n formatters: UnitFormatters = DEFAULT_UNIT_FORMATTERS\n): (value: number) => string {\n const unit = field?.unit\n if (!unit) return (v) => plain.format(v)\n const known = formatters[unit] ?? DEFAULT_UNIT_FORMATTERS[unit]\n return known ?? ((v) => `${plain.format(v)} ${unit}`)\n}\n\n/** The most series (or pie slices) drawn in their own colour; the rest fold into \"Other\". */\nexport const MAX_COLORED = SERIES_COLORS.length\n\nconst additive = (spec: ChartSpec) =>\n (spec.aggregate ?? 'count') === 'count' || spec.aggregate === 'sum'\n\nconst num = (v: DatasetValue | undefined) => (typeof v === 'number' ? v : null)\n\nexport interface ChartModelOptions {\n /** The source's fields, for the x axis's name. */\n fields?: readonly DatasetField[]\n formatters?: UnitFormatters\n /** The words for the folded series and slices. Default \"Other\". */\n otherLabel?: string\n}\n\n/**\n * Turn an aggregated dataset into what a chart plots. Series (and pie slices) beyond the theme's\n * colours fold into \"Other\" when the values add up (count, sum); otherwise the smallest are left out.\n */\nexport function chartModelOf(\n spec: ChartSpec & { type: DrawnChartType },\n dataset: Dataset,\n options: ChartModelOptions = {}\n): ChartModel {\n const other = options.otherLabel ?? 'Other'\n const valueField = dataset.fields.find((f) => f.id === F.value)\n const xField = options.fields?.find((f) => f.id === spec.x)\n const isDate = xField?.type === 'date'\n const keys: string[] = []\n const labels = new Map<string, string>()\n const seriesIds: string[] = []\n const cells = new Map<string, number | null>()\n for (const row of dataset.rows) {\n const key = String(row[F.key] ?? row[F.group] ?? '')\n if (!labels.has(key)) {\n keys.push(key)\n const label = String(row[F.group] ?? key)\n labels.set(key, isDate && key ? formatBucketLabel(key, spec.bucket) : label)\n }\n const s = row[F.series] === undefined ? '' : String(row[F.series])\n if (!seriesIds.includes(s)) seriesIds.push(s)\n cells.set(`${key}\\u0000${s}`, num(row[F.value]))\n }\n const valueLabel = valueField?.label ?? 'value'\n let series = seriesIds.map((s) => ({\n id: s || F.value,\n label: s || valueLabel,\n values: keys.map((k) => cells.get(`${k}\\u0000${s}`) ?? null),\n }))\n let categories = keys.map((k) => labels.get(k) ?? k)\n const sum = (values: (number | null)[]) => values.reduce<number>((a, v) => a + (v ?? 0), 0)\n\n if (spec.type === 'pie' || spec.type === 'donut') {\n const values = series[0]?.values ?? []\n if (categories.length > MAX_COLORED) {\n const order = values.map((_, i) => i).sort((a, b) => (values[b] ?? 0) - (values[a] ?? 0))\n const kept = order.slice(0, MAX_COLORED - 1)\n const rest = order.slice(MAX_COLORED - 1)\n categories = [...kept.map((i) => categories[i]), ...(additive(spec) ? [other] : [])]\n const keptValues = kept.map((i) => values[i])\n series = [\n {\n ...series[0],\n values: additive(spec) ? [...keptValues, sum(rest.map((i) => values[i]))] : keptValues,\n },\n ]\n }\n } else if (series.length > MAX_COLORED) {\n const order = [...series].sort((a, b) => sum(b.values) - sum(a.values))\n const kept = order.slice(0, MAX_COLORED - 1)\n const rest = order.slice(MAX_COLORED - 1)\n series = [\n ...series.filter((s) => kept.includes(s)),\n ...(additive(spec)\n ? [\n {\n id: '__other',\n label: other,\n values: keys.map((_, i) =>\n rest.some((s) => s.values[i] !== null) ? sum(rest.map((s) => s.values[i])) : null\n ),\n },\n ]\n : []),\n ]\n }\n\n const format = formatterOf(valueField, options.formatters)\n return {\n type: spec.type,\n stacked: Boolean(spec.stacked) && (spec.type === 'bar' || spec.type === 'area'),\n categories,\n series: series.map((s, i) => ({\n ...s,\n color: s.id === '__other' ? OTHER_COLOR : SERIES_COLORS[i % SERIES_COLORS.length],\n })),\n xLabel: xField?.label ?? '',\n valueLabel,\n format,\n formatTick:\n valueField?.unit === 'gbp'\n ? formatGbpTick\n : valueField?.unit === 'bytes'\n ? format\n : formatCompact,\n integer: series.every((s) => s.values.every((v) => v === null || Number.isInteger(v))),\n }\n}\n\n/**\n * The value axis's width: room for its longest tick (at 11px, about 6.5px a character), at least\n * 48px. Ticks fall within the largest value (a stack's total), so its fractions stand for them.\n */\nexport function valueAxisWidth(model: ChartModel): number {\n const totals = model.categories.map((_, i) =>\n model.stacked\n ? model.series.reduce((sum, s) => sum + Math.abs(s.values[i] ?? 0), 0)\n : Math.max(0, ...model.series.map((s) => Math.abs(s.values[i] ?? 0)))\n )\n const max = Math.max(0, ...totals)\n const longest = Math.max(\n ...[1, 0.75, 0.5, 0.25, 0.15].map((f) => model.formatTick(max * f).length)\n )\n return Math.max(48, Math.ceil(longest * 6.5) + 10)\n}\n\n/** The pie slice colours (one per category; \"Other\" muted). */\nexport function sliceColors(model: Pick<ChartModel, 'categories'>, otherLabel = 'Other') {\n return model.categories.map((c, i) =>\n c === otherLabel && i === model.categories.length - 1 && i >= MAX_COLORED - 1\n ? OTHER_COLOR\n : SERIES_COLORS[i % SERIES_COLORS.length]\n )\n}\n\n/** The single value of a metric (an aggregated dataset with one group), or null. */\nexport function metricValueOf(dataset: Dataset | undefined): number | null {\n if (!dataset?.rows.length) return null\n return dataset.rows.reduce<number | null>((total, row) => {\n const v = num(row[F.value])\n return v === null ? total : (total ?? 0) + v\n }, null)\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * The renderer adapter's first half: a `ChartSpec` and its aggregated `Dataset` (long form: a row\n * per group and series) become a `ChartModel`, the categories and series a drawing component plots.\n * Nothing here knows the drawing library, so it can change without touching specs or sources.\n */\nimport type {\n AGGREGATE_FIELDS,\n ChartSpec,\n Dataset,\n DatasetField,\n DatasetValue,\n FrontierGoal,\n TimeBucket,\n} from '@arbidocs/react'\n\n/** The aggregated dataset's field ids (`@arbidocs/react`'s `AGGREGATE_FIELDS`, checked). */\nconst F = {\n group: 'group',\n key: 'key',\n series: 'series',\n value: 'value',\n} as const satisfies typeof AGGREGATE_FIELDS\n\n/** The drawing types (a metric and a table are not drawn). */\nexport type DrawnChartType = 'bar' | 'line' | 'area' | 'pie' | 'donut' | 'scatter'\n\nexport interface ChartModelSeries {\n id: string\n label: string\n /** One per category; `null` where the group has no value. */\n values: (number | null)[]\n /** The series' colour as a CSS value (a theme token). */\n color: string\n /** Formats this series' values when it is not the chart's value (a scatter's x column). */\n format?: (value: number) => string\n}\n\n/** One point of a scatter. */\nexport interface ChartPoint {\n label: string\n x: number\n y: number\n /** Named in the spec's `highlight`: drawn in the accent colour. */\n highlighted: boolean\n /** On the Pareto frontier. */\n frontier: boolean\n}\n\n/** What a scatter plots besides the shared fields. */\nexport interface ScatterModel {\n points: ChartPoint[]\n /** The frontier's points in x order (a line through them), or empty. */\n frontier: ChartPoint[]\n /** The median x and y (the quadrant guides), or null. */\n quadrants: { x: number; y: number } | null\n /** The name of the field that labels the points. */\n labelName: string\n formatX: (value: number) => string\n formatXTick: (value: number) => string\n xScale: 'linear' | 'log'\n /** A log axis's range (the points with a margin) and its ticks (1, 2, 5 \u00D7 a power of ten). */\n xDomain: [number, number] | null\n xTicks: number[] | null\n}\n\n/** What a chart plots, library-free. */\nexport interface ChartModel {\n type: DrawnChartType\n stacked: boolean\n /** Category labels, in order (x axis, or pie slices). */\n categories: string[]\n series: ChartModelSeries[]\n /** The x axis's name (the grouped field). */\n xLabel: string\n /** The value's name (\"count\", \"sum of Fee\"). */\n valueLabel: string\n /** Formats a value for ticks, the tooltip and the table. */\n format: (value: number) => string\n /** Short form of `format` for axis ticks. */\n formatTick: (value: number) => string\n /** Every value is a whole number (a count, a sum of counts): the value axis has no 0.5 ticks. */\n integer: boolean\n /** Per category, whether the spec's `highlight` names it (bar, line, area); absent: none. */\n highlighted?: boolean[]\n /** A scatter's points, frontier and guides. */\n scatter?: ScatterModel\n}\n\n/** Formats by unit (`gbp`, `bytes`, `tokens`, \u2026); a host passes its own (the SDK's \u00A3 formatter). */\nexport type UnitFormatters = Readonly<Record<string, (value: number) => string>>\n\n/** The theme's series colours, then a muted \"Other\". */\nexport const SERIES_COLORS = [1, 2, 3, 4, 5].map((i) => `hsl(var(--chart-${i}))`)\nexport const OTHER_COLOR = 'hsl(var(--muted-foreground))'\n/** Highlighted categories and points. */\nexport const HIGHLIGHT_COLOR = SERIES_COLORS[1]\n\nconst MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']\n\n/** A date bucket key as people read it: \"12 Jun 2026\", \"W24 2026\", \"Jun 2026\", \"Q2 2026\", \"2026\". */\nexport function formatBucketLabel(key: string, bucket: TimeBucket = 'month'): string {\n let m: RegExpMatchArray | null\n if (bucket === 'day' && (m = key.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/)))\n return `${Number(m[3])} ${MONTHS[Number(m[2]) - 1]} ${m[1]}`\n if (bucket === 'week' && (m = key.match(/^(\\d{4})-W(\\d{2})$/))) return `W${Number(m[2])} ${m[1]}`\n if (bucket === 'month' && (m = key.match(/^(\\d{4})-(\\d{2})$/)))\n return `${MONTHS[Number(m[2]) - 1]} ${m[1]}`\n if (bucket === 'quarter' && (m = key.match(/^(\\d{4})-Q(\\d)$/))) return `Q${m[2]} ${m[1]}`\n return key\n}\n\nconst plain = new Intl.NumberFormat('en-GB', { maximumFractionDigits: 2 })\nconst oneDecimal = new Intl.NumberFormat('en-GB', { maximumFractionDigits: 1 })\nconst COMPACT_UNITS: readonly [number, string][] = [\n [1e12, 'T'],\n [1e9, 'B'],\n [1e6, 'M'],\n [1e3, 'K'],\n]\n\n/**\n * A number in fixed suffixes (950, 1.2K, 1.5M, 3B), the same in every browser and runtime:\n * `Intl`'s compact notation follows the ICU data, which writes \"1.5m\" in some versions.\n */\nfunction formatCompact(value: number): string {\n const size = Math.abs(value)\n const at = COMPACT_UNITS.findIndex(([divisor]) => size >= divisor)\n if (at === -1) return oneDecimal.format(value)\n // 999,950 rounds to \"1000K\": the next suffix up reads it.\n const [divisor, suffix] =\n at > 0 && Math.round((size / COMPACT_UNITS[at][0]) * 10) / 10 >= 1000\n ? COMPACT_UNITS[at - 1]\n : COMPACT_UNITS[at]\n return `${oneDecimal.format(value / divisor)}${suffix}`\n}\n\n/** The default formatters: \u00A3 with pence, bytes in KB/MB/GB, tokens compact. */\nexport const DEFAULT_UNIT_FORMATTERS: UnitFormatters = {\n gbp: (v) =>\n `${v < 0 ? '-' : ''}\u00A3${Math.abs(v).toLocaleString('en-GB', {\n minimumFractionDigits: Number.isInteger(v) ? 0 : 2,\n maximumFractionDigits: 2,\n })}`,\n bytes: (v) =>\n v < 1024\n ? `${v} B`\n : v < 1024 ** 2\n ? `${(v / 1024).toFixed(1)} KB`\n : v < 1024 ** 3\n ? `${(v / 1024 ** 2).toFixed(1)} MB`\n : `${(v / 1024 ** 3).toFixed(1)} GB`,\n tokens: formatCompact,\n}\n\n/**\n * A \u00A3 axis tick with the pence it needs: \u00A30.0025 where every amount is under a penny (where the\n * display form says \"<\u00A30.01\" on every tick), \u00A312.5 and \u00A31.2K above.\n */\nexport function formatGbpTick(value: number): string {\n const abs = Math.abs(value)\n if (abs >= 1000) return `${value < 0 ? '-' : ''}\u00A3${formatCompact(abs)}`\n const digits =\n abs === 0 || abs >= 1 ? 2 : Math.min(6, Math.max(2, -Math.floor(Math.log10(abs)) + 1))\n return `${value < 0 ? '-' : ''}\u00A3${abs.toLocaleString('en-GB', { maximumFractionDigits: digits })}`\n}\n\n/** The formatter of a value field: by its unit, a suffix for any other unit, else a number. */\nexport function formatterOf(\n field: Pick<DatasetField, 'unit'> | undefined,\n formatters: UnitFormatters = DEFAULT_UNIT_FORMATTERS\n): (value: number) => string {\n const unit = field?.unit\n if (!unit) return (v) => plain.format(v)\n const known = formatters[unit] ?? DEFAULT_UNIT_FORMATTERS[unit]\n return known ?? ((v) => `${plain.format(v)} ${unit}`)\n}\n\n/** The most series (or pie slices) drawn in their own colour; the rest fold into \"Other\". */\nexport const MAX_COLORED = SERIES_COLORS.length\n\nconst additive = (spec: ChartSpec) =>\n (spec.aggregate ?? 'count') === 'count' || spec.aggregate === 'sum'\n\nconst num = (v: DatasetValue | undefined) => (typeof v === 'number' ? v : null)\n\nexport interface ChartModelOptions {\n /** The source's fields, for the x axis's name. */\n fields?: readonly DatasetField[]\n formatters?: UnitFormatters\n /** The words for the folded series and slices. Default \"Other\". */\n otherLabel?: string\n}\n\n/**\n * Turn an aggregated dataset into what a chart plots. Series (and pie slices) beyond the theme's\n * colours fold into \"Other\" when the values add up (count, sum); otherwise the smallest are left out.\n */\nexport function chartModelOf(\n spec: ChartSpec & { type: DrawnChartType },\n dataset: Dataset,\n options: ChartModelOptions = {}\n): ChartModel {\n if (spec.type === 'scatter') return scatterModelOf(spec, dataset, options)\n const other = options.otherLabel ?? 'Other'\n const valueField = dataset.fields.find((f) => f.id === F.value)\n const xField = options.fields?.find((f) => f.id === spec.x)\n const isDate = xField?.type === 'date'\n const keys: string[] = []\n const labels = new Map<string, string>()\n const seriesIds: string[] = []\n const cells = new Map<string, number | null>()\n for (const row of dataset.rows) {\n const key = String(row[F.key] ?? row[F.group] ?? '')\n if (!labels.has(key)) {\n keys.push(key)\n const label = String(row[F.group] ?? key)\n labels.set(key, isDate && key ? formatBucketLabel(key, spec.bucket) : label)\n }\n const s = row[F.series] === undefined ? '' : String(row[F.series])\n if (!seriesIds.includes(s)) seriesIds.push(s)\n cells.set(`${key}\\u0000${s}`, num(row[F.value]))\n }\n const valueLabel = valueField?.label ?? 'value'\n let series = seriesIds.map((s) => ({\n id: s || F.value,\n label: s || valueLabel,\n values: keys.map((k) => cells.get(`${k}\\u0000${s}`) ?? null),\n }))\n let categories = keys.map((k) => labels.get(k) ?? k)\n const sum = (values: (number | null)[]) => values.reduce<number>((a, v) => a + (v ?? 0), 0)\n\n if (spec.type === 'pie' || spec.type === 'donut') {\n const values = series[0]?.values ?? []\n if (categories.length > MAX_COLORED) {\n const order = values.map((_, i) => i).sort((a, b) => (values[b] ?? 0) - (values[a] ?? 0))\n const kept = order.slice(0, MAX_COLORED - 1)\n const rest = order.slice(MAX_COLORED - 1)\n categories = [...kept.map((i) => categories[i]), ...(additive(spec) ? [other] : [])]\n const keptValues = kept.map((i) => values[i])\n series = [\n {\n ...series[0],\n values: additive(spec) ? [...keptValues, sum(rest.map((i) => values[i]))] : keptValues,\n },\n ]\n }\n } else if (series.length > MAX_COLORED) {\n const order = [...series].sort((a, b) => sum(b.values) - sum(a.values))\n const kept = order.slice(0, MAX_COLORED - 1)\n const rest = order.slice(MAX_COLORED - 1)\n series = [\n ...series.filter((s) => kept.includes(s)),\n ...(additive(spec)\n ? [\n {\n id: '__other',\n label: other,\n values: keys.map((_, i) =>\n rest.some((s) => s.values[i] !== null) ? sum(rest.map((s) => s.values[i])) : null\n ),\n },\n ]\n : []),\n ]\n }\n\n const format = formatterOf(valueField, options.formatters)\n return {\n type: spec.type,\n stacked: Boolean(spec.stacked) && (spec.type === 'bar' || spec.type === 'area'),\n categories,\n series: series.map((s, i) => ({\n ...s,\n color: s.id === '__other' ? OTHER_COLOR : SERIES_COLORS[i % SERIES_COLORS.length],\n })),\n xLabel: xField?.label ?? '',\n valueLabel,\n format,\n formatTick: tickFormatterOf(valueField, format),\n integer: series.every((s) => s.values.every((v) => v === null || Number.isInteger(v))),\n ...(spec.highlight?.length\n ? { highlighted: categories.map((c) => spec.highlight?.includes(c) ?? false) }\n : {}),\n }\n}\n\nfunction tickFormatterOf(field: DatasetField | undefined, format: (v: number) => string) {\n return field?.unit === 'gbp' ? formatGbpTick : field?.unit === 'bytes' ? format : formatCompact\n}\n\nconst median = (values: number[]) => {\n const sorted = [...values].sort((a, b) => a - b)\n const mid = Math.floor(sorted.length / 2)\n return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2\n}\n\n/** Ticks for a log axis over [min, max]: 1, 2 and 5 times each power of ten inside it. */\nexport function logTicks(min: number, max: number): number[] {\n if (!(min > 0) || !(max >= min)) return []\n const ticks: number[] = []\n for (let k = Math.floor(Math.log10(min)); k <= Math.ceil(Math.log10(max)); k++) {\n for (const m of [1, 2, 5]) {\n const v = Number((m * 10 ** k).toPrecision(12))\n if (v >= min && v <= max) ticks.push(v)\n }\n }\n return ticks\n}\n\n/**\n * The Pareto frontier: the points no other point beats on both axes (at least as good on each,\n * better on one), in x order. `goal` says which way is better on each axis.\n */\nexport function paretoFrontier<P extends { x: number; y: number }>(\n points: readonly P[],\n goal: { x: FrontierGoal; y: FrontierGoal }\n): P[] {\n const better = (a: number, b: number, g: FrontierGoal) => (g === 'max' ? a > b : a < b)\n const atLeast = (a: number, b: number, g: FrontierGoal) => (g === 'max' ? a >= b : a <= b)\n return points\n .filter(\n (p) =>\n !points.some(\n (q) =>\n q !== p &&\n atLeast(q.x, p.x, goal.x) &&\n atLeast(q.y, p.y, goal.y) &&\n (better(q.x, p.x, goal.x) || better(q.y, p.y, goal.y))\n )\n )\n .sort((a, b) => a.x - b.x || a.y - b.y)\n}\n\n/**\n * A scatter: one point per record with a number `x` and `y` (records without both are left out; on\n * a log axis, so are x values at or below 0). Its table lists each point's x and y.\n */\nfunction scatterModelOf(spec: ChartSpec, dataset: Dataset, options: ChartModelOptions): ChartModel {\n const fieldOf = (id: string | undefined) =>\n id\n ? (dataset.fields.find((f) => f.id === id) ?? options.fields?.find((f) => f.id === id))\n : undefined\n const xField = fieldOf(spec.x)\n const yField = fieldOf(spec.y)\n const labelField = fieldOf(spec.label)\n const xScale = spec.xScale === 'log' ? 'log' : 'linear'\n const highlight = new Set(spec.highlight ?? [])\n const points: ChartPoint[] = []\n dataset.rows.forEach((row, i) => {\n const x = spec.x ? num(row[spec.x]) : null\n const y = spec.y ? num(row[spec.y]) : null\n if (x === null || y === null || !Number.isFinite(x) || !Number.isFinite(y)) return\n if (xScale === 'log' && x <= 0) return\n const raw = spec.label ? row[spec.label] : undefined\n const label = raw === undefined || raw === null ? String(i + 1) : String(raw)\n points.push({ label, x, y, highlighted: highlight.has(label), frontier: false })\n })\n const frontier = spec.frontier ? paretoFrontier(points, spec.frontier) : []\n for (const p of frontier) p.frontier = true\n const format = formatterOf(yField, options.formatters)\n const formatX = formatterOf(xField, options.formatters)\n const xLabel = xField?.label ?? spec.x ?? ''\n const xs = points.map((p) => p.x)\n // A log axis gets room around its points (a third of a decade each side) and readable ticks.\n const xDomain: [number, number] | null =\n xScale === 'log' && xs.length ? [Math.min(...xs) / 1.6, Math.max(...xs) * 1.6] : null\n const valueLabel = yField?.label ?? spec.y ?? ''\n return {\n type: 'scatter',\n stacked: false,\n categories: points.map((p) => p.label),\n series: [\n {\n id: 'x',\n label: xLabel,\n values: points.map((p) => p.x),\n color: SERIES_COLORS[0],\n format: formatX,\n },\n { id: 'y', label: valueLabel, values: points.map((p) => p.y), color: SERIES_COLORS[0] },\n ],\n xLabel,\n valueLabel,\n format,\n formatTick: tickFormatterOf(yField, format),\n integer: points.every((p) => Number.isInteger(p.y)),\n scatter: {\n points,\n frontier,\n quadrants:\n spec.quadrants && points.length > 1\n ? { x: median(points.map((p) => p.x)), y: median(points.map((p) => p.y)) }\n : null,\n labelName: labelField?.label ?? '',\n formatX,\n formatXTick: tickFormatterOf(xField, formatX),\n xScale,\n xDomain,\n xTicks: xDomain ? logTicks(...xDomain) : null,\n },\n }\n}\n\n/**\n * The value axis's width: room for its longest tick (at 11px, about 6.5px a character), at least\n * 48px. Ticks fall within the largest value (a stack's total), so its fractions stand for them.\n */\nexport function valueAxisWidth(model: ChartModel): number {\n // A scatter's series also carry its x values (for the table); only y is on the value axis.\n const values = model.scatter ? model.series.filter((s) => s.id === 'y') : model.series\n const totals = model.categories.map((_, i) =>\n model.stacked\n ? values.reduce((sum, s) => sum + Math.abs(s.values[i] ?? 0), 0)\n : Math.max(0, ...values.map((s) => Math.abs(s.values[i] ?? 0)))\n )\n const max = Math.max(0, ...totals)\n const longest = Math.max(\n ...[1, 0.75, 0.5, 0.25, 0.15].map((f) => model.formatTick(max * f).length)\n )\n return Math.max(48, Math.ceil(longest * 6.5) + 10)\n}\n\n/** The pie slice colours (one per category; \"Other\" muted). */\nexport function sliceColors(model: Pick<ChartModel, 'categories'>, otherLabel = 'Other') {\n return model.categories.map((c, i) =>\n c === otherLabel && i === model.categories.length - 1 && i >= MAX_COLORED - 1\n ? OTHER_COLOR\n : SERIES_COLORS[i % SERIES_COLORS.length]\n )\n}\n\n/** The single value of a metric (an aggregated dataset with one group), or null. */\nexport function metricValueOf(dataset: Dataset | undefined): number | null {\n if (!dataset?.rows.length) return null\n return dataset.rows.reduce<number | null>((total, row) => {\n const v = num(row[F.value])\n return v === null ? total : (total ?? 0) + v\n }, null)\n}\n"],
|
|
5
|
+
"mappings": ";AAgBA,MAAM,IAAI;AAAA,EACR,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AACT;AAuEO,MAAM,gBAAgB,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,mBAAmB,CAAC,IAAI;AACzE,MAAM,cAAc;AAEpB,MAAM,kBAAkB,cAAc,CAAC;AAE9C,MAAM,SAAS,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAG3F,SAAS,kBAAkB,KAAa,SAAqB,SAAiB;AACnF,MAAI;AACJ,MAAI,WAAW,UAAU,IAAI,IAAI,MAAM,2BAA2B;AAChE,WAAO,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC5D,MAAI,WAAW,WAAW,IAAI,IAAI,MAAM,oBAAoB,GAAI,QAAO,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC/F,MAAI,WAAW,YAAY,IAAI,IAAI,MAAM,mBAAmB;AAC1D,WAAO,GAAG,OAAO,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC5C,MAAI,WAAW,cAAc,IAAI,IAAI,MAAM,iBAAiB,GAAI,QAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EA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