@usetheo/ui 0.31.0 → 0.33.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
export { linScale, niceMax, seriesPath, TrendChart, type TrendChartProps, type TrendPoint, type TrendSeries, } from "./trend-chart.js";
|
|
1
|
+
export { linScale, niceMax, pontosComMarcador, seriesPath, TrendChart, type TrendChartProps, type TrendPoint, type TrendSeries, } from "./trend-chart.js";
|
|
@@ -31,8 +31,47 @@ export interface TrendSeries {
|
|
|
31
31
|
export declare function linScale(domain: [number, number], range: [number, number]): (v: number) => number;
|
|
32
32
|
/** A clean upper Y bound ≥ max(values). Returns 0 when there is no positive value. */
|
|
33
33
|
export declare function niceMax(values: number[]): number;
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* SVG path `d` for a polyline over the given scales. A non-finite point is a GAP: the path BREAKS
|
|
36
|
+
* there and resumes with a new `M` subpath.
|
|
37
|
+
*
|
|
38
|
+
* M144 — this used to `filter(Number.isFinite)` and then join everything with `L`, which drew a
|
|
39
|
+
* continuous line straight over the hole. The filter is what made it wrong: it erased the
|
|
40
|
+
* information of WHERE the gap was, so the line could not break even in principle.
|
|
41
|
+
*
|
|
42
|
+
* Breaking is what every serious charting library does by default — `spanGaps` (Chart.js),
|
|
43
|
+
* `connectNulls` (Highcharts, ECharts, Recharts) and `connectgaps` (Plotly) all default to `false`,
|
|
44
|
+
* and Grafana ships "Connect null values: Never". It is also the only honest reading: connecting
|
|
45
|
+
* asserts continuity the data does not have, and the rest of THIS file already treats a non-finite
|
|
46
|
+
* `y` as absent (`niceMax` filters it, `hasData` filters it, and the accessible table renders `—`
|
|
47
|
+
* for a period a series has no point for).
|
|
48
|
+
*
|
|
49
|
+
* A run of one point emits a lone `M` and no `L` — a one-point line has no length, and the sparse
|
|
50
|
+
* marker is what makes it visible.
|
|
51
|
+
*/
|
|
35
52
|
export declare function seriesPath(points: TrendPoint[], xScale: (x: number) => number, yScale: (y: number) => number): string;
|
|
53
|
+
/**
|
|
54
|
+
* Quais pontos recebem marcador.
|
|
55
|
+
*
|
|
56
|
+
* Duas razões distintas para marcar, e a segunda só apareceu quando séries com lacuna passaram a
|
|
57
|
+
* existir (M144):
|
|
58
|
+
*
|
|
59
|
+
* 1. **Série esparsa** (< `SPARSE_MARKER_MAX` baldes) — 1-4 pontos leem como um penhasco dramático;
|
|
60
|
+
* o marcador ancora o leitor no dado real. Regra do M76, preservada.
|
|
61
|
+
* 2. **Ponto isolado** — um ponto finito cercado de lacunas dos dois lados vira um `M` sozinho no
|
|
62
|
+
* `path`, e um `M` sozinho **desenha nada**: bounding-box zero, invisível. O dado existe, está
|
|
63
|
+
* correto, e o operador não vê. Medido no e2e do M144 (`d="M419.86,92.00 M448.00,36.00"`).
|
|
64
|
+
*
|
|
65
|
+
* A regra antiga só cobria (1), chaveando no TOTAL de pontos em vez de perguntar se o ponto de fato
|
|
66
|
+
* é desenhado — apesar de o comentário dela já declarar a intenção *"a dot keeps real data from
|
|
67
|
+
* rendering as an invisible line"*. Depois da densificação, uma série de 30 dias com dois dias
|
|
68
|
+
* finitos separados por lacuna cai fora de (1) e desaparece. Chart.js e Plotly marcam o ponto
|
|
69
|
+
* isolado exatamente por isto.
|
|
70
|
+
*
|
|
71
|
+
* Fora do JSX de propósito: é a aritmética da decisão, e aritmética isolada é aritmética que a
|
|
72
|
+
* mutação alcança.
|
|
73
|
+
*/
|
|
74
|
+
export declare function pontosComMarcador(points: TrendPoint[]): TrendPoint[];
|
|
36
75
|
export interface TrendChartProps extends HTMLAttributes<HTMLElement> {
|
|
37
76
|
title: string;
|
|
38
77
|
series: TrendSeries[];
|
package/dist/index.js
CHANGED
|
@@ -5095,13 +5095,26 @@ function niceMax(values) {
|
|
|
5095
5095
|
return Number((Math.ceil(m / pow) * pow).toPrecision(12));
|
|
5096
5096
|
}
|
|
5097
5097
|
function seriesPath(points, xScale, yScale) {
|
|
5098
|
-
const
|
|
5099
|
-
|
|
5100
|
-
|
|
5098
|
+
const out = [];
|
|
5099
|
+
let emTrecho = false;
|
|
5100
|
+
for (const p of points) {
|
|
5101
|
+
if (!Number.isFinite(p.y)) {
|
|
5102
|
+
emTrecho = false;
|
|
5103
|
+
continue;
|
|
5104
|
+
}
|
|
5105
|
+
out.push(`${emTrecho ? "L" : "M"}${xScale(p.x).toFixed(2)},${yScale(p.y).toFixed(2)}`);
|
|
5106
|
+
emTrecho = true;
|
|
5107
|
+
}
|
|
5108
|
+
return out.join(" ");
|
|
5101
5109
|
}
|
|
5102
5110
|
var VIEW_W = 600;
|
|
5103
5111
|
var PAD = { top: 8, right: 8, bottom: 4, left: 40 };
|
|
5104
5112
|
var SPARSE_MARKER_MAX = 5;
|
|
5113
|
+
function pontosComMarcador(points) {
|
|
5114
|
+
const finito = (p) => Number.isFinite(p?.y);
|
|
5115
|
+
if (points.length < SPARSE_MARKER_MAX) return points.filter(finito);
|
|
5116
|
+
return points.filter((p, i) => finito(p) && !finito(points[i - 1]) && !finito(points[i + 1]));
|
|
5117
|
+
}
|
|
5105
5118
|
var TrendChart = forwardRef(
|
|
5106
5119
|
({
|
|
5107
5120
|
title,
|
|
@@ -5211,7 +5224,7 @@ var TrendChart = forwardRef(
|
|
|
5211
5224
|
children: /* @__PURE__ */ jsx("title", { children: s.name })
|
|
5212
5225
|
}
|
|
5213
5226
|
),
|
|
5214
|
-
s.points
|
|
5227
|
+
pontosComMarcador(s.points).map((p, i) => /* @__PURE__ */ jsx(
|
|
5215
5228
|
"circle",
|
|
5216
5229
|
{
|
|
5217
5230
|
"data-slot": "trend-chart-dot",
|
|
@@ -5222,7 +5235,7 @@ var TrendChart = forwardRef(
|
|
|
5222
5235
|
children: /* @__PURE__ */ jsx("title", { children: s.name })
|
|
5223
5236
|
},
|
|
5224
5237
|
`${s.name}-${p.x}-${i}`
|
|
5225
|
-
))
|
|
5238
|
+
))
|
|
5226
5239
|
] }, s.name))
|
|
5227
5240
|
]
|
|
5228
5241
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usetheo/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|