@lincyaw/aegis-ui 0.8.0 → 0.9.1

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.
Files changed (118) hide show
  1. package/dist/components/ui/AgentHud.cjs +2 -0
  2. package/dist/components/ui/AgentHud.cjs.map +1 -0
  3. package/dist/components/ui/AgentHud.d.ts +23 -0
  4. package/dist/components/ui/AgentHud.js +45 -0
  5. package/dist/components/ui/AgentHud.js.map +1 -0
  6. package/dist/components/ui/ChartLegend.cjs +1 -1
  7. package/dist/components/ui/ChartLegend.cjs.map +1 -1
  8. package/dist/components/ui/ChartLegend.d.ts +2 -0
  9. package/dist/components/ui/ChartLegend.js +11 -10
  10. package/dist/components/ui/ChartLegend.js.map +1 -1
  11. package/dist/components/ui/ColumnChart.cjs +2 -0
  12. package/dist/components/ui/ColumnChart.cjs.map +1 -0
  13. package/dist/components/ui/ColumnChart.d.ts +46 -0
  14. package/dist/components/ui/ColumnChart.js +154 -0
  15. package/dist/components/ui/ColumnChart.js.map +1 -0
  16. package/dist/components/ui/DotRangeChart.cjs +2 -0
  17. package/dist/components/ui/DotRangeChart.cjs.map +1 -0
  18. package/dist/components/ui/DotRangeChart.d.ts +44 -0
  19. package/dist/components/ui/DotRangeChart.js +80 -0
  20. package/dist/components/ui/DotRangeChart.js.map +1 -0
  21. package/dist/components/ui/HeadlineStat.cjs +2 -0
  22. package/dist/components/ui/HeadlineStat.cjs.map +1 -0
  23. package/dist/components/ui/HeadlineStat.d.ts +10 -0
  24. package/dist/components/ui/HeadlineStat.js +22 -0
  25. package/dist/components/ui/HeadlineStat.js.map +1 -0
  26. package/dist/components/ui/Heatmap.cjs +2 -0
  27. package/dist/components/ui/Heatmap.cjs.map +1 -0
  28. package/dist/components/ui/Heatmap.d.ts +52 -0
  29. package/dist/components/ui/Heatmap.js +82 -0
  30. package/dist/components/ui/Heatmap.js.map +1 -0
  31. package/dist/components/ui/KeyMomentCard.cjs +2 -0
  32. package/dist/components/ui/KeyMomentCard.cjs.map +1 -0
  33. package/dist/components/ui/KeyMomentCard.d.ts +19 -0
  34. package/dist/components/ui/KeyMomentCard.js +45 -0
  35. package/dist/components/ui/KeyMomentCard.js.map +1 -0
  36. package/dist/components/ui/LineChart.cjs +2 -0
  37. package/dist/components/ui/LineChart.cjs.map +1 -0
  38. package/dist/components/ui/LineChart.d.ts +48 -0
  39. package/dist/components/ui/LineChart.js +199 -0
  40. package/dist/components/ui/LineChart.js.map +1 -0
  41. package/dist/components/ui/ParetoChart.cjs +1 -1
  42. package/dist/components/ui/ParetoChart.cjs.map +1 -1
  43. package/dist/components/ui/ParetoChart.d.ts +34 -2
  44. package/dist/components/ui/ParetoChart.js +250 -173
  45. package/dist/components/ui/ParetoChart.js.map +1 -1
  46. package/dist/components/ui/RankBar.cjs +1 -1
  47. package/dist/components/ui/RankBar.cjs.map +1 -1
  48. package/dist/components/ui/RankBar.d.ts +7 -3
  49. package/dist/components/ui/RankBar.js +64 -45
  50. package/dist/components/ui/RankBar.js.map +1 -1
  51. package/dist/components/ui/ReplayStepStrip.cjs +1 -1
  52. package/dist/components/ui/ReplayStepStrip.cjs.map +1 -1
  53. package/dist/components/ui/ReplayStepStrip.d.ts +13 -1
  54. package/dist/components/ui/ReplayStepStrip.js +99 -76
  55. package/dist/components/ui/ReplayStepStrip.js.map +1 -1
  56. package/dist/components/ui/ResultMatrix.cjs +2 -0
  57. package/dist/components/ui/ResultMatrix.cjs.map +1 -0
  58. package/dist/components/ui/ResultMatrix.d.ts +23 -0
  59. package/dist/components/ui/ResultMatrix.js +53 -0
  60. package/dist/components/ui/ResultMatrix.js.map +1 -0
  61. package/dist/components/ui/ScrollStory.cjs +2 -2
  62. package/dist/components/ui/ScrollStory.cjs.map +1 -1
  63. package/dist/components/ui/ScrollStory.d.ts +3 -1
  64. package/dist/components/ui/ScrollStory.js +34 -32
  65. package/dist/components/ui/ScrollStory.js.map +1 -1
  66. package/dist/components/ui/SeriesLabel.cjs +2 -0
  67. package/dist/components/ui/SeriesLabel.cjs.map +1 -0
  68. package/dist/components/ui/SeriesLabel.d.ts +21 -0
  69. package/dist/components/ui/SeriesLabel.js +38 -0
  70. package/dist/components/ui/SeriesLabel.js.map +1 -0
  71. package/dist/components/ui/StackedBar.cjs +1 -1
  72. package/dist/components/ui/StackedBar.cjs.map +1 -1
  73. package/dist/components/ui/StackedBar.d.ts +13 -1
  74. package/dist/components/ui/StackedBar.js +95 -74
  75. package/dist/components/ui/StackedBar.js.map +1 -1
  76. package/dist/components/ui/TableOfContents.cjs +1 -1
  77. package/dist/components/ui/TableOfContents.cjs.map +1 -1
  78. package/dist/components/ui/TableOfContents.js +31 -89
  79. package/dist/components/ui/TableOfContents.js.map +1 -1
  80. package/dist/components/ui/ThoughtCard.cjs +2 -0
  81. package/dist/components/ui/ThoughtCard.cjs.map +1 -0
  82. package/dist/components/ui/ThoughtCard.d.ts +23 -0
  83. package/dist/components/ui/ThoughtCard.js +55 -0
  84. package/dist/components/ui/ThoughtCard.js.map +1 -0
  85. package/dist/components/ui/index.d.ts +20 -0
  86. package/dist/hooks/index.d.ts +1 -0
  87. package/dist/hooks/useSectionSpy.cjs +2 -0
  88. package/dist/hooks/useSectionSpy.cjs.map +1 -0
  89. package/dist/hooks/useSectionSpy.d.ts +23 -0
  90. package/dist/hooks/useSectionSpy.js +78 -0
  91. package/dist/hooks/useSectionSpy.js.map +1 -0
  92. package/dist/index.cjs +1 -1
  93. package/dist/index.d.ts +4 -4
  94. package/dist/index.js +337 -310
  95. package/dist/index.js.map +1 -1
  96. package/dist/layouts/site/SiteAnchorNav.cjs +2 -0
  97. package/dist/layouts/site/SiteAnchorNav.cjs.map +1 -0
  98. package/dist/layouts/site/SiteAnchorNav.d.ts +22 -0
  99. package/dist/layouts/site/SiteAnchorNav.js +51 -0
  100. package/dist/layouts/site/SiteAnchorNav.js.map +1 -0
  101. package/dist/layouts/site/SiteSectionHeader.cjs +2 -0
  102. package/dist/layouts/site/SiteSectionHeader.cjs.map +1 -0
  103. package/dist/layouts/site/SiteSectionHeader.d.ts +20 -0
  104. package/dist/layouts/site/SiteSectionHeader.js +30 -0
  105. package/dist/layouts/site/SiteSectionHeader.js.map +1 -0
  106. package/dist/layouts/site/index.d.ts +4 -0
  107. package/dist/lib/chart.cjs +1 -1
  108. package/dist/lib/chart.cjs.map +1 -1
  109. package/dist/lib/chart.d.ts +8 -2
  110. package/dist/lib/chart.js +20 -16
  111. package/dist/lib/chart.js.map +1 -1
  112. package/dist/locale/strings.cjs +1 -1
  113. package/dist/locale/strings.cjs.map +1 -1
  114. package/dist/locale/strings.d.ts +2 -0
  115. package/dist/locale/strings.js +2 -0
  116. package/dist/locale/strings.js.map +1 -1
  117. package/dist/style.css +1 -1
  118. package/package.json +1 -1
