react-cheminfo 0.14.0 → 0.16.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 +175 -21
- package/lib/about/core/about.d.ts +13 -7
- package/lib/about/core/about.d.ts.map +1 -1
- package/lib/about/core/about.js +4 -2
- package/lib/about/core/about.js.map +1 -1
- package/lib/about/ui/AboutBuild.d.ts +20 -0
- package/lib/about/ui/AboutBuild.d.ts.map +1 -0
- package/lib/about/ui/AboutBuild.js +38 -0
- package/lib/about/ui/AboutBuild.js.map +1 -0
- package/lib/about/ui/AboutPage.d.ts +7 -0
- package/lib/about/ui/AboutPage.d.ts.map +1 -1
- package/lib/about/ui/AboutPage.js +5 -2
- package/lib/about/ui/AboutPage.js.map +1 -1
- package/lib/about/ui/index.d.ts +2 -0
- package/lib/about/ui/index.d.ts.map +1 -1
- package/lib/about/ui/index.js +1 -0
- package/lib/about/ui/index.js.map +1 -1
- package/lib/build/core/buildInfo.d.ts +39 -0
- package/lib/build/core/buildInfo.d.ts.map +1 -0
- package/lib/build/core/buildInfo.js +20 -0
- package/lib/build/core/buildInfo.js.map +1 -0
- package/lib/build/core/current.d.ts +12 -0
- package/lib/build/core/current.d.ts.map +1 -0
- package/lib/build/core/current.js +11 -0
- package/lib/build/core/current.js.map +1 -0
- package/lib/build/core/index.d.ts +3 -0
- package/lib/build/core/index.d.ts.map +1 -0
- package/lib/build/core/index.js +2 -0
- package/lib/build/core/index.js.map +1 -0
- package/lib/build/vite/buildInfo.d.ts +57 -0
- package/lib/build/vite/buildInfo.d.ts.map +1 -0
- package/lib/build/vite/buildInfo.js +151 -0
- package/lib/build/vite/buildInfo.js.map +1 -0
- package/lib/build/vite/gitHead.d.ts +29 -0
- package/lib/build/vite/gitHead.d.ts.map +1 -0
- package/lib/build/vite/gitHead.js +102 -0
- package/lib/build/vite/gitHead.js.map +1 -0
- package/lib/build/vite/index.d.ts +4 -0
- package/lib/build/vite/index.d.ts.map +1 -0
- package/lib/build/vite/index.js +3 -0
- package/lib/build/vite/index.js.map +1 -0
- package/lib/build-info.d.ts +3 -0
- package/lib/build-info.d.ts.map +1 -0
- package/lib/build-info.js +2 -0
- package/lib/build-info.js.map +1 -0
- package/lib/core.d.ts +2 -0
- package/lib/core.d.ts.map +1 -1
- package/lib/core.js +2 -0
- package/lib/core.js.map +1 -1
- package/lib/credits/core/credits.d.ts +35 -0
- package/lib/credits/core/credits.d.ts.map +1 -1
- package/lib/credits/core/credits.js +41 -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/Wordmark.d.ts +14 -3
- package/lib/ecosystem/ui/Wordmark.d.ts.map +1 -1
- package/lib/ecosystem/ui/Wordmark.js +8 -4
- package/lib/ecosystem/ui/Wordmark.js.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 +27 -0
- package/lib/parallel/core/index.d.ts.map +1 -0
- package/lib/parallel/core/index.js +20 -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 +79 -0
- package/lib/parallel/core/parallelBrush.d.ts.map +1 -0
- package/lib/parallel/core/parallelBrush.js +99 -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 +36 -0
- package/lib/parallel/core/parallelFilter.d.ts.map +1 -0
- package/lib/parallel/core/parallelFilter.js +74 -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/parallelPaint.d.ts +104 -0
- package/lib/parallel/core/parallelPaint.d.ts.map +1 -0
- package/lib/parallel/core/parallelPaint.js +160 -0
- package/lib/parallel/core/parallelPaint.js.map +1 -0
- package/lib/parallel/core/parallelPalette.d.ts +31 -0
- package/lib/parallel/core/parallelPalette.d.ts.map +1 -0
- package/lib/parallel/core/parallelPalette.js +68 -0
- package/lib/parallel/core/parallelPalette.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 +116 -0
- package/lib/parallel/core/parallelTicks.js.map +1 -0
- package/lib/parallel/core/parallelTypes.d.ts +129 -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 +109 -0
- package/lib/parallel/ui/ParallelCoordinates.js.map +1 -0
- package/lib/parallel/ui/ParallelLabels.d.ts +26 -0
- package/lib/parallel/ui/ParallelLabels.d.ts.map +1 -0
- package/lib/parallel/ui/ParallelLabels.js +25 -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 +25 -0
- package/lib/parallel/ui/index.d.ts.map +1 -0
- package/lib/parallel/ui/index.js +18 -0
- package/lib/parallel/ui/index.js.map +1 -0
- package/lib/parallel/ui/parallelCoordinatesProps.d.ts +185 -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 +52 -0
- package/lib/parallel/ui/parallelGestureModel.d.ts.map +1 -0
- package/lib/parallel/ui/parallelGestureModel.js +80 -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 +83 -0
- package/lib/parallel/ui/parallelStyles.d.ts.map +1 -0
- package/lib/parallel/ui/parallelStyles.js +131 -0
- package/lib/parallel/ui/parallelStyles.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 +67 -0
- package/lib/parallel/ui/useParallelGesture.d.ts.map +1 -0
- package/lib/parallel/ui/useParallelGesture.js +139 -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/lib/vite.d.ts +1 -0
- package/lib/vite.d.ts.map +1 -1
- package/lib/vite.js +1 -0
- package/lib/vite.js.map +1 -1
- package/package.json +2 -1
- package/src/about/core/about.ts +18 -9
- package/src/about/ui/AboutBuild.tsx +83 -0
- package/src/about/ui/AboutPage.tsx +15 -7
- package/src/about/ui/index.ts +2 -0
- package/src/build/core/buildInfo.ts +48 -0
- package/src/build/core/current.ts +12 -0
- package/src/build/core/index.ts +2 -0
- package/src/build/vite/buildInfo.ts +178 -0
- package/src/build/vite/gitHead.ts +114 -0
- package/src/build/vite/index.ts +8 -0
- package/src/build-info.ts +2 -0
- package/src/core.ts +2 -0
- package/src/credits/core/credits.ts +42 -0
- package/src/ecosystem/core/sites.ts +40 -0
- package/src/ecosystem/core/types.ts +4 -1
- package/src/ecosystem/ui/Wordmark.tsx +22 -7
- package/src/ecosystem/ui/glyphs.tsx +46 -0
- package/src/parallel/core/index.ts +80 -0
- package/src/parallel/core/parallelAxes.ts +207 -0
- package/src/parallel/core/parallelBrush.ts +145 -0
- package/src/parallel/core/parallelExtent.ts +56 -0
- package/src/parallel/core/parallelFilter.ts +94 -0
- package/src/parallel/core/parallelHit.ts +106 -0
- package/src/parallel/core/parallelPaint.ts +231 -0
- package/src/parallel/core/parallelPalette.ts +80 -0
- package/src/parallel/core/parallelTicks.ts +164 -0
- package/src/parallel/core/parallelTypes.ts +147 -0
- package/src/parallel/ui/ParallelAxesLayer.tsx +123 -0
- package/src/parallel/ui/ParallelCoordinates.tsx +233 -0
- package/src/parallel/ui/ParallelLabels.tsx +56 -0
- package/src/parallel/ui/ParallelTooltip.tsx +55 -0
- package/src/parallel/ui/index.ts +50 -0
- package/src/parallel/ui/parallelCoordinatesProps.ts +199 -0
- package/src/parallel/ui/parallelGestureModel.ts +109 -0
- package/src/parallel/ui/parallelInk.ts +182 -0
- package/src/parallel/ui/parallelPlotModel.ts +130 -0
- package/src/parallel/ui/parallelStyles.ts +146 -0
- package/src/parallel/ui/useParallelCanvas.ts +104 -0
- package/src/parallel/ui/useParallelGesture.ts +227 -0
- package/src/structure/ui/useToolbarFloor.ts +27 -22
- package/src/ui.ts +1 -0
- package/src/vite.ts +1 -0
|
@@ -0,0 +1,80 @@
|
|
|
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, } from "../core/parallelBrush.js";
|
|
12
|
+
/**
|
|
13
|
+
* Where an event landed, relative to the top left of the drawing area.
|
|
14
|
+
* @param event - The event, for where on the surface it happened.
|
|
15
|
+
* @returns The position, in pixels from the corner of the drawing area.
|
|
16
|
+
*/
|
|
17
|
+
export function parallelPointOf(event) {
|
|
18
|
+
const position = surfacePosition(event, 0, 0);
|
|
19
|
+
return {
|
|
20
|
+
x: position.x - PARALLEL_MARGIN.left,
|
|
21
|
+
y: position.y - PARALLEL_MARGIN.top,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Which axis a press at that horizontal position took hold of.
|
|
26
|
+
* @param x - Pixels from the left of the drawing area.
|
|
27
|
+
* @param axes - The axes, from left to right.
|
|
28
|
+
* @returns The axis's index, or `-1` when the press landed between two of them.
|
|
29
|
+
*/
|
|
30
|
+
export function parallelAxisNear(x, axes) {
|
|
31
|
+
let nearest = -1;
|
|
32
|
+
let nearestDistance = PARALLEL_BRUSH_HALF_WIDTH;
|
|
33
|
+
for (let index = 0; index < axes.length; index++) {
|
|
34
|
+
const axis = axes[index];
|
|
35
|
+
if (axis === undefined)
|
|
36
|
+
continue;
|
|
37
|
+
const distance = Math.abs(x - axis.x);
|
|
38
|
+
if (distance <= nearestDistance) {
|
|
39
|
+
nearestDistance = distance;
|
|
40
|
+
nearest = index;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return nearest;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One axis, by the id a range is keyed on.
|
|
47
|
+
* @param axes - The axes, from left to right.
|
|
48
|
+
* @param axisId - The id to find.
|
|
49
|
+
* @returns The axis, or `undefined` when it is no longer drawn.
|
|
50
|
+
*/
|
|
51
|
+
export function parallelAxisById(axes, axisId) {
|
|
52
|
+
for (const axis of axes) {
|
|
53
|
+
if (axis.id === axisId)
|
|
54
|
+
return axis;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The band to draw on each axis: the one being dragged where there is one, and
|
|
60
|
+
* the interval in force everywhere else.
|
|
61
|
+
* @param axes - The axes, from left to right.
|
|
62
|
+
* @param ranges - The interval each axis keeps, or `null` for none.
|
|
63
|
+
* @param draft - The band being dragged, or `null` when nothing is.
|
|
64
|
+
* @returns The bands, keyed by axis id; an axis with none is left out.
|
|
65
|
+
*/
|
|
66
|
+
export function parallelBandsOf(axes, ranges, draft) {
|
|
67
|
+
const drawn = new Map();
|
|
68
|
+
for (const axis of axes) {
|
|
69
|
+
if (draft !== null && draft.axis === axis.id) {
|
|
70
|
+
drawn.set(axis.id, draft.band);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const range = ranges[axis.id];
|
|
74
|
+
if (range === null || range === undefined)
|
|
75
|
+
continue;
|
|
76
|
+
drawn.set(axis.id, parallelBandOf(range, axis));
|
|
77
|
+
}
|
|
78
|
+
return drawn;
|
|
79
|
+
}
|
|
80
|
+
//# 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,GACf,MAAM,0BAA0B,CAAC;AAWlC;;;;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,CAAC,CAAC,GAAG,eAAe,CAAC,GAAG;KACpC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,CAAS,EACT,IAAmC;IAEnC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC;IACjB,IAAI,eAAe,GAAG,yBAAyB,CAAC;IAChD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAC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|
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":["../../../src/parallel/ui/parallelInk.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,OAAO,KAAK,EAAE,WAAW,EAAE,MA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**
|
|
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;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE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AC5C,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 - The interval 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;AAClE,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,CAMT;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
|
+
/**
|
|
12
|
+
* How many rows the figure draws.
|
|
13
|
+
* @param axes - The axes, whose columns are read.
|
|
14
|
+
* @param count - What the caller insists on, if anything.
|
|
15
|
+
* @returns The count — the shortest column, so no axis is ever read past its
|
|
16
|
+
* own end.
|
|
17
|
+
*/
|
|
18
|
+
export function parallelRowCount(axes, count) {
|
|
19
|
+
if (count !== undefined)
|
|
20
|
+
return Math.max(0, Math.trunc(count));
|
|
21
|
+
let shortest = 0;
|
|
22
|
+
for (let index = 0; index < axes.length; index++) {
|
|
23
|
+
const axis = axes[index];
|
|
24
|
+
if (axis === undefined)
|
|
25
|
+
continue;
|
|
26
|
+
const length = axis.values.length;
|
|
27
|
+
if (index === 0 || length < shortest)
|
|
28
|
+
shortest = length;
|
|
29
|
+
}
|
|
30
|
+
return shortest;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The quantity the lines are coloured by.
|
|
34
|
+
* @param color - The quantity the caller gave outright.
|
|
35
|
+
* @param colorAxis - The id of an axis already drawn, for the common case.
|
|
36
|
+
* @param axes - The axes, to find that id among.
|
|
37
|
+
* @returns The quantity, or `undefined` when the lines all take one ink. An
|
|
38
|
+
* axis named by `colorAxis` lends its own domain as well as its values, so the
|
|
39
|
+
* ramp and the axis beside it read the same range.
|
|
40
|
+
*/
|
|
41
|
+
export function parallelColorOf(color, colorAxis, axes) {
|
|
42
|
+
if (color !== undefined)
|
|
43
|
+
return color;
|
|
44
|
+
if (colorAxis === undefined)
|
|
45
|
+
return undefined;
|
|
46
|
+
for (const axis of axes) {
|
|
47
|
+
if (axis.id !== colorAxis)
|
|
48
|
+
continue;
|
|
49
|
+
const domain = axis.domain;
|
|
50
|
+
if (domain === undefined)
|
|
51
|
+
return { values: axis.values };
|
|
52
|
+
return {
|
|
53
|
+
values: axis.values,
|
|
54
|
+
min: Math.min(domain[0], domain[1]),
|
|
55
|
+
max: Math.max(domain[0], domain[1]),
|
|
56
|
+
logarithmic: axis.scale === 'log',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Whether any axis on the figure carries an interval at all.
|
|
63
|
+
* @param axes - The axes, whose ids the intervals are keyed by.
|
|
64
|
+
* @param ranges - The interval each axis keeps.
|
|
65
|
+
* @returns Whether anything is brushed, which is what decides whether a line
|
|
66
|
+
* is ever drawn in the excluded ink.
|
|
67
|
+
*/
|
|
68
|
+
export function parallelIsBrushed(axes, ranges) {
|
|
69
|
+
for (const axis of axes) {
|
|
70
|
+
const range = ranges[axis.id];
|
|
71
|
+
if (range !== null && range !== undefined)
|
|
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;AAQ7D;;;;;;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,EAAE,KAAK,EAAE,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,IAAI,KAAK,SAAS;YAAE,SAAS;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,MAA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
|
5
|
+
* objects, so a site that never renders one pays nothing and a site that does
|
|
6
|
+
* cannot forget to import a file. The two colours that are not fixed here, the
|
|
7
|
+
* axis ink and the band's, are resolved off the page by `parallelInk.ts` and
|
|
8
|
+
* written onto the elements, so an override applies to the canvas and to the
|
|
9
|
+
* markup alike.
|
|
10
|
+
*/
|
|
11
|
+
import type { CSSProperties } from 'react';
|
|
12
|
+
/** A layer covering the whole figure, stacked over the ones before it. */
|
|
13
|
+
export declare const PARALLEL_LAYER_STYLE: {
|
|
14
|
+
readonly position: "absolute";
|
|
15
|
+
readonly inset: 0;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The block the figure occupies, which every layer is positioned against.
|
|
19
|
+
* @param height - Total height of the figure, in pixels.
|
|
20
|
+
* @returns The wrapper's rules.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parallelFigureStyle(height: number): CSSProperties;
|
|
23
|
+
/**
|
|
24
|
+
* One of the two canvases, stretched over the figure.
|
|
25
|
+
* @param height - Total height of the figure, in pixels.
|
|
26
|
+
* @returns The canvas's rules.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parallelCanvasStyle(height: number): CSSProperties;
|
|
29
|
+
/** The drawing surface the axes, the bands and the pointer target live in. */
|
|
30
|
+
export declare const PARALLEL_SVG_STYLE: {
|
|
31
|
+
readonly display: "block";
|
|
32
|
+
readonly overflow: "visible";
|
|
33
|
+
readonly position: "absolute";
|
|
34
|
+
readonly inset: 0;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The layer the axis names sit in. It is HTML rather than SVG text so that a
|
|
38
|
+
* name can carry a tooltip, and it lets every pointer event through so that a
|
|
39
|
+
* brush started under a name still starts.
|
|
40
|
+
*/
|
|
41
|
+
export declare const PARALLEL_LABELS_STYLE: {
|
|
42
|
+
readonly pointerEvents: "none";
|
|
43
|
+
readonly position: "absolute";
|
|
44
|
+
readonly inset: 0;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* One axis name, centred over its axis and taking the pointer back.
|
|
48
|
+
* @param left - Where the axis stands, in pixels from the figure's left edge.
|
|
49
|
+
* @returns The name's rules.
|
|
50
|
+
*/
|
|
51
|
+
export declare function parallelLabelStyle(left: number): CSSProperties;
|
|
52
|
+
/** One tick written out, tabular so a column of them lines up on the point. */
|
|
53
|
+
export declare const PARALLEL_TICK_LABEL_STYLE: {
|
|
54
|
+
readonly fontSize: 10;
|
|
55
|
+
readonly fontVariantNumeric: "tabular-nums";
|
|
56
|
+
readonly userSelect: "none";
|
|
57
|
+
};
|
|
58
|
+
/** How far a tick mark reaches out of the axis, in pixels. */
|
|
59
|
+
export declare const PARALLEL_TICK_LENGTH = 4;
|
|
60
|
+
/** How far a tick label ends before its axis. */
|
|
61
|
+
export declare const PARALLEL_TICK_LABEL_INSET = 7;
|
|
62
|
+
/**
|
|
63
|
+
* The interval one brush keeps, filled in the site's own colour.
|
|
64
|
+
* @param ink - The colour to fill and outline it in.
|
|
65
|
+
* @returns The band's rules.
|
|
66
|
+
*/
|
|
67
|
+
export declare function parallelBandStyle(ink: string): CSSProperties;
|
|
68
|
+
/**
|
|
69
|
+
* Either edge of a band, drawn so the reader can see it can be dragged.
|
|
70
|
+
* @param ink - The colour to draw it in.
|
|
71
|
+
* @returns The handle's rules.
|
|
72
|
+
*/
|
|
73
|
+
export declare function parallelHandleStyle(ink: string): CSSProperties;
|
|
74
|
+
/** How tall an edge handle is drawn, in pixels. */
|
|
75
|
+
export declare const PARALLEL_HANDLE_HEIGHT = 3;
|
|
76
|
+
/**
|
|
77
|
+
* The card over the row under the pointer.
|
|
78
|
+
* @param left - Where it sits, in pixels from the figure's left edge.
|
|
79
|
+
* @param top - Where it sits, in pixels from its top edge.
|
|
80
|
+
* @returns The card's rules.
|
|
81
|
+
*/
|
|
82
|
+
export declare function parallelTooltipStyle(left: number, top: number): CSSProperties;
|
|
83
|
+
//# sourceMappingURL=parallelStyles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelStyles.d.ts","sourceRoot":"","sources":["../../../src/parallel/ui/parallelStyles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI3C,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB;;;CAGC,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAMjE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAMjE;AAED,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB;;;;;CAIG,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;CAGA,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAY9D;AAED,+EAA+E;AAC/E,eAAO,MAAM,yBAAyB;;;;CAIJ,CAAC;AAEnC,8DAA8D;AAC9D,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,iDAAiD;AACjD,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAO5D;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAE9D;AAED,mDAAmD;AACnD,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa,CAiB7E"}
|