@sincpro/web-ui 1.10.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/board/Board.d.ts +51 -0
- package/dist/components/board/Board.js +15 -0
- package/dist/components/board/index.d.ts +1 -0
- package/dist/components/board/index.js +2 -0
- package/dist/components/frame/Chart.d.ts +12 -7
- package/dist/components/frame/Chart.js +17 -17
- package/dist/components/frame/FrameView.d.ts +3 -3
- package/dist/components/frame/FrameView.js +79 -26
- package/dist/components/frame/model.d.ts +12 -3
- package/dist/components/frame/model.js +53 -19
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/listing/AxisLevels.d.ts +24 -0
- package/dist/components/listing/AxisLevels.js +58 -0
- package/dist/components/listing/ChartExplorer.d.ts +79 -0
- package/dist/components/listing/ChartExplorer.js +114 -0
- package/dist/components/listing/PivotExplorer.js +5 -36
- package/dist/components/listing/index.d.ts +2 -0
- package/dist/components/listing/index.js +2 -0
- package/dist/components/listing/set.d.ts +3 -1
- package/dist/foundations/calendar.d.ts +15 -0
- package/dist/foundations/calendar.js +59 -1
- package/dist/foundations/chart.d.ts +126 -0
- package/dist/foundations/chart.js +297 -0
- package/dist/foundations/copy.d.ts +39 -0
- package/dist/foundations/copy.es.js +27 -0
- package/dist/foundations/copy.js +27 -0
- package/dist/foundations/index.d.ts +2 -1
- package/dist/foundations/index.js +4 -1
- package/dist/foundations/pivot.d.ts +9 -0
- package/dist/foundations/pivot.js +1 -0
- package/dist/primitives/chart/Chart.d.ts +39 -0
- package/dist/primitives/chart/Chart.js +235 -0
- package/dist/primitives/chart/index.d.ts +1 -0
- package/dist/primitives/chart/index.js +1 -0
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.js +1 -0
- package/dist/primitives/value/Metric.d.ts +13 -2
- package/dist/primitives/value/Metric.js +25 -3
- package/dist/tokens.css +45 -0
- package/dist/views/list/List.d.ts +2 -1
- package/dist/views/list/List.js +8 -1
- package/dist/views/list/ListView.d.ts +1 -1
- package/dist/views/list/ListView.js +37 -5
- package/dist/views/list/index.d.ts +1 -1
- package/dist/views/list/types.d.ts +34 -0
- package/package.json +4 -2
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { dateKeysBetween } from "./calendar.js";
|
|
2
|
+
import { currentCopy, fillCopy } from "./copy.js";
|
|
3
|
+
import { pathKey } from "./grouping.js";
|
|
4
|
+
import { axisLabels, } from "./pivot.js";
|
|
5
|
+
/** El conteo de filas de cada cruce, ofrecido como una medida más: es la única que
|
|
6
|
+
* siempre se puede contestar. */
|
|
7
|
+
export const COUNT_MEASURE = "__count";
|
|
8
|
+
/** Cuántas series se distinguen por color. Es el largo de la paleta (`--color-series-*`):
|
|
9
|
+
* una novena serie sería un color generado, y bajo daltonismo ése se confunde con otro. */
|
|
10
|
+
export const SERIES_COLORS = 8;
|
|
11
|
+
/** Las medidas que se pueden graficar de un pivote: el conteo y las suyas. */
|
|
12
|
+
export function chartMeasures(pivot) {
|
|
13
|
+
return [
|
|
14
|
+
{ id: COUNT_MEASURE, header: currentCopy().chart.count, additive: true },
|
|
15
|
+
...pivot.measures.map((one) => ({
|
|
16
|
+
id: one.id,
|
|
17
|
+
header: one.header,
|
|
18
|
+
...(one.format === undefined ? {} : { format: one.format }),
|
|
19
|
+
additive: one.additive === true,
|
|
20
|
+
})),
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
function title(axis) {
|
|
24
|
+
return axis.levels.map((level) => level.label).join(" · ");
|
|
25
|
+
}
|
|
26
|
+
function pointOf(axis, key, fallback) {
|
|
27
|
+
return {
|
|
28
|
+
key,
|
|
29
|
+
id: pathKey(key),
|
|
30
|
+
label: axis.levels.length === 0 ? fallback : axisLabels(axis, key).join(" · "),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function sum(values) {
|
|
34
|
+
let out = null;
|
|
35
|
+
for (const value of values)
|
|
36
|
+
if (value !== null)
|
|
37
|
+
out = (out ?? 0) + value;
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
/** Biggest first; a hole goes last, because «nothing there» is not «less than zero». */
|
|
41
|
+
function byTotal(totals, order) {
|
|
42
|
+
return (a, b) => {
|
|
43
|
+
const x = totals[a] ?? null;
|
|
44
|
+
const y = totals[b] ?? null;
|
|
45
|
+
if (x === null || y === null)
|
|
46
|
+
return x === y ? a - b : x === null ? 1 : -1;
|
|
47
|
+
return order === "asc" ? x - y || a - b : y - x || a - b;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Which indices stay, in their own order, when there are more than `max`: the biggest by
|
|
52
|
+
* total. With an additive measure one place is left for «otros».
|
|
53
|
+
*/
|
|
54
|
+
function keep(totals, max, additive) {
|
|
55
|
+
const all = totals.map((_, at) => at);
|
|
56
|
+
if (all.length <= max)
|
|
57
|
+
return { kept: all, rest: [] };
|
|
58
|
+
const room = additive ? Math.max(1, max - 1) : max;
|
|
59
|
+
const top = new Set([...all].sort(byTotal(totals, "desc")).slice(0, room));
|
|
60
|
+
return {
|
|
61
|
+
kept: all.filter((at) => top.has(at)),
|
|
62
|
+
rest: all.filter((at) => !top.has(at)),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* El pivote como gráfico: las filas son el eje, las columnas las series, y en cada cruce
|
|
67
|
+
* el número de la medida elegida.
|
|
68
|
+
*/
|
|
69
|
+
export function chartFromPivot(pivot, reading = {}) {
|
|
70
|
+
const words = currentCopy();
|
|
71
|
+
const measures = chartMeasures(pivot);
|
|
72
|
+
const wanted = reading.measure ?? pivot.measures[0]?.id ?? COUNT_MEASURE;
|
|
73
|
+
const measure = measures.find((one) => one.id === wanted) ?? measures[0];
|
|
74
|
+
const read = (cell) => cell === undefined
|
|
75
|
+
? null
|
|
76
|
+
: measure.id === COUNT_MEASURE
|
|
77
|
+
? cell.count
|
|
78
|
+
: (cell.values[measure.id] ?? null);
|
|
79
|
+
let categories = pivot.rows.keys.map((key) => pointOf(pivot.rows, key, words.pivot.total));
|
|
80
|
+
let series = pivot.columns.keys.map((key) => pointOf(pivot.columns, key, measure.header));
|
|
81
|
+
let values = categories.map((row) => series.map((column) => read(pivot.cell(row.key, column.key))));
|
|
82
|
+
/* Los márgenes salen de la BASE cuando el pivote los trae; sumar celdas es la salida
|
|
83
|
+
honesta sólo cuando la medida se suma. */
|
|
84
|
+
const margin = (cell, inside) => cell !== undefined ? read(cell) : measure.additive ? sum(inside) : null;
|
|
85
|
+
let totals = categories.map((row, at) => margin(pivot.rowTotal?.(row.key), values[at] ?? []));
|
|
86
|
+
/* 0 · El tiempo entero: los períodos vacíos entre el primero y el último. */
|
|
87
|
+
const grain = pivot.rows.levels.length === 1 ? pivot.rows.levels[0]?.grain : undefined;
|
|
88
|
+
if (grain !== undefined && reading.fillDates !== false) {
|
|
89
|
+
const dated = categories
|
|
90
|
+
.map((point, at) => ({ point, at, key: point.key[0] ?? "" }))
|
|
91
|
+
.filter((one) => one.key !== "")
|
|
92
|
+
.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
|
|
93
|
+
const first = dated[0]?.key;
|
|
94
|
+
const last = dated[dated.length - 1]?.key;
|
|
95
|
+
const full = first === undefined || last === undefined ? null : dateKeysBetween(first, last, grain);
|
|
96
|
+
if (full !== null) {
|
|
97
|
+
const byKey = new Map(dated.map((one) => [one.key, one.at]));
|
|
98
|
+
const empty = measure.id === COUNT_MEASURE ? 0 : null;
|
|
99
|
+
const undated = categories
|
|
100
|
+
.map((_, at) => at)
|
|
101
|
+
.filter((at) => (categories[at]?.key[0] ?? "") === "");
|
|
102
|
+
const filled = full.map((key) => {
|
|
103
|
+
const at = byKey.get(key);
|
|
104
|
+
return at === undefined
|
|
105
|
+
? {
|
|
106
|
+
point: pointOf(pivot.rows, [key], key),
|
|
107
|
+
values: series.map(() => empty),
|
|
108
|
+
total: empty,
|
|
109
|
+
}
|
|
110
|
+
: { point: categories[at], values: values[at], total: totals[at] ?? null };
|
|
111
|
+
});
|
|
112
|
+
/* The records without a date stay, at the end: they are not a moment in time. */
|
|
113
|
+
for (const at of undated) {
|
|
114
|
+
filled.push({
|
|
115
|
+
point: categories[at],
|
|
116
|
+
values: values[at],
|
|
117
|
+
total: totals[at] ?? null,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
categories = filled.map((one) => one.point);
|
|
121
|
+
values = filled.map((one) => one.values);
|
|
122
|
+
totals = filled.map((one) => one.total);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/* 1 · Las series que no entran en la paleta. */
|
|
126
|
+
let hiddenSeries = 0;
|
|
127
|
+
const seriesTotals = series.map((column, at) => margin(pivot.columnTotal?.(column.key), values.map((row) => row[at] ?? null)));
|
|
128
|
+
const seriesCut = keep(seriesTotals, reading.maxSeries ?? SERIES_COLORS, measure.additive);
|
|
129
|
+
if (seriesCut.rest.length > 0) {
|
|
130
|
+
const kept = seriesCut.kept;
|
|
131
|
+
if (measure.additive) {
|
|
132
|
+
series = [
|
|
133
|
+
...kept.map((at) => series[at]),
|
|
134
|
+
{
|
|
135
|
+
key: [],
|
|
136
|
+
id: "\u0000rest",
|
|
137
|
+
label: fillCopy(words.chart.rest, { count: seriesCut.rest.length }),
|
|
138
|
+
rest: true,
|
|
139
|
+
},
|
|
140
|
+
];
|
|
141
|
+
values = values.map((row) => [
|
|
142
|
+
...kept.map((at) => row[at] ?? null),
|
|
143
|
+
sum(seriesCut.rest.map((at) => row[at] ?? null)),
|
|
144
|
+
]);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
hiddenSeries = seriesCut.rest.length;
|
|
148
|
+
series = kept.map((at) => series[at]);
|
|
149
|
+
values = values.map((row) => kept.map((at) => row[at] ?? null));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/* 2 · Las categorías que no entran (una torta). */
|
|
153
|
+
let hiddenCategories = 0;
|
|
154
|
+
let restCategory = null;
|
|
155
|
+
if (reading.maxCategories !== undefined) {
|
|
156
|
+
const cut = keep(totals, reading.maxCategories, measure.additive);
|
|
157
|
+
if (cut.rest.length > 0) {
|
|
158
|
+
if (measure.additive) {
|
|
159
|
+
restCategory = {
|
|
160
|
+
point: {
|
|
161
|
+
key: [],
|
|
162
|
+
id: "\u0000rest",
|
|
163
|
+
label: fillCopy(words.chart.rest, { count: cut.rest.length }),
|
|
164
|
+
rest: true,
|
|
165
|
+
},
|
|
166
|
+
values: series.map((_, s) => sum(cut.rest.map((at) => values[at]?.[s] ?? null))),
|
|
167
|
+
total: sum(cut.rest.map((at) => totals[at] ?? null)),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
hiddenCategories = cut.rest.length;
|
|
172
|
+
}
|
|
173
|
+
categories = cut.kept.map((at) => categories[at]);
|
|
174
|
+
values = cut.kept.map((at) => values[at]);
|
|
175
|
+
totals = cut.kept.map((at) => totals[at] ?? null);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/* 3 · El orden del eje. La cola juntada va siempre al final: no es una categoría más. */
|
|
179
|
+
if (reading.order !== undefined) {
|
|
180
|
+
const at = categories.map((_, index) => index).sort(byTotal(totals, reading.order));
|
|
181
|
+
categories = at.map((index) => categories[index]);
|
|
182
|
+
values = at.map((index) => values[index]);
|
|
183
|
+
totals = at.map((index) => totals[index] ?? null);
|
|
184
|
+
}
|
|
185
|
+
if (restCategory !== null) {
|
|
186
|
+
categories = [...categories, restCategory.point];
|
|
187
|
+
values = [...values, restCategory.values];
|
|
188
|
+
totals = [...totals, restCategory.total];
|
|
189
|
+
}
|
|
190
|
+
/* 4 · Acumulado: un agujero arrastra lo que se llevaba, no lo corta. */
|
|
191
|
+
if (reading.cumulative === true && measure.additive) {
|
|
192
|
+
const running = series.map(() => null);
|
|
193
|
+
values = values.map((row) => row.map((value, s) => {
|
|
194
|
+
if (value !== null)
|
|
195
|
+
running[s] = (running[s] ?? 0) + value;
|
|
196
|
+
return running[s] ?? null;
|
|
197
|
+
}));
|
|
198
|
+
let total = null;
|
|
199
|
+
totals = totals.map((value) => {
|
|
200
|
+
if (value !== null)
|
|
201
|
+
total = (total ?? 0) + value;
|
|
202
|
+
return total;
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
categories,
|
|
207
|
+
series,
|
|
208
|
+
values,
|
|
209
|
+
totals,
|
|
210
|
+
measure,
|
|
211
|
+
categoryTitle: title(pivot.rows),
|
|
212
|
+
seriesTitle: title(pivot.columns),
|
|
213
|
+
hiddenSeries,
|
|
214
|
+
hiddenCategories,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Ordena el EJE de un gráfico ya armado por lo que da cada categoría. La cola juntada
|
|
219
|
+
* («otros») queda al final. Es lo mismo que `order` en `chartFromPivot`, para un gráfico
|
|
220
|
+
* que se armó de otra manera —una comparación, un diccionario—.
|
|
221
|
+
*/
|
|
222
|
+
export function orderChart(data, order) {
|
|
223
|
+
if (order === undefined)
|
|
224
|
+
return data;
|
|
225
|
+
const at = data.categories
|
|
226
|
+
.map((_, index) => index)
|
|
227
|
+
.filter((index) => data.categories[index]?.rest !== true)
|
|
228
|
+
.sort(byTotal(data.totals, order));
|
|
229
|
+
const tail = data.categories
|
|
230
|
+
.map((_, index) => index)
|
|
231
|
+
.filter((index) => data.categories[index]?.rest === true);
|
|
232
|
+
const all = [...at, ...tail];
|
|
233
|
+
return {
|
|
234
|
+
...data,
|
|
235
|
+
categories: all.map((index) => data.categories[index]),
|
|
236
|
+
values: all.map((index) => data.values[index]),
|
|
237
|
+
totals: all.map((index) => data.totals[index] ?? null),
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* EL PERÍODO ANTERIOR al lado del actual — el «comparar con» de Odoo.
|
|
242
|
+
*
|
|
243
|
+
* Cada gráfico se arma por su lado (`chartFromPivot` sobre los registros de cada período)
|
|
244
|
+
* y esto los junta en dos series: el actual y el anterior, que se dibuja callado. Lo que se
|
|
245
|
+
* compara es lo que da cada categoría entera.
|
|
246
|
+
*
|
|
247
|
+
* `by` dice cómo se encuentran: por CLAVE cuando el eje es una cosa —La Paz con La Paz— y
|
|
248
|
+
* por POSICIÓN cuando es tiempo —el primer mes con el primer mes—, porque «2026-09» y
|
|
249
|
+
* «2025-09» son claves distintas y lo que se compara es «el mismo momento del período».
|
|
250
|
+
* Una categoría del anterior que no está en el actual no se dibuja: el eje es el de ahora.
|
|
251
|
+
*/
|
|
252
|
+
export function chartCompare(current, previous, labels, by = "key") {
|
|
253
|
+
const whole = (data, at) => data.series.length === 1 ? (data.values[at]?.[0] ?? null) : (data.totals[at] ?? null);
|
|
254
|
+
const index = new Map(previous.categories.map((point, at) => [point.id, at]));
|
|
255
|
+
const before = (point, at) => {
|
|
256
|
+
const found = by === "position" ? at : index.get(point.id);
|
|
257
|
+
return found === undefined || found >= previous.categories.length
|
|
258
|
+
? null
|
|
259
|
+
: whole(previous, found);
|
|
260
|
+
};
|
|
261
|
+
return {
|
|
262
|
+
...current,
|
|
263
|
+
series: [
|
|
264
|
+
{ key: [], id: "\u0000current", label: labels.current },
|
|
265
|
+
{ key: [], id: "\u0000previous", label: labels.previous, previous: true },
|
|
266
|
+
],
|
|
267
|
+
values: current.categories.map((point, at) => [whole(current, at), before(point, at)]),
|
|
268
|
+
totals: current.categories.map((_, at) => whole(current, at)),
|
|
269
|
+
hiddenSeries: 0,
|
|
270
|
+
compare: true,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Un DICCIONARIO como gráfico: `{ "La Paz": 120, "Oruro": 40 }`, o sus pares. Es lo que
|
|
275
|
+
* devuelve un endpoint de resumen, y no hace falta armarle un pivote.
|
|
276
|
+
*/
|
|
277
|
+
export function chartFromRecord(entries, measure) {
|
|
278
|
+
const pairs = Array.isArray(entries)
|
|
279
|
+
? entries
|
|
280
|
+
: Object.entries(entries);
|
|
281
|
+
return {
|
|
282
|
+
categories: pairs.map(([label]) => ({ key: [label], id: label, label })),
|
|
283
|
+
series: [{ key: [], id: "", label: measure.header }],
|
|
284
|
+
values: pairs.map(([, value]) => [value]),
|
|
285
|
+
totals: pairs.map(([, value]) => value),
|
|
286
|
+
measure: {
|
|
287
|
+
id: "value",
|
|
288
|
+
header: measure.header,
|
|
289
|
+
...(measure.format === undefined ? {} : { format: measure.format }),
|
|
290
|
+
additive: measure.additive ?? true,
|
|
291
|
+
},
|
|
292
|
+
categoryTitle: "",
|
|
293
|
+
seriesTitle: "",
|
|
294
|
+
hiddenSeries: 0,
|
|
295
|
+
hiddenCategories: 0,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
@@ -652,6 +652,45 @@ export type UiCopy = {
|
|
|
652
652
|
download: string;
|
|
653
653
|
fromSearch: string;
|
|
654
654
|
};
|
|
655
|
+
/** The chart of a set (`Chart`, `ChartExplorer`): Odoo's graph view. */
|
|
656
|
+
chart: {
|
|
657
|
+
/** The count of rows, offered as a measure. */
|
|
658
|
+
count: string;
|
|
659
|
+
/** The tail gathered into one bar or slice. */
|
|
660
|
+
rest: string;
|
|
661
|
+
empty: string;
|
|
662
|
+
/** A pie cannot draw a negative part. */
|
|
663
|
+
pieNegative: string;
|
|
664
|
+
/** Series (or slices) left out because the measure does not add up. */
|
|
665
|
+
hidden: string;
|
|
666
|
+
kind: string;
|
|
667
|
+
bar: string;
|
|
668
|
+
line: string;
|
|
669
|
+
pie: string;
|
|
670
|
+
measure: string;
|
|
671
|
+
categoriesAxis: string;
|
|
672
|
+
seriesAxis: string;
|
|
673
|
+
stacked: string;
|
|
674
|
+
cumulative: string;
|
|
675
|
+
ascending: string;
|
|
676
|
+
descending: string;
|
|
677
|
+
/** A legend entry is a toggle: it hides or shows its series. */
|
|
678
|
+
hideSeries: string;
|
|
679
|
+
showSeries: string;
|
|
680
|
+
/** What a press on a bar, a point or a slice does. */
|
|
681
|
+
open: string;
|
|
682
|
+
/** The measures a frame offers for each numeric column. */
|
|
683
|
+
sumOf: string;
|
|
684
|
+
averageOf: string;
|
|
685
|
+
/** The tooltip of a comparison: now against before, as a change. */
|
|
686
|
+
change: string;
|
|
687
|
+
/** The toggle that draws the previous period: «Comparar con {name}». */
|
|
688
|
+
compareWith: string;
|
|
689
|
+
/** The measure menu's label with more than one on: «importe +1». */
|
|
690
|
+
moreMeasures: string;
|
|
691
|
+
/** A metric's change, against a named period: «vs 2025». */
|
|
692
|
+
against: string;
|
|
693
|
+
};
|
|
655
694
|
/** A person as a value: who is not there, and the ways to reach who is. */
|
|
656
695
|
person: {
|
|
657
696
|
unassigned: string;
|
|
@@ -443,6 +443,33 @@ export const SPANISH_COPY = {
|
|
|
443
443
|
download: "Descargar",
|
|
444
444
|
fromSearch: "del agrupado del buscador",
|
|
445
445
|
},
|
|
446
|
+
chart: {
|
|
447
|
+
count: "cantidad",
|
|
448
|
+
rest: "otros ({count})",
|
|
449
|
+
empty: "No hay nada que graficar.",
|
|
450
|
+
pieNegative: "Una torta no puede mostrar valores negativos: probá con barras.",
|
|
451
|
+
hidden: "{count} más no se dibujan: esta medida no se suma, así que no se pueden juntar en «otros». El pivote las muestra todas.",
|
|
452
|
+
kind: "Tipo de gráfico",
|
|
453
|
+
bar: "Barras",
|
|
454
|
+
line: "Líneas",
|
|
455
|
+
pie: "Torta",
|
|
456
|
+
measure: "Medida",
|
|
457
|
+
categoriesAxis: "Eje",
|
|
458
|
+
seriesAxis: "Series",
|
|
459
|
+
stacked: "Apilar",
|
|
460
|
+
cumulative: "Acumulado",
|
|
461
|
+
ascending: "De menor a mayor",
|
|
462
|
+
descending: "De mayor a menor",
|
|
463
|
+
hideSeries: "Esconder {name}",
|
|
464
|
+
showSeries: "Mostrar {name}",
|
|
465
|
+
open: "Abrir {name}",
|
|
466
|
+
sumOf: "suma de {name}",
|
|
467
|
+
averageOf: "promedio de {name}",
|
|
468
|
+
change: "variación",
|
|
469
|
+
compareWith: "Comparar con {name}",
|
|
470
|
+
moreMeasures: "{name} +{count}",
|
|
471
|
+
against: "vs {name}",
|
|
472
|
+
},
|
|
446
473
|
person: {
|
|
447
474
|
unassigned: "sin asignar",
|
|
448
475
|
email: "Escribir un correo",
|
package/dist/foundations/copy.js
CHANGED
|
@@ -433,6 +433,33 @@ export const ENGLISH_COPY = {
|
|
|
433
433
|
download: "Download",
|
|
434
434
|
fromSearch: "from the search's grouping",
|
|
435
435
|
},
|
|
436
|
+
chart: {
|
|
437
|
+
count: "count",
|
|
438
|
+
rest: "others ({count})",
|
|
439
|
+
empty: "Nothing to chart.",
|
|
440
|
+
pieNegative: "A pie cannot show negative values — try bars.",
|
|
441
|
+
hidden: "{count} more not drawn: this measure does not add up, so they cannot be gathered into «others». The pivot shows them all.",
|
|
442
|
+
kind: "Chart type",
|
|
443
|
+
bar: "Bars",
|
|
444
|
+
line: "Lines",
|
|
445
|
+
pie: "Pie",
|
|
446
|
+
measure: "Measure",
|
|
447
|
+
categoriesAxis: "Axis",
|
|
448
|
+
seriesAxis: "Series",
|
|
449
|
+
stacked: "Stack",
|
|
450
|
+
cumulative: "Cumulative",
|
|
451
|
+
ascending: "Smallest first",
|
|
452
|
+
descending: "Largest first",
|
|
453
|
+
hideSeries: "Hide {name}",
|
|
454
|
+
showSeries: "Show {name}",
|
|
455
|
+
open: "Open {name}",
|
|
456
|
+
sumOf: "sum of {name}",
|
|
457
|
+
averageOf: "average of {name}",
|
|
458
|
+
change: "change",
|
|
459
|
+
compareWith: "Compare with {name}",
|
|
460
|
+
moreMeasures: "{name} +{count}",
|
|
461
|
+
against: "vs {name}",
|
|
462
|
+
},
|
|
436
463
|
person: {
|
|
437
464
|
unassigned: "unassigned",
|
|
438
465
|
email: "Write an email",
|
|
@@ -8,9 +8,10 @@ export type { OpenTarget, Size, Surface, Tone } from "./types.js";
|
|
|
8
8
|
/** El castellano del sistema, para quien lo quiera instalar entero. */
|
|
9
9
|
export { SPANISH_COPY } from "./copy.es.js";
|
|
10
10
|
export { flatten, loose, pick, pickAll, propsOf, slot, slotOf, type Slotted, } from "./slots.js";
|
|
11
|
-
export { dateKey, dateLabel, grainName, monthName, } from "./calendar.js";
|
|
11
|
+
export { dateKey, dateKeysBetween, dateLabel, grainName, monthName, nextDateKey, } from "./calendar.js";
|
|
12
12
|
export { GRAIN_ORDER, type GroupableField, type GroupGrain, type Grouping, type GroupLevel, itemPath, levelKey, moveLevel, normalizeLevels, pathKey, pathLabels, type Pile, pileCount, type PileFoot, pileFoot, pileIsOpen, pileItems, pileLabel, type PileLabelOf, type PileOf, pilesFrom, pilesOf, } from "./grouping.js";
|
|
13
13
|
export { axisLabels, axisSpans, keyStarts, type Pivot, type PivotAxis, type PivotCell, type PivotCrossing, type PivotFold, pivotFrom, pivotIsEmpty, type PivotKey, type PivotLevel, type PivotMargin, type PivotMeasure, pivotOf, type PivotSource, type PivotSpec, } from "./pivot.js";
|
|
14
|
+
export { chartCompare, type ChartData, chartFromPivot, chartFromRecord, type ChartKind, type ChartMeasure, chartMeasures, type ChartOrder, type ChartPoint, type ChartReading, COUNT_MEASURE, orderChart, SERIES_COLORS, } from "./chart.js";
|
|
14
15
|
export { downloadPivot, pivotSheet, type PivotSheetOptions, pivotXlsx, } from "./pivotSheet.js";
|
|
15
16
|
export { STICKY_TOP, stickyReset, stickyTop, useScrollBox, useStickyLayer, } from "./sticky.js";
|
|
16
17
|
export { columnName, downloadXlsx, writeXlsx, type XlsxCell, type XlsxMerge, type XlsxSheet, } from "./xlsx.js";
|
|
@@ -19,7 +19,7 @@ export { flatten, loose, pick, pickAll, propsOf, slot, slotOf, } from "./slots.j
|
|
|
19
19
|
/* EL CALENDARIO — de una fecha a una clave y de una clave a un rótulo. Los meses
|
|
20
20
|
y los días de la semana los dice `Intl` con el `locale` de la copia; la semana
|
|
21
21
|
y el trimestre son las dos únicas palabras que hay que escribir. */
|
|
22
|
-
export { dateKey, dateLabel, grainName, monthName, } from "./calendar.js";
|
|
22
|
+
export { dateKey, dateKeysBetween, dateLabel, grainName, monthName, nextDateKey, } from "./calendar.js";
|
|
23
23
|
/* LA AGRUPACIÓN — el vocabulario, que hablan las dos capas: la lista arma el
|
|
24
24
|
árbol de montones y la tabla lo dibuja. Vive acá y no en `contexts/list`
|
|
25
25
|
porque una primitiva no puede importar de un contexto. */
|
|
@@ -28,6 +28,9 @@ export { GRAIN_ORDER, itemPath, levelKey, moveLevel, normalizeLevels, pathKey, p
|
|
|
28
28
|
Que los márgenes vengan de la base y que un agujero no sea un cero son reglas
|
|
29
29
|
del CONTRATO, no del dibujo, y por eso viven de este lado. */
|
|
30
30
|
export { axisLabels, axisSpans, keyStarts, pivotFrom, pivotIsEmpty, pivotOf, } from "./pivot.js";
|
|
31
|
+
/* EL GRÁFICO — un pivote leído como marcas. Lee el mismo `Pivot`, así que sirve igual para
|
|
32
|
+
registros, un dataset o lo plegado en el servidor; un diccionario entra por su helper. */
|
|
33
|
+
export { chartCompare, chartFromPivot, chartFromRecord, chartMeasures, COUNT_MEASURE, orderChart, SERIES_COLORS, } from "./chart.js";
|
|
31
34
|
/* LA PLANILLA: la misma grilla, en un archivo. El escritor es genérico y no
|
|
32
35
|
sabe de pivotes; `pivotSheet` es el que traduce uno. */
|
|
33
36
|
export { downloadPivot, pivotSheet, pivotXlsx, } from "./pivotSheet.js";
|
|
@@ -100,6 +100,15 @@ export type PivotMeasure = {
|
|
|
100
100
|
* sigue pudiendo sumar, que es lo que no se puede perder.
|
|
101
101
|
*/
|
|
102
102
|
numberFormat?: string;
|
|
103
|
+
/**
|
|
104
|
+
* La medida SE SUMA: el pliegue de dos montones juntos es la suma de sus pliegues —un
|
|
105
|
+
* importe, un conteo—. Un promedio no, y una mediana tampoco.
|
|
106
|
+
*
|
|
107
|
+
* Lo lee el gráfico, que a veces tiene que juntar una cola en «otros» o acumular una
|
|
108
|
+
* línea: con esto la suma dice la verdad, y sin esto la cola se deja afuera y se avisa,
|
|
109
|
+
* porque sumar promedios inventa un número que nadie plegó (la regla 2 de arriba).
|
|
110
|
+
*/
|
|
111
|
+
additive?: boolean;
|
|
103
112
|
};
|
|
104
113
|
/**
|
|
105
114
|
* Un CRUCE ya plegado: cuántas filas hay debajo y qué dan las medidas.
|
|
@@ -133,6 +133,7 @@ export function pivotFrom(items, spec) {
|
|
|
133
133
|
header: one.header,
|
|
134
134
|
...(one.format === undefined ? {} : { format: one.format }),
|
|
135
135
|
...(one.numberFormat === undefined ? {} : { numberFormat: one.numberFormat }),
|
|
136
|
+
...(one.additive === undefined ? {} : { additive: one.additive }),
|
|
136
137
|
})),
|
|
137
138
|
cell: (row, column) => crossings.get(crossKey(row, column)),
|
|
138
139
|
rowTotal: (row) => rowMargins.get(pathKey(row)),
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ChartData, type ChartKind } from "../../foundations/chart.js";
|
|
2
|
+
import type { PivotKey } from "../../foundations/pivot.js";
|
|
3
|
+
/**
|
|
4
|
+
* A CHART: the numbers of a set, as marks — bars, lines or a pie.
|
|
5
|
+
*
|
|
6
|
+
* Context: «series» used to be a column of 6 px progress bars stretched across the page, the
|
|
7
|
+
* number 1,200 px away from its bar, and an empty bin drawn with a stub as if it had data. It
|
|
8
|
+
* answered one question (how one column spreads) and Odoo's graph view answers the one an
|
|
9
|
+
* ERP actually asks: the set split by one field, maybe by a second, and a measure in each
|
|
10
|
+
* crossing. That is a pivot, so this draws `ChartData`, which `chartFromPivot` reads off any
|
|
11
|
+
* `Pivot` — records, a dataset, or one folded by the server.
|
|
12
|
+
*
|
|
13
|
+
* Drawn with Recharts (SVG): its fills take `var(--color-*)`, so a token and the dark theme
|
|
14
|
+
* reach the marks with no re-render, which no canvas engine does. What it draws follows the
|
|
15
|
+
* system's chart rules — thin marks (≤ 24 px), a 4 px rounded data end and square at the
|
|
16
|
+
* baseline, hairline solid grid, text in text tokens and never in a series colour, one hue
|
|
17
|
+
* for one series (`data`), the categorical palette only from two, a legend only from two,
|
|
18
|
+
* and no animation: a chart that moves when it loads is decoration (MOTION in tokens.css).
|
|
19
|
+
*
|
|
20
|
+
* A primitive: it knows nothing about lists or toolbars. `ChartExplorer` puts the controls
|
|
21
|
+
* around it; anyone can draw it alone with a `ChartData`.
|
|
22
|
+
*/
|
|
23
|
+
export type ChartProps = {
|
|
24
|
+
data: ChartData;
|
|
25
|
+
kind?: ChartKind;
|
|
26
|
+
/** Series one on top of the other (bars), or areas stacked (lines). */
|
|
27
|
+
stacked?: boolean;
|
|
28
|
+
/** Bars lying down. By default they lie down when the names are long or many — a column
|
|
29
|
+
* chart with thirty customers is thirty unreadable tick labels. */
|
|
30
|
+
horizontal?: boolean;
|
|
31
|
+
/** A bar, a point or a slice was pressed: open what fell there. `series` is absent when
|
|
32
|
+
* the press means every series (a point of a line with several). */
|
|
33
|
+
onPoint?: (category: PivotKey, series?: PivotKey) => void;
|
|
34
|
+
/** The accessible name: what this chart shows. */
|
|
35
|
+
label: string;
|
|
36
|
+
/** The plot's height. By default the chart decides: lying bars grow with their rows. */
|
|
37
|
+
height?: number | string;
|
|
38
|
+
};
|
|
39
|
+
export declare function Chart({ data, kind, stacked: stackedProp, horizontal: horizontalProp, onPoint, label, height, }: ChartProps): import("react").JSX.Element;
|