react-cheminfo 0.15.0 → 0.17.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 +96 -0
- package/lib/core.d.ts +1 -0
- package/lib/core.d.ts.map +1 -1
- package/lib/core.js +1 -0
- package/lib/core.js.map +1 -1
- package/lib/credits/core/credits.d.ts +17 -0
- package/lib/credits/core/credits.d.ts.map +1 -1
- package/lib/credits/core/credits.js +20 -0
- package/lib/credits/core/credits.js.map +1 -1
- package/lib/ecosystem/core/sites.d.ts.map +1 -1
- package/lib/ecosystem/core/sites.js +40 -0
- package/lib/ecosystem/core/sites.js.map +1 -1
- package/lib/ecosystem/core/types.d.ts +1 -1
- package/lib/ecosystem/core/types.d.ts.map +1 -1
- package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
- package/lib/ecosystem/ui/glyphs.js +11 -0
- package/lib/ecosystem/ui/glyphs.js.map +1 -1
- package/lib/parallel/core/index.d.ts +29 -0
- package/lib/parallel/core/index.d.ts.map +1 -0
- package/lib/parallel/core/index.js +22 -0
- package/lib/parallel/core/index.js.map +1 -0
- package/lib/parallel/core/parallelAxes.d.ts +103 -0
- package/lib/parallel/core/parallelAxes.d.ts.map +1 -0
- package/lib/parallel/core/parallelAxes.js +146 -0
- package/lib/parallel/core/parallelAxes.js.map +1 -0
- package/lib/parallel/core/parallelBrush.d.ts +100 -0
- package/lib/parallel/core/parallelBrush.d.ts.map +1 -0
- package/lib/parallel/core/parallelBrush.js +149 -0
- package/lib/parallel/core/parallelBrush.js.map +1 -0
- package/lib/parallel/core/parallelExtent.d.ts +28 -0
- package/lib/parallel/core/parallelExtent.d.ts.map +1 -0
- package/lib/parallel/core/parallelExtent.js +47 -0
- package/lib/parallel/core/parallelExtent.js.map +1 -0
- package/lib/parallel/core/parallelFilter.d.ts +49 -0
- package/lib/parallel/core/parallelFilter.d.ts.map +1 -0
- package/lib/parallel/core/parallelFilter.js +107 -0
- package/lib/parallel/core/parallelFilter.js.map +1 -0
- package/lib/parallel/core/parallelHit.d.ts +47 -0
- package/lib/parallel/core/parallelHit.d.ts.map +1 -0
- package/lib/parallel/core/parallelHit.js +81 -0
- package/lib/parallel/core/parallelHit.js.map +1 -0
- package/lib/parallel/core/parallelOrder.d.ts +36 -0
- package/lib/parallel/core/parallelOrder.d.ts.map +1 -0
- package/lib/parallel/core/parallelOrder.js +65 -0
- package/lib/parallel/core/parallelOrder.js.map +1 -0
- package/lib/parallel/core/parallelPaint.d.ts +108 -0
- package/lib/parallel/core/parallelPaint.d.ts.map +1 -0
- package/lib/parallel/core/parallelPaint.js +169 -0
- package/lib/parallel/core/parallelPaint.js.map +1 -0
- package/lib/parallel/core/parallelPalette.d.ts +40 -0
- package/lib/parallel/core/parallelPalette.d.ts.map +1 -0
- package/lib/parallel/core/parallelPalette.js +81 -0
- package/lib/parallel/core/parallelPalette.js.map +1 -0
- package/lib/parallel/core/parallelSelection.d.ts +43 -0
- package/lib/parallel/core/parallelSelection.d.ts.map +1 -0
- package/lib/parallel/core/parallelSelection.js +87 -0
- package/lib/parallel/core/parallelSelection.js.map +1 -0
- package/lib/parallel/core/parallelTicks.d.ts +34 -0
- package/lib/parallel/core/parallelTicks.d.ts.map +1 -0
- package/lib/parallel/core/parallelTicks.js +119 -0
- package/lib/parallel/core/parallelTicks.js.map +1 -0
- package/lib/parallel/core/parallelTypes.d.ts +140 -0
- package/lib/parallel/core/parallelTypes.d.ts.map +1 -0
- package/lib/parallel/core/parallelTypes.js +29 -0
- package/lib/parallel/core/parallelTypes.js.map +1 -0
- package/lib/parallel/ui/ParallelAxesLayer.d.ts +28 -0
- package/lib/parallel/ui/ParallelAxesLayer.d.ts.map +1 -0
- package/lib/parallel/ui/ParallelAxesLayer.js +29 -0
- package/lib/parallel/ui/ParallelAxesLayer.js.map +1 -0
- package/lib/parallel/ui/ParallelCoordinates.d.ts +21 -0
- package/lib/parallel/ui/ParallelCoordinates.d.ts.map +1 -0
- package/lib/parallel/ui/ParallelCoordinates.js +114 -0
- package/lib/parallel/ui/ParallelCoordinates.js.map +1 -0
- package/lib/parallel/ui/ParallelLabels.d.ts +32 -0
- package/lib/parallel/ui/ParallelLabels.d.ts.map +1 -0
- package/lib/parallel/ui/ParallelLabels.js +37 -0
- package/lib/parallel/ui/ParallelLabels.js.map +1 -0
- package/lib/parallel/ui/ParallelTooltip.d.ts +26 -0
- package/lib/parallel/ui/ParallelTooltip.d.ts.map +1 -0
- package/lib/parallel/ui/ParallelTooltip.js +30 -0
- package/lib/parallel/ui/ParallelTooltip.js.map +1 -0
- package/lib/parallel/ui/index.d.ts +29 -0
- package/lib/parallel/ui/index.d.ts.map +1 -0
- package/lib/parallel/ui/index.js +20 -0
- package/lib/parallel/ui/index.js.map +1 -0
- package/lib/parallel/ui/parallelCoordinatesProps.d.ts +203 -0
- package/lib/parallel/ui/parallelCoordinatesProps.d.ts.map +1 -0
- package/lib/parallel/ui/parallelCoordinatesProps.js +11 -0
- package/lib/parallel/ui/parallelCoordinatesProps.js.map +1 -0
- package/lib/parallel/ui/parallelGestureModel.d.ts +83 -0
- package/lib/parallel/ui/parallelGestureModel.d.ts.map +1 -0
- package/lib/parallel/ui/parallelGestureModel.js +110 -0
- package/lib/parallel/ui/parallelGestureModel.js.map +1 -0
- package/lib/parallel/ui/parallelInk.d.ts +76 -0
- package/lib/parallel/ui/parallelInk.d.ts.map +1 -0
- package/lib/parallel/ui/parallelInk.js +113 -0
- package/lib/parallel/ui/parallelInk.js.map +1 -0
- package/lib/parallel/ui/parallelPlotModel.d.ts +55 -0
- package/lib/parallel/ui/parallelPlotModel.d.ts.map +1 -0
- package/lib/parallel/ui/parallelPlotModel.js +113 -0
- package/lib/parallel/ui/parallelPlotModel.js.map +1 -0
- package/lib/parallel/ui/parallelStyles.d.ts +106 -0
- package/lib/parallel/ui/parallelStyles.d.ts.map +1 -0
- package/lib/parallel/ui/parallelStyles.js +153 -0
- package/lib/parallel/ui/parallelStyles.js.map +1 -0
- package/lib/parallel/ui/useParallelAxisDrag.d.ts +60 -0
- package/lib/parallel/ui/useParallelAxisDrag.d.ts.map +1 -0
- package/lib/parallel/ui/useParallelAxisDrag.js +96 -0
- package/lib/parallel/ui/useParallelAxisDrag.js.map +1 -0
- package/lib/parallel/ui/useParallelCanvas.d.ts +49 -0
- package/lib/parallel/ui/useParallelCanvas.d.ts.map +1 -0
- package/lib/parallel/ui/useParallelCanvas.js +58 -0
- package/lib/parallel/ui/useParallelCanvas.js.map +1 -0
- package/lib/parallel/ui/useParallelGesture.d.ts +72 -0
- package/lib/parallel/ui/useParallelGesture.d.ts.map +1 -0
- package/lib/parallel/ui/useParallelGesture.js +164 -0
- package/lib/parallel/ui/useParallelGesture.js.map +1 -0
- package/lib/structure/ui/useToolbarFloor.d.ts.map +1 -1
- package/lib/structure/ui/useToolbarFloor.js +29 -22
- package/lib/structure/ui/useToolbarFloor.js.map +1 -1
- package/lib/ui.d.ts +1 -0
- package/lib/ui.d.ts.map +1 -1
- package/lib/ui.js +1 -0
- package/lib/ui.js.map +1 -1
- package/package.json +1 -1
- package/src/core.ts +1 -0
- package/src/credits/core/credits.ts +21 -0
- package/src/ecosystem/core/sites.ts +40 -0
- package/src/ecosystem/core/types.ts +4 -1
- package/src/ecosystem/ui/glyphs.tsx +46 -0
- package/src/parallel/core/index.ts +96 -0
- package/src/parallel/core/parallelAxes.ts +207 -0
- package/src/parallel/core/parallelBrush.ts +211 -0
- package/src/parallel/core/parallelExtent.ts +56 -0
- package/src/parallel/core/parallelFilter.ts +131 -0
- package/src/parallel/core/parallelHit.ts +106 -0
- package/src/parallel/core/parallelOrder.ts +73 -0
- package/src/parallel/core/parallelPaint.ts +242 -0
- package/src/parallel/core/parallelPalette.ts +93 -0
- package/src/parallel/core/parallelSelection.ts +99 -0
- package/src/parallel/core/parallelTicks.ts +168 -0
- package/src/parallel/core/parallelTypes.ts +159 -0
- package/src/parallel/ui/ParallelAxesLayer.tsx +129 -0
- package/src/parallel/ui/ParallelCoordinates.tsx +252 -0
- package/src/parallel/ui/ParallelLabels.tsx +77 -0
- package/src/parallel/ui/ParallelTooltip.tsx +55 -0
- package/src/parallel/ui/index.ts +65 -0
- package/src/parallel/ui/parallelCoordinatesProps.ts +217 -0
- package/src/parallel/ui/parallelGestureModel.ts +159 -0
- package/src/parallel/ui/parallelInk.ts +182 -0
- package/src/parallel/ui/parallelPlotModel.ts +130 -0
- package/src/parallel/ui/parallelStyles.ts +188 -0
- package/src/parallel/ui/useParallelAxisDrag.ts +147 -0
- package/src/parallel/ui/useParallelCanvas.ts +104 -0
- package/src/parallel/ui/useParallelGesture.ts +260 -0
- package/src/structure/ui/useToolbarFloor.ts +27 -22
- package/src/ui.ts +1 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colour each line is drawn in, as a step into a sampled ramp.
|
|
3
|
+
*
|
|
4
|
+
* A canvas reassigns `strokeStyle` once per line, and a thousand different
|
|
5
|
+
* colours is a thousand style writes. Quantising the ramp to 121 steps and
|
|
6
|
+
* keeping the rows in the order they came means the style is written about
|
|
7
|
+
* 121 times for the whole figure — while no reader can tell a hundred-and-
|
|
8
|
+
* twenty-first of a ramp apart from its neighbour.
|
|
9
|
+
*/
|
|
10
|
+
import { evenScale, sampleScale } from "../../color/core/interpolate.js";
|
|
11
|
+
import { positionInRange } from "../../color/core/scale.js";
|
|
12
|
+
import { resolveColorScale } from "../../color/core/scaleText.js";
|
|
13
|
+
import { DEFAULT_COLOR_SCALE_ID } from "../../color/core/scales.js";
|
|
14
|
+
import { parallelExtent } from "./parallelExtent.js";
|
|
15
|
+
/** How many steps the ramp is quantised into; there is one more colour than steps. */
|
|
16
|
+
export const PARALLEL_PALETTE_STEPS = 120;
|
|
17
|
+
/**
|
|
18
|
+
* The step a row whose colouring quantity is unknown takes.
|
|
19
|
+
*
|
|
20
|
+
* Past the end of the ramp on purpose: no colour indexes it, so the painter
|
|
21
|
+
* leaves such a row in the neutral ink rather than claiming for it the ink of
|
|
22
|
+
* the smallest value in the set.
|
|
23
|
+
*/
|
|
24
|
+
export const PARALLEL_PALETTE_UNKNOWN = PARALLEL_PALETTE_STEPS + 1;
|
|
25
|
+
/**
|
|
26
|
+
* The ramp, sampled into the steps a line's colour is looked up by.
|
|
27
|
+
* @param scale - The ramp, as the registry hands it over or as a plain list of colours. Defaults to viridis.
|
|
28
|
+
* @returns `PARALLEL_PALETTE_STEPS + 1` colours, from the low end to the high end.
|
|
29
|
+
*/
|
|
30
|
+
export function parallelPalette(scale) {
|
|
31
|
+
return sampleScale(resolveRamp(scale), PARALLEL_PALETTE_STEPS + 1);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Which step of the ramp each row takes.
|
|
35
|
+
*
|
|
36
|
+
* Worked out once per data change rather than per repaint, and held as bytes:
|
|
37
|
+
* a library of ten thousand rows costs ten kilobytes and the painter's inner
|
|
38
|
+
* loop reads an integer instead of placing a value on a ramp.
|
|
39
|
+
* @param color - The quantity the lines are coloured by.
|
|
40
|
+
* @param count - How many rows there are.
|
|
41
|
+
* @returns One step per row, from `0` to {@link PARALLEL_PALETTE_STEPS}, or
|
|
42
|
+
* {@link PARALLEL_PALETTE_UNKNOWN} for a row whose value is not a number.
|
|
43
|
+
*/
|
|
44
|
+
export function parallelColorSteps(color, count) {
|
|
45
|
+
const steps = new Uint8Array(count);
|
|
46
|
+
// A row the column does not reach is as unknown as one holding no number.
|
|
47
|
+
steps.fill(PARALLEL_PALETTE_UNKNOWN);
|
|
48
|
+
const extent = parallelExtent(color.values, count);
|
|
49
|
+
const min = color.min ?? extent.min;
|
|
50
|
+
const max = color.max ?? extent.max;
|
|
51
|
+
const logarithmic = color.logarithmic ?? false;
|
|
52
|
+
const span = max - min;
|
|
53
|
+
const rows = Math.min(count, color.values.length);
|
|
54
|
+
for (let row = 0; row < rows; row++) {
|
|
55
|
+
const value = color.values[row];
|
|
56
|
+
if (!Number.isFinite(value))
|
|
57
|
+
continue;
|
|
58
|
+
steps[row] = logarithmic
|
|
59
|
+
? Math.round(positionInRange(value, min, max, { logarithmic: true }) *
|
|
60
|
+
PARALLEL_PALETTE_STEPS)
|
|
61
|
+
: colorStep(value, min, span);
|
|
62
|
+
}
|
|
63
|
+
return steps;
|
|
64
|
+
}
|
|
65
|
+
function resolveRamp(scale) {
|
|
66
|
+
if (scale === undefined) {
|
|
67
|
+
return resolveColorScale(DEFAULT_COLOR_SCALE_ID).scale;
|
|
68
|
+
}
|
|
69
|
+
return 'stops' in scale ? scale : evenScale(scale);
|
|
70
|
+
}
|
|
71
|
+
function colorStep(value, min, span) {
|
|
72
|
+
if (span <= 0)
|
|
73
|
+
return 0;
|
|
74
|
+
const ratio = (value - min) / span;
|
|
75
|
+
if (Number.isNaN(ratio) || ratio < 0)
|
|
76
|
+
return 0;
|
|
77
|
+
if (ratio > 1)
|
|
78
|
+
return PARALLEL_PALETTE_STEPS;
|
|
79
|
+
return Math.round(ratio * PARALLEL_PALETTE_STEPS);
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=parallelPalette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelPalette.js","sourceRoot":"","sources":["../../../src/parallel/core/parallelPalette.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,sFAAsF;AACtF,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,GAAG,CAAC,CAAC;AAEnE;;;;GAIG;AACH,MAAM,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CAAC,CAAC;IAClC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,WAAW,CAAC,KAAsC;IACzD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,iBAAiB,CAAC,sBAAsB,CAAC,CAAC,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,SAAS,CAAC,KAAa,EAAE,GAAW,EAAE,IAAY;IACzD,IAAI,IAAI,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACxB,MAAM,KAAK,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC;IACnC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IAC/C,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,sBAAsB,CAAC;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,sBAAsB,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an axis keeps, when it keeps more than one interval.
|
|
3
|
+
*
|
|
4
|
+
* The figure reports a list and accepts either a list or a bare interval, so a
|
|
5
|
+
* caller that only ever keeps one is not made to write `[[0, 1]]`. Everything
|
|
6
|
+
* downstream — the filter, the bands, the gesture — reads the list, which is
|
|
7
|
+
* what {@link parallelRangeList} is for: one normalisation, at the edge, and
|
|
8
|
+
* no `Array.isArray` scattered through the painter.
|
|
9
|
+
*
|
|
10
|
+
* Intervals on one axis are held sorted and disjoint. Two that touch are one
|
|
11
|
+
* interval drawn twice, and a reader dragging a band across its neighbour means
|
|
12
|
+
* to widen it rather than to stack two bands nobody can then take hold of.
|
|
13
|
+
*/
|
|
14
|
+
import type { ParallelRange, ParallelSelection } from './parallelTypes.ts';
|
|
15
|
+
/**
|
|
16
|
+
* The intervals one axis keeps, however the caller wrote them.
|
|
17
|
+
* @param selection - One interval, several, or nothing at all.
|
|
18
|
+
* @returns The intervals, in the order given. Read in place — the caller's own
|
|
19
|
+
* array comes back when it gave one.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parallelRangeList(selection: ParallelSelection | undefined): readonly ParallelRange[];
|
|
22
|
+
/**
|
|
23
|
+
* Whether an axis keeps anything at all.
|
|
24
|
+
* @param selection - What that axis keeps.
|
|
25
|
+
* @returns Whether any interval is in force.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parallelHasRange(selection: ParallelSelection | undefined): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The same intervals, sorted low to high and with the overlapping ones joined.
|
|
30
|
+
* @param ranges - The intervals, in any order, each low value first.
|
|
31
|
+
* @returns One list, sorted and disjoint. Intervals that touch at a point are
|
|
32
|
+
* joined too: a reader who dragged one band onto another meant one band.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parallelMergeRanges(ranges: readonly ParallelRange[]): ParallelRange[];
|
|
35
|
+
/**
|
|
36
|
+
* The intervals an axis keeps once one of them is replaced, removed or added.
|
|
37
|
+
* @param ranges - The intervals in force.
|
|
38
|
+
* @param index - Which one is being written, or `-1` to add one.
|
|
39
|
+
* @param range - The interval it becomes, or `null` to take it away.
|
|
40
|
+
* @returns The new list, sorted and disjoint. Never the same array.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parallelWriteRange(ranges: readonly ParallelRange[], index: number, range: ParallelRange | null): ParallelRange[];
|
|
43
|
+
//# sourceMappingURL=parallelSelection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelSelection.d.ts","sourceRoot":"","sources":["../../../src/parallel/core/parallelSelection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAK3E;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,iBAAiB,GAAG,SAAS,GACvC,SAAS,aAAa,EAAE,CAO1B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,iBAAiB,GAAG,SAAS,GACvC,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,aAAa,EAAE,GAC/B,aAAa,EAAE,CAsBjB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,aAAa,GAAG,IAAI,GAC1B,aAAa,EAAE,CAQjB"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an axis keeps, when it keeps more than one interval.
|
|
3
|
+
*
|
|
4
|
+
* The figure reports a list and accepts either a list or a bare interval, so a
|
|
5
|
+
* caller that only ever keeps one is not made to write `[[0, 1]]`. Everything
|
|
6
|
+
* downstream — the filter, the bands, the gesture — reads the list, which is
|
|
7
|
+
* what {@link parallelRangeList} is for: one normalisation, at the edge, and
|
|
8
|
+
* no `Array.isArray` scattered through the painter.
|
|
9
|
+
*
|
|
10
|
+
* Intervals on one axis are held sorted and disjoint. Two that touch are one
|
|
11
|
+
* interval drawn twice, and a reader dragging a band across its neighbour means
|
|
12
|
+
* to widen it rather than to stack two bands nobody can then take hold of.
|
|
13
|
+
*/
|
|
14
|
+
/** Nothing kept, shared so a normalisation never allocates for the common case. */
|
|
15
|
+
const NONE = [];
|
|
16
|
+
/**
|
|
17
|
+
* The intervals one axis keeps, however the caller wrote them.
|
|
18
|
+
* @param selection - One interval, several, or nothing at all.
|
|
19
|
+
* @returns The intervals, in the order given. Read in place — the caller's own
|
|
20
|
+
* array comes back when it gave one.
|
|
21
|
+
*/
|
|
22
|
+
export function parallelRangeList(selection) {
|
|
23
|
+
if (selection === null || selection === undefined)
|
|
24
|
+
return NONE;
|
|
25
|
+
if (selection.length === 0)
|
|
26
|
+
return NONE;
|
|
27
|
+
// A bare interval is two numbers; a list of them holds arrays.
|
|
28
|
+
return typeof selection[0] === 'number'
|
|
29
|
+
? [selection]
|
|
30
|
+
: selection;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Whether an axis keeps anything at all.
|
|
34
|
+
* @param selection - What that axis keeps.
|
|
35
|
+
* @returns Whether any interval is in force.
|
|
36
|
+
*/
|
|
37
|
+
export function parallelHasRange(selection) {
|
|
38
|
+
return parallelRangeList(selection).length > 0;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The same intervals, sorted low to high and with the overlapping ones joined.
|
|
42
|
+
* @param ranges - The intervals, in any order, each low value first.
|
|
43
|
+
* @returns One list, sorted and disjoint. Intervals that touch at a point are
|
|
44
|
+
* joined too: a reader who dragged one band onto another meant one band.
|
|
45
|
+
*/
|
|
46
|
+
export function parallelMergeRanges(ranges) {
|
|
47
|
+
if (ranges.length === 0)
|
|
48
|
+
return [];
|
|
49
|
+
const sorted = ranges
|
|
50
|
+
.map((range) => range[0] <= range[1] ? range : [range[1], range[0]])
|
|
51
|
+
.toSorted((left, right) => left[0] - right[0]);
|
|
52
|
+
const merged = [];
|
|
53
|
+
let low = sorted[0][0];
|
|
54
|
+
let high = sorted[0][1];
|
|
55
|
+
for (let index = 1; index < sorted.length; index++) {
|
|
56
|
+
const range = sorted[index];
|
|
57
|
+
if (range[0] > high) {
|
|
58
|
+
merged.push([low, high]);
|
|
59
|
+
low = range[0];
|
|
60
|
+
high = range[1];
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (range[1] > high)
|
|
64
|
+
high = range[1];
|
|
65
|
+
}
|
|
66
|
+
merged.push([low, high]);
|
|
67
|
+
return merged;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The intervals an axis keeps once one of them is replaced, removed or added.
|
|
71
|
+
* @param ranges - The intervals in force.
|
|
72
|
+
* @param index - Which one is being written, or `-1` to add one.
|
|
73
|
+
* @param range - The interval it becomes, or `null` to take it away.
|
|
74
|
+
* @returns The new list, sorted and disjoint. Never the same array.
|
|
75
|
+
*/
|
|
76
|
+
export function parallelWriteRange(ranges, index, range) {
|
|
77
|
+
const kept = [];
|
|
78
|
+
for (let at = 0; at < ranges.length; at++) {
|
|
79
|
+
if (at === index)
|
|
80
|
+
continue;
|
|
81
|
+
kept.push(ranges[at]);
|
|
82
|
+
}
|
|
83
|
+
if (range !== null)
|
|
84
|
+
kept.push(range);
|
|
85
|
+
return parallelMergeRanges(kept);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=parallelSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelSelection.js","sourceRoot":"","sources":["../../../src/parallel/core/parallelSelection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,mFAAmF;AACnF,MAAM,IAAI,GAA6B,EAAE,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAAwC;IAExC,IAAI,SAAS,KAAK,IAAI,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC/D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACxC,+DAA+D;IAC/D,OAAO,OAAO,SAAS,CAAC,CAAC,CAAC,KAAK,QAAQ;QACrC,CAAC,CAAC,CAAC,SAA0B,CAAC;QAC9B,CAAC,CAAE,SAAsC,CAAC;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAwC;IAExC,OAAO,iBAAiB,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACjD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAgC;IAEhC,IAAI,MAAM,CAAC,MAAM,KAAK,CA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MAAM,UAAU,kBAAkB,CAChC,MAAgC,EAChC,KAAa,EACb,KAA2B;IAE3B,MAAM,IAAI,GAAoB,EAAE,CAAC;IACjC,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC;QAC1C,IAAI,EAAE,KAAK,KAAK;YAAE,SAAS;QAC3B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAkB,CAAC,CAAC;IACzC,CAAC;IACD,IAAI,KAAK,KAAK,IAAI;QAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How one axis is graduated.
|
|
3
|
+
*
|
|
4
|
+
* Five evenly spaced marks across the raw extent, not `chartAxisScale`'s nice
|
|
5
|
+
* ones: nicing moves the ends of the axis, and a figure whose whole job is to
|
|
6
|
+
* compare rows against each other must end exactly where the data does. A
|
|
7
|
+
* caller who wants round numbers asks for them with `nice`, per axis.
|
|
8
|
+
*/
|
|
9
|
+
import type { ParallelAxis, ParallelTick } from './parallelTypes.ts';
|
|
10
|
+
/** How many graduations an axis carries when the caller asks for no number. */
|
|
11
|
+
export declare const PARALLEL_TICK_COUNT = 5;
|
|
12
|
+
/** An axis's ends and the graduations written along it. */
|
|
13
|
+
export interface ParallelGraduation {
|
|
14
|
+
/** The two ends of the axis, low first, after any nicing. */
|
|
15
|
+
domain: readonly [number, number];
|
|
16
|
+
/** The graduations, from the bottom of the axis to the top. */
|
|
17
|
+
ticks: readonly ParallelTick[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The graduations of one axis, and the ends they are spread between.
|
|
21
|
+
*
|
|
22
|
+
* Three ways, in order: the caller's own list wins outright — a coded quantity
|
|
23
|
+
* reading `none`, `low`, `high` is nobody else's to invent; `nice` hands the
|
|
24
|
+
* axis to `chartAxisScale`, which rounds both ends outward to whole steps; and
|
|
25
|
+
* otherwise the extent is divided evenly and a mark whose label repeats the
|
|
26
|
+
* one below it is dropped, so an axis of whole numbers from 0 to 2 reads
|
|
27
|
+
* `0 1 2` rather than writing `1` twice.
|
|
28
|
+
* @param axis - The axis, for its formatting and how many marks it wants.
|
|
29
|
+
* @param min - The value at the bottom of the axis.
|
|
30
|
+
* @param max - The value at its top.
|
|
31
|
+
* @returns The ends and the graduations. See {@link ParallelGraduation}.
|
|
32
|
+
*/
|
|
33
|
+
export declare function parallelTicks(axis: ParallelAxis, min: number, max: number): ParallelGraduation;
|
|
34
|
+
//# sourceMappingURL=parallelTicks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelTicks.d.ts","sourceRoot":"","sources":["../../../src/parallel/core/parallelTicks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAErE,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAQrC,2DAA2D;AAC3D,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,+DAA+D;IAC/D,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;CAChC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,YAAY,EAClB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,kBAAkB,CAWpB"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How one axis is graduated.
|
|
3
|
+
*
|
|
4
|
+
* Five evenly spaced marks across the raw extent, not `chartAxisScale`'s nice
|
|
5
|
+
* ones: nicing moves the ends of the axis, and a figure whose whole job is to
|
|
6
|
+
* compare rows against each other must end exactly where the data does. A
|
|
7
|
+
* caller who wants round numbers asks for them with `nice`, per axis.
|
|
8
|
+
*/
|
|
9
|
+
import { chartAxisScale, chartTickDecimals, chartTickLabel, } from "../../chart/core/chartAxisScale.js";
|
|
10
|
+
import { formatDecimal } from "../../format/core/numbers.js";
|
|
11
|
+
import { roundTo } from "../../format/core/roundTo.js";
|
|
12
|
+
/** How many graduations an axis carries when the caller asks for no number. */
|
|
13
|
+
export const PARALLEL_TICK_COUNT = 5;
|
|
14
|
+
/** The most decimals a graduation is ever written with. */
|
|
15
|
+
const MOST_TICK_DECIMALS = 6;
|
|
16
|
+
/** How far a label may sit from its own value: a tenth of the spacing. */
|
|
17
|
+
const LABEL_TOLERANCE = 10;
|
|
18
|
+
/**
|
|
19
|
+
* The graduations of one axis, and the ends they are spread between.
|
|
20
|
+
*
|
|
21
|
+
* Three ways, in order: the caller's own list wins outright — a coded quantity
|
|
22
|
+
* reading `none`, `low`, `high` is nobody else's to invent; `nice` hands the
|
|
23
|
+
* axis to `chartAxisScale`, which rounds both ends outward to whole steps; and
|
|
24
|
+
* otherwise the extent is divided evenly and a mark whose label repeats the
|
|
25
|
+
* one below it is dropped, so an axis of whole numbers from 0 to 2 reads
|
|
26
|
+
* `0 1 2` rather than writing `1` twice.
|
|
27
|
+
* @param axis - The axis, for its formatting and how many marks it wants.
|
|
28
|
+
* @param min - The value at the bottom of the axis.
|
|
29
|
+
* @param max - The value at its top.
|
|
30
|
+
* @returns The ends and the graduations. See {@link ParallelGraduation}.
|
|
31
|
+
*/
|
|
32
|
+
export function parallelTicks(axis, min, max) {
|
|
33
|
+
const domain = [min, max];
|
|
34
|
+
if (axis.ticks !== undefined)
|
|
35
|
+
return { domain, ticks: axis.ticks };
|
|
36
|
+
const wanted = Math.max(2, Math.trunc(axis.tickCount ?? PARALLEL_TICK_COUNT));
|
|
37
|
+
if (axis.nice === true && axis.scale !== 'log') {
|
|
38
|
+
return nicedGraduation(axis, min, max, wanted);
|
|
39
|
+
}
|
|
40
|
+
const values = evenValues(min, max, wanted, axis.scale === 'log');
|
|
41
|
+
return { domain, ticks: labelled(values, axis.format) };
|
|
42
|
+
}
|
|
43
|
+
function nicedGraduation(axis, min, max, wanted) {
|
|
44
|
+
const scale = chartAxisScale(min, max, { count: wanted, nice: true });
|
|
45
|
+
// Not `scale.labels`: those have a common power of ten lifted out of them,
|
|
46
|
+
// on the understanding that the caller writes it beside the axis name, and
|
|
47
|
+
// this figure writes only the name. Each graduation carries its own value.
|
|
48
|
+
const decimals = chartTickDecimals(scale.step);
|
|
49
|
+
const ticks = [];
|
|
50
|
+
for (const value of scale.values) {
|
|
51
|
+
const label = axis.format === undefined
|
|
52
|
+
? chartTickLabel(value, decimals)
|
|
53
|
+
: axis.format(value);
|
|
54
|
+
if (ticks.at(-1)?.label === label)
|
|
55
|
+
continue;
|
|
56
|
+
ticks.push({ value, label });
|
|
57
|
+
}
|
|
58
|
+
return { domain: scale.domain, ticks };
|
|
59
|
+
}
|
|
60
|
+
function evenValues(min, max, wanted, logarithmic) {
|
|
61
|
+
const values = [];
|
|
62
|
+
const low = logarithmic ? Math.log10(Math.max(min, smallestStep(max))) : min;
|
|
63
|
+
const high = logarithmic ? Math.log10(Math.max(max, smallestStep(max))) : max;
|
|
64
|
+
const span = high - low;
|
|
65
|
+
for (let index = 0; index < wanted; index++) {
|
|
66
|
+
const placed = low + (span * index) / (wanted - 1);
|
|
67
|
+
values.push(logarithmic ? 10 ** placed : placed);
|
|
68
|
+
}
|
|
69
|
+
return values;
|
|
70
|
+
}
|
|
71
|
+
function labelled(values, format) {
|
|
72
|
+
const decimals = format === undefined ? tickDecimals(values) : 0;
|
|
73
|
+
const ticks = [];
|
|
74
|
+
for (const value of values) {
|
|
75
|
+
const label = format === undefined ? formatDecimal(value, decimals) : format(value);
|
|
76
|
+
if (ticks.at(-1)?.label === label)
|
|
77
|
+
continue;
|
|
78
|
+
ticks.push({ value, label });
|
|
79
|
+
}
|
|
80
|
+
return ticks;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* As many decimals as the spacing needs, and one more whenever rounding would
|
|
84
|
+
* move a mark by more than a tenth of that spacing — which is what keeps an
|
|
85
|
+
* axis from 12.3 to 157 reading `12 48 85 121 157` while one from −1.5 to 2.5
|
|
86
|
+
* still reads `−1.5 −0.5 0.5 1.5 2.5` rather than rounding both away.
|
|
87
|
+
* @param values - The graduations, in the axis's own units.
|
|
88
|
+
* @returns How many decimals each of their labels carries.
|
|
89
|
+
*/
|
|
90
|
+
function tickDecimals(values) {
|
|
91
|
+
const step = smallestGap(values);
|
|
92
|
+
const tolerance = step / LABEL_TOLERANCE;
|
|
93
|
+
let decimals = chartTickDecimals(step);
|
|
94
|
+
while (decimals < MOST_TICK_DECIMALS &&
|
|
95
|
+
!faithful(values, decimals, tolerance)) {
|
|
96
|
+
decimals++;
|
|
97
|
+
}
|
|
98
|
+
return decimals;
|
|
99
|
+
}
|
|
100
|
+
function faithful(values, decimals, tolerance) {
|
|
101
|
+
for (const value of values) {
|
|
102
|
+
if (Math.abs(value - roundTo(value, decimals)) > tolerance)
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
function smallestGap(values) {
|
|
108
|
+
let smallest = Number.POSITIVE_INFINITY;
|
|
109
|
+
for (let index = 1; index < values.length; index++) {
|
|
110
|
+
const gap = Math.abs(values[index] - values[index - 1]);
|
|
111
|
+
if (gap > 0 && gap < smallest)
|
|
112
|
+
smallest = gap;
|
|
113
|
+
}
|
|
114
|
+
return Number.isFinite(smallest) ? smallest : 1;
|
|
115
|
+
}
|
|
116
|
+
function smallestStep(max) {
|
|
117
|
+
return max > 0 ? max * 1e-12 : 1;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=parallelTicks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelTicks.js","sourceRoot":"","sources":["../../../src/parallel/core/parallelTicks.ts"],"names":[],"mappings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and the quantity the lines are
|
|
4
|
+
* coloured by.
|
|
5
|
+
*
|
|
6
|
+
* The figure itself is index-based — every axis hands over its column as an
|
|
7
|
+
* `ArrayLike<number>` read in place — so a repaint costs an indexed read per
|
|
8
|
+
* value rather than a call. {@link parallelAxisOf} is the one place a row type
|
|
9
|
+
* is named, and it is run once per data change rather than once per repaint.
|
|
10
|
+
*/
|
|
11
|
+
import type { ColorScale } from '../../color/core/interpolate.ts';
|
|
12
|
+
/** How a value is placed along an axis. */
|
|
13
|
+
export type ParallelAxisScale = 'linear' | 'log';
|
|
14
|
+
/** One labelled graduation a caller writes itself. */
|
|
15
|
+
export interface ParallelTick {
|
|
16
|
+
/** Where it sits, in the axis's own units. */
|
|
17
|
+
value: number;
|
|
18
|
+
/** What is written beside it. */
|
|
19
|
+
label: string;
|
|
20
|
+
}
|
|
21
|
+
/** One vertical axis of a parallel-coordinates figure, and the column it draws. */
|
|
22
|
+
export interface ParallelAxis {
|
|
23
|
+
/**
|
|
24
|
+
* A stable key, which is how a brushed range is reported and how a caller
|
|
25
|
+
* names the axis the colour is read from. Never an index: axes are added and
|
|
26
|
+
* reordered, and a range keyed on a position outlives the axis it belonged
|
|
27
|
+
* to.
|
|
28
|
+
*/
|
|
29
|
+
id: string;
|
|
30
|
+
/** What it is called, written over the axis. */
|
|
31
|
+
label: string;
|
|
32
|
+
/**
|
|
33
|
+
* Every row's value, in the figure's row order. Read in place — nothing is
|
|
34
|
+
* copied — so a `Float64Array` is the cheapest thing to pass.
|
|
35
|
+
*/
|
|
36
|
+
values: ArrayLike<number>;
|
|
37
|
+
/**
|
|
38
|
+
* The two ends of the axis, low first. Left out, they are the column's own
|
|
39
|
+
* smallest and largest finite value, and a column with no spread at all is
|
|
40
|
+
* opened by half a unit on each side so that it still draws.
|
|
41
|
+
* @default undefined — the column's own range
|
|
42
|
+
*/
|
|
43
|
+
domain?: readonly [number, number];
|
|
44
|
+
/**
|
|
45
|
+
* How values are placed between the ends. `log` needs a domain whose low end
|
|
46
|
+
* is above zero; a value at or below zero is pinned to the low end.
|
|
47
|
+
* @default 'linear'
|
|
48
|
+
*/
|
|
49
|
+
scale?: ParallelAxisScale;
|
|
50
|
+
/**
|
|
51
|
+
* How a tick is written. Left out, the ticks carry as many decimals as the
|
|
52
|
+
* spacing needs.
|
|
53
|
+
* @default undefined
|
|
54
|
+
*/
|
|
55
|
+
format?: (value: number) => string;
|
|
56
|
+
/**
|
|
57
|
+
* The graduations, written out by the caller — what a coded quantity needs,
|
|
58
|
+
* where `0`, `1`, `2` should read `none`, `low`, `high`.
|
|
59
|
+
* @default undefined — the figure graduates the axis itself
|
|
60
|
+
*/
|
|
61
|
+
ticks?: readonly ParallelTick[];
|
|
62
|
+
/**
|
|
63
|
+
* Roughly how many graduations to aim for, when the figure picks them.
|
|
64
|
+
* @default 5
|
|
65
|
+
*/
|
|
66
|
+
tickCount?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the ends are rounded outward to whole tick steps. Off, so the axis
|
|
69
|
+
* ends exactly on the data — a reader comparing two molecules on a drug
|
|
70
|
+
* score must see the best one touch the top of its axis, not float below a
|
|
71
|
+
* round number nothing reached.
|
|
72
|
+
* @default false
|
|
73
|
+
*/
|
|
74
|
+
nice?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* The unit written after the axis name, e.g. `g/mol`.
|
|
77
|
+
* @default '' — nothing is written
|
|
78
|
+
*/
|
|
79
|
+
unit?: string;
|
|
80
|
+
}
|
|
81
|
+
/** An interval kept on one axis, in that axis's own units, low first. */
|
|
82
|
+
export type ParallelRange = readonly [number, number];
|
|
83
|
+
/**
|
|
84
|
+
* What one axis keeps: nothing, one interval, or several disjoint ones.
|
|
85
|
+
*
|
|
86
|
+
* A reader comparing molecules wants the light ones *and* the heavy ones, with
|
|
87
|
+
* nothing in between, which one interval cannot say. Several are read as a
|
|
88
|
+
* union — a row is kept when it falls in any of them — while the axes are
|
|
89
|
+
* still read as an intersection, so each axis narrows what the ones before it
|
|
90
|
+
* left. A bare interval means the same as a list holding only it, so a caller
|
|
91
|
+
* that only ever keeps one writes one.
|
|
92
|
+
*/
|
|
93
|
+
export type ParallelSelection = ParallelRange | readonly ParallelRange[] | null;
|
|
94
|
+
/** Which rows a set of brushes keeps, keyed by axis id. */
|
|
95
|
+
export type ParallelRanges = Readonly<Record<string, ParallelSelection>>;
|
|
96
|
+
/** How the lines are coloured. */
|
|
97
|
+
export interface ParallelColorBy {
|
|
98
|
+
/** The quantity read for each row, in the figure's row order. */
|
|
99
|
+
values: ArrayLike<number>;
|
|
100
|
+
/**
|
|
101
|
+
* The value at the low end of the ramp.
|
|
102
|
+
* @default the smallest finite value
|
|
103
|
+
*/
|
|
104
|
+
min?: number;
|
|
105
|
+
/**
|
|
106
|
+
* The value at its high end.
|
|
107
|
+
* @default the largest finite value
|
|
108
|
+
*/
|
|
109
|
+
max?: number;
|
|
110
|
+
/**
|
|
111
|
+
* The ramp, as the registry hands it over or as a plain list of colours.
|
|
112
|
+
* @default viridis — `resolveColorScale(DEFAULT_COLOR_SCALE_ID).scale`
|
|
113
|
+
*/
|
|
114
|
+
scale?: ColorScale | readonly string[];
|
|
115
|
+
/**
|
|
116
|
+
* Whether the quantity is read on a base-10 logarithmic ramp.
|
|
117
|
+
* @default false
|
|
118
|
+
*/
|
|
119
|
+
logarithmic?: boolean;
|
|
120
|
+
}
|
|
121
|
+
/** An axis described by the field to read off each row, rather than by its column. */
|
|
122
|
+
export type ParallelAxisSource<Row> = Omit<ParallelAxis, 'values'> & {
|
|
123
|
+
/**
|
|
124
|
+
* The value this axis reads off one row. Called once per row per data
|
|
125
|
+
* change, never per repaint.
|
|
126
|
+
*/
|
|
127
|
+
readonly value: (row: Row) => number;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* One axis built by reading a field off each row.
|
|
131
|
+
*
|
|
132
|
+
* The one place a row type is named: the figure itself reads numbers out of a
|
|
133
|
+
* typed array, so a repaint costs an indexed read rather than a call per
|
|
134
|
+
* value. Call it inside a `useMemo` keyed on the rows.
|
|
135
|
+
* @param rows - The rows, in the order the figure will index them.
|
|
136
|
+
* @param axis - The axis, with the field to read instead of its values.
|
|
137
|
+
* @returns The axis, with its values filled in.
|
|
138
|
+
*/
|
|
139
|
+
export declare function parallelAxisOf<Row>(rows: readonly Row[], axis: ParallelAxisSource<Row>): ParallelAxis;
|
|
140
|
+
//# sourceMappingURL=parallelTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelTypes.d.ts","sourceRoot":"","sources":["../../../src/parallel/core/parallelTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,2CAA2C;AAC3C,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEjD,sDAAsD;AACtD,MAAM,WAAW,YAAY;IAC3B,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,mFAAmF;AACnF,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC;;;;OAIG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,yEAAyE;AACzE,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEtD;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,SAAS,aAAa,EAAE,GAAG,IAAI,CAAC;AAEhF,2DAA2D;AAC3D,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAEzE,kCAAkC;AAClC,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,GAAG,SAAS,MAAM,EAAE,CAAC;IACvC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,sFAAsF;AACtF,MAAM,MAAM,kBAAkB,CAAC,GAAG,IAAI,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG;IACnE;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC;CACtC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAChC,IAAI,EAAE,SAAS,GAAG,EAAE,EACpB,IAAI,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAC5B,YAAY,CAOd"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a parallel-coordinates figure is asked to draw: one axis per column,
|
|
3
|
+
* the intervals the reader brushed on them, and the quantity the lines are
|
|
4
|
+
* coloured by.
|
|
5
|
+
*
|
|
6
|
+
* The figure itself is index-based — every axis hands over its column as an
|
|
7
|
+
* `ArrayLike<number>` read in place — so a repaint costs an indexed read per
|
|
8
|
+
* value rather than a call. {@link parallelAxisOf} is the one place a row type
|
|
9
|
+
* is named, and it is run once per data change rather than once per repaint.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* One axis built by reading a field off each row.
|
|
13
|
+
*
|
|
14
|
+
* The one place a row type is named: the figure itself reads numbers out of a
|
|
15
|
+
* typed array, so a repaint costs an indexed read rather than a call per
|
|
16
|
+
* value. Call it inside a `useMemo` keyed on the rows.
|
|
17
|
+
* @param rows - The rows, in the order the figure will index them.
|
|
18
|
+
* @param axis - The axis, with the field to read instead of its values.
|
|
19
|
+
* @returns The axis, with its values filled in.
|
|
20
|
+
*/
|
|
21
|
+
export function parallelAxisOf(rows, axis) {
|
|
22
|
+
const { value, ...rest } = axis;
|
|
23
|
+
const values = new Float64Array(rows.length);
|
|
24
|
+
for (let row = 0; row < rows.length; row++) {
|
|
25
|
+
values[row] = value(rows[row]);
|
|
26
|
+
}
|
|
27
|
+
return { ...rest, values };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=parallelTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelTypes.js","sourceRoot":"","sources":["../../../src/parallel/core/parallelTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiIH;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAoB,EACpB,IAA6B;IAE7B,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IAChC,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7C,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;QAC3C,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAQ,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { ParallelAxisLayout } from '../core/parallelAxes.ts';
|
|
3
|
+
import type { ParallelBand } from '../core/parallelBrush.ts';
|
|
4
|
+
/** What {@link ParallelAxesLayer} draws. */
|
|
5
|
+
export interface ParallelAxesLayerProps {
|
|
6
|
+
/** The axes, from left to right, already placed and graduated. */
|
|
7
|
+
layouts: readonly ParallelAxisLayout[];
|
|
8
|
+
/** Height of the drawing area, in pixels. */
|
|
9
|
+
innerHeight: number;
|
|
10
|
+
/** The bands each axis carries right now, the one being dragged included. */
|
|
11
|
+
bands: ReadonlyMap<string, ParallelBand[]>;
|
|
12
|
+
/** The ink the axes, their ticks and their labels are drawn in. */
|
|
13
|
+
axisInk: string;
|
|
14
|
+
/** The ink a band is filled and outlined in. */
|
|
15
|
+
bandInk: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The axes, their graduations and the intervals brushed on them.
|
|
19
|
+
*
|
|
20
|
+
* Every axis carries a `data-parallel-brush` rectangle over the strip a press
|
|
21
|
+
* on it reaches, which nothing points at: one surface over the whole figure
|
|
22
|
+
* takes every event, so the rectangle exists to be found — by a test driving
|
|
23
|
+
* a drag, and by a reader's eye, which is the same thing.
|
|
24
|
+
* @param props - See {@link ParallelAxesLayerProps}.
|
|
25
|
+
* @returns The axes.
|
|
26
|
+
*/
|
|
27
|
+
export declare function ParallelAxesLayer(props: ParallelAxesLayerProps): ReactElement;
|
|
28
|
+
//# sourceMappingURL=ParallelAxesLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParallelAxesLayer.d.ts","sourceRoot":"","sources":["../../../src/parallel/ui/ParallelAxesLayer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAY7D,4CAA4C;AAC5C,MAAM,WAAW,sBAAsB;IACrC,kEAAkE;IAClE,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACvC,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IAC3C,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,YAAY,CAyD7E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PARALLEL_MARGIN, parallelValueToY } from "../core/parallelAxes.js";
|
|
3
|
+
import { PARALLEL_BRUSH_HALF_WIDTH } from "../core/parallelBrush.js";
|
|
4
|
+
import { PARALLEL_HANDLE_HEIGHT, PARALLEL_TICK_LABEL_INSET, PARALLEL_TICK_LABEL_STYLE, PARALLEL_TICK_LENGTH, parallelBandStyle, parallelHandleStyle, } from "./parallelStyles.js";
|
|
5
|
+
/**
|
|
6
|
+
* The axes, their graduations and the intervals brushed on them.
|
|
7
|
+
*
|
|
8
|
+
* Every axis carries a `data-parallel-brush` rectangle over the strip a press
|
|
9
|
+
* on it reaches, which nothing points at: one surface over the whole figure
|
|
10
|
+
* takes every event, so the rectangle exists to be found — by a test driving
|
|
11
|
+
* a drag, and by a reader's eye, which is the same thing.
|
|
12
|
+
* @param props - See {@link ParallelAxesLayerProps}.
|
|
13
|
+
* @returns The axes.
|
|
14
|
+
*/
|
|
15
|
+
export function ParallelAxesLayer(props) {
|
|
16
|
+
const { layouts, innerHeight, bands, axisInk, bandInk } = props;
|
|
17
|
+
const stroke = { stroke: axisInk };
|
|
18
|
+
return (_jsx("g", { transform: `translate(${PARALLEL_MARGIN.left},${PARALLEL_MARGIN.top})`, style: { fill: axisInk }, textAnchor: "middle", children: layouts.map((layout) => {
|
|
19
|
+
const drawn = bands.get(layout.id);
|
|
20
|
+
return (_jsxs("g", { className: "parallel-axis", "data-parallel-axis": layout.id, transform: `translate(${layout.x},0)`, children: [_jsx("line", { y2: innerHeight, style: stroke }), layout.ticks.map((tick) => (_jsxs("g", { transform: `translate(0,${parallelValueToY(tick.value, layout)})`, children: [_jsx("line", { x1: -PARALLEL_TICK_LENGTH, style: stroke }), _jsx("text", { x: -PARALLEL_TICK_LABEL_INSET, dy: "0.32em", textAnchor: "end", style: PARALLEL_TICK_LABEL_STYLE, children: tick.label })] }, tick.value))), _jsx("rect", { "data-parallel-brush": layout.id, x: -PARALLEL_BRUSH_HALF_WIDTH, y: 0, width: PARALLEL_BRUSH_HALF_WIDTH * 2, height: Math.max(0, innerHeight), fill: "transparent", pointerEvents: "none" }), drawn?.map((band) => (_jsx(BrushBand, { band: band, ink: bandInk }, `${band.top}:${band.bottom}`)))] }, layout.id));
|
|
21
|
+
}) }));
|
|
22
|
+
}
|
|
23
|
+
function BrushBand(props) {
|
|
24
|
+
const { band, ink } = props;
|
|
25
|
+
const height = Math.max(0, band.bottom - band.top);
|
|
26
|
+
const width = PARALLEL_BRUSH_HALF_WIDTH * 2;
|
|
27
|
+
return (_jsxs("g", { className: "parallel-axis-band", pointerEvents: "none", children: [_jsx("rect", { x: -PARALLEL_BRUSH_HALF_WIDTH, y: band.top, width: width, height: height, style: parallelBandStyle(ink) }), _jsx("rect", { x: -PARALLEL_BRUSH_HALF_WIDTH, y: band.top - PARALLEL_HANDLE_HEIGHT / 2, width: width, height: PARALLEL_HANDLE_HEIGHT, style: parallelHandleStyle(ink) }), _jsx("rect", { x: -PARALLEL_BRUSH_HALF_WIDTH, y: band.bottom - PARALLEL_HANDLE_HEIGHT / 2, width: width, height: PARALLEL_HANDLE_HEIGHT, style: parallelHandleStyle(ink) })] }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ParallelAxesLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParallelAxesLayer.js","sourceRoot":"","sources":["../../../src/parallel/ui/ParallelAxesLayer.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAgB7B;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAChE,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAEnC,OAAO,CACL,YACE,SAAS,EAAE,aAAa,eAAe,CAAC,IAAI,IAAI,eAAe,CAAC,GAAG,GAAG,EACtE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EACxB,UAAU,EAAC,QAAQ,YAElB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACtB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACnC,OAAO,CACL,aAEE,SAAS,EAAC,eAAe,wBACL,MAAM,CAAC,EAAE,EAC7B,SAAS,EAAE,aAAa,MAAM,CAAC,CAAC,KAAK,aAErC,eAAM,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,G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