@sincpro/web-ui 2.0.0 → 2.2.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.
- package/README.md +45 -0
- package/dist/components/activity/Activity.d.ts +13 -14
- package/dist/components/activity/Activity.js +1 -1
- package/dist/components/activity/Messages.d.ts +5 -5
- package/dist/components/activity/Messages.js +8 -8
- package/dist/components/attachments/Attachments.d.ts +7 -1
- package/dist/components/attachments/Attachments.js +8 -2
- package/dist/components/board/Board.d.ts +32 -2
- package/dist/components/board/Board.js +27 -4
- package/dist/components/board/index.d.ts +1 -1
- package/dist/components/board/index.js +2 -1
- package/dist/components/form/Form.js +6 -6
- package/dist/components/form/index.js +2 -2
- package/dist/components/frame/FrameView.d.ts +5 -5
- package/dist/components/frame/FrameView.js +4 -4
- package/dist/components/listing/GroupingLevels.d.ts +22 -22
- package/dist/components/listing/GroupingLevels.js +9 -9
- package/dist/components/listing/Listing.d.ts +11 -11
- package/dist/components/listing/Listing.js +11 -11
- package/dist/components/listing/ListingBar.js +11 -11
- package/dist/components/listing/Row.d.ts +19 -19
- package/dist/components/listing/Row.js +27 -27
- package/dist/components/listing/SortMenu.d.ts +36 -36
- package/dist/components/listing/SortMenu.js +6 -6
- package/dist/components/listing/grouping.d.ts +16 -16
- package/dist/components/listing/grouping.js +6 -6
- package/dist/components/listing/index.js +1 -1
- package/dist/components/listing/modelColumns.d.ts +25 -25
- package/dist/components/listing/modelColumns.js +24 -24
- package/dist/components/listing/pages.js +4 -4
- package/dist/components/listing/set.d.ts +18 -18
- package/dist/components/navigation/NavigationTree.js +2 -2
- package/dist/components/navigation/index.js +2 -2
- package/dist/components/record/RecordSkeleton.js +7 -7
- package/dist/components/search/CriteriaBuilder.d.ts +22 -22
- package/dist/components/search/CriteriaBuilder.js +31 -31
- package/dist/components/search/CriteriaChips.d.ts +9 -9
- package/dist/components/search/CriteriaChips.js +12 -12
- package/dist/components/search/FilterBuilder.d.ts +67 -67
- package/dist/components/search/FilterBuilder.js +104 -104
- package/dist/components/search/JoinWord.d.ts +1 -1
- package/dist/components/search/JoinWord.js +14 -14
- package/dist/components/search/JsonEditor.d.ts +8 -8
- package/dist/components/search/JsonEditor.js +16 -16
- package/dist/components/search/SearchBar.d.ts +34 -34
- package/dist/components/search/SearchBar.js +140 -117
- package/dist/components/search/criteria.d.ts +61 -61
- package/dist/components/search/criteria.js +39 -39
- package/dist/components/search/datePeriods.d.ts +47 -48
- package/dist/components/search/datePeriods.js +29 -29
- package/dist/components/search/dateRanges.d.ts +27 -27
- package/dist/components/search/dateRanges.js +16 -16
- package/dist/components/search/index.js +13 -13
- package/dist/components/search/model.d.ts +28 -28
- package/dist/components/search/model.js +21 -21
- package/dist/components/search/query.d.ts +71 -71
- package/dist/components/search/query.js +119 -119
- package/dist/components/shell/AppFrame.d.ts +9 -2
- package/dist/components/shell/AppFrame.js +102 -14
- package/dist/components/shell/Sidebar.d.ts +34 -0
- package/dist/components/shell/Sidebar.js +32 -0
- package/dist/components/shell/TopBar.d.ts +2 -0
- package/dist/components/shell/TopBar.js +13 -9
- package/dist/components/shell/index.d.ts +2 -0
- package/dist/components/shell/index.js +5 -1
- package/dist/components/shell/sidebarDrawer.d.ts +26 -0
- package/dist/components/shell/sidebarDrawer.js +22 -0
- package/dist/foundations/calendar.d.ts +27 -27
- package/dist/foundations/calendar.js +72 -72
- package/dist/foundations/chart.d.ts +57 -57
- package/dist/foundations/chart.js +27 -27
- package/dist/foundations/copy.d.ts +109 -94
- package/dist/foundations/copy.es.js +10 -2
- package/dist/foundations/copy.js +10 -2
- package/dist/foundations/grouping.d.ts +175 -175
- package/dist/foundations/grouping.js +0 -0
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +21 -21
- package/dist/foundations/pivot.d.ts +133 -131
- package/dist/foundations/pivot.js +54 -54
- package/dist/foundations/pivotSheet.d.ts +36 -36
- package/dist/foundations/pivotSheet.js +0 -0
- package/dist/foundations/slots.d.ts +38 -38
- package/dist/foundations/slots.js +18 -18
- package/dist/foundations/sticky.d.ts +28 -28
- package/dist/foundations/sticky.js +59 -59
- package/dist/foundations/xlsx.d.ts +47 -47
- package/dist/foundations/xlsx.js +0 -0
- package/dist/primitives/block/Line.d.ts +4 -4
- package/dist/primitives/block/Line.js +28 -28
- package/dist/primitives/block/index.js +2 -2
- package/dist/primitives/cell/index.js +2 -2
- package/dist/primitives/choice/index.js +3 -3
- package/dist/primitives/date/Calendar.d.ts +7 -1
- package/dist/primitives/date/Calendar.js +13 -3
- package/dist/primitives/date/DatePicker.d.ts +4 -1
- package/dist/primitives/date/DatePicker.js +2 -2
- package/dist/primitives/date/index.js +3 -3
- package/dist/primitives/disclosure/index.js +1 -1
- package/dist/primitives/field/DropZone.d.ts +22 -3
- package/dist/primitives/field/DropZone.js +33 -12
- package/dist/primitives/menu/Menu.d.ts +10 -6
- package/dist/primitives/menu/Menu.js +4 -3
- package/dist/primitives/notice/Callout.d.ts +30 -30
- package/dist/primitives/notice/Callout.js +6 -6
- package/dist/primitives/overlay/index.js +3 -3
- package/dist/primitives/picker/Picker.d.ts +6 -0
- package/dist/primitives/picker/Picker.js +27 -4
- package/dist/primitives/picker/index.js +2 -2
- package/dist/primitives/table/DataTable.d.ts +32 -32
- package/dist/primitives/table/DataTable.js +24 -24
- package/dist/primitives/table/EditableTable.d.ts +10 -10
- package/dist/primitives/table/EditableTable.js +9 -9
- package/dist/primitives/table/ReportTable.js +7 -7
- package/dist/primitives/table/SheetTable.d.ts +13 -13
- package/dist/primitives/table/SheetTable.js +14 -14
- package/dist/primitives/table/Table.js +8 -8
- package/dist/primitives/tabs/Tabs.d.ts +46 -46
- package/dist/primitives/tabs/Tabs.js +4 -30
- package/dist/primitives/tag/Count.d.ts +23 -0
- package/dist/primitives/tag/Count.js +59 -0
- package/dist/primitives/tag/index.d.ts +1 -0
- package/dist/primitives/tag/index.js +5 -2
- package/dist/primitives/toolbar/index.js +1 -1
- package/dist/primitives/value/Copyable.d.ts +22 -22
- package/dist/primitives/value/Copyable.js +9 -9
- package/dist/primitives/value/Metric.d.ts +7 -2
- package/dist/primitives/value/Metric.js +12 -4
- package/dist/tokens.css +164 -57
- package/dist/views/list/List.d.ts +36 -36
- package/dist/views/list/List.js +19 -19
- package/dist/views/list/ListView.js +74 -74
- package/dist/views/list/columns.d.ts +10 -10
- package/dist/views/list/columns.js +10 -10
- package/dist/views/list/derive.d.ts +30 -30
- package/dist/views/list/derive.js +49 -49
- package/dist/views/list/index.js +2 -2
- package/dist/views/list/presentations.js +3 -3
- package/dist/views/list/types.d.ts +109 -109
- package/dist/views/record/Record.d.ts +14 -14
- package/dist/views/record/Record.js +24 -24
- package/dist/views/record/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import { type Pivot, type PivotKey } from "./pivot.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* THE CHART: a pivot read as marks.
|
|
4
4
|
*
|
|
5
|
-
* Context:
|
|
6
|
-
*
|
|
7
|
-
* series),
|
|
8
|
-
*
|
|
9
|
-
* (`pivotFrom`),
|
|
10
|
-
*
|
|
11
|
-
* a
|
|
5
|
+
* Context: an ERP chart —Odoo's, anyone's— answers the same question
|
|
6
|
+
* as a pivot: the set split by one field (the axis), sometimes by another (the
|
|
7
|
+
* series), and at each crossing a folded number. That is why this brings NO other way to fold:
|
|
8
|
+
* it reads a `Pivot`. And since a `Pivot` is built the same by whoever holds the records in hand
|
|
9
|
+
* (`pivotFrom`), whoever folded it on the server (`pivotOf`) or whoever built it from the cells
|
|
10
|
+
* of a file, the same chart serves records, a dataset and what is grouped
|
|
11
|
+
* a thousand kilometres away. A dictionary or a `SeriesBar[]` come in through the two helpers below.
|
|
12
12
|
*
|
|
13
|
-
* ──
|
|
13
|
+
* ── The pivot's rows are the AXIS; its columns, the SERIES ──────────
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* As in Odoo: the first grouping goes below and the second is stacked or set beside it.
|
|
16
16
|
*
|
|
17
|
-
* ──
|
|
17
|
+
* ── Three rules that come from the pivot, and still hold ────────────
|
|
18
18
|
*
|
|
19
|
-
* 1. **
|
|
20
|
-
*
|
|
21
|
-
* 2. **
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* 3. **
|
|
25
|
-
*
|
|
19
|
+
* 1. **A hole is not a zero.** `null` is «there are no rows there»: the bar is not drawn and
|
|
20
|
+
* the line breaks. A zero is a bar flush with the axis.
|
|
21
|
+
* 2. **Sums are not invented.** Gathering the tail into «otros» or accumulating a line is summing, and
|
|
22
|
+
* it is only done if the measure sums (`additive`; the count always). Otherwise the tail is
|
|
23
|
+
* left out and SAID (`hiddenSeries`): an average of averages is not an average.
|
|
24
|
+
* 3. **Colour follows the series, not its position.** The remaining series keep the
|
|
25
|
+
* pivot's order; sorting by size sorts the AXIS, never repaints.
|
|
26
26
|
*/
|
|
27
27
|
export type ChartKind = "bar" | "line" | "pie";
|
|
28
28
|
export type ChartOrder = "asc" | "desc";
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
29
|
+
/** The row count of each crossing, offered as one more measure: it is the only one that
|
|
30
|
+
* can always be answered. */
|
|
31
31
|
export declare const COUNT_MEASURE = "__count";
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
32
|
+
/** How many series are told apart by colour. It is the palette's length (`--color-series-*`):
|
|
33
|
+
* a ninth series would be a generated colour, and under colour blindness that one gets confused with another. */
|
|
34
34
|
export declare const SERIES_COLORS = 8;
|
|
35
|
-
/**
|
|
35
|
+
/** A key of a chart axis: its path in the pivot and how it reads. */
|
|
36
36
|
export type ChartPoint = {
|
|
37
37
|
key: PivotKey;
|
|
38
|
-
/** `pathKey(key)`:
|
|
38
|
+
/** `pathKey(key)`: the stable identity for React and for colour. */
|
|
39
39
|
id: string;
|
|
40
40
|
label: string;
|
|
41
|
-
/**
|
|
41
|
+
/** The tail gathered into one: «otros (12)». Drawn quieter and does not open. */
|
|
42
42
|
rest?: boolean;
|
|
43
|
-
/**
|
|
43
|
+
/** The previous period of a comparison: drawn quiet, behind the current one. */
|
|
44
44
|
previous?: boolean;
|
|
45
45
|
};
|
|
46
46
|
export type ChartMeasure = {
|
|
@@ -52,72 +52,72 @@ export type ChartMeasure = {
|
|
|
52
52
|
export type ChartData = {
|
|
53
53
|
categories: readonly ChartPoint[];
|
|
54
54
|
series: readonly ChartPoint[];
|
|
55
|
-
/** `values[
|
|
55
|
+
/** `values[category][series]`; `null` is a hole. */
|
|
56
56
|
values: readonly (readonly (number | null)[])[];
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
57
|
+
/** What each whole category gives, folded from the base when the pivot brings it. It is what
|
|
58
|
+
* a pie measures and what orders the axis. */
|
|
59
59
|
totals: readonly (number | null)[];
|
|
60
60
|
measure: ChartMeasure;
|
|
61
|
-
/**
|
|
61
|
+
/** What the cuts are called: «sucursal», «año · forma de pago». */
|
|
62
62
|
categoryTitle: string;
|
|
63
63
|
seriesTitle: string;
|
|
64
|
-
/** Series
|
|
64
|
+
/** Series that did not make it and could not be gathered into «otros» (the measure does not sum). */
|
|
65
65
|
hiddenSeries: number;
|
|
66
|
-
/**
|
|
66
|
+
/** The same, for the categories a pie cannot show. */
|
|
67
67
|
hiddenCategories: number;
|
|
68
|
-
/**
|
|
68
|
+
/** The two series are the current and the previous period (`chartCompare`). */
|
|
69
69
|
compare?: boolean;
|
|
70
70
|
};
|
|
71
71
|
export type ChartReading = {
|
|
72
|
-
/**
|
|
72
|
+
/** The measure's id, or `COUNT_MEASURE`. By default the pivot's first. */
|
|
73
73
|
measure?: string;
|
|
74
|
-
/**
|
|
74
|
+
/** Sorts the AXIS by what each category gives. Without this, the order of its keys. */
|
|
75
75
|
order?: ChartOrder;
|
|
76
|
-
/**
|
|
76
|
+
/** Each point adds the previous ones: «how much we have so far». Only with a measure that sums. */
|
|
77
77
|
cumulative?: boolean;
|
|
78
|
-
/**
|
|
78
|
+
/** More series than this are gathered into «otros». By default, the palette's colours. */
|
|
79
79
|
maxSeries?: number;
|
|
80
|
-
/**
|
|
80
|
+
/** More categories than this are gathered into «otros». A pie asks for six. */
|
|
81
81
|
maxCategories?: number;
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
83
|
+
* With a single DATE level on the axis, fills in the periods where nothing happened:
|
|
84
|
+
* August is not left stuck to October. The count of an empty period is 0; any other
|
|
85
|
+
* measure is a hole (`null`), like any crossing without rows. On by default.
|
|
86
86
|
*/
|
|
87
87
|
fillDates?: boolean;
|
|
88
88
|
};
|
|
89
|
-
/**
|
|
89
|
+
/** The measures that can be charted from a pivot: the count and its own. */
|
|
90
90
|
export declare function chartMeasures(pivot: Pivot): ChartMeasure[];
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
92
|
+
* The pivot as a chart: the rows are the axis, the columns the series, and at each crossing
|
|
93
|
+
* the number of the chosen measure.
|
|
94
94
|
*/
|
|
95
95
|
export declare function chartFromPivot(pivot: Pivot, reading?: ChartReading): ChartData;
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
98
|
-
* («otros»)
|
|
99
|
-
*
|
|
97
|
+
* Sorts the AXIS of an already built chart by what each category gives. The gathered tail
|
|
98
|
+
* («otros») stays last. It is the same as `order` in `chartFromPivot`, for a chart
|
|
99
|
+
* that was built another way —a comparison, a dictionary—.
|
|
100
100
|
*/
|
|
101
101
|
export declare function orderChart(data: ChartData, order: ChartOrder | undefined): ChartData;
|
|
102
102
|
/**
|
|
103
|
-
*
|
|
103
|
+
* THE PREVIOUS PERIOD beside the current one — Odoo's «comparar con».
|
|
104
104
|
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
105
|
+
* Each chart is built on its own (`chartFromPivot` over each period's records)
|
|
106
|
+
* and this joins them into two series: the current and the previous, which is drawn quiet. What is
|
|
107
|
+
* compared is what each whole category gives.
|
|
108
108
|
*
|
|
109
|
-
* `by`
|
|
110
|
-
*
|
|
111
|
-
* «2025-09»
|
|
112
|
-
*
|
|
109
|
+
* `by` says how they are matched: by KEY when the axis is a thing —La Paz with La Paz— and
|
|
110
|
+
* by POSITION when it is time —the first month with the first month—, because «2026-09» and
|
|
111
|
+
* «2025-09» are different keys and what is compared is «the same moment of the period».
|
|
112
|
+
* A category of the previous that is not in the current is not drawn: the axis is today's.
|
|
113
113
|
*/
|
|
114
114
|
export declare function chartCompare(current: ChartData, previous: ChartData, labels: {
|
|
115
115
|
current: string;
|
|
116
116
|
previous: string;
|
|
117
117
|
}, by?: "key" | "position"): ChartData;
|
|
118
118
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
119
|
+
* A DICTIONARY as a chart: `{ "La Paz": 120, "Oruro": 40 }`, or its pairs. It is what
|
|
120
|
+
* a summary endpoint returns, and there is no need to build a pivot for it.
|
|
121
121
|
*/
|
|
122
122
|
export declare function chartFromRecord(entries: Readonly<Record<string, number | null>> | readonly (readonly [string, number | null])[], measure: {
|
|
123
123
|
header: string;
|
|
@@ -2,13 +2,13 @@ import { dateKeysBetween } from "./calendar.js";
|
|
|
2
2
|
import { currentCopy, fillCopy } from "./copy.js";
|
|
3
3
|
import { pathKey } from "./grouping.js";
|
|
4
4
|
import { axisLabels, } from "./pivot.js";
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
5
|
+
/** The row count of each crossing, offered as one more measure: it is the only one that
|
|
6
|
+
* can always be answered. */
|
|
7
7
|
export const COUNT_MEASURE = "__count";
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
8
|
+
/** How many series are told apart by colour. It is the palette's length (`--color-series-*`):
|
|
9
|
+
* a ninth series would be a generated colour, and under colour blindness that one gets confused with another. */
|
|
10
10
|
export const SERIES_COLORS = 8;
|
|
11
|
-
/**
|
|
11
|
+
/** The measures that can be charted from a pivot: the count and its own. */
|
|
12
12
|
export function chartMeasures(pivot) {
|
|
13
13
|
return [
|
|
14
14
|
{ id: COUNT_MEASURE, header: currentCopy().chart.count, additive: true },
|
|
@@ -63,8 +63,8 @@ function keep(totals, max, additive) {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
66
|
+
* The pivot as a chart: the rows are the axis, the columns the series, and at each crossing
|
|
67
|
+
* the number of the chosen measure.
|
|
68
68
|
*/
|
|
69
69
|
export function chartFromPivot(pivot, reading = {}) {
|
|
70
70
|
const words = currentCopy();
|
|
@@ -79,11 +79,11 @@ export function chartFromPivot(pivot, reading = {}) {
|
|
|
79
79
|
let categories = pivot.rows.keys.map((key) => pointOf(pivot.rows, key, words.pivot.total));
|
|
80
80
|
let series = pivot.columns.keys.map((key) => pointOf(pivot.columns, key, measure.header));
|
|
81
81
|
let values = categories.map((row) => series.map((column) => read(pivot.cell(row.key, column.key))));
|
|
82
|
-
/*
|
|
83
|
-
|
|
82
|
+
/* The margins come from the BASE when the pivot brings them; summing cells is the honest
|
|
83
|
+
way out only when the measure sums. */
|
|
84
84
|
const margin = (cell, inside) => cell !== undefined ? read(cell) : measure.additive ? sum(inside) : null;
|
|
85
85
|
let totals = categories.map((row, at) => margin(pivot.rowTotal?.(row.key), values[at] ?? []));
|
|
86
|
-
/* 0 ·
|
|
86
|
+
/* 0 · The whole time span: the empty periods between the first and the last. */
|
|
87
87
|
const grain = pivot.rows.levels.length === 1 ? pivot.rows.levels[0]?.grain : undefined;
|
|
88
88
|
if (grain !== undefined && reading.fillDates !== false) {
|
|
89
89
|
const dated = categories
|
|
@@ -122,7 +122,7 @@ export function chartFromPivot(pivot, reading = {}) {
|
|
|
122
122
|
totals = filled.map((one) => one.total);
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
/* 1 ·
|
|
125
|
+
/* 1 · The series that do not fit in the palette. */
|
|
126
126
|
let hiddenSeries = 0;
|
|
127
127
|
const seriesTotals = series.map((column, at) => margin(pivot.columnTotal?.(column.key), values.map((row) => row[at] ?? null)));
|
|
128
128
|
const seriesCut = keep(seriesTotals, reading.maxSeries ?? SERIES_COLORS, measure.additive);
|
|
@@ -149,7 +149,7 @@ export function chartFromPivot(pivot, reading = {}) {
|
|
|
149
149
|
values = values.map((row) => kept.map((at) => row[at] ?? null));
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
/* 2 ·
|
|
152
|
+
/* 2 · The categories that do not fit (a pie). */
|
|
153
153
|
let hiddenCategories = 0;
|
|
154
154
|
let restCategory = null;
|
|
155
155
|
if (reading.maxCategories !== undefined) {
|
|
@@ -175,7 +175,7 @@ export function chartFromPivot(pivot, reading = {}) {
|
|
|
175
175
|
totals = cut.kept.map((at) => totals[at] ?? null);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
/* 3 ·
|
|
178
|
+
/* 3 · The axis order. The gathered tail always goes last: it is not one more category. */
|
|
179
179
|
if (reading.order !== undefined) {
|
|
180
180
|
const at = categories.map((_, index) => index).sort(byTotal(totals, reading.order));
|
|
181
181
|
categories = at.map((index) => categories[index]);
|
|
@@ -187,7 +187,7 @@ export function chartFromPivot(pivot, reading = {}) {
|
|
|
187
187
|
values = [...values, restCategory.values];
|
|
188
188
|
totals = [...totals, restCategory.total];
|
|
189
189
|
}
|
|
190
|
-
/* 4 ·
|
|
190
|
+
/* 4 · Cumulative: a hole carries over what was running, it does not cut it. */
|
|
191
191
|
if (reading.cumulative === true && measure.additive) {
|
|
192
192
|
const running = series.map(() => null);
|
|
193
193
|
values = values.map((row) => row.map((value, s) => {
|
|
@@ -215,9 +215,9 @@ export function chartFromPivot(pivot, reading = {}) {
|
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
217
|
/**
|
|
218
|
-
*
|
|
219
|
-
* («otros»)
|
|
220
|
-
*
|
|
218
|
+
* Sorts the AXIS of an already built chart by what each category gives. The gathered tail
|
|
219
|
+
* («otros») stays last. It is the same as `order` in `chartFromPivot`, for a chart
|
|
220
|
+
* that was built another way —a comparison, a dictionary—.
|
|
221
221
|
*/
|
|
222
222
|
export function orderChart(data, order) {
|
|
223
223
|
if (order === undefined)
|
|
@@ -238,16 +238,16 @@ export function orderChart(data, order) {
|
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
241
|
-
*
|
|
241
|
+
* THE PREVIOUS PERIOD beside the current one — Odoo's «comparar con».
|
|
242
242
|
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
243
|
+
* Each chart is built on its own (`chartFromPivot` over each period's records)
|
|
244
|
+
* and this joins them into two series: the current and the previous, which is drawn quiet. What is
|
|
245
|
+
* compared is what each whole category gives.
|
|
246
246
|
*
|
|
247
|
-
* `by`
|
|
248
|
-
*
|
|
249
|
-
* «2025-09»
|
|
250
|
-
*
|
|
247
|
+
* `by` says how they are matched: by KEY when the axis is a thing —La Paz with La Paz— and
|
|
248
|
+
* by POSITION when it is time —the first month with the first month—, because «2026-09» and
|
|
249
|
+
* «2025-09» are different keys and what is compared is «the same moment of the period».
|
|
250
|
+
* A category of the previous that is not in the current is not drawn: the axis is today's.
|
|
251
251
|
*/
|
|
252
252
|
export function chartCompare(current, previous, labels, by = "key") {
|
|
253
253
|
const whole = (data, at) => data.series.length === 1 ? (data.values[at]?.[0] ?? null) : (data.totals[at] ?? null);
|
|
@@ -271,8 +271,8 @@ export function chartCompare(current, previous, labels, by = "key") {
|
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
/**
|
|
274
|
-
*
|
|
275
|
-
*
|
|
274
|
+
* A DICTIONARY as a chart: `{ "La Paz": 120, "Oruro": 40 }`, or its pairs. It is what
|
|
275
|
+
* a summary endpoint returns, and there is no need to build a pivot for it.
|
|
276
276
|
*/
|
|
277
277
|
export function chartFromRecord(entries, measure) {
|
|
278
278
|
const pairs = Array.isArray(entries)
|