@@ -0,0 +1,199 @@
1
+ import { jsx as n, jsxs as v } from "react/jsx-runtime";
2
+ import { useRef as F } from "react";
3
+ import { useElementWidth as G } from "../../hooks/useElementWidth.js";
4
+ import { niceTicks as K, chartColorValue as w } from "../../lib/chart.js";
5
+ /* empty css */
6
+ import { useStrings as U } from "../../locale/useStrings.js";
7
+ const g = 240, V = 32, W = 8, q = 20, z = 28, x = 8, B = 16, J = 4;
8
+ function nt({
9
+ series: A,
10
+ label: H,
11
+ xLabel: D,
12
+ yTicks: $,
13
+ formatX: f = String,
14
+ formatY: E = String,
15
+ playhead: a,
16
+ onSeek: r,
17
+ markers: k = [],
18
+ progress: M,
19
+ className: C
20
+ }) {
21
+ const I = U(), N = F(null), u = G(N), b = A.flatMap((t) => t.points), s = [...new Set(b.map((t) => t.x))].sort((t, e) => t - e), L = ["aegis-line-chart", C ?? ""].filter(Boolean).join(" ");
22
+ if (u === 0 || s.length === 0)
23
+ return /* @__PURE__ */ n("div", { ref: N, className: L });
24
+ const i = s[0], m = s[s.length - 1], P = b.map((t) => t.y), R = $ ?? K(0, Math.max(...P, 1)), j = Math.max(...R, ...P), c = V, l = u - W, d = q, _ = g - z, y = (t) => c + (m > i ? (t - i) / (m - i) : 0) * (l - c), p = (t) => _ - t / j * (_ - d), h = A.flatMap((t) => {
25
+ const e = t.points[t.points.length - 1];
26
+ return e === void 0 ? [] : [{ line: t, last: e, y: p(e.y) }];
27
+ }).sort((t, e) => e.y - t.y);
28
+ for (let t = 1; t < h.length; t += 1)
29
+ h[t - 1].y - h[t].y < B && (h[t].y = h[t - 1].y - B);
30
+ const T = (t) => s.reduce(
31
+ (e, o) => Math.abs(o - t) < Math.abs(e - t) ? o : e
32
+ ), O = (t) => {
33
+ const e = t.currentTarget.getBoundingClientRect(), o = (t.clientX - e.left) / e.width;
34
+ r?.(T(i + o * (m - i)));
35
+ }, S = (t) => {
36
+ const e = s.indexOf(T(a ?? i)), o = {
37
+ ArrowLeft: e - 1,
38
+ ArrowDown: e - 1,
39
+ ArrowRight: e + 1,
40
+ ArrowUp: e + 1,
41
+ Home: 0,
42
+ End: s.length - 1
43
+ };
44
+ t.key in o && (t.preventDefault(), r?.(s[Math.min(Math.max(o[t.key], 0), s.length - 1)]));
45
+ };
46
+ return /* @__PURE__ */ n("div", { ref: N, className: L, children: /* @__PURE__ */ v(
47
+ "svg",
48
+ {
49
+ className: "aegis-line-chart__svg",
50
+ width: u,
51
+ height: g,
52
+ viewBox: `0 0 ${u.toString()} ${g.toString()}`,
53
+ role: r ? "group" : "img",
54
+ "aria-label": H,
55
+ children: [
56
+ R.map((t) => /* @__PURE__ */ v("g", { children: [
57
+ /* @__PURE__ */ n(
58
+ "line",
59
+ {
60
+ className: "aegis-line-chart__grid",
61
+ x1: c,
62
+ x2: l,
63
+ y1: p(t),
64
+ y2: p(t)
65
+ }
66
+ ),
67
+ /* @__PURE__ */ n(
68
+ "text",
69
+ {
70
+ className: "aegis-line-chart__tick",
71
+ x: c - x,
72
+ y: p(t),
73
+ textAnchor: "end",
74
+ dominantBaseline: "middle",
75
+ children: E(t)
76
+ }
77
+ )
78
+ ] }, t)),
79
+ A.map((t) => /* @__PURE__ */ n(
80
+ "polyline",
81
+ {
82
+ className: "aegis-line-chart__line",
83
+ pathLength: 1,
84
+ points: t.points.map(
85
+ (e) => `${y(e.x).toString()},${p(e.y).toString()}`
86
+ ).join(" "),
87
+ style: {
88
+ stroke: w(t.color),
89
+ ...M === void 0 ? {} : { "--aegis-line-chart-progress": M }
90
+ }
91
+ },
92
+ t.key
93
+ )),
94
+ h.map(({ line: t, last: e, y: o }) => /* @__PURE__ */ n(
95
+ "text",
96
+ {
97
+ className: "aegis-line-chart__end-label",
98
+ x: l,
99
+ y: o - x,
100
+ textAnchor: "end",
101
+ style: { fill: w(t.color) },
102
+ children: `${t.label} ${E(e.y)}`
103
+ },
104
+ t.key
105
+ )),
106
+ a !== void 0 && /* @__PURE__ */ v("g", { children: [
107
+ /* @__PURE__ */ n(
108
+ "line",
109
+ {
110
+ className: "aegis-line-chart__playhead",
111
+ x1: y(a),
112
+ x2: y(a),
113
+ y1: d,
114
+ y2: _
115
+ }
116
+ ),
117
+ /* @__PURE__ */ n(
118
+ "text",
119
+ {
120
+ className: "aegis-line-chart__playhead-label",
121
+ x: y(a),
122
+ y: d - x / 2,
123
+ textAnchor: "middle",
124
+ children: f(a)
125
+ }
126
+ )
127
+ ] }),
128
+ /* @__PURE__ */ n(
129
+ "text",
130
+ {
131
+ className: "aegis-line-chart__tick",
132
+ x: c,
133
+ y: g - x,
134
+ textAnchor: "start",
135
+ children: f(i)
136
+ }
137
+ ),
138
+ /* @__PURE__ */ n(
139
+ "text",
140
+ {
141
+ className: "aegis-line-chart__tick",
142
+ x: l,
143
+ y: g - x,
144
+ textAnchor: "end",
145
+ children: f(m)
146
+ }
147
+ ),
148
+ D !== void 0 && /* @__PURE__ */ n(
149
+ "text",
150
+ {
151
+ className: "aegis-line-chart__tick",
152
+ x: (c + l) / 2,
153
+ y: g - x,
154
+ textAnchor: "middle",
155
+ children: D
156
+ }
157
+ ),
158
+ r && /* @__PURE__ */ n(
159
+ "rect",
160
+ {
161
+ className: "aegis-line-chart__seek",
162
+ x: c,
163
+ y: d,
164
+ width: l - c,
165
+ height: _ - d,
166
+ role: "slider",
167
+ tabIndex: 0,
168
+ "aria-label": I.replayPosition,
169
+ "aria-valuemin": i,
170
+ "aria-valuemax": m,
171
+ "aria-valuenow": a ?? i,
172
+ "aria-valuetext": f(a ?? i),
173
+ onClick: O,
174
+ onKeyDown: S
175
+ }
176
+ ),
177
+ k.map((t) => /* @__PURE__ */ n(
178
+ "circle",
179
+ {
180
+ className: "aegis-line-chart__marker",
181
+ cx: y(t.x),
182
+ cy: _,
183
+ r: J,
184
+ style: { fill: w(t.color) },
185
+ onClick: r ? () => {
186
+ r(t.x);
187
+ } : void 0,
188
+ children: /* @__PURE__ */ n("title", { children: t.label })
189
+ },
190
+ t.key
191
+ ))
192
+ ]
193
+ }
194
+ ) });
195
+ }
196
+ export {
197
+ nt as LineChart
198
+ };
199
+ //# sourceMappingURL=LineChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineChart.js","sources":["../../../src/components/ui/LineChart.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n useRef,\n} from 'react';\n\nimport { useElementWidth } from '../../hooks/useElementWidth';\nimport { type ChartColor, chartColorValue, niceTicks } from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './LineChart.css';\n\nexport interface LineChartPoint {\n x: number;\n y: number;\n}\n\nexport interface LineChartSeries {\n key: string;\n /** Written at the end of the line, with its last value. */\n label: string;\n color: ChartColor;\n points: LineChartPoint[];\n}\n\nexport interface LineChartMarker {\n key: string;\n x: number;\n color: ChartColor;\n /** Names the event in its tooltip. */\n label: string;\n}\n\nexport interface LineChartProps {\n series: LineChartSeries[];\n /** Names the chart for a screen reader. */\n label: string;\n /** Names the horizontal axis, e.g. \"回合\". */\n xLabel?: string;\n /** The gridlines. Defaults to about five round values. */\n yTicks?: number[];\n formatX?: (value: number) => string;\n formatY?: (value: number) => string;\n /** Where a replay's playhead is on the horizontal axis. */\n playhead?: number;\n /** Lets the reader click or use the arrow keys to move the playhead. */\n onSeek?: (x: number) => void;\n /** Events on the horizontal axis, e.g. a replay's key moments. */\n markers?: LineChartMarker[];\n /**\n * How far the lines are drawn, 0 to 1, for a chart that draws as its\n * section scrolls in (`useScrollProgress`). Omitted, it shows its final state.\n */\n progress?: number;\n className?: string;\n}\n\n// The SVG is drawn at its measured CSS width, so these are true px.\nconst HEIGHT = 240;\nconst PAD_LEFT = 32;\nconst PAD_RIGHT = 8;\nconst PAD_TOP = 20;\nconst PAD_BOTTOM = 28;\nconst END_LABEL_GAP = 8;\nconst END_LABEL_LINE = 16;\nconst MARKER_RADIUS = 4;\n\n/**\n * Lines over a shared horizontal axis, labelled at their ends instead of\n * in a legend, with an optional playhead the reader can move.\n */\nexport function LineChart({\n series,\n label,\n xLabel,\n yTicks,\n formatX = String,\n formatY = String,\n playhead,\n onSeek,\n markers = [],\n progress,\n className,\n}: LineChartProps): ReactElement {\n const strings = useStrings();\n const wrapRef = useRef<HTMLDivElement>(null);\n const width = useElementWidth(wrapRef);\n const points = series.flatMap((line) => line.points);\n const xs = [...new Set(points.map((point) => point.x))].sort((a, b) => a - b);\n const cls = ['aegis-line-chart', className ?? ''].filter(Boolean).join(' ');\n if (width === 0 || xs.length === 0) {\n return <div ref={wrapRef} className={cls} />;\n }\n\n const xLo = xs[0];\n const xHi = xs[xs.length - 1];\n const values = points.map((point) => point.y);\n const ticks = yTicks ?? niceTicks(0, Math.max(...values, 1));\n const yHi = Math.max(...ticks, ...values);\n const left = PAD_LEFT;\n const right = width - PAD_RIGHT;\n const top = PAD_TOP;\n const bottom = HEIGHT - PAD_BOTTOM;\n const sx = (x: number): number =>\n left + (xHi > xLo ? (x - xLo) / (xHi - xLo) : 0) * (right - left);\n const sy = (y: number): number => bottom - (y / yHi) * (bottom - top);\n\n // The end labels stack upwards when two lines finish close together, so\n // the lowest stays where its line ends and none runs into the x axis.\n const ends = series\n .flatMap((line) => {\n const last = line.points[line.points.length - 1] as\n | LineChartPoint\n | undefined;\n return last === undefined ? [] : [{ line, last, y: sy(last.y) }];\n })\n .sort((a, b) => b.y - a.y);\n for (let i = 1; i < ends.length; i += 1) {\n if (ends[i - 1].y - ends[i].y < END_LABEL_LINE) {\n ends[i].y = ends[i - 1].y - END_LABEL_LINE;\n }\n }\n\n const nearestX = (x: number): number =>\n xs.reduce((best, candidate) =>\n Math.abs(candidate - x) < Math.abs(best - x) ? candidate : best,\n );\n const seekFromPointer = (event: MouseEvent<SVGRectElement>): void => {\n const box = event.currentTarget.getBoundingClientRect();\n const share = (event.clientX - box.left) / box.width;\n onSeek?.(nearestX(xLo + share * (xHi - xLo)));\n };\n const seekFromKey = (event: KeyboardEvent<SVGRectElement>): void => {\n const index = xs.indexOf(nearestX(playhead ?? xLo));\n const target: Record<string, number> = {\n ArrowLeft: index - 1,\n ArrowDown: index - 1,\n ArrowRight: index + 1,\n ArrowUp: index + 1,\n Home: 0,\n End: xs.length - 1,\n };\n if (event.key in target) {\n event.preventDefault();\n onSeek?.(xs[Math.min(Math.max(target[event.key], 0), xs.length - 1)]);\n }\n };\n\n return (\n <div ref={wrapRef} className={cls}>\n <svg\n className=\"aegis-line-chart__svg\"\n width={width}\n height={HEIGHT}\n viewBox={`0 0 ${width.toString()} ${HEIGHT.toString()}`}\n role={onSeek ? 'group' : 'img'}\n aria-label={label}\n >\n {ticks.map((tick) => (\n <g key={tick}>\n <line\n className=\"aegis-line-chart__grid\"\n x1={left}\n x2={right}\n y1={sy(tick)}\n y2={sy(tick)}\n />\n <text\n className=\"aegis-line-chart__tick\"\n x={left - END_LABEL_GAP}\n y={sy(tick)}\n textAnchor=\"end\"\n dominantBaseline=\"middle\"\n >\n {formatY(tick)}\n </text>\n </g>\n ))}\n {series.map((line) => (\n <polyline\n key={line.key}\n className=\"aegis-line-chart__line\"\n pathLength={1}\n points={line.points\n .map(\n (point) =>\n `${sx(point.x).toString()},${sy(point.y).toString()}`,\n )\n .join(' ')}\n style={\n {\n stroke: chartColorValue(line.color),\n ...(progress === undefined\n ? {}\n : { '--aegis-line-chart-progress': progress }),\n } as CSSProperties\n }\n />\n ))}\n {ends.map(({ line, last, y }) => (\n <text\n key={line.key}\n className=\"aegis-line-chart__end-label\"\n x={right}\n y={y - END_LABEL_GAP}\n textAnchor=\"end\"\n style={{ fill: chartColorValue(line.color) }}\n >\n {`${line.label} ${formatY(last.y)}`}\n </text>\n ))}\n {playhead !== undefined && (\n <g>\n <line\n className=\"aegis-line-chart__playhead\"\n x1={sx(playhead)}\n x2={sx(playhead)}\n y1={top}\n y2={bottom}\n />\n <text\n className=\"aegis-line-chart__playhead-label\"\n x={sx(playhead)}\n y={top - END_LABEL_GAP / 2}\n textAnchor=\"middle\"\n >\n {formatX(playhead)}\n </text>\n </g>\n )}\n <text\n className=\"aegis-line-chart__tick\"\n x={left}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"start\"\n >\n {formatX(xLo)}\n </text>\n <text\n className=\"aegis-line-chart__tick\"\n x={right}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"end\"\n >\n {formatX(xHi)}\n </text>\n {xLabel !== undefined && (\n <text\n className=\"aegis-line-chart__tick\"\n x={(left + right) / 2}\n y={HEIGHT - END_LABEL_GAP}\n textAnchor=\"middle\"\n >\n {xLabel}\n </text>\n )}\n {onSeek && (\n <rect\n className=\"aegis-line-chart__seek\"\n x={left}\n y={top}\n width={right - left}\n height={bottom - top}\n role=\"slider\"\n tabIndex={0}\n aria-label={strings.replayPosition}\n aria-valuemin={xLo}\n aria-valuemax={xHi}\n aria-valuenow={playhead ?? xLo}\n aria-valuetext={formatX(playhead ?? xLo)}\n onClick={seekFromPointer}\n onKeyDown={seekFromKey}\n />\n )}\n {markers.map((marker) => (\n <circle\n key={marker.key}\n className=\"aegis-line-chart__marker\"\n cx={sx(marker.x)}\n cy={bottom}\n r={MARKER_RADIUS}\n style={{ fill: chartColorValue(marker.color) }}\n onClick={\n onSeek\n ? () => {\n onSeek(marker.x);\n }\n : undefined\n }\n >\n <title>{marker.label}</title>\n </circle>\n ))}\n </svg>\n </div>\n );\n}\n"],"names":["HEIGHT","PAD_LEFT","PAD_RIGHT","PAD_TOP","PAD_BOTTOM","END_LABEL_GAP","END_LABEL_LINE","MARKER_RADIUS","LineChart","series","label","xLabel","yTicks","formatX","formatY","playhead","onSeek","markers","progress","className","strings","useStrings","wrapRef","useRef","width","useElementWidth","points","line","xs","point","a","b","cls","jsx","xLo","xHi","values","ticks","niceTicks","yHi","left","right","top","bottom","sx","x","sy","y","ends","last","i","nearestX","best","candidate","seekFromPointer","event","box","share","seekFromKey","index","target","jsxs","tick","chartColorValue","marker"],"mappings":";;;;;;AA2DA,MAAMA,IAAS,KACTC,IAAW,IACXC,IAAY,GACZC,IAAU,IACVC,IAAa,IACbC,IAAgB,GAChBC,IAAiB,IACjBC,IAAgB;AAMf,SAASC,GAAU;AAAA,EACxB,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,SAAAC,IAAU;AAAA,EACV,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC,IAAU,CAAA;AAAA,EACV,UAAAC;AAAA,EACA,WAAAC;AACF,GAAiC;AAC/B,QAAMC,IAAUC,EAAA,GACVC,IAAUC,EAAuB,IAAI,GACrCC,IAAQC,EAAgBH,CAAO,GAC/BI,IAASjB,EAAO,QAAQ,CAACkB,MAASA,EAAK,MAAM,GAC7CC,IAAK,CAAC,GAAG,IAAI,IAAIF,EAAO,IAAI,CAACG,MAAUA,EAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAACC,GAAGC,MAAMD,IAAIC,CAAC,GACtEC,IAAM,CAAC,oBAAoBb,KAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAC1E,MAAIK,MAAU,KAAKI,EAAG,WAAW;AAC/B,WAAO,gBAAAK,EAAC,OAAA,EAAI,KAAKX,GAAS,WAAWU,GAAK;AAG5C,QAAME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AGpC;AAAA,YACH,OAAO,EAAE,MAAMwD,EAAgBC,EAAO,KAAK,EAAA;AAAA,YAC3C,SACEhD,IACI,MAAM;AACJ,cAAAA,EAAOgD,EAAO,CAAC;AAAA,YACjB,IACA;AAAA,YAGN,UAAA,gBAAA/B,EAAC,SAAA,EAAO,UAAA+B,EAAO,MAAA,CAAM;AAAA,UAAA;AAAA,UAdhBA,EAAO;AAAA,QAAA,CAgBf;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAEL;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),K=require("react"),Q=require("../../hooks/useElementWidth.cjs"),p=require("../../lib/chart.cjs"),Z=require("./ChartLegend.cjs"),ee=require("./EmptyState.cjs");;/* empty css */const te=require("../../locale/useStrings.cjs"),se=320,z=220,re=56,ae=16,oe=28,ie=44,le=5,i=8,W=4;function N(r,m,f){return f==="lower"?r<m:r>m}function ne({points:r,xLabel:m,yLabel:f,xDirection:k="lower",yDirection:b="higher",formatX:I=String,formatY:L=String,onSelect:n,legend:A,empty:$,emptyTitle:X,emptyDescription:F,progress:h,className:U}){const B=te.useStrings(),j=K.useRef(null),d=Q.useElementWidth(j),P=["aegis-pareto",h===void 0?"":"aegis-pareto--scroll",U??""].filter(Boolean).join(" "),c=K.useMemo(()=>{if(r.length===0||d===0)return null;const e=Math.round(Math.min(se,Math.max(z,d/2))),[o,x]=p.zeroAnchoredDomain(r.map(t=>t.x)),[g,M]=p.zeroAnchoredDomain(r.map(t=>t.y)),q=re,C=d-ae,D=oe,w=e-ie,v=t=>q+(t-o)/(x-o)*(C-q),O=t=>w-(t-g)/(M-g)*(w-D),R=r.filter(t=>!r.some(a=>a.key!==t.key&&(N(a.x,t.x,k)||a.x===t.x)&&(N(a.y,t.y,b)||a.y===t.y)&&(N(a.x,t.x,k)||N(a.y,t.y,b)))).sort((t,a)=>t.x-a.x),G=Array.from({length:W},(t,a)=>(a+1)/W),J=new Map([...r].sort((t,a)=>v(t.x)-v(a.x)).map((t,a)=>[t.key,a]));return{height:e,order:J,left:q,right:C,top:D,bottom:w,sx:v,sy:O,front:R,frontKeys:new Set(R.map(t=>t.key)),gridX:G.map(t=>v(o+(x-o)*t)),gridY:G.map(t=>O(g+(M-g)*t)),xLo:o,xHi:x,yLo:g,yHi:M}},[r,d,k,b]);if(r.length===0)return s.jsx("div",{ref:j,className:P,children:$===void 0?s.jsx(ee.EmptyState,{title:X??B.paretoEmptyTitle,description:F}):s.jsx("div",{className:"aegis-pareto__empty",style:{"--aegis-pareto-min-height":`${z.toString()}px`},children:$})});if(!c)return s.jsx("div",{ref:j,className:P});const{height:E,left:l,right:_,top:u,bottom:y,sx:S,sy:T,front:H,frontKeys:V}=c,Y=(e,o)=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),n?.(o))};return s.jsxs("div",{ref:j,className:P,children:[s.jsxs("svg",{className:"aegis-pareto__svg",width:d,height:E,viewBox:`0 0 ${d.toString()} ${E.toString()}`,role:n?"group":"img","aria-label":B.paretoChartLabel(m,f),style:{"--aegis-pareto-count":r.length,...h===void 0?{}:{"--aegis-pareto-front-progress":p.staggeredProgress(h,r.length,r.length+1)}},children:[c.gridY.map(e=>s.jsx("line",{className:"aegis-pareto__grid",x1:l,y1:e,x2:_,y2:e},`gy-${e.toString()}`)),c.gridX.map(e=>s.jsx("line",{className:"aegis-pareto__grid",x1:e,y1:u,x2:e,y2:y},`gx-${e.toString()}`)),s.jsx("line",{className:"aegis-pareto__axis",x1:l,y1:y,x2:_,y2:y}),s.jsx("line",{className:"aegis-pareto__axis",x1:l,y1:u,x2:l,y2:y}),H.length>1&&s.jsx("polyline",{className:"aegis-pareto__front",points:H.map(e=>`${S(e.x).toString()},${T(e.y).toString()}`).join(" ")}),r.map((e,o)=>s.jsx("circle",{className:["aegis-pareto__point",V.has(e.key)?"":"aegis-pareto__point--dominated",n?"aegis-pareto__point--interactive":""].filter(Boolean).join(" "),style:{fill:e.color===void 0?void 0:p.chartColorValue(e.color),"--aegis-pareto-index":o,...h===void 0?{}:{"--aegis-pareto-point-progress":p.staggeredProgress(h,c.order.get(e.key)??o,r.length+1)}},cx:S(e.x),cy:T(e.y),r:le,role:n?"button":void 0,tabIndex:n?0:void 0,"aria-label":n?e.label:void 0,onClick:n?()=>{n(e.key)}:void 0,onKeyDown:n?x=>{Y(x,e.key)}:void 0,children:s.jsx("title",{children:e.label})},e.key)),H.map(e=>{const o=S(e.x),x=T(e.y),g=o>l+(_-l)*.7;return s.jsx("text",{className:"aegis-pareto__point-label",x:g?o-i:o+i,y:x<u+i*2?x+i*2:x-i,textAnchor:g?"end":"start",children:e.label},`label-${e.key}`)}),s.jsx("text",{className:"aegis-pareto__tick",x:l,y:y+i*2,textAnchor:"middle",children:I(c.xLo)}),s.jsx("text",{className:"aegis-pareto__tick",x:_,y:y+i*2,textAnchor:"end",children:I(c.xHi)}),s.jsx("text",{className:"aegis-pareto__tick",x:l-i,y,textAnchor:"end",dominantBaseline:"middle",children:L(c.yLo)}),s.jsx("text",{className:"aegis-pareto__tick",x:l-i,y:u,textAnchor:"end",dominantBaseline:"middle",children:L(c.yHi)}),s.jsx("text",{className:"aegis-pareto__axis-label",x:_,y:E-i,textAnchor:"end",children:m}),s.jsx("text",{className:"aegis-pareto__axis-label",x:l-i,y:u-i*2,textAnchor:"start",children:f})]}),A!==void 0&&A.length>0?s.jsx(Z.ChartLegend,{className:"aegis-pareto__legend",shape:"dot",items:A.map(e=>({key:e.key,label:e.label,color:e.color??"var(--bg-inverted)"}))}):null]})}exports.ParetoChart=ne;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),ee=require("react"),ve=require("../../hooks/useElementWidth.cjs"),M=require("../../lib/chart.cjs"),ke=require("./ChartLegend.cjs"),je=require("./EmptyState.cjs");;/* empty css */const Ae=require("../../locale/useStrings.cjs"),Le=320,de=220,Ne=56,Ee=16,Pe=28,Ie=44,S=5,B=8,he=4,we=6.2,Me=11,X=14,Se=520;function K(r,y,i){return i==="lower"?r<y:r>y}function Be(r){return[...r].reduce((y,i)=>y+((i.codePointAt(0)??0)>255?Me:we),0)}function $e(r,y,i){const p=[],b=new Map,v=S+B/2;for(const l of r){const m=Be(l.label),k=[{x:l.x+v,y:l.y+X/3,anchor:"start"},{x:l.x-v,y:l.y+X/3,anchor:"end"},{x:l.x-m/2,y:l.y-v,anchor:"start"},{x:l.x-m/2,y:l.y+v+X,anchor:"start"}],j=g=>{const x=g.anchor==="end"?g.x-m:g.x;return{l:x,r:x+m,t:g.y-X,b:g.y}},A=g=>{const{l:x,r:_,t:n,b:N}=j(g);return x>=i.left&&_<=i.right&&n>=i.top&&N<=i.bottom},$=g=>{const{l:x,r:_,t:n,b:N}=j(g);return A(g)&&p.every(c=>_<c.l||x>c.r||N<c.t||n>c.b)&&y.every(c=>c.key===l.key||c.x+S<x||c.x-S>_||c.y+S<n||c.y-S>N)},L=k.find($)??k.find(A)??k[l.x>(i.left+i.right)/2?1:0];p.push(j(L)),b.set(l.key,L)}return b}function He({points:r,xLabel:y,yLabel:i,xDirection:p="lower",yDirection:b="higher",formatX:v=String,formatY:l=String,xScale:m="linear",xDomain:k,yDomain:j,xTicks:A,yTicks:$,labels:L="front",fadeDominated:g=!0,highlightKeys:x,maxHeight:_=Le,onSelect:n,legend:N,empty:c,emptyTitle:me,emptyDescription:_e,progress:u,frontProgress:te,className:ue}){const re=Ae.useStrings(),se=ee.useId(),T=ee.useRef(null),f=ve.useElementWidth(T),z=["aegis-pareto",u===void 0&&te===void 0?"":"aegis-pareto--scroll",ue??""].filter(Boolean).join(" "),d=ee.useMemo(()=>{if(r.length===0||f===0)return null;const e=Math.round(Math.min(_,Math.max(de,f/2))),a=r.map(t=>t.x),w=Math.min(...a),O=Math.max(...a),[F,ce]=k??(m==="log"?[O>w?w:w/2,O>w?O:O*2]:M.zeroAnchoredDomain(a)),[q,U]=j??M.zeroAnchoredDomain(r.map(t=>t.y)),G=m==="log"?Math.log10:t=>t,R=Ne,J=f-Ee,ge=Pe,Q=e-Ie,W=t=>R+(G(t)-G(F))/(G(ce)-G(F))*(J-R),Z=t=>Q-(t-q)/(U-q)*(Q-ge),xe=r.filter(t=>!r.some(o=>o.key!==t.key&&(K(o.x,t.x,p)||o.x===t.x)&&(K(o.y,t.y,b)||o.y===t.y)&&(K(o.x,t.x,p)||K(o.y,t.y,b)))).sort((t,o)=>t.x-o.x),ye=Array.from({length:he},(t,o)=>(o+1)/he),be=new Map([...r].sort((t,o)=>W(t.x)-W(o.x)).map((t,o)=>[t.key,o]));return{height:e,order:be,left:R,right:J,top:ge,bottom:Q,sx:W,sy:Z,front:xe,frontKeys:new Set(xe.map(t=>t.key)),gridX:A?.map(W)??ye.map(t=>R+(J-R)*t),gridY:$?.map(Z)??ye.map(t=>Z(q+(U-q)*t)),xLabels:A??[F,ce],yLabels:$??[q,U]}},[r,f,p,b,m,k,j,A,$,_]);if(r.length===0)return s.jsx("div",{ref:T,className:z,children:c===void 0?s.jsx(je.EmptyState,{title:me??re.paretoEmptyTitle,description:_e}):s.jsx("div",{className:"aegis-pareto__empty",style:{"--aegis-pareto-min-height":`${de.toString()}px`},children:c})});if(!d)return s.jsx("div",{ref:T,className:z});const{height:D,left:h,right:E,top:V,bottom:P,sx:I,sy:H,front:ae,frontKeys:oe}=d,Y=x===void 0?null:new Set(x),le=e=>Y!==null&&!Y.has(e),ne=L==="all"&&f>=Se,fe=$e(r.filter(e=>ne||oe.has(e.key)||(Y?.has(e.key)??!1)).map(e=>({key:e.key,label:e.label,x:I(e.x),y:H(e.y)})),r.map(e=>({key:e.key,x:I(e.x),y:H(e.y)})),{left:h,right:E,top:0,bottom:P}),ie=N?.map(e=>({key:e.key,label:e.label,color:e.color??"var(--bg-inverted)"}))??(L==="all"&&!ne?r.map(e=>({key:e.key,label:e.label,color:e.color??"var(--bg-inverted)"})):[]),C=te??(u===void 0?void 0:M.staggeredProgress(u,r.length,r.length+1)),pe=(e,a)=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),n?.(a))};return s.jsxs("div",{ref:T,className:z,children:[s.jsxs("svg",{className:"aegis-pareto__svg",width:f,height:D,viewBox:`0 0 ${f.toString()} ${D.toString()}`,role:n?"group":"img","aria-label":re.paretoChartLabel(y,i),style:{"--aegis-pareto-count":r.length,...C===void 0?{}:{"--aegis-pareto-front-progress":C}},children:[d.gridY.map(e=>s.jsx("line",{className:"aegis-pareto__grid",x1:h,y1:e,x2:E,y2:e},`gy-${e.toString()}`)),d.gridX.map(e=>s.jsx("line",{className:"aegis-pareto__grid",x1:e,y1:V,x2:e,y2:P},`gx-${e.toString()}`)),s.jsx("line",{className:"aegis-pareto__axis",x1:h,y1:P,x2:E,y2:P}),s.jsx("line",{className:"aegis-pareto__axis",x1:h,y1:V,x2:h,y2:P}),C!==void 0&&s.jsx("clipPath",{id:se,children:s.jsx("rect",{x:h,y:0,width:(E-h)*C,height:D})}),ae.length>1&&s.jsx("polyline",{className:"aegis-pareto__front",clipPath:C===void 0?void 0:`url(#${se})`,points:ae.map(e=>`${I(e.x).toString()},${H(e.y).toString()}`).join(" ")}),r.map((e,a)=>s.jsx("circle",{className:["aegis-pareto__point",g&&!oe.has(e.key)?"aegis-pareto__point--dominated":"",le(e.key)?"aegis-pareto__point--dimmed":"",n?"aegis-pareto__point--interactive":""].filter(Boolean).join(" "),style:{fill:e.color===void 0?void 0:M.chartColorValue(e.color),"--aegis-pareto-index":a,"--aegis-pareto-point-progress":u===void 0?1:M.staggeredProgress(u,d.order.get(e.key)??a,r.length+1)},cx:I(e.x),cy:H(e.y),r:S,role:n?"button":void 0,tabIndex:n?0:void 0,"aria-label":n?e.label:void 0,onClick:n?()=>{n(e.key)}:void 0,onKeyDown:n?w=>{pe(w,e.key)}:void 0,children:s.jsx("title",{children:e.label})},e.key)),r.map(e=>{const a=fe.get(e.key);return a===void 0?null:s.jsx("text",{className:["aegis-pareto__point-label",le(e.key)?"aegis-pareto__point-label--dimmed":""].filter(Boolean).join(" "),style:L==="all"?{"--aegis-pareto-front-progress":u===void 0?1:M.staggeredProgress(u,d.order.get(e.key)??0,r.length+1)}:void 0,x:a.x,y:a.y,textAnchor:a.anchor,children:e.label},`label-${e.key}`)}),d.xLabels.map((e,a)=>s.jsx("text",{className:"aegis-pareto__tick",x:I(e),y:P+B*2,textAnchor:a===d.xLabels.length-1&&I(e)>=E-1?"end":"middle",children:v(e)},`x-${e.toString()}`)),d.yLabels.map(e=>s.jsx("text",{className:"aegis-pareto__tick",x:h-B,y:H(e),textAnchor:"end",dominantBaseline:"middle",children:l(e)},`y-${e.toString()}`)),s.jsx("text",{className:"aegis-pareto__axis-label",x:E,y:D-B,textAnchor:"end",children:y}),s.jsx("text",{className:"aegis-pareto__axis-label",x:h-B,y:V-B*2,textAnchor:"start",children:i})]}),ie.length>0?s.jsx(ke.ChartLegend,{className:"aegis-pareto__legend",shape:"dot",items:ie}):null]})}exports.ParetoChart=He;
2
2
  //# sourceMappingURL=ParetoChart.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ParetoChart.cjs","sources":["../../../src/components/ui/ParetoChart.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactNode,\n useMemo,\n useRef,\n} from 'react';\n\nimport { useElementWidth } from '../../hooks/useElementWidth';\nimport {\n type ChartColor,\n chartColorValue,\n staggeredProgress,\n zeroAnchoredDomain,\n} from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport { ChartLegend } from './ChartLegend';\nimport { EmptyState } from './EmptyState';\nimport './ParetoChart.css';\n\nexport interface ParetoPoint {\n key: string;\n label: string;\n x: number;\n y: number;\n /** Point fill, e.g. `cat-2` or a series token, to match the series elsewhere. */\n color?: ChartColor;\n}\n\n/** One series in the legend under the plot, e.g. a model and its colour. */\nexport interface ParetoLegendItem {\n key: string;\n label: ReactNode;\n /** Swatch fill; the same value its points use. */\n color?: ChartColor;\n}\n\ninterface ParetoChartProps {\n points: ParetoPoint[];\n xLabel: string;\n yLabel: string;\n /** Which direction counts as better on each axis. */\n xDirection?: 'lower' | 'higher';\n yDirection?: 'lower' | 'higher';\n /** Formats the 0 and maximum labels of each axis. */\n formatX?: (value: number) => string;\n formatY?: (value: number) => string;\n onSelect?: (key: string) => void;\n /** Series swatches with labels, listed under the plot. */\n legend?: ParetoLegendItem[];\n /**\n * Shown in place of the plot, at its minimum height, while there are no\n * points — e.g. an EmptyState with an icon asking for both axes. Replaces\n * the default empty state built from `emptyTitle`.\n */\n empty?: ReactNode;\n emptyTitle?: string;\n emptyDescription?: string;\n /**\n * How far the chart is drawn, 0 to 1, for a chart that draws as its\n * section scrolls in (`useScrollProgress`): points fade in from left to\n * right, then the frontier. Omitted, they fade in once on mount.\n */\n progress?: number;\n className?: string;\n}\n\n// The SVG is drawn at its measured CSS width, so these are true px.\nconst MAX_HEIGHT = 320;\nconst MIN_HEIGHT = 220;\nconst PAD_LEFT = 56;\nconst PAD_RIGHT = 16;\nconst PAD_TOP = 28;\nconst PAD_BOTTOM = 44;\nconst POINT_RADIUS = 5;\nconst LABEL_GAP = 8;\nconst GRID_STEPS = 4;\n\ntype Direction = 'lower' | 'higher';\n\nfunction better(a: number, b: number, direction: Direction): boolean {\n return direction === 'lower' ? a < b : a > b;\n}\n\nexport function ParetoChart({\n points,\n xLabel,\n yLabel,\n xDirection = 'lower',\n yDirection = 'higher',\n formatX = String,\n formatY = String,\n onSelect,\n legend,\n empty,\n emptyTitle,\n emptyDescription,\n progress,\n className,\n}: ParetoChartProps) {\n const strings = useStrings();\n const wrapRef = useRef<HTMLDivElement>(null);\n const width = useElementWidth(wrapRef);\n const cls = [\n 'aegis-pareto',\n progress === undefined ? '' : 'aegis-pareto--scroll',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const geometry = useMemo(() => {\n if (points.length === 0 || width === 0) {\n return null;\n }\n const height = Math.round(\n Math.min(MAX_HEIGHT, Math.max(MIN_HEIGHT, width / 2)),\n );\n const [xLo, xHi] = zeroAnchoredDomain(points.map((point) => point.x));\n const [yLo, yHi] = zeroAnchoredDomain(points.map((point) => point.y));\n const left = PAD_LEFT;\n const right = width - PAD_RIGHT;\n const top = PAD_TOP;\n const bottom = height - PAD_BOTTOM;\n const sx = (value: number): number =>\n left + ((value - xLo) / (xHi - xLo)) * (right - left);\n const sy = (value: number): number =>\n bottom - ((value - yLo) / (yHi - yLo)) * (bottom - top);\n const front = points\n .filter(\n (candidate) =>\n !points.some(\n (other) =>\n other.key !== candidate.key &&\n (better(other.x, candidate.x, xDirection) ||\n other.x === candidate.x) &&\n (better(other.y, candidate.y, yDirection) ||\n other.y === candidate.y) &&\n (better(other.x, candidate.x, xDirection) ||\n better(other.y, candidate.y, yDirection)),\n ),\n )\n .sort((a, b) => a.x - b.x);\n const steps = Array.from(\n { length: GRID_STEPS },\n (_, i) => (i + 1) / GRID_STEPS,\n );\n // Points draw in from left to right; the frontier comes last.\n const order = new Map(\n [...points]\n .sort((a, b) => sx(a.x) - sx(b.x))\n .map((point, rank) => [point.key, rank]),\n );\n return {\n height,\n order,\n left,\n right,\n top,\n bottom,\n sx,\n sy,\n front,\n frontKeys: new Set(front.map((point) => point.key)),\n gridX: steps.map((t) => sx(xLo + (xHi - xLo) * t)),\n gridY: steps.map((t) => sy(yLo + (yHi - yLo) * t)),\n xLo,\n xHi,\n yLo,\n yHi,\n };\n }, [points, width, xDirection, yDirection]);\n\n if (points.length === 0) {\n return (\n <div ref={wrapRef} className={cls}>\n {empty === undefined ? (\n <EmptyState\n title={emptyTitle ?? strings.paretoEmptyTitle}\n description={emptyDescription}\n />\n ) : (\n <div\n className=\"aegis-pareto__empty\"\n style={\n {\n '--aegis-pareto-min-height': `${MIN_HEIGHT.toString()}px`,\n } as CSSProperties\n }\n >\n {empty}\n </div>\n )}\n </div>\n );\n }\n\n if (!geometry) {\n return <div ref={wrapRef} className={cls} />;\n }\n\n const { height, left, right, top, bottom, sx, sy, front, frontKeys } =\n geometry;\n const selectOnKey = (event: KeyboardEvent<SVGCircleElement>, key: string) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n onSelect?.(key);\n }\n };\n\n return (\n <div ref={wrapRef} className={cls}>\n <svg\n className=\"aegis-pareto__svg\"\n width={width}\n height={height}\n viewBox={`0 0 ${width.toString()} ${height.toString()}`}\n role={onSelect ? 'group' : 'img'}\n aria-label={strings.paretoChartLabel(xLabel, yLabel)}\n style={\n {\n '--aegis-pareto-count': points.length,\n ...(progress === undefined\n ? {}\n : {\n '--aegis-pareto-front-progress': staggeredProgress(\n progress,\n points.length,\n points.length + 1,\n ),\n }),\n } as CSSProperties\n }\n >\n {geometry.gridY.map((y) => (\n <line\n key={`gy-${y.toString()}`}\n className=\"aegis-pareto__grid\"\n x1={left}\n y1={y}\n x2={right}\n y2={y}\n />\n ))}\n {geometry.gridX.map((x) => (\n <line\n key={`gx-${x.toString()}`}\n className=\"aegis-pareto__grid\"\n x1={x}\n y1={top}\n x2={x}\n y2={bottom}\n />\n ))}\n <line\n className=\"aegis-pareto__axis\"\n x1={left}\n y1={bottom}\n x2={right}\n y2={bottom}\n />\n <line\n className=\"aegis-pareto__axis\"\n x1={left}\n y1={top}\n x2={left}\n y2={bottom}\n />\n {front.length > 1 && (\n <polyline\n className=\"aegis-pareto__front\"\n points={front\n .map(\n (point) =>\n `${sx(point.x).toString()},${sy(point.y).toString()}`,\n )\n .join(' ')}\n />\n )}\n {points.map((point, index) => (\n <circle\n key={point.key}\n className={[\n 'aegis-pareto__point',\n frontKeys.has(point.key) ? '' : 'aegis-pareto__point--dominated',\n onSelect ? 'aegis-pareto__point--interactive' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n style={\n {\n fill:\n point.color === undefined\n ? undefined\n : chartColorValue(point.color),\n '--aegis-pareto-index': index,\n ...(progress === undefined\n ? {}\n : {\n '--aegis-pareto-point-progress': staggeredProgress(\n progress,\n geometry.order.get(point.key) ?? index,\n points.length + 1,\n ),\n }),\n } as CSSProperties\n }\n cx={sx(point.x)}\n cy={sy(point.y)}\n r={POINT_RADIUS}\n role={onSelect ? 'button' : undefined}\n tabIndex={onSelect ? 0 : undefined}\n aria-label={onSelect ? point.label : undefined}\n onClick={\n onSelect\n ? () => {\n onSelect(point.key);\n }\n : undefined\n }\n onKeyDown={\n onSelect\n ? (event) => {\n selectOnKey(event, point.key);\n }\n : undefined\n }\n >\n <title>{point.label}</title>\n </circle>\n ))}\n {front.map((point) => {\n const x = sx(point.x);\n const y = sy(point.y);\n const flip = x > left + (right - left) * 0.7;\n return (\n <text\n key={`label-${point.key}`}\n className=\"aegis-pareto__point-label\"\n x={flip ? x - LABEL_GAP : x + LABEL_GAP}\n y={y < top + LABEL_GAP * 2 ? y + LABEL_GAP * 2 : y - LABEL_GAP}\n textAnchor={flip ? 'end' : 'start'}\n >\n {point.label}\n </text>\n );\n })}\n <text\n className=\"aegis-pareto__tick\"\n x={left}\n y={bottom + LABEL_GAP * 2}\n textAnchor=\"middle\"\n >\n {formatX(geometry.xLo)}\n </text>\n <text\n className=\"aegis-pareto__tick\"\n x={right}\n y={bottom + LABEL_GAP * 2}\n textAnchor=\"end\"\n >\n {formatX(geometry.xHi)}\n </text>\n <text\n className=\"aegis-pareto__tick\"\n x={left - LABEL_GAP}\n y={bottom}\n textAnchor=\"end\"\n dominantBaseline=\"middle\"\n >\n {formatY(geometry.yLo)}\n </text>\n <text\n className=\"aegis-pareto__tick\"\n x={left - LABEL_GAP}\n y={top}\n textAnchor=\"end\"\n dominantBaseline=\"middle\"\n >\n {formatY(geometry.yHi)}\n </text>\n <text\n className=\"aegis-pareto__axis-label\"\n x={right}\n y={height - LABEL_GAP}\n textAnchor=\"end\"\n >\n {xLabel}\n </text>\n <text\n className=\"aegis-pareto__axis-label\"\n x={left - LABEL_GAP}\n y={top - LABEL_GAP * 2}\n textAnchor=\"start\"\n >\n {yLabel}\n </text>\n </svg>\n {legend !== undefined && legend.length > 0 ? (\n <ChartLegend\n className=\"aegis-pareto__legend\"\n shape=\"dot\"\n items={legend.map((item) => ({\n key: item.key,\n label: item.label,\n color: item.color ?? 'var(--bg-inverted)',\n }))}\n />\n ) : null}\n </div>\n );\n}\n"],"names":["MAX_HEIGHT","MIN_HEIGHT","PAD_LEFT","PAD_RIGHT","PAD_TOP","PAD_BOTTOM","POINT_RADIUS","LABEL_GAP","GRID_STEPS","better","a","b","direction","ParetoChart","points","xLabel","yLabel","xDirection","yDirection","formatX","formatY","onSelect","legend","empty","emptyTitle","emptyDescription","progress","className","strings","useStrings","wrapRef","useRef","width","useElementWidth","cls","geometry","useMemo","height","xLo","xHi","zeroAnchoredDomain","point","yLo","yHi","left","right","top","bottom","sx","value","sy","front","candidate","other","steps","_","i","order","rank","jsx","EmptyState","frontKeys","selectOnKey","event","key","jsxs","staggeredProgress","y","x","index","chartColorValue","flip","ChartLegend","item"],"mappings":"qWAoEMA,GAAa,IACbC,EAAa,IACbC,GAAW,GACXC,GAAY,GACZC,GAAU,GACVC,GAAa,GACbC,GAAe,EACfC,EAAY,EACZC,EAAa,EAInB,SAASC,EAAOC,EAAWC,EAAWC,EAA+B,CACnE,OAAOA,IAAc,QAAUF,EAAIC,EAAID,EAAIC,CAC7C,CAEO,SAASE,GAAY,CAC1B,OAAAC,EACA,OAAAC,EACA,OAAAC,EACA,WAAAC,EAAa,QACb,WAAAC,EAAa,SACb,QAAAC,EAAU,OACV,QAAAC,EAAU,OACV,SAAAC,EACA,OAAAC,EACA,MAAAC,EACA,WAAAC,EACA,iBAAAC,EACA,SAAAC,EACA,UAAAC,CACF,EAAqB,CACnB,MAAMC,EAAUC,GAAAA,WAAA,EACVC,EAAUC,EAAAA,OAAuB,IAAI,EACrCC,EAAQC,EAAAA,gBAAgBH,CAAO,EAC/BI,EAAM,CACV,eACAR,IAAa,OAAY,GAAK,uBAC9BC,GAAa,EAAA,EAEZ,OAAO,OAAO,EACd,KAAK,GAAG,EAELQ,EAAWC,EAAAA,QAAQ,IAAM,CAC7B,GAAItB,EAAO,S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xB,WAAW,MAEV,SAAAY,EAAQgB,EAAS,GAAG,CAAA,CAAA,EAEvBwB,EAAAA,IAAC,OAAA,CACC,UAAU,qBACV,EAAGf,EAAOrC,EACVwC,EACA,WAAW,MACX,iBAAiB,SAEhB,SAAA3B,EAAQe,EAAS,GAAG,CAAA,CAAA,EAEvBwB,EAAAA,IAAC,OAAA,CACC,UAAU,qBACV,EAAGf,EAAOrC,EACV,EAAGuC,EACH,WAAW,MACX,iBAAiB,SAEhB,SAAA1B,EAAQe,EAAS,GAAG,CAAA,CAAA,EAEvBwB,EAAAA,IAAC,OAAA,CACC,UAAU,2BACV,EAAGd,EACH,EAAGR,EAAS9B,EACZ,WAAW,MAEV,SAAAQ,CAAA,CAAA,EAEH4C,EAAAA,IAAC,OAAA,CACC,UAAU,2BACV,EAAGf,EAAOrC,EACV,EAAGuC,EAAMvC,EAAY,EACrB,WAAW,QAEV,SAAAS,CAAA,CAAA,CACH,CAAA,CAAA,EAEDM,IAAW,QAAaA,EAAO,OAAS,EACvCqC,EAAAA,IAACa,EAAAA,YAAA,CACC,UAAU,uBACV,MAAM,MACN,MAAOlD,EAAO,IAAKmD,IAAU,CAC3B,IAAKA,EAAK,IACV,MAAOA,EAAK,MACZ,MAAOA,EAAK,OAAS,oBAAA,EACrB,CAAA,CAAA,EAEF,IAAA,EACN,CAEJ"}
