@jbrowse/display-ui 4.3.0 → 5.0.0-beta.10
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 +53 -13
- package/esm/AxisCaption.d.ts +24 -0
- package/esm/AxisCaption.js +57 -0
- package/esm/AxisGutter.d.ts +12 -0
- package/esm/AxisGutter.js +15 -0
- package/esm/CrossHatches.d.ts +12 -0
- package/esm/CrossHatches.js +31 -0
- package/esm/FloatingLegend.d.ts +4 -6
- package/esm/FloatingLegend.js +93 -29
- package/esm/FloatingSvgOverlay.d.ts +5 -0
- package/esm/FloatingSvgOverlay.js +25 -0
- package/esm/FloatingText.d.ts +50 -0
- package/esm/FloatingText.js +48 -0
- package/esm/PointerLayer.d.ts +12 -18
- package/esm/PointerLayer.js +14 -20
- package/esm/ScoreDomainCaption.d.ts +15 -0
- package/esm/ScoreDomainCaption.js +23 -0
- package/esm/ScoreRules.d.ts +21 -0
- package/esm/ScoreRules.js +46 -0
- package/esm/YScaleBar.d.ts +6 -0
- package/esm/YScaleBar.js +47 -0
- package/esm/YScaleBarOverlay.d.ts +11 -0
- package/esm/YScaleBarOverlay.js +20 -0
- package/esm/axisPlacement.d.ts +44 -0
- package/esm/axisPlacement.js +70 -0
- package/esm/bottomRightCorner.d.ts +3 -4
- package/esm/bottomRightCorner.js +3 -4
- package/esm/chromeOverlayContext.d.ts +1 -1
- package/esm/chromeOverlayContext.js +4 -5
- package/esm/chromeOverlays.d.ts +4 -2
- package/esm/cullOverlappingLabels.d.ts +14 -0
- package/esm/cullOverlappingLabels.js +31 -0
- package/esm/embed/index.d.ts +70 -0
- package/esm/embed/index.js +72 -0
- package/esm/embed/legend.d.ts +10 -0
- package/esm/embed/legend.js +40 -0
- package/esm/embed/location.d.ts +17 -0
- package/esm/embed/location.js +65 -0
- package/esm/embed/provider.d.ts +11 -0
- package/esm/embed/provider.js +6 -0
- package/esm/embed/regions.d.ts +53 -0
- package/esm/embed/regions.js +95 -0
- package/esm/floatingLegendTop.d.ts +2 -0
- package/esm/floatingLegendTop.js +3 -0
- package/esm/index.d.ts +19 -0
- package/esm/index.js +24 -0
- package/esm/plainChromeOverlays.d.ts +1 -1
- package/esm/plainChromeOverlays.js +6 -6
- package/esm/tooltip/Tooltip.d.ts +3 -3
- package/esm/tooltip/Tooltip.js +3 -3
- package/esm/trackControl/trackControlContext.d.ts +1 -1
- package/esm/trackControl/trackControlContext.js +6 -6
- package/esm/trackOverlay/TrackOverlaySlot.d.ts +2 -2
- package/esm/trackOverlay/TrackOverlaySlot.js +2 -2
- package/esm/valueScale.d.ts +72 -0
- package/esm/valueScale.js +1 -0
- package/esm/yAxisConstants.d.ts +7 -0
- package/esm/yAxisConstants.js +19 -0
- package/esm/yScaleTicks.d.ts +49 -0
- package/esm/yScaleTicks.js +47 -0
- package/package.json +11 -7
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ScoreRuleMark } from './ScoreRules.tsx';
|
|
2
|
+
import type { YScaleTicks } from './yScaleTicks.ts';
|
|
3
|
+
export type AxisSide = 'left' | 'right';
|
|
4
|
+
/**
|
|
5
|
+
* #api
|
|
6
|
+
* One reference line a value scale declares, at a value in the scale's own
|
|
7
|
+
* units. `label` is free text and carries no meaning the chrome assigns: over
|
|
8
|
+
* a coverage plot "2 copies" is a claim only the author can make, since no
|
|
9
|
+
* ploidy can be assumed.
|
|
10
|
+
*/
|
|
11
|
+
export interface ValueScaleRule {
|
|
12
|
+
value: number;
|
|
13
|
+
color?: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* #api
|
|
18
|
+
* A value scale a display places its y through, declared so the chrome can
|
|
19
|
+
* derive the axis from it — the score axis's counterpart to a colour scale.
|
|
20
|
+
*
|
|
21
|
+
* `domain` is the resolved `[min, max]`; `height` the band it rules and
|
|
22
|
+
* `offset` the inset of the plot box inside that band (`axisPlotBox(height,
|
|
23
|
+
* offset)`); `minimalTicks` and `symlogConstant` how the ticks are chosen.
|
|
24
|
+
* `ticks` is the display's own ladder where the band's arithmetic is its own
|
|
25
|
+
* (the coverage band's octaves against the shader's box, the read cloud's
|
|
26
|
+
* decades against the arc geometry); `ScoreScaleMixin` derives one through
|
|
27
|
+
* `computeYTicks` otherwise.
|
|
28
|
+
*
|
|
29
|
+
* `bandTops` is the screen y of each band the scale rules — one at 0 unless
|
|
30
|
+
* the display stacks the same plot: the multi-wiggle's rows, a grouped
|
|
31
|
+
* alignments track's coverage band per group, each projected through the
|
|
32
|
+
* display's own scroll; the chrome drops the ones off screen. `[]` is a scale
|
|
33
|
+
* the display maps to colour rather than to y (density rows each in their own
|
|
34
|
+
* colour), which gets the `[min, max]` caption and no axis, as a scale whose
|
|
35
|
+
* bands are too short for one does. `side` and `left` are which of the band's
|
|
36
|
+
* edges the display's own panels leave clear for a gutter: `right` where a
|
|
37
|
+
* group label chip takes the left, `left: n` where a dendrogram takes the
|
|
38
|
+
* first `n` px. `caption` is what the scale measures (`TLEN`), as a colour
|
|
39
|
+
* scale's `field` is; the chrome draws it once for the scale, beside the
|
|
40
|
+
* bands on screen, however many it rules. `rules` are the reference lines the
|
|
41
|
+
* scale declares and `grid` a line at every tick, both drawn across every
|
|
42
|
+
* band.
|
|
43
|
+
*
|
|
44
|
+
* A member describes the scale or the band it rules, never the axis — not an
|
|
45
|
+
* orientation, a form, a gutter width or a font. The chrome reads a member to
|
|
46
|
+
* keep off what the display put in the band, never to choose between two
|
|
47
|
+
* drawings of it (ADR-109).
|
|
48
|
+
*/
|
|
49
|
+
export interface ValueScale {
|
|
50
|
+
domain: [number, number] | undefined;
|
|
51
|
+
scaleType: string;
|
|
52
|
+
height: number;
|
|
53
|
+
offset?: number;
|
|
54
|
+
minimalTicks?: boolean;
|
|
55
|
+
symlogConstant?: number;
|
|
56
|
+
ticks?: YScaleTicks;
|
|
57
|
+
bandTops?: number[];
|
|
58
|
+
side?: AxisSide;
|
|
59
|
+
left?: number;
|
|
60
|
+
caption?: string;
|
|
61
|
+
rules?: readonly ValueScaleRule[];
|
|
62
|
+
grid?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A value scale whose ticks resolved: what the chrome draws. `ruleMarks` are
|
|
66
|
+
* its `rules` inside the domain, each at its y in the band's pixel space.
|
|
67
|
+
*/
|
|
68
|
+
export interface YAxis extends ValueScale {
|
|
69
|
+
domain: [number, number];
|
|
70
|
+
ticks: YScaleTicks;
|
|
71
|
+
ruleMarks?: ScoreRuleMark[];
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const YSCALEBAR_LABEL_OFFSET = 5;
|
|
2
|
+
export declare const AXIS_FONT_PX = 10;
|
|
3
|
+
export declare const TICK_LABEL_X_PX = 9;
|
|
4
|
+
export declare const CAPTION_INSET_PX = 8;
|
|
5
|
+
export declare const CAPTION_BAND_PX = 13;
|
|
6
|
+
export declare const SCORE_CAPTION_HEIGHT = 16;
|
|
7
|
+
export declare const DEFAULT_RULE_COLOR = "rgb(120,120,120)";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Vertical inset a plot box reserves above and below itself so the top and
|
|
2
|
+
// bottom y-axis labels aren't clipped. Its own module because both index.ts
|
|
3
|
+
// (which re-exports computeYTicks) and computeYTicks.ts need it — importing it
|
|
4
|
+
// from index.ts would close a cycle.
|
|
5
|
+
export const YSCALEBAR_LABEL_OFFSET = 5;
|
|
6
|
+
// A tick label's font size and how far from the spine it ends, and a
|
|
7
|
+
// caption's font size.
|
|
8
|
+
export const AXIS_FONT_PX = 10;
|
|
9
|
+
export const TICK_LABEL_X_PX = 9;
|
|
10
|
+
// How far in from its gutter's outer edge a caption's rotated baseline sits,
|
|
11
|
+
// and the outer band of the gutter the caption then takes: its glyphs, their
|
|
12
|
+
// halo and a px before the tick labels.
|
|
13
|
+
export const CAPTION_INSET_PX = 8;
|
|
14
|
+
export const CAPTION_BAND_PX = 13;
|
|
15
|
+
// The height one score caption occupies above the plot.
|
|
16
|
+
export const SCORE_CAPTION_HEIGHT = 16;
|
|
17
|
+
// The grey a reference line is drawn in where neither the rule nor its display
|
|
18
|
+
// names another.
|
|
19
|
+
export const DEFAULT_RULE_COLOR = 'rgb(120,120,120)';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface YScaleTicks {
|
|
2
|
+
items: {
|
|
3
|
+
value: number;
|
|
4
|
+
y: number;
|
|
5
|
+
label?: string;
|
|
6
|
+
}[];
|
|
7
|
+
yTop: number;
|
|
8
|
+
yBottom: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The plot box a wiggle-family display insets inside its own height, for both
|
|
12
|
+
* sides of the contract above: the renderer positions its canvas at `yTop` and
|
|
13
|
+
* draws `plotHeight` tall, and the axis puts domain-max at `yTop` and
|
|
14
|
+
* domain-min at `yBottom`.
|
|
15
|
+
*
|
|
16
|
+
* One function because the two have to agree exactly, and `height - 2 * offset`
|
|
17
|
+
* spelled out at each end is how they stopped: `computeYTicks` derived its own
|
|
18
|
+
* bottom as `height - offset - 1`, and every tick above it inherited a fraction
|
|
19
|
+
* of that pixel.
|
|
20
|
+
*/
|
|
21
|
+
export declare function axisPlotBox(height: number, offset?: number): {
|
|
22
|
+
yTop: number;
|
|
23
|
+
yBottom: number;
|
|
24
|
+
plotHeight: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Screen y for an already-normalized ([0,1], 0 at domain-min) score. The
|
|
28
|
+
* composition of {@link axisPlotBox} with a `makeScoreNormalizer` result, which
|
|
29
|
+
* is what a tick at that score must land on.
|
|
30
|
+
*/
|
|
31
|
+
export declare function scoreToAxisY(normalized: number, box: ReturnType<typeof axisPlotBox>): number;
|
|
32
|
+
/**
|
|
33
|
+
* Width of the gutter an axis is drawn in, on screen and in the export
|
|
34
|
+
* margin alike, unless a caption beside wide labels grows it
|
|
35
|
+
* (`axisGutterWidth`). `YScaleBar` grows its ticks and numbers away from the spine,
|
|
36
|
+
* and `x = ±9`, `fontSize 10` put a label of ordinary width inside this many
|
|
37
|
+
* px; the alignments coverage axis and the MAF band axes had each arrived at
|
|
38
|
+
* the same number independently, so a change to the labels moved neither.
|
|
39
|
+
*/
|
|
40
|
+
export declare const AXIS_GUTTER_WIDTH_PX = 50;
|
|
41
|
+
/**
|
|
42
|
+
* Keep a 1px stroke's center inside the axis box. At `yBottom` — the box's own
|
|
43
|
+
* bottom edge — the stroke has to cover the pixel *above* the boundary, since
|
|
44
|
+
* the one below belongs to whatever is drawn next; in multi-wiggle, where rows
|
|
45
|
+
* stack edge to edge, that is literally the next sample's first row of pixels.
|
|
46
|
+
* Callers pass whatever stroke center their own convention gives (the axis
|
|
47
|
+
* crispens to `y + 0.5`, the guide lines don't); only the bottom edge moves.
|
|
48
|
+
*/
|
|
49
|
+
export declare function clampStrokeInsideAxis(strokeY: number, yBottom: number): number;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { YSCALEBAR_LABEL_OFFSET } from './yAxisConstants.js';
|
|
2
|
+
/**
|
|
3
|
+
* The plot box a wiggle-family display insets inside its own height, for both
|
|
4
|
+
* sides of the contract above: the renderer positions its canvas at `yTop` and
|
|
5
|
+
* draws `plotHeight` tall, and the axis puts domain-max at `yTop` and
|
|
6
|
+
* domain-min at `yBottom`.
|
|
7
|
+
*
|
|
8
|
+
* One function because the two have to agree exactly, and `height - 2 * offset`
|
|
9
|
+
* spelled out at each end is how they stopped: `computeYTicks` derived its own
|
|
10
|
+
* bottom as `height - offset - 1`, and every tick above it inherited a fraction
|
|
11
|
+
* of that pixel.
|
|
12
|
+
*/
|
|
13
|
+
export function axisPlotBox(height, offset = YSCALEBAR_LABEL_OFFSET) {
|
|
14
|
+
return {
|
|
15
|
+
yTop: offset,
|
|
16
|
+
yBottom: height - offset,
|
|
17
|
+
plotHeight: height - 2 * offset,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Screen y for an already-normalized ([0,1], 0 at domain-min) score. The
|
|
22
|
+
* composition of {@link axisPlotBox} with a `makeScoreNormalizer` result, which
|
|
23
|
+
* is what a tick at that score must land on.
|
|
24
|
+
*/
|
|
25
|
+
export function scoreToAxisY(normalized, box) {
|
|
26
|
+
return box.yTop + (1 - normalized) * box.plotHeight;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Width of the gutter an axis is drawn in, on screen and in the export
|
|
30
|
+
* margin alike, unless a caption beside wide labels grows it
|
|
31
|
+
* (`axisGutterWidth`). `YScaleBar` grows its ticks and numbers away from the spine,
|
|
32
|
+
* and `x = ±9`, `fontSize 10` put a label of ordinary width inside this many
|
|
33
|
+
* px; the alignments coverage axis and the MAF band axes had each arrived at
|
|
34
|
+
* the same number independently, so a change to the labels moved neither.
|
|
35
|
+
*/
|
|
36
|
+
export const AXIS_GUTTER_WIDTH_PX = 50;
|
|
37
|
+
/**
|
|
38
|
+
* Keep a 1px stroke's center inside the axis box. At `yBottom` — the box's own
|
|
39
|
+
* bottom edge — the stroke has to cover the pixel *above* the boundary, since
|
|
40
|
+
* the one below belongs to whatever is drawn next; in multi-wiggle, where rows
|
|
41
|
+
* stack edge to edge, that is literally the next sample's first row of pixels.
|
|
42
|
+
* Callers pass whatever stroke center their own convention gives (the axis
|
|
43
|
+
* crispens to `y + 0.5`, the guide lines don't); only the bottom edge moves.
|
|
44
|
+
*/
|
|
45
|
+
export function clampStrokeInsideAxis(strokeY, yBottom) {
|
|
46
|
+
return Math.min(strokeY, yBottom - 0.5);
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/display-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-beta.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The UI a display draws that is not data: the swappable chrome contract, its toolkit-free implementations, and the track overlay layer",
|
|
6
6
|
"keywords": [
|
|
@@ -18,13 +18,20 @@
|
|
|
18
18
|
},
|
|
19
19
|
"author": "JBrowse Team",
|
|
20
20
|
"main": "esm/index.js",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./esm/index.js",
|
|
23
|
+
"./axisPlacement": "./esm/axisPlacement.js",
|
|
24
|
+
"./embed": "./esm/embed/index.js",
|
|
25
|
+
"./yAxisConstants": "./esm/yAxisConstants.js",
|
|
26
|
+
"./yScaleTicks": "./esm/yScaleTicks.js"
|
|
27
|
+
},
|
|
21
28
|
"files": [
|
|
22
29
|
"esm"
|
|
23
30
|
],
|
|
24
31
|
"dependencies": {
|
|
25
|
-
"@jbrowse/mobx-state-tree": "^6.
|
|
32
|
+
"@jbrowse/mobx-state-tree": "^6.6.1",
|
|
26
33
|
"mobx-react": "^10.0.2",
|
|
27
|
-
"@jbrowse/core": "^
|
|
34
|
+
"@jbrowse/core": "^5.0.0-beta.10"
|
|
28
35
|
},
|
|
29
36
|
"peerDependencies": {
|
|
30
37
|
"react": ">=19.0.0",
|
|
@@ -41,8 +48,5 @@
|
|
|
41
48
|
"clean": "rimraf esm *.tsbuildinfo",
|
|
42
49
|
"prebuild": "pnpm clean"
|
|
43
50
|
},
|
|
44
|
-
"types": "esm/index.d.ts"
|
|
45
|
-
"exports": {
|
|
46
|
-
".": "./esm/index.js"
|
|
47
|
-
}
|
|
51
|
+
"types": "esm/index.d.ts"
|
|
48
52
|
}
|