orn-ui 0.2.8 → 0.2.10

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 (80) hide show
  1. package/AGENTS.md +6 -2
  2. package/README.md +6 -6
  3. package/lib/commonjs/atoms/ShinyText.js +188 -0
  4. package/lib/commonjs/atoms/ShinyText.js.map +1 -0
  5. package/lib/commonjs/atoms/index.js +7 -0
  6. package/lib/commonjs/atoms/index.js.map +1 -1
  7. package/lib/commonjs/organisms/Chart.js +968 -0
  8. package/lib/commonjs/organisms/Chart.js.map +1 -0
  9. package/lib/commonjs/organisms/OptionWheel.js +408 -0
  10. package/lib/commonjs/organisms/OptionWheel.js.map +1 -0
  11. package/lib/commonjs/organisms/Timeline.js +420 -0
  12. package/lib/commonjs/organisms/Timeline.js.map +1 -0
  13. package/lib/commonjs/organisms/chart/frame.js +373 -0
  14. package/lib/commonjs/organisms/chart/frame.js.map +1 -0
  15. package/lib/commonjs/organisms/chart/marks.js +316 -0
  16. package/lib/commonjs/organisms/chart/marks.js.map +1 -0
  17. package/lib/commonjs/organisms/chart/math.js +468 -0
  18. package/lib/commonjs/organisms/chart/math.js.map +1 -0
  19. package/lib/commonjs/organisms/chart/palette.js +120 -0
  20. package/lib/commonjs/organisms/chart/palette.js.map +1 -0
  21. package/lib/commonjs/organisms/index.js +21 -0
  22. package/lib/commonjs/organisms/index.js.map +1 -1
  23. package/lib/module/atoms/ShinyText.js +183 -0
  24. package/lib/module/atoms/ShinyText.js.map +1 -0
  25. package/lib/module/atoms/index.js +1 -0
  26. package/lib/module/atoms/index.js.map +1 -1
  27. package/lib/module/organisms/Chart.js +963 -0
  28. package/lib/module/organisms/Chart.js.map +1 -0
  29. package/lib/module/organisms/OptionWheel.js +403 -0
  30. package/lib/module/organisms/OptionWheel.js.map +1 -0
  31. package/lib/module/organisms/Timeline.js +415 -0
  32. package/lib/module/organisms/Timeline.js.map +1 -0
  33. package/lib/module/organisms/chart/frame.js +367 -0
  34. package/lib/module/organisms/chart/frame.js.map +1 -0
  35. package/lib/module/organisms/chart/marks.js +310 -0
  36. package/lib/module/organisms/chart/marks.js.map +1 -0
  37. package/lib/module/organisms/chart/math.js +445 -0
  38. package/lib/module/organisms/chart/math.js.map +1 -0
  39. package/lib/module/organisms/chart/palette.js +114 -0
  40. package/lib/module/organisms/chart/palette.js.map +1 -0
  41. package/lib/module/organisms/index.js +3 -0
  42. package/lib/module/organisms/index.js.map +1 -1
  43. package/lib/typescript/atoms/ShinyText.d.ts +48 -0
  44. package/lib/typescript/atoms/ShinyText.d.ts.map +1 -0
  45. package/lib/typescript/atoms/index.d.ts +2 -0
  46. package/lib/typescript/atoms/index.d.ts.map +1 -1
  47. package/lib/typescript/organisms/Chart.d.ts +208 -0
  48. package/lib/typescript/organisms/Chart.d.ts.map +1 -0
  49. package/lib/typescript/organisms/OptionWheel.d.ts +78 -0
  50. package/lib/typescript/organisms/OptionWheel.d.ts.map +1 -0
  51. package/lib/typescript/organisms/Timeline.d.ts +61 -0
  52. package/lib/typescript/organisms/Timeline.d.ts.map +1 -0
  53. package/lib/typescript/organisms/chart/frame.d.ts +85 -0
  54. package/lib/typescript/organisms/chart/frame.d.ts.map +1 -0
  55. package/lib/typescript/organisms/chart/marks.d.ts +88 -0
  56. package/lib/typescript/organisms/chart/marks.d.ts.map +1 -0
  57. package/lib/typescript/organisms/chart/math.d.ts +161 -0
  58. package/lib/typescript/organisms/chart/math.d.ts.map +1 -0
  59. package/lib/typescript/organisms/chart/palette.d.ts +6 -0
  60. package/lib/typescript/organisms/chart/palette.d.ts.map +1 -0
  61. package/lib/typescript/organisms/index.d.ts +6 -0
  62. package/lib/typescript/organisms/index.d.ts.map +1 -1
  63. package/llms.txt +3 -3
  64. package/package.json +23 -2
  65. package/registry/chart.json +35 -0
  66. package/registry/index.json +53 -0
  67. package/registry/manifest.json +28 -0
  68. package/registry/option-wheel.json +19 -0
  69. package/registry/shiny-text.json +19 -0
  70. package/registry/timeline.json +20 -0
  71. package/src/atoms/ShinyText.tsx +226 -0
  72. package/src/atoms/index.ts +2 -0
  73. package/src/organisms/Chart.tsx +1252 -0
  74. package/src/organisms/OptionWheel.tsx +476 -0
  75. package/src/organisms/Timeline.tsx +467 -0
  76. package/src/organisms/chart/frame.tsx +349 -0
  77. package/src/organisms/chart/marks.tsx +295 -0
  78. package/src/organisms/chart/math.ts +475 -0
  79. package/src/organisms/chart/palette.ts +112 -0
  80. package/src/organisms/index.ts +14 -0
