derive-dashboards 0.3.0 → 0.5.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/README.md +6 -3
- package/dist/cli/check.mjs +36 -1
- package/dist/cli/doctor.mjs +2 -2
- package/dist/core/document/display-entries.mjs +48 -0
- package/dist/core/document/display.d.mts +15 -3
- package/dist/core/document/display.mjs +35 -11
- package/dist/core/engine/filter.mjs +4 -2
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +2 -0
- package/dist/core/error/codes.mjs +2 -0
- package/dist/core/index.d.mts +4 -3
- package/dist/core/index.mjs +8 -7
- package/dist/core/model/catalog/check.mjs +11 -5
- package/dist/core/model/member.mjs +6 -1
- package/dist/core/model/validate/members.mjs +31 -1
- package/dist/core/oracle/visibility.mjs +3 -1
- package/dist/core/query/drill/line.mjs +2 -2
- package/dist/core/query/to-wire.d.mts +7 -0
- package/dist/core/query/to-wire.mjs +18 -7
- package/dist/core/result/additive.d.mts +9 -0
- package/dist/core/result/additive.mjs +59 -0
- package/dist/core/result/columns.mjs +8 -2
- package/dist/core/result/types.d.mts +12 -0
- package/dist/core/schema/answer-parts.mjs +2 -1
- package/dist/core/schema/answers.d.mts +6 -0
- package/dist/core/types/api.d.mts +1 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/handler.mjs +10 -2
- package/dist/index.mjs +1 -1
- package/dist/llms.txt +1 -1
- package/dist/react/History.mjs +1 -1
- package/dist/react/Tile.mjs +18 -10
- package/dist/react/builder/FilterEditor.mjs +2 -7
- package/dist/react/builder/Preview.mjs +1 -1
- package/dist/react/columns.mjs +15 -0
- package/dist/react/context.d.mts +7 -0
- package/dist/react/context.mjs +3 -0
- package/dist/react/digits.mjs +46 -0
- package/dist/react/drill/Bars.mjs +2 -1
- package/dist/react/drill/Controls.mjs +2 -1
- package/dist/react/drill/Header.mjs +2 -1
- package/dist/react/drill/Items.mjs +6 -1
- package/dist/react/drill/Notes.mjs +2 -1
- package/dist/react/drill/item-parts.mjs +2 -1
- package/dist/react/english.mjs +4 -0
- package/dist/react/export/ExportButton.mjs +23 -0
- package/dist/react/export/csv.d.mts +9 -0
- package/dist/react/export/csv.mjs +42 -0
- package/dist/react/export/download.d.mts +5 -0
- package/dist/react/export/download.mjs +61 -0
- package/dist/react/format-time.d.mts +15 -0
- package/dist/react/format-time.mjs +71 -0
- package/dist/react/format.d.mts +6 -10
- package/dist/react/format.mjs +55 -87
- package/dist/react/index.d.mts +10 -4
- package/dist/react/index.mjs +10 -4
- package/dist/react/messages.d.mts +8 -0
- package/dist/react/renderers/entries.mjs +15 -0
- package/dist/react/renderers/exact.d.mts +6 -0
- package/dist/react/renderers/exact.mjs +68 -0
- package/dist/react/renderers/index.d.mts +5 -5
- package/dist/react/renderers/index.mjs +72 -83
- package/dist/react/renderers/list.mjs +5 -17
- package/dist/react/renderers/table-cells.mjs +130 -0
- package/dist/react/renderers/table-fit.mjs +52 -0
- package/dist/react/renderers/table-head.mjs +47 -0
- package/dist/react/renderers/table-measure.mjs +49 -0
- package/dist/react/renderers/table-row.mjs +61 -0
- package/dist/react/renderers/table-scale.mjs +70 -0
- package/dist/react/renderers/table-sort.mjs +99 -0
- package/dist/react/renderers/table.d.mts +3 -0
- package/dist/react/renderers/table.mjs +121 -0
- package/dist/react/series-points.d.mts +18 -0
- package/dist/react/series-points.mjs +19 -0
- package/dist/react/series.d.mts +7 -10
- package/dist/react/series.mjs +7 -10
- package/dist/react/theme-unlayered.css +3144 -0
- package/dist/react/theme-unlayered.css.d.ts +1 -0
- package/dist/react/theme.css +379 -8
- package/dist/recharts/axes.mjs +13 -10
- package/dist/recharts/axis.mjs +25 -1
- package/dist/recharts/bar.d.mts +2 -1
- package/dist/recharts/bar.mjs +29 -6
- package/dist/recharts/parts.mjs +1 -1
- package/dist/recharts/table.mjs +10 -8
- package/dist/skills/derive-dashboards/SKILL.md +13 -1
- package/package.json +42 -4
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { isNumeric, isValue } from "../columns.mjs";
|
|
2
|
+
import { compareExact, digitsOf } from "./exact.mjs";
|
|
3
|
+
import { isSummary } from "./table-scale.mjs";
|
|
4
|
+
import { isMark } from "derive-dashboards/core";
|
|
5
|
+
// src/renderers/table-sort.ts
|
|
6
|
+
/**
|
|
7
|
+
* Whether a table's rows can be sorted: every row that folds dimensions comes after every row
|
|
8
|
+
* that does not. A table with a subtotal between its groups keeps the order it was given, since
|
|
9
|
+
* sorting would part a subtotal from its rows.
|
|
10
|
+
*/
|
|
11
|
+
function sortable(rows) {
|
|
12
|
+
const first = rows.findIndex((cells) => isSummary(cells));
|
|
13
|
+
return first === -1 || rows.slice(first).every((cells) => isSummary(cells));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The sort after a click on a column's header: values largest first and words A to Z, then the
|
|
17
|
+
* other way round, then the answer's own order again.
|
|
18
|
+
*/
|
|
19
|
+
function nextSort(sort, column) {
|
|
20
|
+
const first = isValue(column) ? "descending" : "ascending";
|
|
21
|
+
if (sort?.id !== column.id) return {
|
|
22
|
+
id: column.id,
|
|
23
|
+
way: first
|
|
24
|
+
};
|
|
25
|
+
if (sort.way !== first) return void 0;
|
|
26
|
+
return {
|
|
27
|
+
id: column.id,
|
|
28
|
+
way: first === "ascending" ? "descending" : "ascending"
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A number's cell as a float, for a first comparison: past what a float holds it is infinite,
|
|
33
|
+
* and a cell that is no number (a text that is none, a fold) is not a number here either.
|
|
34
|
+
*/
|
|
35
|
+
const floatOf = (cell) => {
|
|
36
|
+
if (typeof cell === "number") return cell;
|
|
37
|
+
if (typeof cell === "string") return cell.trim() === "" ? NaN : Number(cell);
|
|
38
|
+
return cell !== null && typeof cell === "object" && "v" in cell ? Number(cell.v) : NaN;
|
|
39
|
+
};
|
|
40
|
+
/** A cell as words to sort by: text as it is, yes after no, an exact value by its digits. */
|
|
41
|
+
function wordsOf(cell) {
|
|
42
|
+
if (typeof cell === "string") return cell;
|
|
43
|
+
if (typeof cell === "number" || typeof cell === "boolean") return String(cell);
|
|
44
|
+
return cell === null || isMark(cell) ? "" : cell.v;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Numbers by size. Each cell is read as a float once, before the sort. Two that differ as
|
|
48
|
+
* floats stand as their floats do, since a float never puts a larger decimal below a smaller
|
|
49
|
+
* one; two a float cannot tell apart are told apart by their digits, an exact amount's own
|
|
50
|
+
* and a float's as it is written.
|
|
51
|
+
*/
|
|
52
|
+
function byNumber(cells, floats) {
|
|
53
|
+
return (a, b) => {
|
|
54
|
+
const [p, q] = [floats[a] ?? 0, floats[b] ?? 0];
|
|
55
|
+
if (p !== q) return p < q ? -1 : 1;
|
|
56
|
+
if (typeof cells[a] === "number" && typeof cells[b] === "number") return 0;
|
|
57
|
+
const [x, y] = [digitsOf(cells[a]), digitsOf(cells[b])];
|
|
58
|
+
return x !== void 0 && y !== void 0 ? compareExact(x, y) : 0;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* How the rows stand in a column of words, smaller first, from the column's cell of each row
|
|
63
|
+
* by its place: a time by its text, which is written to sort as its instant does, and
|
|
64
|
+
* anything else as words in the reader's language.
|
|
65
|
+
*/
|
|
66
|
+
function byWords(column, cells, locale) {
|
|
67
|
+
const words = cells.map((cell) => wordsOf(cell));
|
|
68
|
+
if (column.type === "time") return (a, b) => words[a] === words[b] ? 0 : (words[a] ?? "") < (words[b] ?? "") ? -1 : 1;
|
|
69
|
+
const collator = new Intl.Collator(locale, {
|
|
70
|
+
numeric: true,
|
|
71
|
+
sensitivity: "base"
|
|
72
|
+
});
|
|
73
|
+
return (a, b) => collator.compare(words[a] ?? "", words[b] ?? "");
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The rows in a viewer's order, each named by its place in the answer: those that fold
|
|
77
|
+
* dimensions where they were, the rest by the column, a row with no value there last whichever
|
|
78
|
+
* way. Rows that stand alike keep the answer's order. With no sort, or a table that cannot be
|
|
79
|
+
* sorted, the answer's own order. A place names one row, so two rows that read alike stay two.
|
|
80
|
+
*/
|
|
81
|
+
function orderOf(rows, columns, how) {
|
|
82
|
+
const all = rows.map((_, place) => place);
|
|
83
|
+
const at = columns.findIndex((column) => column.id === how.sort?.id);
|
|
84
|
+
const column = columns[at];
|
|
85
|
+
if (how.sort === void 0 || column === void 0 || !sortable(rows)) return all;
|
|
86
|
+
const cells = rows.map((row) => row[at] ?? null);
|
|
87
|
+
const floats = isNumeric(column) ? cells.map((cell) => floatOf(cell)) : void 0;
|
|
88
|
+
const compare = floats === void 0 ? byWords(column, cells, how.locale) : byNumber(cells, floats);
|
|
89
|
+
const valued = (place) => cells[place] !== null && !(floats !== void 0 && Number.isNaN(floats[place]));
|
|
90
|
+
const turn = how.sort.way === "ascending" ? 1 : -1;
|
|
91
|
+
const folds = all.filter((place) => isSummary(rows[place] ?? []));
|
|
92
|
+
const plain = all.filter((place) => !isSummary(rows[place] ?? []));
|
|
93
|
+
return [
|
|
94
|
+
...plain.filter((place) => valued(place)).toSorted((a, b) => turn * compare(a, b)),
|
|
95
|
+
...plain.filter((place) => !valued(place)),
|
|
96
|
+
...folds
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
export { nextSort, orderOf, sortable };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { nameCut, useFit } from "./table-fit.mjs";
|
|
2
|
+
import { Head } from "./table-head.mjs";
|
|
3
|
+
import { drawnOf, measuredOf } from "./table-measure.mjs";
|
|
4
|
+
import { Row } from "./table-row.mjs";
|
|
5
|
+
import { isSummary, isTotal } from "./table-scale.mjs";
|
|
6
|
+
import { orderOf, sortable } from "./table-sort.mjs";
|
|
7
|
+
import { useMemo, useState } from "react";
|
|
8
|
+
import { displayOf } from "derive-dashboards/core";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
// src/renderers/table.tsx
|
|
11
|
+
/** Under a long table that draws its first rows only: the button that draws more. Nothing under a table drawn whole. */
|
|
12
|
+
function More({ hidden, of, onMore, tile }) {
|
|
13
|
+
if (hidden <= 0) return null;
|
|
14
|
+
const written = (count) => count.toLocaleString(tile.locale);
|
|
15
|
+
return /* @__PURE__ */ jsx("button", {
|
|
16
|
+
type: "button",
|
|
17
|
+
className: "dd-table-more",
|
|
18
|
+
onClick: onMore,
|
|
19
|
+
children: tile.messages.showMoreRows(written(Math.min(hidden, 500)), written(of))
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The rows a table draws, in a viewer's order, and what its value columns are measured against:
|
|
24
|
+
* each worked out once for an answer, a sort and the rows drawn, not on every draw. A long
|
|
25
|
+
* table draws its first rows, and more with each press of its button.
|
|
26
|
+
*/
|
|
27
|
+
function useRows({ answer, widget, locale, messages }, sort) {
|
|
28
|
+
const { columns, rows } = answer;
|
|
29
|
+
const [limit, setLimit] = useState(500);
|
|
30
|
+
const [seen, setSeen] = useState(answer);
|
|
31
|
+
if (seen !== answer) {
|
|
32
|
+
setSeen(answer);
|
|
33
|
+
setLimit(500);
|
|
34
|
+
}
|
|
35
|
+
const order = useMemo(() => orderOf(rows, columns, {
|
|
36
|
+
sort,
|
|
37
|
+
locale
|
|
38
|
+
}), [
|
|
39
|
+
rows,
|
|
40
|
+
columns,
|
|
41
|
+
sort,
|
|
42
|
+
locale
|
|
43
|
+
]);
|
|
44
|
+
const drawn = useMemo(() => drawnOf(order, rows, limit), [
|
|
45
|
+
order,
|
|
46
|
+
rows,
|
|
47
|
+
limit
|
|
48
|
+
]);
|
|
49
|
+
const written = drawn.length < rows.length ? drawn : void 0;
|
|
50
|
+
const measured = useMemo(() => measuredOf({
|
|
51
|
+
answer,
|
|
52
|
+
widget,
|
|
53
|
+
locale,
|
|
54
|
+
messages,
|
|
55
|
+
drawn: written
|
|
56
|
+
}), [
|
|
57
|
+
answer,
|
|
58
|
+
widget,
|
|
59
|
+
locale,
|
|
60
|
+
messages,
|
|
61
|
+
written
|
|
62
|
+
]);
|
|
63
|
+
const drawMore = () => {
|
|
64
|
+
setLimit((now) => now + 500);
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
measured,
|
|
68
|
+
drawn,
|
|
69
|
+
drawMore,
|
|
70
|
+
plain: useMemo(() => rows.filter((cells) => !isSummary(cells)).length, [rows]),
|
|
71
|
+
hidden: order.length - drawn.length
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** Every row and column: the groups, then Other and the total under them. */
|
|
75
|
+
function TableTile(props) {
|
|
76
|
+
const { columns, rows } = props.answer;
|
|
77
|
+
const [sort, setSort] = useState();
|
|
78
|
+
const [table, fit] = useFit(props.answer);
|
|
79
|
+
const cards = fit === "cards";
|
|
80
|
+
const { measured, drawn, drawMore, plain, hidden } = useRows(props, sort);
|
|
81
|
+
const onMore = () => {
|
|
82
|
+
if (hidden <= 500) table.current?.focus();
|
|
83
|
+
drawMore();
|
|
84
|
+
};
|
|
85
|
+
const compact = displayOf("table", props.widget.display).compact === true;
|
|
86
|
+
const onSort = sortable(rows) ? setSort : void 0;
|
|
87
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("table", {
|
|
88
|
+
ref: table,
|
|
89
|
+
className: "dd-table",
|
|
90
|
+
"data-density": compact ? "compact" : void 0,
|
|
91
|
+
"data-layout": fit === "columns" ? void 0 : fit,
|
|
92
|
+
role: cards ? "table" : void 0,
|
|
93
|
+
tabIndex: -1,
|
|
94
|
+
onPointerOver: nameCut,
|
|
95
|
+
children: [/* @__PURE__ */ jsx(Head, {
|
|
96
|
+
columns,
|
|
97
|
+
sort,
|
|
98
|
+
onSort,
|
|
99
|
+
cards,
|
|
100
|
+
messages: props.messages
|
|
101
|
+
}), /* @__PURE__ */ jsx("tbody", {
|
|
102
|
+
role: cards ? "rowgroup" : void 0,
|
|
103
|
+
children: drawn.map((place, i) => /* @__PURE__ */ jsx(Row, {
|
|
104
|
+
cells: rows[place] ?? [],
|
|
105
|
+
columns,
|
|
106
|
+
format: props,
|
|
107
|
+
measured,
|
|
108
|
+
place,
|
|
109
|
+
cards,
|
|
110
|
+
ruled: isTotal(rows[drawn[i + 1] ?? -1] ?? []),
|
|
111
|
+
drill: props.drill
|
|
112
|
+
}, place))
|
|
113
|
+
})]
|
|
114
|
+
}), /* @__PURE__ */ jsx(More, {
|
|
115
|
+
hidden,
|
|
116
|
+
of: plain,
|
|
117
|
+
onMore,
|
|
118
|
+
tile: props
|
|
119
|
+
})] });
|
|
120
|
+
}
|
|
121
|
+
export { TableTile };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CellFormat } from "./messages.mjs";
|
|
2
|
+
import { Drawn, Point, Series } from "./series.mjs";
|
|
3
|
+
import { ResultCell, TileAnswer } from "derive-dashboards/core";
|
|
4
|
+
/**
|
|
5
|
+
* The answer's row behind a point (or its place) of a series, for `drill.open(row,
|
|
6
|
+
* series.column.id)`; undefined for a point no row stands behind.
|
|
7
|
+
*/
|
|
8
|
+
export declare const rowAt: (drawn: Drawn, point: number | Point, seriesKey: string) => number | undefined;
|
|
9
|
+
/** The answer's own cell behind a point of a series; none when no row stands behind it. */
|
|
10
|
+
export declare function pointCell(answer: Pick<TileAnswer, "columns" | "rows">, drawn: Drawn, at: {
|
|
11
|
+
point: number | Point;
|
|
12
|
+
series: Series;
|
|
13
|
+
}): ResultCell | undefined;
|
|
14
|
+
/** The answer's own cell behind a point of a series, as its column writes it; none with no row. */
|
|
15
|
+
export declare function pointText(answer: Pick<TileAnswer, "columns" | "rows">, drawn: Drawn, at: {
|
|
16
|
+
point: number | Point;
|
|
17
|
+
series: Series;
|
|
18
|
+
}, format?: CellFormat): string | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { formatCell } from "./format.mjs";
|
|
2
|
+
// src/series-points.ts
|
|
3
|
+
/**
|
|
4
|
+
* The answer's row behind a point (or its place) of a series, for `drill.open(row,
|
|
5
|
+
* series.column.id)`; undefined for a point no row stands behind.
|
|
6
|
+
*/
|
|
7
|
+
const rowAt = (drawn, point, seriesKey) => drawn.rowAt(point, seriesKey);
|
|
8
|
+
/** The answer's own cell behind a point of a series; none when no row stands behind it. */
|
|
9
|
+
function pointCell(answer, drawn, at) {
|
|
10
|
+
const row = drawn.rowAt(at.point, at.series.key);
|
|
11
|
+
const column = answer.columns.indexOf(at.series.column);
|
|
12
|
+
return row === void 0 ? void 0 : answer.rows[row]?.[column];
|
|
13
|
+
}
|
|
14
|
+
/** The answer's own cell behind a point of a series, as its column writes it; none with no row. */
|
|
15
|
+
function pointText(answer, drawn, at, format = {}) {
|
|
16
|
+
const cell = pointCell(answer, drawn, at);
|
|
17
|
+
return cell === void 0 ? void 0 : formatCell(cell, at.series.column, format);
|
|
18
|
+
}
|
|
19
|
+
export { pointCell, pointText, rowAt };
|
package/dist/react/series.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CellFormat } from "./messages.mjs";
|
|
2
2
|
import { SeriesSlots } from "./series-slots.mjs";
|
|
3
|
-
import { ResultColumn, TileAnswer, TimeBucket } from "derive-dashboards/core";
|
|
3
|
+
import { ResultCell, ResultColumn, TileAnswer, TimeBucket } from "derive-dashboards/core";
|
|
4
4
|
/** One point of a chart: its x label, its place (`#`, never an entry id) and a number per series key. */
|
|
5
5
|
export type Point = {
|
|
6
6
|
x: string;
|
|
@@ -44,20 +44,17 @@ export type Drawn = {
|
|
|
44
44
|
split: boolean;
|
|
45
45
|
notDrawn: ResultColumn[];
|
|
46
46
|
/**
|
|
47
|
-
* When the x axis is time: each point's bucket as instants, in the points' order,
|
|
48
|
-
*
|
|
49
|
-
* time on; the points' `x` is only the bucket's name.
|
|
47
|
+
* When the x axis is time: each point's bucket as instants, in the points' order, `partial`
|
|
48
|
+
* on one not whole (the week still running). A chart draws time on these; `x` only names it.
|
|
50
49
|
*/
|
|
51
50
|
buckets?: readonly (TimeBucket | undefined)[];
|
|
51
|
+
/** Whether a point stands for the values a limit folded together: its x is Other. */
|
|
52
|
+
isOther: (point: number) => boolean;
|
|
53
|
+
/** A point's raw x cell, as the answer has it; null for a point with none. What a point is of, however it reads. */
|
|
54
|
+
xAt: (point: number) => ResultCell;
|
|
52
55
|
rowAt: (point: number | Point, seriesKey: string) => number | undefined;
|
|
53
56
|
};
|
|
54
57
|
type Answer = Pick<TileAnswer, "columns" | "rows" | "time">;
|
|
55
|
-
/**
|
|
56
|
-
* The row of the answer behind a point of any chart kit's series, by the point's place (or the
|
|
57
|
-
* point) and the series key; undefined for a point no row stands behind. Pass it to
|
|
58
|
-
* `drill.open(row, series.column.id)` to open what is behind the point.
|
|
59
|
-
*/
|
|
60
|
-
export declare const rowAt: (drawn: Drawn, point: number | Point, seriesKey: string) => number | undefined;
|
|
61
58
|
/**
|
|
62
59
|
* Whether the answer's last time bucket is still running: the range ends before the bucket
|
|
63
60
|
* does, as this week does on its Monday. Its value is not final, so a chart marks it rather
|
package/dist/react/series.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { isValue } from "./columns.mjs";
|
|
1
2
|
import { formatCell, plotValue } from "./format.mjs";
|
|
2
3
|
import { ENGLISH } from "./english.mjs";
|
|
3
4
|
import { seriesSlots } from "./series-slots.mjs";
|
|
4
5
|
import { isMark, roleOf } from "derive-dashboards/core";
|
|
5
6
|
// src/series.ts
|
|
6
|
-
const isValue = (c) => roleOf(c) === "measure" || roleOf(c) === "calc";
|
|
7
7
|
/** The series key a dimension's Other draws as. */
|
|
8
8
|
const OTHER_KEY = "other";
|
|
9
|
-
|
|
9
|
+
/** Whether a cell is the given mark: Other, or the total row's All. */
|
|
10
|
+
const isMarked = (cell, mark) => isMark(cell) && cell.mark === mark;
|
|
10
11
|
/** What a value is read against: two columns share an axis only when this is equal. */
|
|
11
12
|
const scaleOf = (c) => JSON.stringify([
|
|
12
13
|
c.unit ?? null,
|
|
@@ -34,6 +35,8 @@ function toSeries(answer, format = {}, slots) {
|
|
|
34
35
|
return {
|
|
35
36
|
...drawn,
|
|
36
37
|
...bucketsOf(answer, shape.keys, xs),
|
|
38
|
+
isOther: (point) => isMarked(xs[point] ?? null, "other"),
|
|
39
|
+
xAt: (point) => xs[point] ?? null,
|
|
37
40
|
rowAt: (point, key) => {
|
|
38
41
|
const index = typeof point === "number" ? point : drawn.points.indexOf(point);
|
|
39
42
|
return at.get(`${String(index)}|${key}`) ?? at.get(`${String(index)}|*`);
|
|
@@ -74,7 +77,7 @@ function drawSeries(answer, shape) {
|
|
|
74
77
|
const rows = answer.rows.map((row, index) => ({
|
|
75
78
|
row,
|
|
76
79
|
index
|
|
77
|
-
})).filter(({ row }) => !row.some((cell) =>
|
|
80
|
+
})).filter(({ row }) => !row.some((cell) => isMarked(cell, "all")));
|
|
78
81
|
return shape.keys.length < 2 ? plainSeries(rows, values, shape) : splitSeries(rows, values, shape);
|
|
79
82
|
}
|
|
80
83
|
/** The x label of a row, from its first key. */
|
|
@@ -173,12 +176,6 @@ function splitKey(cells) {
|
|
|
173
176
|
return `s${JSON.stringify(cells.length === 1 ? only ?? null : cells)}`;
|
|
174
177
|
}
|
|
175
178
|
/**
|
|
176
|
-
* The row of the answer behind a point of any chart kit's series, by the point's place (or the
|
|
177
|
-
* point) and the series key; undefined for a point no row stands behind. Pass it to
|
|
178
|
-
* `drill.open(row, series.column.id)` to open what is behind the point.
|
|
179
|
-
*/
|
|
180
|
-
const rowAt = (drawn, point, seriesKey) => drawn.rowAt(point, seriesKey);
|
|
181
|
-
/**
|
|
182
179
|
* Whether the answer's last time bucket is still running: the range ends before the bucket
|
|
183
180
|
* does, as this week does on its Monday. Its value is not final, so a chart marks it rather
|
|
184
181
|
* than draw it as a fall. The server says so (`answer.time`), by the engine's own calendar.
|
|
@@ -189,4 +186,4 @@ function lastBucketOpen(answer) {
|
|
|
189
186
|
const bucket = answer.time?.buckets.find((b) => b.label === last);
|
|
190
187
|
return bucket?.partial === "end" || bucket?.partial === "both";
|
|
191
188
|
}
|
|
192
|
-
export { OTHER_KEY, lastBucketOpen,
|
|
189
|
+
export { OTHER_KEY, lastBucketOpen, toSeries };
|