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,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The questions the gesture asks that need neither React nor state: where a
|
|
3
|
+
* press landed, which axis it reached, and which band each axis should be
|
|
4
|
+
* drawn with once the one being dragged is taken into account.
|
|
5
|
+
*
|
|
6
|
+
* Kept out of the hook the way `lassoGesture.ts` is kept out of its own — each
|
|
7
|
+
* of these has exactly one answer, and none of them needs a render to be read.
|
|
8
|
+
*/
|
|
9
|
+
import type { SurfaceEvent } from '../../scatter/ui/lassoGesture.ts';
|
|
10
|
+
import type { ParallelAxisLayout } from '../core/parallelAxes.ts';
|
|
11
|
+
import type { ParallelBand } from '../core/parallelBrush.ts';
|
|
12
|
+
import type { ParallelRange, ParallelRanges } from '../core/parallelTypes.ts';
|
|
13
|
+
/** A band being dragged, before the interval it keeps is reported. */
|
|
14
|
+
export interface ParallelDraft {
|
|
15
|
+
/** The axis it is on. */
|
|
16
|
+
axis: string;
|
|
17
|
+
/** Which of that axis's bands it is, or `-1` when it is a new one. */
|
|
18
|
+
index: number;
|
|
19
|
+
/** Where it stands this frame. */
|
|
20
|
+
band: ParallelBand;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Where an event landed, relative to the top left of the drawing area.
|
|
24
|
+
* @param event - The event, for where on the surface it happened.
|
|
25
|
+
* @returns The position, in pixels from the corner of the drawing area.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parallelPointOf(event: SurfaceEvent): {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Which axis a press at that horizontal position took hold of.
|
|
33
|
+
* @param x - Pixels from the left of the drawing area.
|
|
34
|
+
* @param axes - The axes, from left to right.
|
|
35
|
+
* @returns The axis's index, or `-1` when the press landed between two of them.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parallelAxisNear(x: number, axes: readonly ParallelAxisLayout[]): number;
|
|
38
|
+
/**
|
|
39
|
+
* One axis, by the id a range is keyed on.
|
|
40
|
+
* @param axes - The axes, from left to right.
|
|
41
|
+
* @param axisId - The id to find.
|
|
42
|
+
* @returns The axis, or `undefined` when it is no longer drawn.
|
|
43
|
+
*/
|
|
44
|
+
export declare function parallelAxisById(axes: readonly ParallelAxisLayout[], axisId: string): ParallelAxisLayout | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* The bands to draw on each axis: the one being dragged where there is one,
|
|
47
|
+
* and the intervals in force everywhere else.
|
|
48
|
+
* @param axes - The axes, from left to right.
|
|
49
|
+
* @param ranges - What each axis keeps: one interval, several, or none.
|
|
50
|
+
* @param draft - The band being dragged, or `null` when nothing is.
|
|
51
|
+
* @returns The bands, keyed by axis id; an axis with none is left out. The
|
|
52
|
+
* band being dragged replaces the interval it came from rather than being
|
|
53
|
+
* drawn beside it, so an interval never appears twice mid-gesture.
|
|
54
|
+
*/
|
|
55
|
+
export declare function parallelBandsOf(axes: readonly ParallelAxisLayout[], ranges: ParallelRanges, draft: ParallelDraft | null): ReadonlyMap<string, ParallelBand[]>;
|
|
56
|
+
/** What a released band does to the intervals its axis already kept. */
|
|
57
|
+
export interface ParallelCommit {
|
|
58
|
+
/** The intervals in force on that axis. */
|
|
59
|
+
list: readonly ParallelRange[];
|
|
60
|
+
/** Which of them the drag took hold of, or `-1` when it began a new one. */
|
|
61
|
+
index: number;
|
|
62
|
+
/** The band as the pointer left it. */
|
|
63
|
+
band: ParallelBand;
|
|
64
|
+
/** The axis it is on, to read the band back into its own units. */
|
|
65
|
+
layout: ParallelAxisLayout;
|
|
66
|
+
/** Whether the press took an interval and let it go without moving it. */
|
|
67
|
+
still: boolean;
|
|
68
|
+
/** Whether the axis may keep more than one interval. */
|
|
69
|
+
several: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The intervals an axis keeps once a band has been let go.
|
|
73
|
+
*
|
|
74
|
+
* A press that keeps nothing is a click, and a click says "take this away":
|
|
75
|
+
* the interval under the pointer when it landed on one, and every interval on
|
|
76
|
+
* the axis when it landed on bare axis. That is the only way to be rid of one
|
|
77
|
+
* interval on an axis carrying four, and it is the gesture that already
|
|
78
|
+
* cleared an axis before it could carry more than one.
|
|
79
|
+
* @param commit - See {@link ParallelCommit}.
|
|
80
|
+
* @returns The intervals, sorted and disjoint.
|
|
81
|
+
*/
|
|
82
|
+
export declare function parallelCommitOf(commit: ParallelCommit): ParallelRange[];
|
|
83
|
+
//# sourceMappingURL=parallelGestureModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelGestureModel.d.ts","sourceRoot":"","sources":["../../../src/parallel/ui/parallelGestureModel.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAW7D,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE9E,sEAAsE;AACtE,MAAM,WAAW,aAAa;IAC5B,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG;IACpD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAMA;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,SAAS,kBAAkB,EAAE,GAClC,MAAM,CAaR;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,SAAS,kBAAkB,EAAE,EACnC,MAAM,EAAE,MAAM,GACb,kBAAkB,GAAG,SAAS,CAKhC;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,SAAS,kBAAkB,EAAE,EACnC,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,aAAa,GAAG,IAAI,GAC1B,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAcrC;AAED,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,IAAI,EAAE,SAAS,aAAa,EAAE,CAAC;IAC/B,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,IAAI,EAAE,YAAY,CAAC;IACnB,mEAAmE;IACnE,MAAM,EAAE,kBAAkB,CAAC;IAC3B,0EAA0E;IAC1E,KAAK,EAAE,OAAO,CAAC;IACf,wDAAwD;IACxD,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa,EAAE,CASxE"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The questions the gesture asks that need neither React nor state: where a
|
|
3
|
+
* press landed, which axis it reached, and which band each axis should be
|
|
4
|
+
* drawn with once the one being dragged is taken into account.
|
|
5
|
+
*
|
|
6
|
+
* Kept out of the hook the way `lassoGesture.ts` is kept out of its own — each
|
|
7
|
+
* of these has exactly one answer, and none of them needs a render to be read.
|
|
8
|
+
*/
|
|
9
|
+
import { surfacePosition } from "../../scatter/ui/lassoGesture.js";
|
|
10
|
+
import { PARALLEL_MARGIN } from "../core/parallelAxes.js";
|
|
11
|
+
import { PARALLEL_BRUSH_HALF_WIDTH, parallelBandOf, parallelIsBand, parallelRangeOf, } from "../core/parallelBrush.js";
|
|
12
|
+
import { parallelRangeList, parallelWriteRange, } from "../core/parallelSelection.js";
|
|
13
|
+
/**
|
|
14
|
+
* Where an event landed, relative to the top left of the drawing area.
|
|
15
|
+
* @param event - The event, for where on the surface it happened.
|
|
16
|
+
* @returns The position, in pixels from the corner of the drawing area.
|
|
17
|
+
*/
|
|
18
|
+
export function parallelPointOf(event) {
|
|
19
|
+
const position = surfacePosition(event, 0, 0);
|
|
20
|
+
return {
|
|
21
|
+
x: position.x - PARALLEL_MARGIN.left,
|
|
22
|
+
y: position.y - PARALLEL_MARGIN.top,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Which axis a press at that horizontal position took hold of.
|
|
27
|
+
* @param x - Pixels from the left of the drawing area.
|
|
28
|
+
* @param axes - The axes, from left to right.
|
|
29
|
+
* @returns The axis's index, or `-1` when the press landed between two of them.
|
|
30
|
+
*/
|
|
31
|
+
export function parallelAxisNear(x, axes) {
|
|
32
|
+
let nearest = -1;
|
|
33
|
+
let nearestDistance = PARALLEL_BRUSH_HALF_WIDTH;
|
|
34
|
+
for (let index = 0; index < axes.length; index++) {
|
|
35
|
+
const axis = axes[index];
|
|
36
|
+
if (axis === undefined)
|
|
37
|
+
continue;
|
|
38
|
+
const distance = Math.abs(x - axis.x);
|
|
39
|
+
if (distance <= nearestDistance) {
|
|
40
|
+
nearestDistance = distance;
|
|
41
|
+
nearest = index;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return nearest;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* One axis, by the id a range is keyed on.
|
|
48
|
+
* @param axes - The axes, from left to right.
|
|
49
|
+
* @param axisId - The id to find.
|
|
50
|
+
* @returns The axis, or `undefined` when it is no longer drawn.
|
|
51
|
+
*/
|
|
52
|
+
export function parallelAxisById(axes, axisId) {
|
|
53
|
+
for (const axis of axes) {
|
|
54
|
+
if (axis.id === axisId)
|
|
55
|
+
return axis;
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The bands to draw on each axis: the one being dragged where there is one,
|
|
61
|
+
* and the intervals in force everywhere else.
|
|
62
|
+
* @param axes - The axes, from left to right.
|
|
63
|
+
* @param ranges - What each axis keeps: one interval, several, or none.
|
|
64
|
+
* @param draft - The band being dragged, or `null` when nothing is.
|
|
65
|
+
* @returns The bands, keyed by axis id; an axis with none is left out. The
|
|
66
|
+
* band being dragged replaces the interval it came from rather than being
|
|
67
|
+
* drawn beside it, so an interval never appears twice mid-gesture.
|
|
68
|
+
*/
|
|
69
|
+
export function parallelBandsOf(axes, ranges, draft) {
|
|
70
|
+
const drawn = new Map();
|
|
71
|
+
for (const axis of axes) {
|
|
72
|
+
const list = parallelRangeList(ranges[axis.id]);
|
|
73
|
+
const dragging = draft !== null && draft.axis === axis.id;
|
|
74
|
+
const bands = [];
|
|
75
|
+
for (let index = 0; index < list.length; index++) {
|
|
76
|
+
if (dragging && index === draft.index)
|
|
77
|
+
continue;
|
|
78
|
+
bands.push(parallelBandOf(list[index], axis));
|
|
79
|
+
}
|
|
80
|
+
if (dragging)
|
|
81
|
+
bands.push(draft.band);
|
|
82
|
+
if (bands.length > 0)
|
|
83
|
+
drawn.set(axis.id, bands);
|
|
84
|
+
}
|
|
85
|
+
return drawn;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The intervals an axis keeps once a band has been let go.
|
|
89
|
+
*
|
|
90
|
+
* A press that keeps nothing is a click, and a click says "take this away":
|
|
91
|
+
* the interval under the pointer when it landed on one, and every interval on
|
|
92
|
+
* the axis when it landed on bare axis. That is the only way to be rid of one
|
|
93
|
+
* interval on an axis carrying four, and it is the gesture that already
|
|
94
|
+
* cleared an axis before it could carry more than one.
|
|
95
|
+
* @param commit - See {@link ParallelCommit}.
|
|
96
|
+
* @returns The intervals, sorted and disjoint.
|
|
97
|
+
*/
|
|
98
|
+
export function parallelCommitOf(commit) {
|
|
99
|
+
const { list, index, band, layout, still, several } = commit;
|
|
100
|
+
if (still)
|
|
101
|
+
return parallelWriteRange(list, index, null);
|
|
102
|
+
if (!parallelIsBand(band)) {
|
|
103
|
+
return index === -1 ? [] : parallelWriteRange(list, index, null);
|
|
104
|
+
}
|
|
105
|
+
const range = parallelRangeOf(band, layout);
|
|
106
|
+
if (!several && index === -1)
|
|
107
|
+
return [range];
|
|
108
|
+
return parallelWriteRange(list, index, range);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=parallelGestureModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelGestureModel.js","sourceRoot":"","sources":["../../../src/parallel/ui/parallelGestureModel.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EACL,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AAatC;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAmB;IAIjD,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9C,OAAO;QACL,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,eAAe,CAAC,IAAI;QACpC,CAAC,EAAE,QAAQ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,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colours the canvas is painted with, read off the figure itself.
|
|
3
|
+
*
|
|
4
|
+
* A canvas takes a colour, not a CSS declaration, so `var(--accent)` means
|
|
5
|
+
* nothing to it — and the family's accent is the one colour a site owns, so it
|
|
6
|
+
* cannot be written into a shared library either. The figure therefore asks
|
|
7
|
+
* the browser what its own tokens resolved to, once it is on the page, and
|
|
8
|
+
* paints with the answer.
|
|
9
|
+
*/
|
|
10
|
+
import type { ParallelInk } from './parallelCoordinatesProps.ts';
|
|
11
|
+
/** The four tokens the figure paints from, as the page resolved them. */
|
|
12
|
+
export interface ParallelTokenInk {
|
|
13
|
+
/** What `--text` resolved to. */
|
|
14
|
+
text: string;
|
|
15
|
+
/** What `--text-muted` resolved to. */
|
|
16
|
+
textMuted: string;
|
|
17
|
+
/** What `--surface` resolved to. */
|
|
18
|
+
surface: string;
|
|
19
|
+
/** What `--accent` resolved to, or the text colour when a site declares none. */
|
|
20
|
+
accent: string;
|
|
21
|
+
}
|
|
22
|
+
/** Every colour the figure paints with, resolved to something a canvas takes. */
|
|
23
|
+
export interface ParallelInkValues {
|
|
24
|
+
/** The rows a brush left out. */
|
|
25
|
+
excluded: string;
|
|
26
|
+
/** The rows nothing is colouring. */
|
|
27
|
+
line: string;
|
|
28
|
+
/** The row under the pointer. */
|
|
29
|
+
hover: string;
|
|
30
|
+
/** The rows singled out elsewhere. */
|
|
31
|
+
selection: string;
|
|
32
|
+
/** The halo a singled-out line is drawn over. */
|
|
33
|
+
halo: string;
|
|
34
|
+
/** The axis lines, their ticks and their labels. */
|
|
35
|
+
axis: string;
|
|
36
|
+
/** How strongly a kept line is drawn. */
|
|
37
|
+
includedAlpha: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* What the figure's own tokens resolved to.
|
|
41
|
+
* @param element - The figure, once it is on the page, or `null` before it is.
|
|
42
|
+
* @returns The four colours. Off the page — a server render, a test — the
|
|
43
|
+
* family's own token values stand in, so the figure never paints with nothing.
|
|
44
|
+
*/
|
|
45
|
+
export declare function readParallelTokens(element: Element | null): ParallelTokenInk;
|
|
46
|
+
/**
|
|
47
|
+
* The inks to paint with, from the page's tokens and the caller's overrides.
|
|
48
|
+
* @param tokens - What the figure's own tokens resolved to.
|
|
49
|
+
* @param ink - What the caller insists on, over every one of them.
|
|
50
|
+
* @returns The inks.
|
|
51
|
+
*/
|
|
52
|
+
export declare function parallelInkFrom(tokens: ParallelTokenInk, ink?: ParallelInk): ParallelInkValues;
|
|
53
|
+
/**
|
|
54
|
+
* The inks to paint with, read off one element.
|
|
55
|
+
* @param element - The figure, once it is on the page, or `null` before it is.
|
|
56
|
+
* @param ink - What the caller insists on, over everything read off the page.
|
|
57
|
+
* @returns The inks.
|
|
58
|
+
*/
|
|
59
|
+
export declare function readParallelInk(element: Element | null, ink?: ParallelInk): ParallelInkValues;
|
|
60
|
+
/** The inks, and the ref that has to reach the figure for them to be read. */
|
|
61
|
+
export interface ParallelInkBinding {
|
|
62
|
+
/** The colours to paint with. */
|
|
63
|
+
ink: ParallelInkValues;
|
|
64
|
+
/** Put on the figure's outermost element. */
|
|
65
|
+
ref: (element: Element | null) => void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The inks, with the page's own tokens read the moment the figure is mounted.
|
|
69
|
+
*
|
|
70
|
+
* A callback ref rather than an effect, because the question is asked once, of
|
|
71
|
+
* the element itself, and there is nothing to keep in step afterwards.
|
|
72
|
+
* @param ink - What the caller insists on.
|
|
73
|
+
* @returns The inks and the ref. See {@link ParallelInkBinding}.
|
|
74
|
+
*/
|
|
75
|
+
export declare function useParallelInk(ink?: ParallelInk): ParallelInkBinding;
|
|
76
|
+
//# sourceMappingURL=parallelInk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelInk.d.ts","sourceRoot":"","sources":["../../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cAAc,CAAC,GAAG,GAAE,WAAgB,GAAG,kBAAkB,CAuBxE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colours the canvas is painted with, read off the figure itself.
|
|
3
|
+
*
|
|
4
|
+
* A canvas takes a colour, not a CSS declaration, so `var(--accent)` means
|
|
5
|
+
* nothing to it — and the family's accent is the one colour a site owns, so it
|
|
6
|
+
* cannot be written into a shared library either. The figure therefore asks
|
|
7
|
+
* the browser what its own tokens resolved to, once it is on the page, and
|
|
8
|
+
* paints with the answer.
|
|
9
|
+
*/
|
|
10
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
11
|
+
import { parseHexColor } from "../../color/core/hex.js";
|
|
12
|
+
import { FAMILY_TOKEN_VALUES } from "../../tokens/core/familyTokens.js";
|
|
13
|
+
import { PARALLEL_INCLUDED_ALPHA } from "../core/parallelPaint.js";
|
|
14
|
+
/**
|
|
15
|
+
* The rows a brush left out. A light grey rather than a translucent black:
|
|
16
|
+
* overlapping segments of one stroked path accumulate alpha, so a translucent
|
|
17
|
+
* black saturates wherever the library is dense, while this is the colour the
|
|
18
|
+
* pile can only converge on.
|
|
19
|
+
*/
|
|
20
|
+
const EXCLUDED = 'rgba(171, 179, 191, 0.16)';
|
|
21
|
+
/** How solid the halo under a singled-out line is. */
|
|
22
|
+
const HALO_ALPHA = 0.85;
|
|
23
|
+
/** The halo a page that declares no surface colour still gets. */
|
|
24
|
+
const WHITE_HALO = `rgba(255, 255, 255, ${HALO_ALPHA})`;
|
|
25
|
+
/**
|
|
26
|
+
* What the figure's own tokens resolved to.
|
|
27
|
+
* @param element - The figure, once it is on the page, or `null` before it is.
|
|
28
|
+
* @returns The four colours. Off the page — a server render, a test — the
|
|
29
|
+
* family's own token values stand in, so the figure never paints with nothing.
|
|
30
|
+
*/
|
|
31
|
+
export function readParallelTokens(element) {
|
|
32
|
+
const text = tokenColor(element, '--text', FAMILY_TOKEN_VALUES['--text']);
|
|
33
|
+
return {
|
|
34
|
+
text,
|
|
35
|
+
textMuted: tokenColor(element, '--text-muted', FAMILY_TOKEN_VALUES['--text-muted']),
|
|
36
|
+
surface: tokenColor(element, '--surface', FAMILY_TOKEN_VALUES['--surface']),
|
|
37
|
+
// A site that declares no accent still singles a row out, in its ink.
|
|
38
|
+
accent: tokenColor(element, '--accent', text),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The inks to paint with, from the page's tokens and the caller's overrides.
|
|
43
|
+
* @param tokens - What the figure's own tokens resolved to.
|
|
44
|
+
* @param ink - What the caller insists on, over every one of them.
|
|
45
|
+
* @returns The inks.
|
|
46
|
+
*/
|
|
47
|
+
export function parallelInkFrom(tokens, ink = {}) {
|
|
48
|
+
return {
|
|
49
|
+
excluded: ink.excluded ?? EXCLUDED,
|
|
50
|
+
line: ink.line ?? tokens.textMuted,
|
|
51
|
+
hover: ink.hover ?? tokens.text,
|
|
52
|
+
selection: ink.selection ?? tokens.accent,
|
|
53
|
+
halo: ink.halo ?? haloOf(tokens.surface),
|
|
54
|
+
axis: ink.axis ?? tokens.textMuted,
|
|
55
|
+
includedAlpha: ink.includedAlpha ?? PARALLEL_INCLUDED_ALPHA,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The inks to paint with, read off one element.
|
|
60
|
+
* @param element - The figure, once it is on the page, or `null` before it is.
|
|
61
|
+
* @param ink - What the caller insists on, over everything read off the page.
|
|
62
|
+
* @returns The inks.
|
|
63
|
+
*/
|
|
64
|
+
export function readParallelInk(element, ink = {}) {
|
|
65
|
+
return parallelInkFrom(readParallelTokens(element), ink);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The inks, with the page's own tokens read the moment the figure is mounted.
|
|
69
|
+
*
|
|
70
|
+
* A callback ref rather than an effect, because the question is asked once, of
|
|
71
|
+
* the element itself, and there is nothing to keep in step afterwards.
|
|
72
|
+
* @param ink - What the caller insists on.
|
|
73
|
+
* @returns The inks and the ref. See {@link ParallelInkBinding}.
|
|
74
|
+
*/
|
|
75
|
+
export function useParallelInk(ink = {}) {
|
|
76
|
+
const [tokens, setTokens] = useState(readFamilyTokens);
|
|
77
|
+
const { excluded, line, hover, selection, halo, axis, includedAlpha } = ink;
|
|
78
|
+
const ref = useCallback((element) => {
|
|
79
|
+
if (element !== null)
|
|
80
|
+
setTokens(readParallelTokens(element));
|
|
81
|
+
}, []);
|
|
82
|
+
const resolved = useMemo(() => parallelInkFrom(tokens, {
|
|
83
|
+
excluded,
|
|
84
|
+
line,
|
|
85
|
+
hover,
|
|
86
|
+
selection,
|
|
87
|
+
halo,
|
|
88
|
+
axis,
|
|
89
|
+
includedAlpha,
|
|
90
|
+
}), [tokens, excluded, line, hover, selection, halo, axis, includedAlpha]);
|
|
91
|
+
return { ink: resolved, ref };
|
|
92
|
+
}
|
|
93
|
+
function readFamilyTokens() {
|
|
94
|
+
return readParallelTokens(null);
|
|
95
|
+
}
|
|
96
|
+
function tokenColor(element, name, fallback) {
|
|
97
|
+
const resolve = globalThis.getComputedStyle;
|
|
98
|
+
if (element === null || typeof resolve !== 'function')
|
|
99
|
+
return fallback;
|
|
100
|
+
const declared = resolve(element).getPropertyValue(name).trim();
|
|
101
|
+
return declared === '' ? fallback : declared;
|
|
102
|
+
}
|
|
103
|
+
function haloOf(surface) {
|
|
104
|
+
try {
|
|
105
|
+
const { red, green, blue } = parseHexColor(surface);
|
|
106
|
+
return `rgba(${red}, ${green}, ${blue}, ${HALO_ALPHA})`;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// A surface written as anything but a hex colour still gets a halo.
|
|
110
|
+
return WHITE_HALO;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=parallelInk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelInk.js","sourceRoot":"","sources":["../../../src/parallel/ui/parallelInk.ts"],"names":[],"mappings":"AAAA;;;;;;;;G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AAU,CACjB,OAAuB,EACvB,IAAY,EACZ,QAAgB;IAEhB,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC;IAC5C,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,UAAU;QAAE,OAAO,QAAQ,CAAC;IACvE,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IAChE,OAAO,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC/C,CAAC;AAED,SAAS,MAAM,CAAC,OAAe;IAC7B,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QACpD,OAAO,QAAQ,GAAG,KAAK,KAAK,KAAK,IAAI,KAAK,UAAU,GAAG,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,oEAAoE;QACpE,OAAO,UAAU,CAAC;IACpB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The small answers the figure needs before it renders: how many rows there
|
|
3
|
+
* are, what is colouring the lines, which rows are drawn over the mass, and
|
|
4
|
+
* what a screen reader is told.
|
|
5
|
+
*
|
|
6
|
+
* Kept out of the component for the reason `scatterPlotModel.ts` is: none of
|
|
7
|
+
* them needs React to be read or checked, and a component that is mostly
|
|
8
|
+
* arithmetic is a component nobody can see the layout in.
|
|
9
|
+
*/
|
|
10
|
+
import type { ParallelHighlight } from '../core/parallelPaint.ts';
|
|
11
|
+
import type { ParallelAxis, ParallelColorBy, ParallelRanges } from '../core/parallelTypes.ts';
|
|
12
|
+
/**
|
|
13
|
+
* How many rows the figure draws.
|
|
14
|
+
* @param axes - The axes, whose columns are read.
|
|
15
|
+
* @param count - What the caller insists on, if anything.
|
|
16
|
+
* @returns The count — the shortest column, so no axis is ever read past its
|
|
17
|
+
* own end.
|
|
18
|
+
*/
|
|
19
|
+
export declare function parallelRowCount(axes: readonly ParallelAxis[], count?: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* The quantity the lines are coloured by.
|
|
22
|
+
* @param color - The quantity the caller gave outright.
|
|
23
|
+
* @param colorAxis - The id of an axis already drawn, for the common case.
|
|
24
|
+
* @param axes - The axes, to find that id among.
|
|
25
|
+
* @returns The quantity, or `undefined` when the lines all take one ink. An
|
|
26
|
+
* axis named by `colorAxis` lends its own domain as well as its values, so the
|
|
27
|
+
* ramp and the axis beside it read the same range.
|
|
28
|
+
*/
|
|
29
|
+
export declare function parallelColorOf(color: ParallelColorBy | undefined, colorAxis: string | undefined, axes: readonly ParallelAxis[]): ParallelColorBy | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Whether any axis on the figure carries an interval at all.
|
|
32
|
+
* @param axes - The axes, whose ids the intervals are keyed by.
|
|
33
|
+
* @param ranges - What each axis keeps.
|
|
34
|
+
* @returns Whether anything is brushed, which is what decides whether a line
|
|
35
|
+
* is ever drawn in the excluded ink.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parallelIsBrushed(axes: readonly ParallelAxis[], ranges: ParallelRanges): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The rows drawn over the mass, in the order they are painted.
|
|
40
|
+
* @param selected - The rows singled out elsewhere.
|
|
41
|
+
* @param hovered - The row under the pointer, or `-1`.
|
|
42
|
+
* @param selectionInk - The ink a singled-out row takes.
|
|
43
|
+
* @param hoverInk - The ink the hovered row takes.
|
|
44
|
+
* @returns The highlights, the hovered row last so that it paints on top and
|
|
45
|
+
* a row that is both selected and hovered is drawn once rather than twice.
|
|
46
|
+
*/
|
|
47
|
+
export declare function parallelHighlightsOf(selected: readonly number[] | undefined, hovered: number, selectionInk: string, hoverInk: string): ParallelHighlight[];
|
|
48
|
+
/**
|
|
49
|
+
* What a screen reader is told the figure shows.
|
|
50
|
+
* @param axes - The axes, from left to right.
|
|
51
|
+
* @param count - How many rows are drawn.
|
|
52
|
+
* @returns The sentence, naming every axis and how much is on the figure.
|
|
53
|
+
*/
|
|
54
|
+
export declare function parallelFigureLabel(axes: readonly ParallelAxis[], count: number): string;
|
|
55
|
+
//# sourceMappingURL=parallelPlotModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelPlotModel.d.ts","sourceRoot":"","sources":["../../../src/parallel/ui/parallelPlotModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACf,MAAM,0BAA0B,CAAC;AAElC;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,SAAS,YAAY,EAAE,EAC7B,KAAK,CAAC,EAAE,MAAM,GACb,MAAM,CAUR;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,eAAe,GAAG,SAAS,EAClC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,IAAI,EAAE,SAAS,YAAY,EAAE,GAC5B,eAAe,GAAG,SAAS,CAe7B;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,YAAY,EAAE,EAC7B,MAAM,EAAE,cAAc,GACrB,OAAO,CAKT;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EACvC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACf,iBAAiB,EAAE,CAUrB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,SAAS,YAAY,EAAE,EAC7B,KAAK,EAAE,MAAM,GACZ,MAAM,CAMR"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The small answers the figure needs before it renders: how many rows there
|
|
3
|
+
* are, what is colouring the lines, which rows are drawn over the mass, and
|
|
4
|
+
* what a screen reader is told.
|
|
5
|
+
*
|
|
6
|
+
* Kept out of the component for the reason `scatterPlotModel.ts` is: none of
|
|
7
|
+
* them needs React to be read or checked, and a component that is mostly
|
|
8
|
+
* arithmetic is a component nobody can see the layout in.
|
|
9
|
+
*/
|
|
10
|
+
import { formatInteger } from "../../format/core/numbers.js";
|
|
11
|
+
import { parallelHasRange } from "../core/parallelSelection.js";
|
|
12
|
+
/**
|
|
13
|
+
* How many rows the figure draws.
|
|
14
|
+
* @param axes - The axes, whose columns are read.
|
|
15
|
+
* @param count - What the caller insists on, if anything.
|
|
16
|
+
* @returns The count — the shortest column, so no axis is ever read past its
|
|
17
|
+
* own end.
|
|
18
|
+
*/
|
|
19
|
+
export function parallelRowCount(axes, count) {
|
|
20
|
+
if (count !== undefined)
|
|
21
|
+
return Math.max(0, Math.trunc(count));
|
|
22
|
+
let shortest = 0;
|
|
23
|
+
for (let index = 0; index < axes.length; index++) {
|
|
24
|
+
const axis = axes[index];
|
|
25
|
+
if (axis === undefined)
|
|
26
|
+
continue;
|
|
27
|
+
const length = axis.values.length;
|
|
28
|
+
if (index === 0 || length < shortest)
|
|
29
|
+
shortest = length;
|
|
30
|
+
}
|
|
31
|
+
return shortest;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The quantity the lines are coloured by.
|
|
35
|
+
* @param color - The quantity the caller gave outright.
|
|
36
|
+
* @param colorAxis - The id of an axis already drawn, for the common case.
|
|
37
|
+
* @param axes - The axes, to find that id among.
|
|
38
|
+
* @returns The quantity, or `undefined` when the lines all take one ink. An
|
|
39
|
+
* axis named by `colorAxis` lends its own domain as well as its values, so the
|
|
40
|
+
* ramp and the axis beside it read the same range.
|
|
41
|
+
*/
|
|
42
|
+
export function parallelColorOf(color, colorAxis, axes) {
|
|
43
|
+
if (color !== undefined)
|
|
44
|
+
return color;
|
|
45
|
+
if (colorAxis === undefined)
|
|
46
|
+
return undefined;
|
|
47
|
+
for (const axis of axes) {
|
|
48
|
+
if (axis.id !== colorAxis)
|
|
49
|
+
continue;
|
|
50
|
+
const domain = axis.domain;
|
|
51
|
+
if (domain === undefined)
|
|
52
|
+
return { values: axis.values };
|
|
53
|
+
return {
|
|
54
|
+
values: axis.values,
|
|
55
|
+
min: Math.min(domain[0], domain[1]),
|
|
56
|
+
max: Math.max(domain[0], domain[1]),
|
|
57
|
+
logarithmic: axis.scale === 'log',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Whether any axis on the figure carries an interval at all.
|
|
64
|
+
* @param axes - The axes, whose ids the intervals are keyed by.
|
|
65
|
+
* @param ranges - What each axis keeps.
|
|
66
|
+
* @returns Whether anything is brushed, which is what decides whether a line
|
|
67
|
+
* is ever drawn in the excluded ink.
|
|
68
|
+
*/
|
|
69
|
+
export function parallelIsBrushed(axes, ranges) {
|
|
70
|
+
for (const axis of axes) {
|
|
71
|
+
if (parallelHasRange(ranges[axis.id]))
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The rows drawn over the mass, in the order they are painted.
|
|
78
|
+
* @param selected - The rows singled out elsewhere.
|
|
79
|
+
* @param hovered - The row under the pointer, or `-1`.
|
|
80
|
+
* @param selectionInk - The ink a singled-out row takes.
|
|
81
|
+
* @param hoverInk - The ink the hovered row takes.
|
|
82
|
+
* @returns The highlights, the hovered row last so that it paints on top and
|
|
83
|
+
* a row that is both selected and hovered is drawn once rather than twice.
|
|
84
|
+
*/
|
|
85
|
+
export function parallelHighlightsOf(selected, hovered, selectionInk, hoverInk) {
|
|
86
|
+
const highlights = [];
|
|
87
|
+
if (selected !== undefined) {
|
|
88
|
+
for (const row of selected) {
|
|
89
|
+
if (row < 0 || row === hovered)
|
|
90
|
+
continue;
|
|
91
|
+
highlights.push({ row, color: selectionInk });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (hovered >= 0)
|
|
95
|
+
highlights.push({ row: hovered, color: hoverInk });
|
|
96
|
+
return highlights;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* What a screen reader is told the figure shows.
|
|
100
|
+
* @param axes - The axes, from left to right.
|
|
101
|
+
* @param count - How many rows are drawn.
|
|
102
|
+
* @returns The sentence, naming every axis and how much is on the figure.
|
|
103
|
+
*/
|
|
104
|
+
export function parallelFigureLabel(axes, count) {
|
|
105
|
+
const names = [];
|
|
106
|
+
for (const axis of axes)
|
|
107
|
+
names.push(axis.label);
|
|
108
|
+
const rows = count === 1 ? '1 row' : `${formatInteger(count)} rows`;
|
|
109
|
+
if (names.length === 0)
|
|
110
|
+
return `Parallel coordinates of ${rows}.`;
|
|
111
|
+
return `Parallel coordinates of ${rows}, on ${names.join(', ')}.`;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=parallelPlotModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelPlotModel.js","sourceRoot":"","sources":["../../../src/parallel/ui/parallelPlotModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAOhE;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAA6B,EAC7B,KAAc;IAEd,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,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