orn-ui 0.2.7 → 0.2.9

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