@fasl-work/caos-app-shell 0.7.1 → 0.7.2
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/chart.d.ts +2 -2
- package/dist/chart.js +28 -3
- package/gate/inpage.mjs +4 -0
- package/gate/run.mjs +3 -0
- package/package.json +1 -1
package/dist/chart.d.ts
CHANGED
|
@@ -50,8 +50,8 @@ interface UPlotChartProps {
|
|
|
50
50
|
* its longest tick label, so no tick is cut; the cursor value is written into a readout row under the plot instead of
|
|
51
51
|
* uPlot's legend, which a sized host clips (known shell defect 3). A chart of two or more series keys every series
|
|
52
52
|
* under the plot, always (its colour, a dashed or a dotted swatch, its label): at rest the readout names none of them
|
|
53
|
-
* (known shell defect 17).
|
|
54
|
-
* the gate.
|
|
53
|
+
* (known shell defect 17). An axis with fixed decimals ticks only where its labels differ (`tickSteps`). The host
|
|
54
|
+
* declares `data-series`, `data-axis-titles`, `data-ticks-cut`, `data-ticks-repeat` and `data-drawn` for the gate.
|
|
55
55
|
*/
|
|
56
56
|
declare function UPlotChart({ x, y, series, marks, height, onCursor }: UPlotChartProps): react.JSX.Element;
|
|
57
57
|
|
package/dist/chart.js
CHANGED
|
@@ -5,6 +5,18 @@ import uPlot from 'uplot';
|
|
|
5
5
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
var ROTATION = ["--color-accent", "--color-magenta", "--color-accent-2", "--color-good", "--color-warn", "--color-bad"];
|
|
8
|
+
var STEPS = [];
|
|
9
|
+
for (let e = -16; e <= 16; e++) for (const m of [1, 2, 2.5, 5]) STEPS.push(Number((m * 10 ** e).toPrecision(3)));
|
|
10
|
+
function tickSteps(fmt) {
|
|
11
|
+
if (!fmt || fmt.decimals === void 0) return void 0;
|
|
12
|
+
const res = 10 ** -fmt.decimals / (fmt.percent ? 100 : 1);
|
|
13
|
+
return STEPS.filter((s) => s >= res * (1 - 1e-9) && Math.abs(s / res - Math.round(s / res)) < 1e-6);
|
|
14
|
+
}
|
|
15
|
+
function repeatedLabels(labels) {
|
|
16
|
+
let n = 0;
|
|
17
|
+
for (let i = 1; i < labels.length; i++) if (labels[i] && labels[i] === labels[i - 1]) n++;
|
|
18
|
+
return n;
|
|
19
|
+
}
|
|
8
20
|
function UPlotChart({ x, y, series, marks, height = 280, onCursor }) {
|
|
9
21
|
const lang = useShellLang();
|
|
10
22
|
const theme = useThemeStore((s) => s.theme);
|
|
@@ -21,6 +33,7 @@ function UPlotChart({ x, y, series, marks, height = 280, onCursor }) {
|
|
|
21
33
|
const width = box.width;
|
|
22
34
|
const h = fill ? box.height : height;
|
|
23
35
|
const uRef = useRef(null);
|
|
36
|
+
const hostRef = useRef(null);
|
|
24
37
|
const [cursor, setCursor] = useState(null);
|
|
25
38
|
const onCursorRef = useRef(onCursor);
|
|
26
39
|
onCursorRef.current = onCursor;
|
|
@@ -45,7 +58,15 @@ function UPlotChart({ x, y, series, marks, height = 280, onCursor }) {
|
|
|
45
58
|
const fg = resolveToken("--color-fg-subtle", "#888");
|
|
46
59
|
const grid = resolveToken("--color-border", "#ccc");
|
|
47
60
|
const font = `11px ${resolveToken("--font-sans", "sans-serif")}`;
|
|
48
|
-
const
|
|
61
|
+
const repeats = { x: 0, y: 0 };
|
|
62
|
+
const tick = (fmt, axis) => (_u, vals) => {
|
|
63
|
+
const labels = vals.map((v) => v === null || v === void 0 ? "" : formatNumber(v, lang, fmt ?? { digits: 4 }));
|
|
64
|
+
repeats[axis] = repeatedLabels(labels);
|
|
65
|
+
hostRef.current?.setAttribute("data-ticks-repeat", String(repeats.x + repeats.y));
|
|
66
|
+
return labels;
|
|
67
|
+
};
|
|
68
|
+
const xSteps = x.time ? void 0 : tickSteps(x.format);
|
|
69
|
+
const ySteps = y.log ? void 0 : tickSteps(y.format);
|
|
49
70
|
const opts = {
|
|
50
71
|
width,
|
|
51
72
|
height: h,
|
|
@@ -59,7 +80,8 @@ function UPlotChart({ x, y, series, marks, height = 280, onCursor }) {
|
|
|
59
80
|
font,
|
|
60
81
|
label: xUnit ? `${xLabel} (${xUnit})` : xLabel,
|
|
61
82
|
labelFont: font,
|
|
62
|
-
values: x.time ? void 0 : tick(x.format)
|
|
83
|
+
values: x.time ? void 0 : tick(x.format, "x"),
|
|
84
|
+
...xSteps ? { incrs: xSteps } : {}
|
|
63
85
|
},
|
|
64
86
|
{
|
|
65
87
|
stroke: fg,
|
|
@@ -68,7 +90,8 @@ function UPlotChart({ x, y, series, marks, height = 280, onCursor }) {
|
|
|
68
90
|
font,
|
|
69
91
|
label: yUnit ? `${yLabel} (${yUnit})` : yLabel,
|
|
70
92
|
labelFont: font,
|
|
71
|
-
values: tick(y.format),
|
|
93
|
+
values: tick(y.format, "y"),
|
|
94
|
+
...ySteps ? { incrs: ySteps } : {},
|
|
72
95
|
size: (u, values) => {
|
|
73
96
|
if (!values || values.length === 0) return 48;
|
|
74
97
|
u.ctx.font = font;
|
|
@@ -133,10 +156,12 @@ function UPlotChart({ x, y, series, marks, height = 280, onCursor }) {
|
|
|
133
156
|
return /* @__PURE__ */ jsxs(
|
|
134
157
|
"div",
|
|
135
158
|
{
|
|
159
|
+
ref: hostRef,
|
|
136
160
|
className: fill ? "caos-chart fill" : "caos-chart",
|
|
137
161
|
"data-series": series.length,
|
|
138
162
|
"data-axis-titles": `${xLabel}|${yLabel}`,
|
|
139
163
|
"data-ticks-cut": "0",
|
|
164
|
+
"data-ticks-repeat": "0",
|
|
140
165
|
"data-drawn": width > 0 && h > 0 ? "1" : "0",
|
|
141
166
|
children: [
|
|
142
167
|
/* @__PURE__ */ jsx("div", { ref: setPlot, className: "caos-chart-plot" }),
|
package/gate/inpage.mjs
CHANGED
|
@@ -276,6 +276,10 @@ export function installLib() {
|
|
|
276
276
|
pageText: pageBody ? (pageBody.innerText || '').trim().length : 0,
|
|
277
277
|
referenceLists: [...document.querySelectorAll('.reference-list')].filter(visible).length,
|
|
278
278
|
uncaptioned: [...document.querySelectorAll('.equation')].filter((e) => visible(e) && !e.querySelector('.equation-caption')).length,
|
|
279
|
+
// charts whose axis gives a tick the label of the tick before it (UPlotChart declares data-ticks-repeat)
|
|
280
|
+
repeatedTicks: [...document.querySelectorAll('[data-ticks-repeat]')]
|
|
281
|
+
.filter((el) => visible(el) && Number(el.getAttribute('data-ticks-repeat')) > 0)
|
|
282
|
+
.map((el) => ({ label: describe(el.closest('[data-plot]') || el), n: Number(el.getAttribute('data-ticks-repeat')) })),
|
|
279
283
|
sectionsWithoutRefs: [...document.querySelectorAll('[data-no-refs-reason="missing"]')].filter(visible).length,
|
|
280
284
|
};
|
|
281
285
|
};
|
package/gate/run.mjs
CHANGED
|
@@ -345,6 +345,9 @@ export async function runGate(o) {
|
|
|
345
345
|
if (f.offCentre !== null && f.offCentre > 2) fail('ADR-0017.1', where, `the prose page is off-centre by ${f.offCentre.toFixed(1)}px`);
|
|
346
346
|
if (f.referenceLists) fail('ADR-0017.4', where, `${f.referenceLists} bibliography dump(s); references belong at the end of each section`);
|
|
347
347
|
if (f.uncaptioned) fail('ADR-0017.2', where, `${f.uncaptioned} equation(s) without a caption`);
|
|
348
|
+
for (const r of f.repeatedTicks ?? []) {
|
|
349
|
+
fail('G6', where, `${r.label}: ${r.n} axis tick label(s) repeat the label before them (give the axis fixed decimals)`);
|
|
350
|
+
}
|
|
348
351
|
if (f.sectionsWithoutRefs) fail('ADR-0017.4', where, `${f.sectionsWithoutRefs} section(s) end without references or a stated reason`);
|
|
349
352
|
if (s.first && !s.isWorkbench && f.pageText < opt.textFloor) fail('G4', where, `the page body holds ${f.pageText} characters of text (floor ${opt.textFloor}); the route rendered without its content`);
|
|
350
353
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fasl-work/caos-app-shell",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Shared web-app shell, workbench primitives, content primitives, design system and measured gate for the CAOS / Faena public apps (ADR-0016, ADR-0017, ADR-0071).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Felipe Santibáñez-Leal",
|