@@ -0,0 +1,968 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Chart = Chart;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _colors = require("../theme/colors");
10
+ var _createStyles = require("../theme/createStyles");
11
+ var _UIProvider = require("../theme/UIProvider");
12
+ var _SegmentedControl = require("../molecules/SegmentedControl");
13
+ var _marks = require("./chart/marks");
14
+ var _frame = require("./chart/frame");
15
+ var _palette = require("./chart/palette");
16
+ var _math = require("./chart/math");
17
+ var _jsxRuntime = require("react/jsx-runtime");
18
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
19
+ /**
20
+ * Un filtro de la barra superior. Chart no filtra nada por su cuenta: muestra
21
+ * el control y avisa. Quien tiene los datos decide qué significa "últimos 7
22
+ * días", y eso no se puede adivinar desde acá.
23
+ */
24
+
25
+ // 'pie' y 'donut' van separados aunque compartan todo: con un solo miembro
26
+ // cuyo `type` fuera `'pie' | 'donut'`, TypeScript no saca ese miembro de la
27
+ // unión al descartarlo, y el resto del componente deja de estrecharse.
28
+
29
+ const DEFAULT_HEIGHT = 220;
30
+ const DEFAULT_TICKS = 4;
31
+ /** Piso del canal de las etiquetas de valor, a la izquierda. */
32
+ const VALUE_GUTTER = 38;
33
+ /**
34
+ * Ancho estimado de un caracter de etiqueta. React Native no mide texto sin
35
+ * renderizarlo, y medir para decidir el layout haría aparecer el chart
36
+ * corrido un frame; a `fontSize.xs` un dígito ronda 0.6em, y de más es mejor
37
+ * que de menos — sobra aire, no se corta el número.
38
+ */
39
+ const VALUE_CHAR = 6.5;
40
+ /** Tope del canal: un eje ancho no puede comerse el plot. */
41
+ const VALUE_GUTTER_MAX = 0.3;
42
+ /** Canal de las categorías cuando van a la izquierda (barras horizontales). */
43
+ const CATEGORY_GUTTER = 64;
44
+ /** Canal de las etiquetas de abajo. */
45
+ const BOTTOM_GUTTER = 16;
46
+ /** Fracción del ancho de banda que ocupan las barras; el resto es aire. */
47
+ const BAND_FILL = 0.7;
48
+ /** Aire alrededor del radar para que entren las etiquetas de los ejes. */
49
+ const RADAR_INSET = 26;
50
+ const DIM_OPACITY = 0.3;
51
+ const useStyles = (0, _createStyles.createStyles)(theme => ({
52
+ root: {
53
+ alignSelf: 'stretch'
54
+ },
55
+ filters: {
56
+ gap: theme.tokens.spacing.sm,
57
+ marginBottom: theme.tokens.spacing.md
58
+ },
59
+ plot: {
60
+ position: 'relative',
61
+ overflow: 'visible'
62
+ },
63
+ empty: {
64
+ position: 'absolute',
65
+ left: 0,
66
+ right: 0,
67
+ top: 0,
68
+ bottom: 0,
69
+ alignItems: 'center',
70
+ justifyContent: 'center'
71
+ },
72
+ emptyText: {
73
+ fontSize: theme.tokens.fontSize.sm,
74
+ color: theme.colors.textLight
75
+ },
76
+ sliceLabel: {
77
+ position: 'absolute',
78
+ fontSize: theme.tokens.fontSize.xs,
79
+ fontWeight: theme.tokens.fontWeight.semibold,
80
+ textAlign: 'center'
81
+ },
82
+ radarAxisLabel: {
83
+ position: 'absolute',
84
+ fontSize: theme.tokens.fontSize.xs,
85
+ color: theme.colors.textLight,
86
+ textAlign: 'center'
87
+ }
88
+ }));
89
+
90
+ /** Estado controlado o propio, con el mismo contrato en los dos casos. */
91
+ function useControlled(controlled, fallback) {
92
+ const [own, setOwn] = (0, _react.useState)(fallback);
93
+ const isControlled = controlled !== undefined;
94
+ return [isControlled ? controlled : own, setOwn, isControlled];
95
+ }
96
+
97
+ /**
98
+ * Resuelve el dominio del eje de valores a partir de lo que pidió el
99
+ * consumidor. En 'sticky' la referencia vive en un ref: lo que importa no es
100
+ * el dominio de este render sino el más ancho que se haya visto, y guardarlo
101
+ * en estado dispararía un render de más por cada tick que ensancha el eje.
102
+ */
103
+ function useDomain(measured, domain) {
104
+ const widest = (0, _react.useRef)(null);
105
+ if (domain === 'sticky') {
106
+ widest.current = (0, _math.growExtent)(widest.current, measured);
107
+ return widest.current;
108
+ }
109
+ widest.current = null;
110
+ return domain ?? measured;
111
+ }
112
+
113
+ /**
114
+ * Chart
115
+ * Barras (verticales, horizontales, agrupadas, apiladas), línea, área, torta,
116
+ * dona y radar en un solo componente, porque lo que cambia entre ellos es la
117
+ * marca que se dibuja y no el resto: datos, escala, ejes, leyenda, tooltip,
118
+ * selección y filtros son los mismos seis mecanismos en todos.
119
+ *
120
+ * Se dibuja con `View`: React Native no trae lienzo vectorial y la librería no
121
+ * puede agregar uno. Las tres primitivas están en `chart/marks.tsx` y la
122
+ * geometría entera, sin React, en `chart/math.ts`.
123
+ *
124
+ * Gestalt: destino común — al tocar una categoría, todo lo que no es ella baja
125
+ * a {@link DIM_OPACITY} a la vez, así que lo resaltado se lee como un grupo y
126
+ * no como una marca suelta. La leyenda usa similitud: el mismo color que la
127
+ * serie, y por eso puede apagarla sin que haga falta explicar qué apaga.
128
+ */
129
+ function Chart(props) {
130
+ const {
131
+ data,
132
+ series,
133
+ xKey = 'x',
134
+ selectBy,
135
+ window: windowSize,
136
+ height = DEFAULT_HEIGHT,
137
+ legend = 'auto',
138
+ hiddenKeys,
139
+ defaultHiddenKeys,
140
+ onHiddenKeysChange,
141
+ filters,
142
+ selected,
143
+ onSelect,
144
+ tooltip = true,
145
+ formatValue = _math.formatNumber,
146
+ animate = true,
147
+ duration,
148
+ emptyText,
149
+ accessibilityLabel,
150
+ style,
151
+ testID
152
+ } = props;
153
+ const theme = (0, _UIProvider.useTheme)();
154
+ const styles = useStyles();
155
+ const allowFontScaling = (0, _UIProvider.useAllowFontScaling)();
156
+ const uiLabels = (0, _UIProvider.useLabels)();
157
+ const [width, setWidth] = (0, _react.useState)(0);
158
+ const [hidden, setHidden, hiddenIsControlled] = useControlled(hiddenKeys, defaultHiddenKeys ?? []);
159
+ const [pick, setPick, selectionIsControlled] = useControlled(selected, null);
160
+ const isPie = props.type === 'pie' || props.type === 'donut';
161
+ const polyline = props.type === 'line' || props.type === 'area';
162
+ const decimate = polyline ? props.decimate : false;
163
+
164
+ /**
165
+ * Lo que se dibuja: la ventana de `data`, y de ahí los puntos que caben.
166
+ * El diezmado corre sobre la fila entera, elegida con la primera serie
167
+ * visible: las series comparten eje x, así que quedarse con índices
168
+ * distintos por serie rompería la alineación, la capa de toque y el tooltip.
169
+ */
170
+ const rows = (0, _react.useMemo)(() => {
171
+ const windowed = windowSize && windowSize > 0 ? data.slice(-windowSize) : data;
172
+ if (!polyline || decimate === false || width === 0) return windowed;
173
+ // Un punto cada dos píxeles: más no se ve y sí se paga.
174
+ const target = typeof decimate === 'number' ? decimate : Math.floor(width / 2);
175
+ if (windowed.length <= target) return windowed;
176
+ const lead = series.find(item => !hidden.includes(item.key))?.key ?? series[0]?.key;
177
+ const values = windowed.map(row => lead ? (0, _math.toNumber)(row[lead]) : null);
178
+ return (0, _math.lttbIndices)(values, target).map(index => windowed[index]);
179
+ }, [data, windowSize, polyline, decimate, width, series, hidden]);
180
+ const labels = (0, _react.useMemo)(() => rows.map(row => String(row[xKey] ?? '')), [rows, xKey]);
181
+ const ids = (0, _react.useMemo)(() => rows.map((row, index) => selectBy ? selectBy(row, index) : String(index)), [rows, selectBy]);
182
+
183
+ /**
184
+ * La selección se guarda por `id` y se resuelve contra las filas de ahora:
185
+ * si el dato se corrió, el resaltado lo sigue; si salió de la ventana,
186
+ * desaparece. Reusar el índice a ciegas señalaría el dato que quedó en ese
187
+ * lugar, que no es el que nadie eligió.
188
+ */
189
+ const selection = (0, _react.useMemo)(() => {
190
+ if (!pick) return null;
191
+ const index = ids.indexOf(pick.id);
192
+ if (index === -1) return null;
193
+ const row = rows[index];
194
+ return {
195
+ ...pick,
196
+ index,
197
+ row,
198
+ label: labels[index] ?? pick.label,
199
+ value: (0, _math.toNumber)(row[pick.seriesKey]) ?? pick.value
200
+ };
201
+ }, [pick, ids, rows, labels]);
202
+
203
+ // En torta las categorías son las filas; en el resto, las columnas. De eso
204
+ // dependen el color, la leyenda y qué apaga un toque en ella.
205
+ const palette = (0, _palette.seriesPalette)(theme, Math.max(1, isPie ? rows.length : series.length));
206
+ const entries = (0, _react.useMemo)(() => isPie ? labels.map((label, index) => ({
207
+ key: label,
208
+ label,
209
+ color: series[0]?.color ?? palette[index] ?? theme.colors.primary
210
+ })) : series.map((item, index) => ({
211
+ key: item.key,
212
+ label: item.label ?? item.key,
213
+ color: item.color ?? palette[index] ?? theme.colors.primary
214
+ })), [isPie, labels, series, palette, theme.colors.primary]);
215
+ const visible = (0, _react.useMemo)(() => entries.filter(entry => !hidden.includes(entry.key)), [entries, hidden]);
216
+ const duration_ = duration ?? theme.tokens.duration.slow * 2;
217
+ const applyHidden = (0, _react.useCallback)(key => {
218
+ const next = hidden.includes(key) ? hidden.filter(k => k !== key) : [...hidden, key];
219
+ if (!hiddenIsControlled) setHidden(next);
220
+ onHiddenKeysChange?.(next);
221
+ }, [hidden, hiddenIsControlled, setHidden, onHiddenKeysChange]);
222
+
223
+ /**
224
+ * Los plots avisan qué se tocó —fila y serie— y la selección entera se
225
+ * arma acá: es el único lugar que conoce `selectBy`, las etiquetas y las
226
+ * filas de verdad, y así los tres no repiten el armado.
227
+ */
228
+ const applySelection = (0, _react.useCallback)(hit => {
229
+ const row = hit ? rows[hit.index] : undefined;
230
+ const next = hit && row ? {
231
+ id: ids[hit.index] ?? String(hit.index),
232
+ index: hit.index,
233
+ row,
234
+ label: labels[hit.index] ?? '',
235
+ seriesKey: hit.seriesKey,
236
+ value: (0, _math.toNumber)(row[hit.seriesKey]) ?? 0
237
+ } : null;
238
+ // Tocar lo ya elegido lo suelta: sin eso no habría forma de volver al
239
+ // chart entero sin tocar afuera, y "afuera" en una pantalla con scroll
240
+ // no siempre existe.
241
+ const same = next && selection && next.id === selection.id && next.seriesKey === selection.seriesKey;
242
+ const value = same ? null : next;
243
+ if (!selectionIsControlled) setPick(value);
244
+ onSelect?.(value);
245
+ }, [rows, ids, labels, selection, selectionIsControlled, setPick, onSelect]);
246
+ const onLayout = (0, _react.useCallback)(event => setWidth(event.nativeEvent.layout.width), []);
247
+ const showLegend = legend === 'toggle' || legend === 'static' || legend === 'auto' && entries.length > 1;
248
+ const toggleable = legend === 'toggle' || legend === 'auto' && entries.length > 1;
249
+ const empty = rows.length === 0 || visible.length === 0;
250
+ const shared = {
251
+ rows,
252
+ labels,
253
+ entries,
254
+ visible,
255
+ width,
256
+ height,
257
+ formatValue,
258
+ animate,
259
+ duration: duration_,
260
+ selection,
261
+ onPick: applySelection,
262
+ tooltip,
263
+ testID
264
+ };
265
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
266
+ style: [styles.root, style],
267
+ testID: testID,
268
+ accessible: false,
269
+ children: [filters && filters.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
270
+ style: styles.filters,
271
+ children: filters.map(filter => /*#__PURE__*/(0, _jsxRuntime.jsx)(_SegmentedControl.SegmentedControl, {
272
+ options: filter.options,
273
+ value: filter.value,
274
+ onChange: filter.onChange,
275
+ testID: testID && `${testID}-filter-${filter.key}`
276
+ }, filter.key))
277
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
278
+ style: [styles.plot, {
279
+ height
280
+ }],
281
+ onLayout: onLayout,
282
+ accessible: true,
283
+ accessibilityRole: "image",
284
+ accessibilityLabel: accessibilityLabel,
285
+ testID: testID && `${testID}-plot`,
286
+ children: [width === 0 || empty ? null : props.type === 'pie' || props.type === 'donut' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(PiePlot, {
287
+ ...shared,
288
+ donut: props.type === 'donut',
289
+ innerRadius: props.innerRadius,
290
+ sliceLabels: props.sliceLabels ?? 'percent',
291
+ valueKey: series[0]?.key ?? ''
292
+ }) : props.type === 'radar' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(RadarPlot, {
293
+ ...shared,
294
+ domain: props.domain,
295
+ levels: props.levels ?? 4,
296
+ fill: props.fill ?? true,
297
+ thickness: props.thickness ?? 2,
298
+ dots: props.dots ?? true
299
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(CartesianPlot, {
300
+ ...shared,
301
+ type: props.type,
302
+ orientation: props.type === 'bar' ? props.orientation ?? 'vertical' : 'vertical',
303
+ stacked: props.type === 'bar' || props.type === 'area' ? props.stacked ?? false : false,
304
+ barRadius: props.type === 'bar' ? props.barRadius ?? theme.tokens.radius.xs : 0,
305
+ smooth: props.type !== 'bar' ? props.smooth ?? false : false,
306
+ thickness: props.type !== 'bar' ? props.thickness ?? 2 : 0,
307
+ dots: props.type === 'line' ? props.dots ?? true : props.type === 'area' ? props.dots ?? false : false,
308
+ fillOpacity: props.type === 'area' ? props.fillOpacity ?? 0.22 : 0,
309
+ domain: props.domain,
310
+ grid: props.grid ?? true,
311
+ ticks: props.ticks ?? DEFAULT_TICKS,
312
+ xAxis: props.xAxis ?? true,
313
+ yAxis: props.yAxis ?? true
314
+ }), empty ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
315
+ style: styles.empty,
316
+ testID: testID && `${testID}-empty`,
317
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
318
+ allowFontScaling: allowFontScaling,
319
+ style: styles.emptyText,
320
+ children: emptyText ?? uiLabels.noResultsTitle
321
+ })
322
+ }) : null]
323
+ }), showLegend ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_frame.Legend, {
324
+ items: entries,
325
+ hidden: hidden,
326
+ onToggle: toggleable ? applyHidden : undefined,
327
+ testID: testID && `${testID}-legend`
328
+ }) : null]
329
+ });
330
+ }
331
+ Chart.displayName = 'Chart';
332
+
333
+ // ── lo que comparten los tres plots ────────────────────────────────────────
334
+
335
+ /** Filas del tooltip para una categoría del eje x. */
336
+ function tooltipRowsAt(rows, index, visible, format) {
337
+ const row = rows[index];
338
+ if (!row) return [];
339
+ return visible.map(entry => {
340
+ const value = (0, _math.toNumber)(row[entry.key]);
341
+ return value === null ? null : {
342
+ key: entry.key,
343
+ label: entry.label,
344
+ value: format(value),
345
+ color: entry.color
346
+ };
347
+ }).filter(item => item !== null);
348
+ }
349
+
350
+ // ── barras, línea y área ───────────────────────────────────────────────────
351
+
352
+ /** Ancho de una tira del relleno de área, en píxeles. Más fino = más vistas. */
353
+ const STRIP_WIDTH = 4;
354
+ const MAX_STRIPS = 140;
355
+ /** Aire entre dos barras del mismo grupo. */
356
+ const GROUP_GAP = 2;
357
+ const CartesianPlot = /*#__PURE__*/(0, _react.memo)(props => {
358
+ const {
359
+ rows,
360
+ labels,
361
+ visible,
362
+ width,
363
+ height,
364
+ formatValue,
365
+ animate,
366
+ duration,
367
+ selection,
368
+ onPick,
369
+ tooltip,
370
+ testID,
371
+ type,
372
+ orientation,
373
+ stacked,
374
+ barRadius,
375
+ smooth,
376
+ thickness,
377
+ dots,
378
+ fillOpacity,
379
+ domain,
380
+ grid,
381
+ ticks: tickCount,
382
+ xAxis,
383
+ yAxis
384
+ } = props;
385
+ const theme = (0, _UIProvider.useTheme)();
386
+ const horizontal = type === 'bar' && orientation === 'horizontal';
387
+ const keys = (0, _react.useMemo)(() => visible.map(entry => entry.key), [visible]);
388
+ const bottomGutter = xAxis ? BOTTOM_GUTTER : 0;
389
+
390
+ // La línea puede no tocar el cero (una temperatura, un ranking); una barra
391
+ // sí tiene que hacerlo, porque su largo es el que dice el valor.
392
+ const measured = (0, _react.useMemo)(() => (0, _math.extent)(rows, keys, {
393
+ stacked,
394
+ includeZero: type !== 'line'
395
+ }), [rows, keys, stacked, type]);
396
+ const [low, high] = useDomain(measured, domain);
397
+
398
+ // Un dominio a mano se respeta tal cual; uno medido (o 'sticky') se
399
+ // redondea, que es lo que hace legible el eje.
400
+ const nice = (0, _react.useMemo)(() => Array.isArray(domain) ? (0, _math.exactTicks)(low, high, tickCount) : (0, _math.niceScale)(low, high, tickCount), [domain, low, high, tickCount]);
401
+
402
+ /**
403
+ * El canal sale de la etiqueta más larga, no de una constante: con un
404
+ * `formatValue` propio ("$3000", "1.250 ms") un ancho fijo corta el número
405
+ * y el eje pasa a decir "$30…". Los ticks no dependen del ancho del plot,
406
+ * así que se pueden medir antes de repartirlo.
407
+ */
408
+ const leftGutter = (0, _react.useMemo)(() => {
409
+ if (!yAxis) return 0;
410
+ if (horizontal) return CATEGORY_GUTTER;
411
+ const longest = nice.values.reduce((widest, value) => Math.max(widest, formatValue(value).length), 0);
412
+ const wanted = Math.ceil(longest * VALUE_CHAR) + theme.tokens.spacing.sm;
413
+ return Math.max(VALUE_GUTTER, Math.min(wanted, Math.floor(width * VALUE_GUTTER_MAX)));
414
+ }, [yAxis, horizontal, nice, formatValue, width, theme.tokens.spacing.sm]);
415
+ const plotW = Math.max(1, width - leftGutter);
416
+ const plotH = Math.max(1, height - bottomGutter);
417
+ const toPixel = (0, _react.useMemo)(() => horizontal ? (0, _math.linearScale)([nice.min, nice.max], [0, plotW]) : (0, _math.linearScale)([nice.min, nice.max], [plotH, 0]), [horizontal, nice, plotW, plotH]);
418
+ const scale = (0, _react.useMemo)(() => ({
419
+ nice,
420
+ toPixel
421
+ }), [nice, toPixel]);
422
+ const band = (horizontal ? plotH : plotW) / Math.max(1, rows.length);
423
+ const centerOf = (0, _react.useCallback)(index => (index + 0.5) * band, [band]);
424
+ const baseline = scale.toPixel((0, _math.clamp)(0, scale.nice.min, scale.nice.max));
425
+ const stacks = (0, _react.useMemo)(() => stacked ? rows.map(row => (0, _math.stackRow)(row, keys)) : null, [stacked, rows, keys]);
426
+
427
+ /** Puntos de una serie: `to` es el valor, `from` el piso desde donde se rellena. */
428
+ const pointsFor = (0, _react.useCallback)((key, edge) => {
429
+ const out = [];
430
+ rows.forEach((row, index) => {
431
+ if (stacks) {
432
+ const stackBand = stacks[index].find(item => item.key === key);
433
+ if (!stackBand) return;
434
+ out.push({
435
+ x: centerOf(index),
436
+ y: scale.toPixel(stackBand[edge])
437
+ });
438
+ return;
439
+ }
440
+ const value = (0, _math.toNumber)(row[key]);
441
+ if (value === null) return;
442
+ out.push({
443
+ x: centerOf(index),
444
+ y: edge === 'to' ? scale.toPixel(value) : baseline
445
+ });
446
+ });
447
+ return out;
448
+ }, [rows, stacks, centerOf, scale, baseline]);
449
+ const pickAt = (0, _react.useCallback)((index, event) => {
450
+ // Sobre qué serie cayó el dedo: la que tiene su marca más cerca del
451
+ // toque en el eje de valores. Con una sola serie es siempre esa.
452
+ const touch = (horizontal ? event?.nativeEvent?.locationX : event?.nativeEvent?.locationY) ?? 0;
453
+ let bestKey = keys[0] ?? '';
454
+ let bestDistance = Infinity;
455
+ for (const key of keys) {
456
+ const value = (0, _math.toNumber)(rows[index]?.[key]);
457
+ if (value === null) continue;
458
+ const distance = Math.abs(scale.toPixel(value) - touch);
459
+ if (distance < bestDistance) {
460
+ bestDistance = distance;
461
+ bestKey = key;
462
+ }
463
+ }
464
+ onPick({
465
+ index,
466
+ seriesKey: bestKey
467
+ });
468
+ }, [horizontal, keys, rows, scale, onPick]);
469
+ const gridLines = scale.nice.values.map(value => scale.toPixel(value));
470
+ const zeroIndex = scale.nice.values.findIndex(value => value === 0);
471
+ const rowsForTooltip = selection ? tooltipRowsAt(rows, selection.index, visible, formatValue) : [];
472
+ const anchor = !selection ? null : horizontal ? {
473
+ x: leftGutter + Math.max(...visible.map(entry => scale.toPixel((0, _math.toNumber)(rows[selection.index]?.[entry.key]) ?? 0))),
474
+ y: centerOf(selection.index)
475
+ } : {
476
+ x: leftGutter + centerOf(selection.index),
477
+ y: Math.min(...visible.map(entry => scale.toPixel((0, _math.toNumber)(rows[selection.index]?.[entry.key]) ?? 0)))
478
+ };
479
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
480
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
481
+ style: {
482
+ position: 'absolute',
483
+ left: leftGutter,
484
+ top: 0,
485
+ width: plotW,
486
+ height: plotH
487
+ },
488
+ children: [grid ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_frame.CartesianGrid, {
489
+ width: plotW,
490
+ height: plotH,
491
+ lines: gridLines,
492
+ orientation: horizontal ? 'vertical' : 'horizontal',
493
+ zeroIndex: zeroIndex === -1 ? undefined : zeroIndex,
494
+ testID: testID && `${testID}-grid`
495
+ }) : null, type === 'bar' ? rows.map((row, rowIndex) => {
496
+ const fill = band * BAND_FILL;
497
+ const slot = fill / (stacked ? 1 : Math.max(1, keys.length));
498
+ const bands = stacks ? stacks[rowIndex].filter(item => keys.includes(item.key)) : keys.map(key => {
499
+ const value = (0, _math.toNumber)(row[key]);
500
+ return value === null ? null : {
501
+ key,
502
+ from: 0,
503
+ to: value,
504
+ value
505
+ };
506
+ }).filter(item => item !== null);
507
+ return bands.map(item => {
508
+ const seriesIndex = keys.indexOf(item.key);
509
+ const color = visible[seriesIndex]?.color ?? theme.colors.primary;
510
+ const start = centerOf(rowIndex) - fill / 2 + (stacked ? 0 : seriesIndex * slot);
511
+ const thicknessOfBar = Math.max(1, slot - (stacked || keys.length === 1 ? 0 : GROUP_GAP));
512
+ const near = scale.toPixel(item.from);
513
+ const far = scale.toPixel(item.to);
514
+ const size = Math.abs(far - near);
515
+ const positive = item.value >= 0;
516
+ const dim = !!selection && selection.index !== rowIndex;
517
+ return horizontal ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_marks.Bar, {
518
+ x: positive ? near : plotW - near,
519
+ y: start,
520
+ width: size,
521
+ height: thicknessOfBar,
522
+ from: positive ? 'left' : 'right',
523
+ color: color,
524
+ radius: barRadius,
525
+ dim: dim,
526
+ animate: animate,
527
+ duration: duration,
528
+ testID: testID && `${testID}-bar-${rowIndex}-${item.key}`
529
+ }, `${rowIndex}-${item.key}`) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_marks.Bar, {
530
+ x: start,
531
+ y: positive ? plotH - near : near,
532
+ width: thicknessOfBar,
533
+ height: size,
534
+ from: positive ? 'bottom' : 'top',
535
+ color: color,
536
+ radius: barRadius,
537
+ dim: dim,
538
+ animate: animate,
539
+ duration: duration,
540
+ testID: testID && `${testID}-bar-${rowIndex}-${item.key}`
541
+ }, `${rowIndex}-${item.key}`);
542
+ });
543
+ }) : visible.map(entry => {
544
+ const raw = pointsFor(entry.key, 'to');
545
+ const line = smooth ? (0, _math.smoothPoints)(raw) : raw;
546
+ const base = smooth ? (0, _math.smoothPoints)(pointsFor(entry.key, 'from')) : pointsFor(entry.key, 'from');
547
+ const stripCount = Math.min(MAX_STRIPS, Math.max(8, Math.round(plotW / STRIP_WIDTH)));
548
+ const stripWidth = plotW / stripCount;
549
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
550
+ style: {
551
+ position: 'absolute',
552
+ left: 0,
553
+ top: 0,
554
+ width: plotW,
555
+ height: plotH
556
+ },
557
+ children: [type === 'area' ?
558
+ /*#__PURE__*/
559
+ // La opacidad va en el grupo, no en cada tira: el medio
560
+ // píxel de solape que tapa la costura del antialias se
561
+ // compone dos veces y deja una raya vertical cada cuatro
562
+ // píxeles. Atenuado el grupo entero, se pinta una sola vez.
563
+ (0, _jsxRuntime.jsx)(_reactNative.View, {
564
+ pointerEvents: "none",
565
+ style: {
566
+ position: 'absolute',
567
+ left: 0,
568
+ top: 0,
569
+ width: plotW,
570
+ height: plotH,
571
+ opacity: fillOpacity
572
+ },
573
+ children: Array.from({
574
+ length: stripCount
575
+ }, (_, strip) => {
576
+ const x = (strip + 0.5) * stripWidth;
577
+ const top = (0, _math.sampleY)(line, x);
578
+ const bottom = (0, _math.sampleY)(base, x);
579
+ if (top === null || bottom === null) return null;
580
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
581
+ style: {
582
+ position: 'absolute',
583
+ left: strip * stripWidth,
584
+ width: stripWidth + 0.5,
585
+ top: Math.min(top, bottom),
586
+ height: Math.abs(bottom - top),
587
+ backgroundColor: entry.color
588
+ }
589
+ }, strip);
590
+ })
591
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_marks.Polyline, {
592
+ points: line,
593
+ color: entry.color,
594
+ thickness: thickness,
595
+ testID: testID && `${testID}-line-${entry.key}`
596
+ }), dots ? raw.map((point, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_marks.Dot, {
597
+ point: point,
598
+ color: entry.color,
599
+ ringColor: theme.colors.surface,
600
+ size: selection?.index === index ? 8 : 6,
601
+ testID: testID && `${testID}-dot-${entry.key}-${index}`
602
+ }, index)) : null]
603
+ }, entry.key);
604
+ }), rows.map((row, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
605
+ onPress: event => pickAt(index, event),
606
+ accessibilityRole: "button",
607
+ accessibilityState: {
608
+ selected: selection?.index === index
609
+ },
610
+ accessibilityLabel: [labels[index], ...tooltipRowsAt(rows, index, visible, formatValue).map(item => `${item.label} ${item.value}`)].join(', '),
611
+ style: horizontal ? {
612
+ position: 'absolute',
613
+ left: 0,
614
+ width: plotW,
615
+ top: index * band,
616
+ height: band
617
+ } : {
618
+ position: 'absolute',
619
+ top: 0,
620
+ height: plotH,
621
+ left: index * band,
622
+ width: band
623
+ },
624
+ testID: testID && `${testID}-band-${index}`
625
+ }, index))]
626
+ }), yAxis ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
627
+ style: {
628
+ position: 'absolute',
629
+ left: 0,
630
+ top: 0,
631
+ width: leftGutter,
632
+ height: plotH
633
+ },
634
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_frame.AxisLabels, {
635
+ axis: "y",
636
+ gutter: Math.max(0, leftGutter - 6),
637
+ span: plotH,
638
+ labels: horizontal ? labels.map((text, index) => ({
639
+ text,
640
+ position: centerOf(index)
641
+ })) : scale.nice.values.map(value => ({
642
+ text: formatValue(value),
643
+ position: scale.toPixel(value)
644
+ })),
645
+ testID: testID && `${testID}-y-axis`
646
+ })
647
+ }) : null, xAxis ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
648
+ style: {
649
+ position: 'absolute',
650
+ left: leftGutter,
651
+ top: plotH + 2,
652
+ width: plotW,
653
+ height: bottomGutter
654
+ },
655
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_frame.AxisLabels, {
656
+ axis: "x",
657
+ gutter: 0,
658
+ span: plotW,
659
+ labels: horizontal ? scale.nice.values.map(value => ({
660
+ text: formatValue(value),
661
+ position: scale.toPixel(value)
662
+ })) : labels.map((text, index) => ({
663
+ text,
664
+ position: centerOf(index)
665
+ })),
666
+ testID: testID && `${testID}-x-axis`
667
+ })
668
+ }) : null, tooltip && selection && anchor && rowsForTooltip.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_frame.Tooltip, {
669
+ title: selection.label,
670
+ rows: rowsForTooltip,
671
+ anchor: anchor,
672
+ containerWidth: width,
673
+ testID: testID && `${testID}-tooltip`
674
+ }) : null]
675
+ });
676
+ });
677
+ CartesianPlot.displayName = 'CartesianPlot';
678
+
679
+ // ── torta y dona ───────────────────────────────────────────────────────────
680
+
681
+ const DONUT_RADIUS = 0.6;
682
+ /** Cuánto sale la porción elegida, en píxeles. */
683
+ const EXPLODE = 8;
684
+ /** Dónde cae la etiqueta, como fracción entre el agujero y el borde. */
685
+ const LABEL_AT = 0.62;
686
+
687
+ /** Blanco o negro, el que se lea encima del color. Un color raro no rompe: cae en `text`. */
688
+ function inkOn(background, theme) {
689
+ try {
690
+ return (0, _colors.contrast)(background, theme.colors.white) >= (0, _colors.contrast)(background, theme.colors.black) ? theme.colors.white : theme.colors.black;
691
+ } catch {
692
+ return theme.colors.text;
693
+ }
694
+ }
695
+ const PiePlot = /*#__PURE__*/(0, _react.memo)(props => {
696
+ const {
697
+ rows,
698
+ labels,
699
+ entries,
700
+ visible,
701
+ width,
702
+ height,
703
+ formatValue,
704
+ selection,
705
+ onPick,
706
+ tooltip,
707
+ testID,
708
+ donut,
709
+ innerRadius,
710
+ sliceLabels,
711
+ valueKey
712
+ } = props;
713
+ const theme = (0, _UIProvider.useTheme)();
714
+ const styles = useStyles();
715
+ const allowFontScaling = (0, _UIProvider.useAllowFontScaling)();
716
+ const center = {
717
+ x: width / 2,
718
+ y: height / 2
719
+ };
720
+ const radius = Math.max(0, Math.min(width, height) / 2 - 2);
721
+ const hole = (0, _math.clamp)(innerRadius ?? (donut ? DONUT_RADIUS : 0), 0, 0.9) * radius;
722
+ const arcs = (0, _react.useMemo)(() => {
723
+ // Una categoría apagada vale 0: sale de la torta y el resto se reparte el
724
+ // 100%, que es lo que espera quien la apagó desde la leyenda.
725
+ const values = rows.map((row, index) => visible.some(entry => entry.key === labels[index]) ? (0, _math.toNumber)(row[valueKey]) ?? 0 : 0);
726
+ return (0, _math.arcsFor)(values);
727
+ }, [rows, labels, visible, valueKey]);
728
+ const pickAt = (0, _react.useCallback)(event => {
729
+ const point = {
730
+ x: event?.nativeEvent?.locationX ?? 0,
731
+ y: event?.nativeEvent?.locationY ?? 0
732
+ };
733
+ const distance = Math.hypot(point.x - center.x, point.y - center.y);
734
+ // El agujero de una dona no es parte de ninguna porción, y afuera del
735
+ // círculo tampoco: los dos sueltan la selección.
736
+ if (distance > radius || distance < hole) return onPick(null);
737
+ const index = (0, _math.arcAt)(arcs, (0, _math.angleOf)(center, point));
738
+ if (index === -1) return onPick(null);
739
+ onPick({
740
+ index,
741
+ seriesKey: labels[index] ?? ''
742
+ });
743
+ }, [center.x, center.y, radius, hole, arcs, labels, onPick]);
744
+ const chosen = selection ? arcs.find(arc => arc.index === selection.index) : undefined;
745
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
746
+ children: [arcs.map(arc => {
747
+ const dim = !!selection && selection.index !== arc.index;
748
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_marks.Wedge, {
749
+ size: radius * 2,
750
+ center: center,
751
+ start: arc.start,
752
+ sweep: arc.sweep,
753
+ color: entries[arc.index]?.color ?? theme.colors.primary,
754
+ opacity: dim ? DIM_OPACITY : 1,
755
+ explode: selection?.index === arc.index ? EXPLODE : 0,
756
+ testID: testID && `${testID}-slice-${arc.index}`
757
+ }, arc.index);
758
+ }), hole > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
759
+ pointerEvents: "none",
760
+ style: {
761
+ position: 'absolute',
762
+ left: center.x - hole,
763
+ top: center.y - hole,
764
+ width: hole * 2,
765
+ height: hole * 2,
766
+ borderRadius: hole,
767
+ backgroundColor: theme.colors.surface
768
+ }
769
+ }) : null, sliceLabels === 'none' ? null : arcs.map(arc => {
770
+ // Una porción muy fina no tiene dónde escribir: la etiqueta se
771
+ // saldría encima de las vecinas y no se leería ninguna.
772
+ if (arc.sweep < 18) return null;
773
+ const at = (0, _math.polar)(center, hole + (radius - hole) * LABEL_AT, arc.start + arc.sweep / 2);
774
+ const color = entries[arc.index]?.color ?? theme.colors.primary;
775
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
776
+ allowFontScaling: allowFontScaling,
777
+ style: [styles.sliceLabel, {
778
+ left: at.x - 28,
779
+ top: at.y - 8,
780
+ width: 56,
781
+ color: inkOn(color, theme)
782
+ }],
783
+ testID: testID && `${testID}-slice-label-${arc.index}`,
784
+ children: sliceLabels === 'percent' ? `${Math.round(arc.ratio * 100)}%` : formatValue(arc.value)
785
+ }, arc.index);
786
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
787
+ onPress: pickAt,
788
+ accessibilityRole: "adjustable",
789
+ accessibilityLabel: arcs.map(arc => `${labels[arc.index]} ${Math.round(arc.ratio * 100)}%`).join(', '),
790
+ style: {
791
+ position: 'absolute',
792
+ left: 0,
793
+ top: 0,
794
+ width,
795
+ height
796
+ },
797
+ testID: testID && `${testID}-hit`
798
+ }), tooltip && selection && chosen ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_frame.Tooltip, {
799
+ title: selection.label,
800
+ rows: [{
801
+ key: selection.seriesKey,
802
+ label: `${Math.round(chosen.ratio * 100)}%`,
803
+ value: formatValue(selection.value),
804
+ color: entries[selection.index]?.color ?? theme.colors.primary
805
+ }],
806
+ anchor: (0, _math.polar)(center, radius * 0.9, chosen.start + chosen.sweep / 2),
807
+ containerWidth: width,
808
+ testID: testID && `${testID}-tooltip`
809
+ }) : null]
810
+ });
811
+ });
812
+ PiePlot.displayName = 'PiePlot';
813
+
814
+ // ── radar ──────────────────────────────────────────────────────────────────
815
+
816
+ /** Tiras por lado del polígono cuando se rellena. Más = borde más limpio, más vistas. */
817
+ const RADAR_STEPS = 5;
818
+ const RADAR_FILL_OPACITY = 0.18;
819
+ const RADAR_LABEL_WIDTH = 56;
820
+ const RadarPlot = /*#__PURE__*/(0, _react.memo)(props => {
821
+ const {
822
+ rows,
823
+ labels,
824
+ visible,
825
+ width,
826
+ height,
827
+ formatValue,
828
+ selection,
829
+ onPick,
830
+ tooltip,
831
+ testID,
832
+ domain,
833
+ levels,
834
+ fill,
835
+ thickness,
836
+ dots
837
+ } = props;
838
+ const theme = (0, _UIProvider.useTheme)();
839
+ const styles = useStyles();
840
+ const allowFontScaling = (0, _UIProvider.useAllowFontScaling)();
841
+ const center = {
842
+ x: width / 2,
843
+ y: height / 2
844
+ };
845
+ const radius = Math.max(0, Math.min(width, height) / 2 - RADAR_INSET);
846
+ const angles = (0, _react.useMemo)(() => (0, _math.radarAngles)(rows.length), [rows.length]);
847
+ const keys = (0, _react.useMemo)(() => visible.map(entry => entry.key), [visible]);
848
+
849
+ // El radar mide desde el centro, y el centro es 0: un mínimo distinto de
850
+ // cero haría que dos valores parecidos se vean lejísimos.
851
+ const measured = (0, _react.useMemo)(() => [0, (0, _math.extent)(rows, keys, {
852
+ includeZero: true
853
+ })[1]], [rows, keys]);
854
+ const [, top] = useDomain(measured, domain);
855
+ const scale = (0, _react.useMemo)(() => {
856
+ const nice = Array.isArray(domain) ? (0, _math.exactTicks)(0, top, levels) : (0, _math.niceScale)(0, top, levels);
857
+ return {
858
+ nice,
859
+ toRadius: (0, _math.linearScale)([0, nice.max], [0, radius])
860
+ };
861
+ }, [domain, top, levels, radius]);
862
+ const pointsOf = (0, _react.useCallback)(key => rows.map((row, index) => (0, _math.polar)(center, scale.toRadius(Math.max(0, (0, _math.toNumber)(row[key]) ?? 0)), angles[index] ?? 0)), [rows, center, scale, angles]);
863
+ const pickAt = (0, _react.useCallback)(event => {
864
+ if (rows.length === 0) return;
865
+ const angle = (0, _math.angleOf)(center, {
866
+ x: event?.nativeEvent?.locationX ?? 0,
867
+ y: event?.nativeEvent?.locationY ?? 0
868
+ });
869
+ const index = Math.round(angle / (360 / rows.length)) % rows.length;
870
+ const key = keys[0] ?? '';
871
+ onPick({
872
+ index,
873
+ seriesKey: key
874
+ });
875
+ }, [rows, center, keys, onPick]);
876
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
877
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_frame.RadarGrid, {
878
+ center: center,
879
+ radius: radius,
880
+ angles: angles,
881
+ levels: levels,
882
+ testID: testID && `${testID}-grid`
883
+ }), visible.map(entry => {
884
+ const points = pointsOf(entry.key);
885
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
886
+ style: {
887
+ position: 'absolute',
888
+ left: 0,
889
+ top: 0,
890
+ width,
891
+ height
892
+ },
893
+ children: [fill ?
894
+ /*#__PURE__*/
895
+ // La opacidad va en el grupo, no en cada tira. Por tira, el
896
+ // solape de 0.4° que tapa la costura del antialias se compone
897
+ // dos veces y deja un radio más oscuro por corte: el relleno
898
+ // termina pareciendo una telaraña. Aplicada al grupo, las tiras
899
+ // se pintan opacas entre sí y el conjunto se atenúa una vez.
900
+ (0, _jsxRuntime.jsx)(_reactNative.View, {
901
+ pointerEvents: "none",
902
+ style: {
903
+ position: 'absolute',
904
+ left: 0,
905
+ top: 0,
906
+ width,
907
+ height,
908
+ opacity: RADAR_FILL_OPACITY
909
+ },
910
+ testID: testID && `${testID}-fill-${entry.key}`,
911
+ children: (0, _math.fanStrips)(center, points, RADAR_STEPS).map((strip, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_marks.Wedge, {
912
+ size: strip.radius * 2,
913
+ center: center,
914
+ start: strip.start,
915
+ sweep: strip.sweep,
916
+ color: entry.color
917
+ }, index))
918
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_marks.Polyline, {
919
+ points: points,
920
+ color: entry.color,
921
+ thickness: thickness,
922
+ closed: true,
923
+ testID: testID && `${testID}-outline-${entry.key}`
924
+ }), dots ? points.map((point, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_marks.Dot, {
925
+ point: point,
926
+ color: entry.color,
927
+ ringColor: theme.colors.surface,
928
+ size: selection?.index === index ? 8 : 6
929
+ }, index)) : null]
930
+ }, entry.key);
931
+ }), labels.map((label, index) => {
932
+ const at = (0, _math.polar)(center, radius + RADAR_INSET / 2, angles[index] ?? 0);
933
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
934
+ numberOfLines: 1,
935
+ allowFontScaling: allowFontScaling,
936
+ style: [styles.radarAxisLabel, {
937
+ left: at.x - RADAR_LABEL_WIDTH / 2,
938
+ top: at.y - 7,
939
+ width: RADAR_LABEL_WIDTH
940
+ }, selection?.index === index && {
941
+ color: theme.colors.text
942
+ }],
943
+ testID: testID && `${testID}-axis-${index}`,
944
+ children: label
945
+ }, `${label}-${index}`);
946
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
947
+ onPress: pickAt,
948
+ accessibilityRole: "adjustable",
949
+ accessibilityLabel: labels.join(', '),
950
+ style: {
951
+ position: 'absolute',
952
+ left: 0,
953
+ top: 0,
954
+ width,
955
+ height
956
+ },
957
+ testID: testID && `${testID}-hit`
958
+ }), tooltip && selection ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_frame.Tooltip, {
959
+ title: selection.label,
960
+ rows: tooltipRowsAt(rows, selection.index, visible, formatValue),
961
+ anchor: (0, _math.polar)(center, radius, angles[selection.index] ?? 0),
962
+ containerWidth: width,
963
+ testID: testID && `${testID}-tooltip`
964
+ }) : null]
965
+ });
966
+ });
967
+ RadarPlot.displayName = 'RadarPlot';
968
+ //# sourceMappingURL=Chart.js.map