1
+ {"version":3,"file":"ParetoChart.cjs","sources":["../../../src/components/ui/ParetoChart.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactNode,\n useId,\n useMemo,\n useRef,\n} from 'react';\n\nimport { useElementWidth } from '../../hooks/useElementWidth';\nimport {\n type ChartColor,\n chartColorValue,\n staggeredProgress,\n zeroAnchoredDomain,\n} from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport { ChartLegend } from './ChartLegend';\nimport { EmptyState } from './EmptyState';\nimport './ParetoChart.css';\n\nexport interface ParetoPoint {\n key: string;\n label: string;\n x: number;\n y: number;\n /** Point fill, e.g. `cat-2` or a series token, to match the series elsewhere. */\n color?: ChartColor;\n}\n\n/** One series in the legend under the plot, e.g. a model and its colour. */\nexport interface ParetoLegendItem {\n key: string;\n label: ReactNode;\n /** Swatch fill; the same value its points use. */\n color?: ChartColor;\n}\n\ninterface ParetoChartProps {\n points: ParetoPoint[];\n xLabel: string;\n yLabel: string;\n /** Which direction counts as better on each axis. */\n xDirection?: 'lower' | 'higher';\n yDirection?: 'lower' | 'higher';\n /** Formats the labels of each axis. */\n formatX?: (value: number) => string;\n formatY?: (value: number) => string;\n /**\n * `log` spaces the horizontal axis by ratio, e.g. for a cost that spans\n * orders of magnitude; its values must be above 0. Defaults to `linear`.\n */\n xScale?: 'linear' | 'log';\n /** The ends of each axis. Defaults to from 0, or the data's own range on a log axis. */\n xDomain?: [number, number];\n yDomain?: [number, number];\n /**\n * The labelled gridlines of each axis. Defaults to plain gridlines with\n * labels at the two ends.\n */\n xTicks?: number[];\n yTicks?: number[];\n /**\n * Which points carry their name. `front` names the frontier; `all` names\n * every point, so the chart needs no legend. A plot too narrow for them\n * names the frontier and `highlightKeys` and lists every point under it.\n * Defaults to `front`.\n */\n labels?: 'front' | 'all';\n /** Fades the points off the frontier. Defaults to true. */\n fadeDominated?: boolean;\n /** Fades every other point, to pick out the ones a finding is about. */\n highlightKeys?: string[];\n /** The tallest the plot grows. */\n maxHeight?: number;\n onSelect?: (key: string) => void;\n /** Series swatches with labels, listed under the plot. */\n legend?: ParetoLegendItem[];\n /**\n * Shown in place of the plot, at its minimum height, while there are no\n * points — e.g. an EmptyState with an icon asking for both axes. Replaces\n * the default empty state built from `emptyTitle`.\n */\n empty?: ReactNode;\n emptyTitle?: string;\n emptyDescription?: string;\n /**\n * How far the chart is drawn, 0 to 1, for a chart that draws as its\n * section scrolls in (`useScrollProgress`): points fade in from left to\n * right, then the frontier. Omitted, they fade in once on mount.\n */\n progress?: number;\n /**\n * How far the frontier is traced, 0 to 1, for a host that draws it apart\n * from the points, such as one step of a scrolling story.\n */\n frontProgress?: number;\n className?: string;\n}\n\n// The SVG is drawn at its measured CSS width, so these are true px.\nconst MAX_HEIGHT = 320;\nconst MIN_HEIGHT = 220;\nconst PAD_LEFT = 56;\nconst PAD_RIGHT = 16;\nconst PAD_TOP = 28;\nconst PAD_BOTTOM = 44;\nconst POINT_RADIUS = 5;\nconst LABEL_GAP = 8;\nconst GRID_STEPS = 4;\n// Estimates for placing labels: --fs-11 text, and the width below which\n// `labels='all'` would crowd the plot.\nconst LABEL_CHAR = 6.2;\nconst LABEL_WIDE_CHAR = 11;\nconst LABEL_LINE = 14;\nconst ALL_LABELS_MIN_WIDTH = 520;\n\ntype Direction = 'lower' | 'higher';\n\nfunction better(a: number, b: number, direction: Direction): boolean {\n return direction === 'lower' ? a < b : a > b;\n}\n\ninterface LabelBox {\n x: number;\n y: number;\n anchor: 'start' | 'end';\n}\n\nfunction labelWidth(text: string): number {\n return [...text].reduce(\n (sum, char) =>\n sum + ((char.codePointAt(0) ?? 0) > 255 ? LABEL_WIDE_CHAR : LABEL_CHAR),\n 0,\n );\n}\n\n/**\n * Puts each label beside its point on the first side where it stays on the\n * plot and clear of the labels already placed and of the other points.\n */\nfunction placeLabels(\n labelled: Array<{ key: string; label: string; x: number; y: number }>,\n allPoints: Array<{ key: string; x: number; y: number }>,\n bounds: { left: number; right: number; top: number; bottom: number },\n): Map<string, LabelBox> {\n const placed: Array<{ l: number; r: number; t: number; b: number }> = [];\n const result = new Map<string, LabelBox>();\n const reach = POINT_RADIUS + LABEL_GAP / 2;\n for (const point of labelled) {\n const w = labelWidth(point.label);\n const candidates: LabelBox[] = [\n { x: point.x + reach, y: point.y + LABEL_LINE / 3, anchor: 'start' },\n { x: point.x - reach, y: point.y + LABEL_LINE / 3, anchor: 'end' },\n { x: point.x - w / 2, y: point.y - reach, anchor: 'start' },\n { x: point.x - w / 2, y: point.y + reach + LABEL_LINE, anchor: 'start' },\n ];\n const box = (candidate: LabelBox) => {\n const l = candidate.anchor === 'end' ? candidate.x - w : candidate.x;\n return {\n l,\n r: l + w,\n t: candidate.y - LABEL_LINE,\n b: candidate.y,\n };\n };\n const onPlot = (candidate: LabelBox): boolean => {\n const { l, r, t, b } = box(candidate);\n return (\n l >= bounds.left &&\n r <= bounds.right &&\n t >= bounds.top &&\n b <= bounds.bottom\n );\n };\n const clear = (candidate: LabelBox): boolean => {\n const { l, r, t, b } = box(candidate);\n return (\n onPlot(candidate) &&\n placed.every(\n (other) => r < other.l || l > other.r || b < other.t || t > other.b,\n ) &&\n allPoints.every(\n (other) =>\n other.key === point.key ||\n other.x + POINT_RADIUS < l ||\n other.x - POINT_RADIUS > r ||\n other.y + POINT_RADIUS < t ||\n other.y - POINT_RADIUS > b,\n )\n );\n };\n // With no side free the label still stays on the plot, towards its middle.\n const chosen =\n candidates.find(clear) ??\n candidates.find(onPlot) ??\n candidates[point.x > (bounds.left + bounds.right) / 2 ? 1 : 0];\n placed.push(box(chosen));\n result.set(point.key, chosen);\n }\n return result;\n}\n\nexport function ParetoChart({\n points,\n xLabel,\n yLabel,\n xDirection = 'lower',\n yDirection = 'higher',\n formatX = String,\n formatY = String,\n xScale = 'linear',\n xDomain,\n yDomain,\n xTicks,\n yTicks,\n labels = 'front',\n fadeDominated = true,\n highlightKeys,\n maxHeight = MAX_HEIGHT,\n onSelect,\n legend,\n empty,\n emptyTitle,\n emptyDescription,\n progress,\n frontProgress,\n className,\n}: ParetoChartProps) {\n const strings = useStrings();\n const clipId = useId();\n const wrapRef = useRef<HTMLDivElement>(null);\n const width = useElementWidth(wrapRef);\n const cls = [\n 'aegis-pareto',\n progress === undefined && frontProgress === undefined\n ? ''\n : 'aegis-pareto--scroll',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const geometry = useMemo(() => {\n if (points.length === 0 || width === 0) {\n return null;\n }\n const height = Math.round(\n Math.min(maxHeight, Math.max(MIN_HEIGHT, width / 2)),\n );\n const xValues = points.map((point) => point.x);\n const logLo = Math.min(...xValues);\n const logHi = Math.max(...xValues);\n const [xLo, xHi] =\n xDomain ??\n (xScale === 'log'\n ? // One value has no span to divide, so it sits mid-axis.\n ([\n logHi > logLo ? logLo : logLo / 2,\n logHi > logLo ? logHi : logHi * 2,\n ] as const)\n : zeroAnchoredDomain(xValues));\n const [yLo, yHi] =\n yDomain ?? zeroAnchoredDomain(points.map((point) => point.y));\n const scaleX = xScale === 'log' ? Math.log10 : (value: number) => value;\n const left = PAD_LEFT;\n const right = width - PAD_RIGHT;\n const top = PAD_TOP;\n const bottom = height - PAD_BOTTOM;\n const sx = (value: number): number =>\n left +\n ((scaleX(value) - scaleX(xLo)) / (scaleX(xHi) - scaleX(xLo))) *\n (right - left);\n const sy = (value: number): number =>\n bottom - ((value - yLo) / (yHi - yLo)) * (bottom - top);\n const front = points\n .filter(\n (candidate) =>\n !points.some(\n (other) =>\n other.key !== candidate.key &&\n (better(other.x, candidate.x, xDirection) ||\n other.x === candidate.x) &&\n (better(other.y, candidate.y, yDirection) ||\n other.y === candidate.y) &&\n (better(other.x, candidate.x, xDirection) ||\n better(other.y, candidate.y, yDirection)),\n ),\n )\n .sort((a, b) => a.x - b.x);\n const steps = Array.from(\n { length: GRID_STEPS },\n (_, i) => (i + 1) / GRID_STEPS,\n );\n // Points draw in from left to right; the frontier comes last.\n const order = new Map(\n [...points]\n .sort((a, b) => sx(a.x) - sx(b.x))\n .map((point, rank) => [point.key, rank]),\n );\n return {\n height,\n order,\n left,\n right,\n top,\n bottom,\n sx,\n sy,\n front,\n frontKeys: new Set(front.map((point) => point.key)),\n // Even shares of the plot, which on a log axis are even ratios.\n gridX: xTicks?.map(sx) ?? steps.map((t) => left + (right - left) * t),\n gridY: yTicks?.map(sy) ?? steps.map((t) => sy(yLo + (yHi - yLo) * t)),\n xLabels: xTicks ?? [xLo, xHi],\n yLabels: yTicks ?? [yLo, yHi],\n };\n }, [\n points,\n width,\n xDirection,\n yDirection,\n xScale,\n xDomain,\n yDomain,\n xTicks,\n yTicks,\n maxHeight,\n ]);\n\n if (points.length === 0) {\n return (\n <div ref={wrapRef} className={cls}>\n {empty === undefined ? (\n <EmptyState\n title={emptyTitle ?? strings.paretoEmptyTitle}\n description={emptyDescription}\n />\n ) : (\n <div\n className=\"aegis-pareto__empty\"\n style={\n {\n '--aegis-pareto-min-height': `${MIN_HEIGHT.toString()}px`,\n } as CSSProperties\n }\n >\n {empty}\n </div>\n )}\n </div>\n );\n }\n\n if (!geometry) {\n return <div ref={wrapRef} className={cls} />;\n }\n\n const { height, left, right, top, bottom, sx, sy, front, frontKeys } =\n geometry;\n const highlighted =\n highlightKeys === undefined ? null : new Set(highlightKeys);\n const dimmed = (key: string): boolean =>\n highlighted !== null && !highlighted.has(key);\n const showAllLabels = labels === 'all' && width >= ALL_LABELS_MIN_WIDTH;\n const labelBoxes = placeLabels(\n points\n .filter(\n (point) =>\n showAllLabels ||\n frontKeys.has(point.key) ||\n (highlighted?.has(point.key) ?? false),\n )\n .map((point) => ({\n key: point.key,\n label: point.label,\n x: sx(point.x),\n y: sy(point.y),\n })),\n points.map((point) => ({\n key: point.key,\n x: sx(point.x),\n y: sy(point.y),\n })),\n // A label may run up into the space above the plot.\n { left, right, top: 0, bottom },\n );\n // A plot too narrow to name every point names them under it instead, so\n // none is left to a tooltip a phone cannot show.\n const legendItems =\n legend?.map((item) => ({\n key: item.key,\n label: item.label,\n color: item.color ?? ('var(--bg-inverted)' as const),\n })) ??\n (labels === 'all' && !showAllLabels\n ? points.map((point) => ({\n key: point.key,\n label: point.label,\n color: point.color ?? ('var(--bg-inverted)' as const),\n }))\n : []);\n const frontDrawn =\n frontProgress ??\n (progress === undefined\n ? undefined\n : staggeredProgress(progress, points.length, points.length + 1));\n const selectOnKey = (event: KeyboardEvent<SVGCircleElement>, key: string) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n onSelect?.(key);\n }\n };\n\n return (\n <div ref={wrapRef} className={cls}>\n <svg\n className=\"aegis-pareto__svg\"\n width={width}\n height={height}\n viewBox={`0 0 ${width.toString()} ${height.toString()}`}\n role={onSelect ? 'group' : 'img'}\n aria-label={strings.paretoChartLabel(xLabel, yLabel)}\n style={\n {\n '--aegis-pareto-count': points.length,\n ...(frontDrawn === undefined\n ? {}\n : { '--aegis-pareto-front-progress': frontDrawn }),\n } as CSSProperties\n }\n >\n {geometry.gridY.map((y) => (\n <line\n key={`gy-${y.toString()}`}\n className=\"aegis-pareto__grid\"\n x1={left}\n y1={y}\n x2={right}\n y2={y}\n />\n ))}\n {geometry.gridX.map((x) => (\n <line\n key={`gx-${x.toString()}`}\n className=\"aegis-pareto__grid\"\n x1={x}\n y1={top}\n x2={x}\n y2={bottom}\n />\n ))}\n <line\n className=\"aegis-pareto__axis\"\n x1={left}\n y1={bottom}\n x2={right}\n y2={bottom}\n />\n <line\n className=\"aegis-pareto__axis\"\n x1={left}\n y1={top}\n x2={left}\n y2={bottom}\n />\n {frontDrawn !== undefined && (\n <clipPath id={clipId}>\n <rect\n x={left}\n y={0}\n width={(right - left) * frontDrawn}\n height={height}\n />\n </clipPath>\n )}\n {front.length > 1 && (\n <polyline\n className=\"aegis-pareto__front\"\n clipPath={frontDrawn === undefined ? undefined : `url(#${clipId})`}\n points={front\n .map(\n (point) =>\n `${sx(point.x).toString()},${sy(point.y).toString()}`,\n )\n .join(' ')}\n />\n )}\n {points.map((point, index) => (\n <circle\n key={point.key}\n className={[\n 'aegis-pareto__point',\n fadeDominated && !frontKeys.has(point.key)\n ? 'aegis-pareto__point--dominated'\n : '',\n dimmed(point.key) ? 'aegis-pareto__point--dimmed' : '',\n onSelect ? 'aegis-pareto__point--interactive' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n style={\n {\n fill:\n point.color === undefined\n ? undefined\n : chartColorValue(point.color),\n '--aegis-pareto-index': index,\n '--aegis-pareto-point-progress':\n progress === undefined\n ? 1\n : staggeredProgress(\n progress,\n geometry.order.get(point.key) ?? index,\n points.length + 1,\n ),\n } as CSSProperties\n }\n cx={sx(point.x)}\n cy={sy(point.y)}\n r={POINT_RADIUS}\n role={onSelect ? 'button' : undefined}\n tabIndex={onSelect ? 0 : undefined}\n aria-label={onSelect ? point.label : undefined}\n onClick={\n onSelect\n ? () => {\n onSelect(point.key);\n }\n : undefined\n }\n onKeyDown={\n onSelect\n ? (event) => {\n selectOnKey(event, point.key);\n }\n : undefined\n }\n >\n <title>{point.label}</title>\n </circle>\n ))}\n {points.map((point) => {\n const box = labelBoxes.get(point.key);\n return box === undefined ? null : (\n <text\n key={`label-${point.key}`}\n className={[\n 'aegis-pareto__point-label',\n dimmed(point.key) ? 'aegis-pareto__point-label--dimmed' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n style={\n labels === 'all'\n ? ({\n '--aegis-pareto-front-progress':\n progress === undefined\n ? 1\n : staggeredProgress(\n progress,\n geometry.order.get(point.key) ?? 0,\n points.length + 1,\n ),\n } as CSSProperties)\n : undefined\n }\n x={box.x}\n y={box.y}\n textAnchor={box.anchor}\n >\n {point.label}\n </text>\n );\n })}\n {geometry.xLabels.map((value, index) => (\n <text\n key={`x-${value.toString()}`}\n className=\"aegis-pareto__tick\"\n x={sx(value)}\n y={bottom + LABEL_GAP * 2}\n textAnchor={\n index === geometry.xLabels.length - 1 && sx(value) >= right - 1\n ? 'end'\n : 'middle'\n }\n >\n {formatX(value)}\n </text>\n ))}\n {geometry.yLabels.map((value) => (\n <text\n key={`y-${value.toString()}`}\n className=\"aegis-pareto__tick\"\n x={left - LABEL_GAP}\n y={sy(value)}\n textAnchor=\"end\"\n dominantBaseline=\"middle\"\n >\n {formatY(value)}\n </text>\n ))}\n <text\n className=\"aegis-pareto__axis-label\"\n x={right}\n y={height - LABEL_GAP}\n textAnchor=\"end\"\n >\n {xLabel}\n </text>\n <text\n className=\"aegis-pareto__axis-label\"\n x={left - LABEL_GAP}\n y={top - LABEL_GAP * 2}\n textAnchor=\"start\"\n >\n {yLabel}\n </text>\n </svg>\n {legendItems.length > 0 ? (\n <ChartLegend\n className=\"aegis-pareto__legend\"\n shape=\"dot\"\n items={legendItems}\n />\n ) : null}\n </div>\n );\n}\n"],"names":["MAX_HEIGHT","MIN_HEIGHT","PAD_LEFT","PAD_RIGHT","PAD_TOP","PAD_BOTTOM","POINT_RADIUS","LABEL_GAP","GRID_STEPS","LABEL_CHAR","LABEL_WIDE_CHAR","LABEL_LINE","ALL_LABELS_MIN_WIDTH","better","a","b","direction","labelWidth","text","sum","char","placeLabels","labelled","allPoints","bounds","placed","result","reach","point","w","candidates","box","candidate","l","onPlot","r","t","clear","other","chosen","ParetoChart","points","xLabel","yLabel","xDirection","yDirection","formatX","formatY","xScale","xDomain","yDomain","xTicks","yTicks","labels","fadeDominated","highlightKeys","maxHeight","onSelect","legend","empty","emptyTitle","emptyDescription","progress","frontProgress","className","strings","useStrings","clipId","useId","wrapRef","useRef","width","useElementWidth","cls","geometry","useMemo","height","xValues","logLo","logHi","xLo","xHi","zeroAnchoredDomain","yLo","yHi","scaleX","value","left","right","top","bottom","sx","sy","front","steps","_","i","order","rank","jsx","EmptyState","frontKeys","highlighted","dimmed","key","showAllLabels","labelBoxes","legendItems","item","frontDrawn","staggeredProgress","selectOnKey","event","jsxs","y","x","index","chartColorValue","ChartLegend"],"mappings":"wWAqGMA,GAAa,IACbC,GAAa,IACbC,GAAW,GACXC,GAAY,GACZC,GAAU,GACVC,GAAa,GACbC,EAAe,EACfC,EAAY,EACZC,GAAa,EAGbC,GAAa,IACbC,GAAkB,GAClBC,EAAa,GACbC,GAAuB,IAI7B,SAASC,EAAOC,EAAWC,EAAWC,EAA+B,CACnE,OAAOA,IAAc,QAAUF,EAAIC,EAAID,EAAIC,CAC7C,CAQA,SAASE,GAAWC,EAAsB,CACxC,MAAO,CAAC,GAAGA,CAAI,EAAE,OACf,CAACC,EAAKC,IACJD,IAAQC,EAAK,YAAY,CAAC,GAAK,GAAK,IAAMV,GAAkBD,IAC9D,CAAA,CAEJ,CAMA,SAASY,GACPC,EACAC,EACAC,EACuB,CACvB,MAAMC,EAAgE,CAAA,EAChEC,M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C,EACA8C,EAAS,QAAQ,IAAI,CAACY,EAAO8B,IAC5BjB,EAAAA,IAAC,OAAA,CAEC,UAAU,qBACV,EAAGR,EAAGL,CAAK,EACX,EAAGI,EAASnF,EAAY,EACxB,WACE6G,IAAU1C,EAAS,QAAQ,OAAS,GAAKiB,EAAGL,CAAK,GAAKE,EAAQ,EAC1D,MACA,SAGL,WAAQF,CAAK,CAAA,EAVT,KAAKA,EAAM,UAAU,EAAA,CAY7B,EACAZ,EAAS,QAAQ,IAAKY,GACrBa,EAAAA,IAAC,OAAA,CAEC,UAAU,qBACV,EAAGZ,EAAOhF,EACV,EAAGqF,EAAGN,CAAK,EACX,WAAW,MACX,iBAAiB,SAEhB,WAAQA,CAAK,CAAA,EAPT,KAAKA,EAAM,UAAU,EAAA,CAS7B,EACDa,EAAAA,IAAC,OAAA,CACC,UAAU,2BACV,EAAGX,EACH,EAAGZ,EAASrE,EACZ,WAAW,MAEV,SAAAmC,CAAA,CAAA,EAEHyD,EAAAA,IAAC,OAAA,CACC,UAAU,2BACV,EAAGZ,EAAOhF,EACV,EAAGkF,EAAMlF,EAAY,EACrB,WAAW,QAEV,SAAAoC,CAAA,CAAA,CACH,CAAA,CAAA,EAEDgE,GAAY,OAAS,EACpBR,EAAAA,IAACmB,GAAAA,YAAA,CACC,UAAU,uBACV,MAAM,MACN,MAAOX,EAAA,CAAA,EAEP,IAAA,EACN,CAEJ"}
@@ -22,9 +22,36 @@ interface ParetoChartProps {
22
22
  /** Which direction counts as better on each axis. */
23
23
  xDirection?: 'lower' | 'higher';
24
24
  yDirection?: 'lower' | 'higher';
25
- /** Formats the 0 and maximum labels of each axis. */
25
+ /** Formats the labels of each axis. */
26
26
  formatX?: (value: number) => string;
27
27
  formatY?: (value: number) => string;
28
+ /**
29
+ * `log` spaces the horizontal axis by ratio, e.g. for a cost that spans
30
+ * orders of magnitude; its values must be above 0. Defaults to `linear`.
31
+ */
32
+ xScale?: 'linear' | 'log';
33
+ /** The ends of each axis. Defaults to from 0, or the data's own range on a log axis. */
34
+ xDomain?: [number, number];
35
+ yDomain?: [number, number];
36
+ /**
37
+ * The labelled gridlines of each axis. Defaults to plain gridlines with
38
+ * labels at the two ends.
39
+ */
40
+ xTicks?: number[];
41
+ yTicks?: number[];
42
+ /**
43
+ * Which points carry their name. `front` names the frontier; `all` names
44
+ * every point, so the chart needs no legend. A plot too narrow for them
45
+ * names the frontier and `highlightKeys` and lists every point under it.
46
+ * Defaults to `front`.
47
+ */
48
+ labels?: 'front' | 'all';
49
+ /** Fades the points off the frontier. Defaults to true. */
50
+ fadeDominated?: boolean;
51
+ /** Fades every other point, to pick out the ones a finding is about. */
52
+ highlightKeys?: string[];
53
+ /** The tallest the plot grows. */
54
+ maxHeight?: number;
28
55
  onSelect?: (key: string) => void;
29
56
  /** Series swatches with labels, listed under the plot. */
30
57
  legend?: ParetoLegendItem[];
@@ -42,7 +69,12 @@ interface ParetoChartProps {
42
69
  * right, then the frontier. Omitted, they fade in once on mount.
43
70
  */
44
71
  progress?: number;
72
+ /**
73
+ * How far the frontier is traced, 0 to 1, for a host that draws it apart
74
+ * from the points, such as one step of a scrolling story.
75
+ */
76
+ frontProgress?: number;
45
77
  className?: string;
46
78
  }
47
- export declare function ParetoChart({ points, xLabel, yLabel, xDirection, yDirection, formatX, formatY, onSelect, legend, empty, emptyTitle, emptyDescription, progress, className, }: ParetoChartProps): import("react/jsx-runtime").JSX.Element;
79
+ export declare function ParetoChart({ points, xLabel, yLabel, xDirection, yDirection, formatX, formatY, xScale, xDomain, yDomain, xTicks, yTicks, labels, fadeDominated, highlightKeys, maxHeight, onSelect, legend, empty, emptyTitle, emptyDescription, progress, frontProgress, className, }: ParetoChartProps): import("react/jsx-runtime").JSX.Element;
48
80
  export {};