@fasl-work/caos-app-shell 0.16.0 → 0.18.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/chart.css +5 -0
- package/dist/chart.d.ts +107 -9
- package/dist/chart.js +311 -31
- package/dist/{chunk-YECZXGVG.js → chunk-DBCMAL2G.js} +73 -1
- package/dist/index.d.ts +7 -40
- package/dist/index.js +67 -94
- package/dist/{tokens-BTOzar-U.d.ts → text-DyQ1A8oo.d.ts} +39 -1
- package/gate/inpage.mjs +67 -1
- package/gate/run.mjs +15 -2
- package/package.json +3 -4
- package/reserved-classes.json +10 -2
- package/styles.css +25 -4
package/chart.css
CHANGED
|
@@ -22,3 +22,8 @@
|
|
|
22
22
|
.caos-chart.fill[data-parity] > .caos-chart-plot { display: flex; align-items: center; justify-content: center; }
|
|
23
23
|
.caos-chart[data-pick] .u-over { cursor: pointer; }
|
|
24
24
|
.caos-chart .u-cursor-x, .caos-chart .u-cursor-y { border-color: var(--color-fg-faint) !important; }
|
|
25
|
+
/* The key that solos a series (`solo`, 0.18.0): each entry is a button. At rest it reads as the plain key; the soloed one is
|
|
26
|
+
set off by a border and bold text, in the text colour, never by colour alone. */
|
|
27
|
+
.caos-chart-key-button { display: inline-flex; align-items: center; gap: 0.3rem; min-width: 0; margin: 0; padding: 0.15rem 0.45rem; border: 1px solid transparent; border-radius: 0.4rem; background: none; color: inherit; font: inherit; line-height: inherit; text-align: start; cursor: pointer; }
|
|
28
|
+
.caos-chart-key-button:hover { border-color: var(--color-border); }
|
|
29
|
+
.caos-chart-key-button[aria-pressed="true"] { border-color: var(--color-fg-subtle); color: var(--color-fg); font-weight: 600; }
|
package/dist/chart.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import uPlot from 'uplot';
|
|
3
|
-
import { F as FormatOptions, S as ShellColorToken } from './
|
|
4
|
-
|
|
3
|
+
import { F as FormatOptions, S as ShellColorToken } from './text-DyQ1A8oo.js';
|
|
4
|
+
export { r as referenceLineName } from './text-DyQ1A8oo.js';
|
|
5
|
+
import { B as BiText, L as Lang } from './text-BlY47nIt.js';
|
|
5
6
|
import 'zustand';
|
|
6
7
|
|
|
7
8
|
interface ChartSeries {
|
|
9
|
+
/** What identifies the series to the solo key (0.18.0): the solo follows the series with this id when the list of series
|
|
10
|
+
* changes (one dropped, one added, a label changed), not its position. Without an id the English label is the key. Unique
|
|
11
|
+
* within the chart; with two series of one key the first is taken. */
|
|
12
|
+
id?: string;
|
|
8
13
|
label: BiText;
|
|
9
14
|
/** One value per x; `null` leaves a gap. */
|
|
10
15
|
values: (number | null)[];
|
|
@@ -16,6 +21,25 @@ interface ChartSeries {
|
|
|
16
21
|
mode?: 'line' | 'points';
|
|
17
22
|
/** The marker diameter of a `points` series, in CSS pixels (9 by default): a larger one rings the selected case. */
|
|
18
23
|
size?: number;
|
|
24
|
+
/** A `points` series on x values of its own (measured cases over a modelled curve that has other sizes): one x per
|
|
25
|
+
* value. It is drawn over the plot on its own x, outside the curve's data, so it takes no part in the cursor, the
|
|
26
|
+
* pick or the readout, and the axes take its extent in. */
|
|
27
|
+
x?: number[];
|
|
28
|
+
/** A dot at each value of a `line` series (CAOS_Fragmenta drew them under 40 values: `dots={x.length < 40}`). Off by
|
|
29
|
+
* default; no dot is drawn at a `null`. */
|
|
30
|
+
dots?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** A named x tick: the x value it sits at and the text the axis reads there (and the readout, for an x on it). */
|
|
33
|
+
interface ChartTick {
|
|
34
|
+
value: number;
|
|
35
|
+
label: BiText;
|
|
36
|
+
}
|
|
37
|
+
/** What a reference line may be dragged over: the range it stays inside, and the step it snaps to (a hundredth of the
|
|
38
|
+
* range when not given; on a log axis the step is a factor). */
|
|
39
|
+
interface YMarkDrag {
|
|
40
|
+
min: number;
|
|
41
|
+
max: number;
|
|
42
|
+
step?: number;
|
|
19
43
|
}
|
|
20
44
|
interface ChartAxis {
|
|
21
45
|
label: BiText;
|
|
@@ -35,6 +59,17 @@ interface UPlotChartProps {
|
|
|
35
59
|
values: number[];
|
|
36
60
|
time?: boolean;
|
|
37
61
|
log?: boolean;
|
|
62
|
+
/** Named ticks (0.18.0): the axis ticks exactly at these values, no other, each labelled with its text in the page
|
|
63
|
+
* language (a categorical axis: protocols, blast ids). The readout names an x that sits on one by its label. A tick
|
|
64
|
+
* outside the range is not drawn; an empty list leaves uPlot its own ticks. A value listed twice keeps its first label.
|
|
65
|
+
* Labels must be different from each other, adjacent or not (the gate fails any repeated label, G6). An x is on a tick
|
|
66
|
+
* when it is within 1e-9 of the x span of it. Ignored on a time axis. */
|
|
67
|
+
ticks?: ChartTick[];
|
|
68
|
+
/** The x scale spans at least this range (0.18.0), as `y.range` fixes the y scale: widen it past the data so an end tick's
|
|
69
|
+
* label is not cut by the plot edge. The data and the overlays still widen it further. On a log axis a range that reaches 0
|
|
70
|
+
* or below is ignored (the overlays still widen the scale); on a parity chart it is ignored, the chart's own shared range
|
|
71
|
+
* rules. */
|
|
72
|
+
range?: [number, number];
|
|
38
73
|
};
|
|
39
74
|
y: ChartAxis & {
|
|
40
75
|
log?: boolean;
|
|
@@ -47,12 +82,17 @@ interface UPlotChartProps {
|
|
|
47
82
|
label: BiText;
|
|
48
83
|
}[];
|
|
49
84
|
/** Horizontal reference lines at y values, labelled at their right end (a null model's constant prediction, a
|
|
50
|
-
* target, a limit). */
|
|
85
|
+
* target, a limit). A line without a `label` is drawn with no label box and nothing reserved for one (a zero line). */
|
|
51
86
|
yMarks?: {
|
|
52
87
|
y: number;
|
|
53
|
-
label
|
|
88
|
+
label?: BiText;
|
|
54
89
|
tone?: YMarkTone;
|
|
90
|
+
drag?: YMarkDrag;
|
|
55
91
|
}[];
|
|
92
|
+
/** Called with the index in `yMarks` and the new y of a draggable reference line (`drag`) every time the reader moves
|
|
93
|
+
* it, by the pointer or the keyboard (a slider on the line: arrows, Page keys, Home and End); the caller sets the new
|
|
94
|
+
* y in `yMarks`. */
|
|
95
|
+
onYMarkChange?: (index: number, y: number) => void;
|
|
56
96
|
/** Height in pixels, or `fill` to take the container's height (inside `PlotCard fill`); the width is always the
|
|
57
97
|
* container's. */
|
|
58
98
|
height?: number | 'fill';
|
|
@@ -72,7 +112,40 @@ interface UPlotChartProps {
|
|
|
72
112
|
readout?: (index: number) => string;
|
|
73
113
|
/** The readout at rest; by default "Hover the chart to read the values". */
|
|
74
114
|
hint?: BiText;
|
|
115
|
+
/** The key solos a series (0.18.0): each entry is a button (`aria-pressed`, Tab, click, Enter or Space) that dims every
|
|
116
|
+
* other series (alpha 0.12, 1 px) and leaves the chosen one as drawn; pressing it again releases it, pressing another
|
|
117
|
+
* moves the solo. The chart is redrawn, not rebuilt. A chart of one series shows the key too. Off by default. */
|
|
118
|
+
solo?: boolean;
|
|
75
119
|
}
|
|
120
|
+
/** The alpha a series takes when another one is soloed (0.18.0; what CAOS_Fragmenta's key did). */
|
|
121
|
+
declare const SOLO_DIM_ALPHA = 0.12;
|
|
122
|
+
/** How a series is drawn while `solo` (the index in `series` of the soloed one, or null) is held: as given, or dimmed to
|
|
123
|
+
* `SOLO_DIM_ALPHA` and 1 px when another is soloed. Dimmed, never hidden, so the reader keeps the context. */
|
|
124
|
+
declare function soloStyle(solo: number | null, i: number, width: number): {
|
|
125
|
+
alpha: number;
|
|
126
|
+
width: number;
|
|
127
|
+
};
|
|
128
|
+
/** The values a named x axis ticks at inside [min, max]: ascending, each once; on a log axis only the ones above 0. A value
|
|
129
|
+
* that is not a number is dropped. */
|
|
130
|
+
declare function tickSplits(ticks: readonly ChartTick[], min: number, max: number, log?: boolean): number[];
|
|
131
|
+
/** The label of the named tick at an x, in the page language; null when no tick sits there. An x is on a tick when it is
|
|
132
|
+
* within 1e-9 of `span` (the x span, as `tickSplits` takes the range) of its value, so 0.1 + 0.2 is on a tick at 0.3; without
|
|
133
|
+
* a span only an equal x is. A value listed twice keeps its first label. */
|
|
134
|
+
declare function tickLabelAt(ticks: readonly ChartTick[] | undefined, x: number, lang: Lang, span?: number): string | null;
|
|
135
|
+
/** How many of the labels of named ticks repeat another's, adjacent or not (the gate's check of numeric ticks counts only
|
|
136
|
+
* neighbours, and on a categorical axis order means nothing), and which ones; an empty label is no label. */
|
|
137
|
+
declare function namedRepeats(labels: readonly string[]): {
|
|
138
|
+
n: number;
|
|
139
|
+
names: string[];
|
|
140
|
+
};
|
|
141
|
+
/** What a series is known by to the solo key: its id, else its English label. */
|
|
142
|
+
declare function soloKey(s: ChartSeries): string;
|
|
143
|
+
/** The x scale of a chart whose x range is fixed, or whose overlays reach past the curve: the data's extent widened by the
|
|
144
|
+
* given range and by the overlays' x; null when none is given (uPlot's own range), and on a log axis when the data would reach 0.
|
|
145
|
+
* One x alone gets a unit either side, a decade on a log axis. `xs` is sorted ascending. */
|
|
146
|
+
declare function xScaleRange(xs: readonly number[], ext: {
|
|
147
|
+
x: [number, number];
|
|
148
|
+
} | null, range: readonly [number, number] | undefined, log: boolean): [number, number] | null;
|
|
76
149
|
/** The colour and dash of a series: its own, or the rotation's; when the rotation comes round (a seventh series
|
|
77
150
|
* repeats the first colour) the repeat is dashed, so two series never look the same (CAOS_Fragmenta drew this for
|
|
78
151
|
* itself until 0.9.0). */
|
|
@@ -110,6 +183,29 @@ declare const LOG_TABLE_FLOOR = 1e-22;
|
|
|
110
183
|
declare function logDecades(min: number, max: number, most?: number): number[];
|
|
111
184
|
/** The smallest positive value among columns of values and the lower end of a fixed range; Infinity if none. */
|
|
112
185
|
declare function smallestPositive(columns: readonly (readonly (number | null)[])[], range?: readonly [number, number] | null): number;
|
|
186
|
+
/**
|
|
187
|
+
* The ticks of a log x axis that get a label: the powers of ten only (null for every other tick, which formatTicks leaves
|
|
188
|
+
* blank). A range with no power of ten in it keeps its ticks, so the axis is never left without a label.
|
|
189
|
+
*/
|
|
190
|
+
declare function decadeOnly(ticks: readonly (number | null)[]): (number | null)[];
|
|
191
|
+
/** The side of the square box of a parity plot: the smaller of the box's width and the height asked for (the box's
|
|
192
|
+
* height when the chart fills it). */
|
|
193
|
+
declare function parityBox(boxWidth: number, boxHeight: number, height: number, fill: boolean): number;
|
|
194
|
+
/** A dragged value kept inside the range of its line and snapped to its step; a value that is not a number falls to the
|
|
195
|
+
* lower end. */
|
|
196
|
+
declare function clampMark(y: number, drag: YMarkDrag): number;
|
|
197
|
+
/**
|
|
198
|
+
* The value a key sets on a draggable line, or null for a key it does not handle: the arrows one step, Page Up and Down
|
|
199
|
+
* ten, Home and End the ends of the range. A step is a hundredth of the range, or `drag.step`; on a log axis it is a factor
|
|
200
|
+
* (a hundredth of the range in decades) and `drag.step` is not used.
|
|
201
|
+
*/
|
|
202
|
+
declare function nudgeMark(y: number, key: string, drag: YMarkDrag, log?: boolean): number | null;
|
|
203
|
+
/** The x and y extent of the series that bring an x of their own, finite points only (on a log x axis, `positiveX`,
|
|
204
|
+
* only the points with x above 0); null when there are none. */
|
|
205
|
+
declare function overlayExtent(series: readonly ChartSeries[], positiveX?: boolean): {
|
|
206
|
+
x: [number, number];
|
|
207
|
+
y: [number, number];
|
|
208
|
+
} | null;
|
|
113
209
|
/** How many tick labels repeat the label before them (empty labels apart); the gate fails a chart with any (G6). */
|
|
114
210
|
declare function repeatedLabels(labels: readonly (string | null | undefined)[]): number;
|
|
115
211
|
/**
|
|
@@ -130,12 +226,12 @@ declare function drawMarks(u: uPlot, marks: {
|
|
|
130
226
|
/**
|
|
131
227
|
* The horizontal reference lines of a chart and their labels: a dashed line across the plot, its label at the right
|
|
132
228
|
* end above the line (below it when the line runs along the top), inside the plot, haloed; a label that would overlap
|
|
133
|
-
* the one placed before it moves left of it. A line outside the y range is not drawn. A mark's `color` (the tone's) draws
|
|
229
|
+
* the one placed before it moves left of it. A line outside the y range is not drawn; a line without a label is drawn alone. A mark's `color` (the tone's) draws
|
|
134
230
|
* its line and its label; without one `style.color` does.
|
|
135
231
|
*/
|
|
136
232
|
declare function drawYMarks(u: uPlot, marks: {
|
|
137
233
|
y: number;
|
|
138
|
-
label
|
|
234
|
+
label?: string;
|
|
139
235
|
color?: string;
|
|
140
236
|
}[], style: {
|
|
141
237
|
color: string;
|
|
@@ -156,8 +252,10 @@ declare function nearestPoint(xs: readonly number[], ys: readonly (readonly (num
|
|
|
156
252
|
* uPlot's legend, which a sized host clips (known shell defect 3). A chart of two or more series keys every series
|
|
157
253
|
* under the plot, always (its colour, a dashed or a dotted swatch, its label): at rest the readout names none of them
|
|
158
254
|
* (known shell defect 17). An axis with fixed decimals ticks only where its labels differ (`tickSteps`). The host
|
|
159
|
-
* declares `data-series`, `data-axis-titles`, `data-ticks-cut`, `data-ticks-repeat` and `data-drawn` for the gate.
|
|
255
|
+
* declares `data-series`, `data-axis-titles`, `data-ticks-cut`, `data-ticks-repeat` and `data-drawn` for the gate. Since
|
|
256
|
+
* 0.18.0: named x ticks (`x.ticks`, declared in `data-x-tick-labels`), an x range (`x.range`), a key that solos a series
|
|
257
|
+
* (`solo`, declared in `data-solo`), dots on a line (`ChartSeries.dots`) and reference lines without a label.
|
|
160
258
|
*/
|
|
161
|
-
declare function UPlotChart({ x, y, series, marks, yMarks, height, onCursor, onPick, parity, readout, hint }: UPlotChartProps): react.JSX.Element;
|
|
259
|
+
declare function UPlotChart({ x, y, series, marks, yMarks, onYMarkChange, height, onCursor, onPick, parity, readout, hint, solo }: UPlotChartProps): react.JSX.Element;
|
|
162
260
|
|
|
163
|
-
export { type ChartAxis, type ChartSeries, LOG_TABLE_FLOOR, UPlotChart, type UPlotChartProps, YMARK_TONE_TOKENS, type YMarkTone, drawMarks, drawYMarks, logDecades, nearestPoint, parityRange, rangeWithLevels, repeatedLabels, seriesStyle, smallestPositive, sortOrder, tickSteps };
|
|
261
|
+
export { type ChartAxis, type ChartSeries, type ChartTick, LOG_TABLE_FLOOR, SOLO_DIM_ALPHA, UPlotChart, type UPlotChartProps, YMARK_TONE_TOKENS, type YMarkDrag, type YMarkTone, clampMark, decadeOnly, drawMarks, drawYMarks, logDecades, namedRepeats, nearestPoint, nudgeMark, overlayExtent, parityBox, parityRange, rangeWithLevels, repeatedLabels, seriesStyle, smallestPositive, soloKey, soloStyle, sortOrder, tickLabelAt, tickSplits, tickSteps, xScaleRange };
|