@beweco/aurora-ui 0.6.64 → 0.6.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +26 -9
- package/dist/index.esm.js +26 -9
- package/dist/types/components/violin-plot/ViolinPlot.d.ts +1 -1
- package/dist/types/components/violin-plot/ViolinPlot.d.ts.map +1 -1
- package/dist/types/components/violin-plot/ViolinPlot.types.d.ts +8 -0
- package/dist/types/components/violin-plot/ViolinPlot.types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -6437,6 +6437,10 @@ function ViolinFallback(_a) {
|
|
|
6437
6437
|
var MARGIN = { top: 24, right: 16, bottom: 40, left: 44 };
|
|
6438
6438
|
var VIEW_WIDTH = 640;
|
|
6439
6439
|
var VIOLIN_HALF_WIDTH = 46;
|
|
6440
|
+
/** Espacio extra que reserva cada título de eje cuando se pinta. */
|
|
6441
|
+
var AXIS_TITLE_SPACE = 18;
|
|
6442
|
+
/** Aire sobre el dato para que el bigote p95 no quede pegado a la línea de arriba. */
|
|
6443
|
+
var HEADROOM = 0.05;
|
|
6440
6444
|
var COLOR_BODY = "#c7d2fe";
|
|
6441
6445
|
var COLOR_STROKE = "#4338ca";
|
|
6442
6446
|
var COLOR_MEDIAN = "#1e3a8a";
|
|
@@ -6462,25 +6466,38 @@ function formatTick(value, factor, unit) {
|
|
|
6462
6466
|
* server-side directo en tests.
|
|
6463
6467
|
*/
|
|
6464
6468
|
function ViolinPlot(_a) {
|
|
6465
|
-
var groups = _a.groups, valueLabel = _a.valueLabel, _b = _a.baseUnit, baseUnit = _b === void 0 ? "none" : _b, formatValue = _a.formatValue, _c = _a.height, height = _c === void 0 ? 320 : _c, _d = _a.minSampleForViolin, minSampleForViolin = _d === void 0 ? 20 : _d, _e = _a.translations, translations = _e === void 0 ? {} : _e;
|
|
6469
|
+
var groups = _a.groups, valueLabel = _a.valueLabel, groupLabel = _a.groupLabel, _b = _a.baseUnit, baseUnit = _b === void 0 ? "none" : _b, formatValue = _a.formatValue, _c = _a.height, height = _c === void 0 ? 320 : _c, _d = _a.minSampleForViolin, minSampleForViolin = _d === void 0 ? 20 : _d, _e = _a.translations, translations = _e === void 0 ? {} : _e;
|
|
6466
6470
|
var t = __assign(__assign({}, defaultTranslations$1), translations);
|
|
6467
6471
|
if (groups.length === 0) {
|
|
6468
6472
|
return (jsxRuntime.jsx("svg", { viewBox: "0 0 ".concat(VIEW_WIDTH, " ").concat(height), width: "100%", role: "img", "aria-label": valueLabel, children: jsxRuntime.jsx("text", { x: VIEW_WIDTH / 2, y: height / 2, textAnchor: "middle", fill: COLOR_AXIS, children: t.emptyState }) }));
|
|
6469
6473
|
}
|
|
6474
|
+
var marginLeft = MARGIN.left + (valueLabel ? AXIS_TITLE_SPACE : 0);
|
|
6475
|
+
var marginBottom = MARGIN.bottom + (groupLabel ? AXIS_TITLE_SPACE : 0);
|
|
6470
6476
|
var plotTop = MARGIN.top;
|
|
6471
|
-
var plotBottom = height -
|
|
6477
|
+
var plotBottom = height - marginBottom;
|
|
6472
6478
|
var plotHeight = plotBottom - plotTop;
|
|
6473
|
-
// Escala Y común a todos los grupos
|
|
6474
|
-
|
|
6479
|
+
// Escala Y común a todos los grupos: de 0 al p95 máximo, con aire.
|
|
6480
|
+
//
|
|
6481
|
+
// El suelo NO puede ser un literal en unidad base. Antes era `Math.max(..., 1)`,
|
|
6482
|
+
// que con `baseUnit="d"` fija el techo en 1 día = 86400 s: una distribución de
|
|
6483
|
+
// onboardings de ~5 min (el caso real) se dibujaba entera aplastada contra el 0
|
|
6484
|
+
// y el eje rotulaba "86400s". El único caso que de verdad hay que blindar es la
|
|
6485
|
+
// división por cero, así que el fallback se aplica SOLO si no hay dato ninguno.
|
|
6486
|
+
var dataMax = Math.max.apply(Math, groups.map(function (g) { return g.p95; }));
|
|
6487
|
+
var maxValue = dataMax > 0 ? dataMax * (1 + HEADROOM) : 1;
|
|
6475
6488
|
var valueToY = function (v) {
|
|
6476
6489
|
return plotBottom - (v / maxValue) * plotHeight;
|
|
6477
6490
|
};
|
|
6478
|
-
|
|
6479
|
-
|
|
6491
|
+
// La unidad se elige sobre el MÁXIMO, no sobre la mediana: los tres ticks que se
|
|
6492
|
+
// pintan son 0, max/2 y max, así que es el máximo el que decide qué unidad hace
|
|
6493
|
+
// legibles esos números. Con la mediana, un p50 que redondea a 0 devolvía "s" y
|
|
6494
|
+
// el techo del eje se imprimía como 86400 en vez de 1d.
|
|
6495
|
+
var _f = pickDisplayUnit(maxValue, baseUnit), unit = _f.unit, factor = _f.factor;
|
|
6480
6496
|
var fmt = formatValue !== null && formatValue !== void 0 ? formatValue : (function (v) { return formatTick(v, factor, unit); });
|
|
6481
|
-
var columnWidth = (VIEW_WIDTH -
|
|
6482
|
-
|
|
6483
|
-
|
|
6497
|
+
var columnWidth = (VIEW_WIDTH - marginLeft - MARGIN.right) / groups.length;
|
|
6498
|
+
var axisTitle = unit ? "".concat(valueLabel, " (").concat(unit, ")") : valueLabel;
|
|
6499
|
+
return (jsxRuntime.jsxs("svg", { viewBox: "0 0 ".concat(VIEW_WIDTH, " ").concat(height), width: "100%", role: "img", "aria-label": valueLabel, children: [[0, maxValue / 2, maxValue].map(function (v) { return (jsxRuntime.jsxs("g", { children: [jsxRuntime.jsx("line", { x1: marginLeft, x2: VIEW_WIDTH - MARGIN.right, y1: valueToY(v), y2: valueToY(v), stroke: "#e5e7eb", strokeDasharray: "3 3" }), jsxRuntime.jsx("text", { x: marginLeft - 6, y: valueToY(v) + 4, textAnchor: "end", fontSize: 11, fill: COLOR_AXIS, children: fmt(v) })] }, v)); }), jsxRuntime.jsx("text", { transform: "translate(12 ".concat(plotTop + plotHeight / 2, ") rotate(-90)"), textAnchor: "middle", fontSize: 12, fill: COLOR_AXIS, children: axisTitle }), groupLabel ? (jsxRuntime.jsx("text", { x: marginLeft + (VIEW_WIDTH - marginLeft - MARGIN.right) / 2, y: height - 6, textAnchor: "middle", fontSize: 12, fill: COLOR_AXIS, children: groupLabel })) : null, groups.map(function (group, i) {
|
|
6500
|
+
var centerX = marginLeft + columnWidth * (i + 0.5);
|
|
6484
6501
|
return (jsxRuntime.jsxs("g", { children: [shouldFallback(group, minSampleForViolin) ? (jsxRuntime.jsx(ViolinFallback, { group: group, centerX: centerX, valueToY: valueToY })) : (jsxRuntime.jsx(ViolinBody, { group: group, centerX: centerX, valueToY: valueToY })), jsxRuntime.jsx("text", { x: centerX, y: plotBottom + 16, textAnchor: "middle", fontSize: 12, fill: COLOR_AXIS, children: group.label }), jsxRuntime.jsxs("text", { x: centerX, y: plotBottom + 30, textAnchor: "middle", fontSize: 10, fill: COLOR_AXIS, children: [t.sampleSizeLabel, "=", group.n, group.nExcluded > 0
|
|
6485
6502
|
? " \u00B7 \u2212".concat(group.nExcluded, " ").concat(t.outliersLabel)
|
|
6486
6503
|
: ""] })] }, group.label));
|
package/dist/index.esm.js
CHANGED
|
@@ -6438,6 +6438,10 @@ function ViolinFallback(_a) {
|
|
|
6438
6438
|
var MARGIN = { top: 24, right: 16, bottom: 40, left: 44 };
|
|
6439
6439
|
var VIEW_WIDTH = 640;
|
|
6440
6440
|
var VIOLIN_HALF_WIDTH = 46;
|
|
6441
|
+
/** Espacio extra que reserva cada título de eje cuando se pinta. */
|
|
6442
|
+
var AXIS_TITLE_SPACE = 18;
|
|
6443
|
+
/** Aire sobre el dato para que el bigote p95 no quede pegado a la línea de arriba. */
|
|
6444
|
+
var HEADROOM = 0.05;
|
|
6441
6445
|
var COLOR_BODY = "#c7d2fe";
|
|
6442
6446
|
var COLOR_STROKE = "#4338ca";
|
|
6443
6447
|
var COLOR_MEDIAN = "#1e3a8a";
|
|
@@ -6463,25 +6467,38 @@ function formatTick(value, factor, unit) {
|
|
|
6463
6467
|
* server-side directo en tests.
|
|
6464
6468
|
*/
|
|
6465
6469
|
function ViolinPlot(_a) {
|
|
6466
|
-
var groups = _a.groups, valueLabel = _a.valueLabel, _b = _a.baseUnit, baseUnit = _b === void 0 ? "none" : _b, formatValue = _a.formatValue, _c = _a.height, height = _c === void 0 ? 320 : _c, _d = _a.minSampleForViolin, minSampleForViolin = _d === void 0 ? 20 : _d, _e = _a.translations, translations = _e === void 0 ? {} : _e;
|
|
6470
|
+
var groups = _a.groups, valueLabel = _a.valueLabel, groupLabel = _a.groupLabel, _b = _a.baseUnit, baseUnit = _b === void 0 ? "none" : _b, formatValue = _a.formatValue, _c = _a.height, height = _c === void 0 ? 320 : _c, _d = _a.minSampleForViolin, minSampleForViolin = _d === void 0 ? 20 : _d, _e = _a.translations, translations = _e === void 0 ? {} : _e;
|
|
6467
6471
|
var t = __assign(__assign({}, defaultTranslations$1), translations);
|
|
6468
6472
|
if (groups.length === 0) {
|
|
6469
6473
|
return (jsx("svg", { viewBox: "0 0 ".concat(VIEW_WIDTH, " ").concat(height), width: "100%", role: "img", "aria-label": valueLabel, children: jsx("text", { x: VIEW_WIDTH / 2, y: height / 2, textAnchor: "middle", fill: COLOR_AXIS, children: t.emptyState }) }));
|
|
6470
6474
|
}
|
|
6475
|
+
var marginLeft = MARGIN.left + (valueLabel ? AXIS_TITLE_SPACE : 0);
|
|
6476
|
+
var marginBottom = MARGIN.bottom + (groupLabel ? AXIS_TITLE_SPACE : 0);
|
|
6471
6477
|
var plotTop = MARGIN.top;
|
|
6472
|
-
var plotBottom = height -
|
|
6478
|
+
var plotBottom = height - marginBottom;
|
|
6473
6479
|
var plotHeight = plotBottom - plotTop;
|
|
6474
|
-
// Escala Y común a todos los grupos
|
|
6475
|
-
|
|
6480
|
+
// Escala Y común a todos los grupos: de 0 al p95 máximo, con aire.
|
|
6481
|
+
//
|
|
6482
|
+
// El suelo NO puede ser un literal en unidad base. Antes era `Math.max(..., 1)`,
|
|
6483
|
+
// que con `baseUnit="d"` fija el techo en 1 día = 86400 s: una distribución de
|
|
6484
|
+
// onboardings de ~5 min (el caso real) se dibujaba entera aplastada contra el 0
|
|
6485
|
+
// y el eje rotulaba "86400s". El único caso que de verdad hay que blindar es la
|
|
6486
|
+
// división por cero, así que el fallback se aplica SOLO si no hay dato ninguno.
|
|
6487
|
+
var dataMax = Math.max.apply(Math, groups.map(function (g) { return g.p95; }));
|
|
6488
|
+
var maxValue = dataMax > 0 ? dataMax * (1 + HEADROOM) : 1;
|
|
6476
6489
|
var valueToY = function (v) {
|
|
6477
6490
|
return plotBottom - (v / maxValue) * plotHeight;
|
|
6478
6491
|
};
|
|
6479
|
-
|
|
6480
|
-
|
|
6492
|
+
// La unidad se elige sobre el MÁXIMO, no sobre la mediana: los tres ticks que se
|
|
6493
|
+
// pintan son 0, max/2 y max, así que es el máximo el que decide qué unidad hace
|
|
6494
|
+
// legibles esos números. Con la mediana, un p50 que redondea a 0 devolvía "s" y
|
|
6495
|
+
// el techo del eje se imprimía como 86400 en vez de 1d.
|
|
6496
|
+
var _f = pickDisplayUnit(maxValue, baseUnit), unit = _f.unit, factor = _f.factor;
|
|
6481
6497
|
var fmt = formatValue !== null && formatValue !== void 0 ? formatValue : (function (v) { return formatTick(v, factor, unit); });
|
|
6482
|
-
var columnWidth = (VIEW_WIDTH -
|
|
6483
|
-
|
|
6484
|
-
|
|
6498
|
+
var columnWidth = (VIEW_WIDTH - marginLeft - MARGIN.right) / groups.length;
|
|
6499
|
+
var axisTitle = unit ? "".concat(valueLabel, " (").concat(unit, ")") : valueLabel;
|
|
6500
|
+
return (jsxs("svg", { viewBox: "0 0 ".concat(VIEW_WIDTH, " ").concat(height), width: "100%", role: "img", "aria-label": valueLabel, children: [[0, maxValue / 2, maxValue].map(function (v) { return (jsxs("g", { children: [jsx("line", { x1: marginLeft, x2: VIEW_WIDTH - MARGIN.right, y1: valueToY(v), y2: valueToY(v), stroke: "#e5e7eb", strokeDasharray: "3 3" }), jsx("text", { x: marginLeft - 6, y: valueToY(v) + 4, textAnchor: "end", fontSize: 11, fill: COLOR_AXIS, children: fmt(v) })] }, v)); }), jsx("text", { transform: "translate(12 ".concat(plotTop + plotHeight / 2, ") rotate(-90)"), textAnchor: "middle", fontSize: 12, fill: COLOR_AXIS, children: axisTitle }), groupLabel ? (jsx("text", { x: marginLeft + (VIEW_WIDTH - marginLeft - MARGIN.right) / 2, y: height - 6, textAnchor: "middle", fontSize: 12, fill: COLOR_AXIS, children: groupLabel })) : null, groups.map(function (group, i) {
|
|
6501
|
+
var centerX = marginLeft + columnWidth * (i + 0.5);
|
|
6485
6502
|
return (jsxs("g", { children: [shouldFallback(group, minSampleForViolin) ? (jsx(ViolinFallback, { group: group, centerX: centerX, valueToY: valueToY })) : (jsx(ViolinBody, { group: group, centerX: centerX, valueToY: valueToY })), jsx("text", { x: centerX, y: plotBottom + 16, textAnchor: "middle", fontSize: 12, fill: COLOR_AXIS, children: group.label }), jsxs("text", { x: centerX, y: plotBottom + 30, textAnchor: "middle", fontSize: 10, fill: COLOR_AXIS, children: [t.sampleSizeLabel, "=", group.n, group.nExcluded > 0
|
|
6486
6503
|
? " \u00B7 \u2212".concat(group.nExcluded, " ").concat(t.outliersLabel)
|
|
6487
6504
|
: ""] })] }, group.label));
|
|
@@ -9,6 +9,6 @@ import type { ViolinPlotProps } from "./ViolinPlot.types";
|
|
|
9
9
|
* `<svg viewBox>` + `width="100%"`. Autocontenido, sin HeroUI, para render
|
|
10
10
|
* server-side directo en tests.
|
|
11
11
|
*/
|
|
12
|
-
export declare function ViolinPlot({ groups, valueLabel, baseUnit, formatValue, height, minSampleForViolin, translations, }: ViolinPlotProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function ViolinPlot({ groups, valueLabel, groupLabel, baseUnit, formatValue, height, minSampleForViolin, translations, }: ViolinPlotProps): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export default ViolinPlot;
|
|
14
14
|
//# sourceMappingURL=ViolinPlot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViolinPlot.d.ts","sourceRoot":"","sources":["../../../../src/components/violin-plot/ViolinPlot.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEX,eAAe,EAEf,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ViolinPlot.d.ts","sourceRoot":"","sources":["../../../../src/components/violin-plot/ViolinPlot.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEX,eAAe,EAEf,MAAM,oBAAoB,CAAC;AA+B5B;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,EAC1B,MAAM,EACN,UAAU,EACV,UAAU,EACV,QAAiB,EACjB,WAAW,EACX,MAAY,EACZ,kBAAuB,EACvB,YAAiB,GACjB,EAAE,eAAe,2CA8IjB;AA2DD,eAAe,UAAU,CAAC"}
|
|
@@ -37,7 +37,15 @@ export interface ViolinPlotTranslations {
|
|
|
37
37
|
}
|
|
38
38
|
export interface ViolinPlotProps {
|
|
39
39
|
groups: ViolinGroup[];
|
|
40
|
+
/**
|
|
41
|
+
* Nombre de la magnitud medida, SIN unidad — se pinta como título del eje Y y
|
|
42
|
+
* el componente le añade la unidad que haya resuelto (`Tiempo de setup (min)`).
|
|
43
|
+
* Escribir la unidad aquí ("Días hasta completar") acaba contradiciendo al eje
|
|
44
|
+
* en cuanto `pickDisplayUnit` elige otra escala.
|
|
45
|
+
*/
|
|
40
46
|
valueLabel: string;
|
|
47
|
+
/** Dimensión por la que se agrupan las columnas (título del eje X, p.ej. "Carril"). */
|
|
48
|
+
groupLabel?: string;
|
|
41
49
|
baseUnit?: BaseUnit;
|
|
42
50
|
formatValue?: (value: number) => string;
|
|
43
51
|
height?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViolinPlot.types.d.ts","sourceRoot":"","sources":["../../../../src/components/violin-plot/ViolinPlot.types.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,WAAW,SAAS;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACd;AAED,wEAAwE;AACxE,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,sBAAsB,CAAC;CACtC"}
|
|
1
|
+
{"version":3,"file":"ViolinPlot.types.d.ts","sourceRoot":"","sources":["../../../../src/components/violin-plot/ViolinPlot.types.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,WAAW,SAAS;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACd;AAED,wEAAwE;AACxE,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,sBAAsB,CAAC;CACtC"}
|