@jbrowse/display-ui 5.0.0-beta.8 → 5.0.0-beta.9

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.
Files changed (49) hide show
  1. package/README.md +24 -14
  2. package/esm/AxisCaption.d.ts +24 -0
  3. package/esm/AxisCaption.js +57 -0
  4. package/esm/AxisGutter.d.ts +3 -3
  5. package/esm/AxisGutter.js +6 -16
  6. package/esm/FloatingLegend.d.ts +0 -1
  7. package/esm/FloatingLegend.js +16 -8
  8. package/esm/ScoreDomainCaption.d.ts +4 -3
  9. package/esm/ScoreDomainCaption.js +6 -5
  10. package/esm/ScoreRules.js +1 -1
  11. package/esm/YScaleBar.js +2 -1
  12. package/esm/YScaleBarOverlay.js +2 -3
  13. package/esm/axisPlacement.d.ts +23 -4
  14. package/esm/axisPlacement.js +42 -7
  15. package/esm/bottomRightCorner.d.ts +3 -4
  16. package/esm/bottomRightCorner.js +3 -4
  17. package/esm/chromeOverlayContext.d.ts +1 -1
  18. package/esm/chromeOverlayContext.js +4 -5
  19. package/esm/chromeOverlays.d.ts +4 -2
  20. package/esm/embed/index.d.ts +70 -0
  21. package/esm/embed/index.js +69 -0
  22. package/esm/embed/legend.d.ts +8 -0
  23. package/esm/embed/legend.js +35 -0
  24. package/esm/embed/location.d.ts +17 -0
  25. package/esm/embed/location.js +65 -0
  26. package/esm/embed/provider.d.ts +11 -0
  27. package/esm/embed/provider.js +6 -0
  28. package/esm/embed/regions.d.ts +53 -0
  29. package/esm/embed/regions.js +95 -0
  30. package/esm/floatingLegendTop.d.ts +1 -0
  31. package/esm/floatingLegendTop.js +2 -0
  32. package/esm/index.d.ts +8 -6
  33. package/esm/index.js +7 -5
  34. package/esm/plainChromeOverlays.d.ts +1 -1
  35. package/esm/plainChromeOverlays.js +5 -5
  36. package/esm/tooltip/Tooltip.d.ts +3 -3
  37. package/esm/tooltip/Tooltip.js +3 -3
  38. package/esm/trackControl/trackControlContext.d.ts +1 -1
  39. package/esm/trackControl/trackControlContext.js +6 -6
  40. package/esm/trackOverlay/TrackOverlaySlot.d.ts +2 -2
  41. package/esm/trackOverlay/TrackOverlaySlot.js +2 -2
  42. package/esm/valueScale.d.ts +22 -2
  43. package/esm/yAxisConstants.d.ts +6 -0
  44. package/esm/yAxisConstants.js +14 -0
  45. package/esm/yScaleTicks.d.ts +2 -1
  46. package/esm/yScaleTicks.js +2 -1
  47. package/package.json +7 -4
  48. package/esm/formatScore.d.ts +0 -1
  49. package/esm/formatScore.js +0 -14
@@ -1,5 +1,18 @@
1
+ import type { ScoreRuleMark } from './ScoreRules.tsx';
1
2
  import type { YScaleTicks } from './yScaleTicks.ts';
2
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
+ }
3
16
  /**
4
17
  * #api
5
18
  * A value scale a display places its y through, declared so the chrome can
@@ -23,7 +36,9 @@ export type AxisSide = 'left' | 'right';
23
36
  * edges the display's own panels leave clear for a gutter: `right` where a
24
37
  * group label chip takes the left, `left: n` where a dendrogram takes the
25
38
  * first `n` px. `caption` is what the scale measures (`TLEN`), as a colour
26
- * scale's `field` is.
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, which the chrome draws across every band.
27
42
  *
28
43
  * A member describes the scale or the band it rules, never the axis — not an
29
44
  * orientation, a form, a gutter width or a font. The chrome reads a member to
@@ -42,9 +57,14 @@ export interface ValueScale {
42
57
  side?: AxisSide;
43
58
  left?: number;
44
59
  caption?: string;
60
+ rules?: readonly ValueScaleRule[];
45
61
  }
46
- /** A value scale whose ticks resolved: what the chrome draws. */
62
+ /**
63
+ * A value scale whose ticks resolved: what the chrome draws. `ruleMarks` are
64
+ * its `rules` inside the domain, each at its y in the band's pixel space.
65
+ */
47
66
  export interface YAxis extends ValueScale {
48
67
  domain: [number, number];
49
68
  ticks: YScaleTicks;
69
+ ruleMarks?: ScoreRuleMark[];
50
70
  }
@@ -1 +1,7 @@
1
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)";
@@ -3,3 +3,17 @@
3
3
  // (which re-exports computeYTicks) and computeYTicks.ts need it — importing it
4
4
  // from index.ts would close a cycle.
5
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)';
@@ -31,7 +31,8 @@ export declare function axisPlotBox(height: number, offset?: number): {
31
31
  export declare function scoreToAxisY(normalized: number, box: ReturnType<typeof axisPlotBox>): number;
32
32
  /**
33
33
  * Width of the gutter an axis is drawn in, on screen and in the export
34
- * margin alike. `YScaleBar` grows its ticks and numbers away from the spine,
34
+ * margin alike, unless a caption beside wide labels grows it
35
+ * (`axisGutterWidth`). `YScaleBar` grows its ticks and numbers away from the spine,
35
36
  * and `x = ±9`, `fontSize 10` put a label of ordinary width inside this many
36
37
  * px; the alignments coverage axis and the MAF band axes had each arrived at
37
38
  * the same number independently, so a change to the labels moved neither.
@@ -27,7 +27,8 @@ export function scoreToAxisY(normalized, box) {
27
27
  }
28
28
  /**
29
29
  * Width of the gutter an axis is drawn in, on screen and in the export
30
- * margin alike. `YScaleBar` grows its ticks and numbers away from the spine,
30
+ * margin alike, unless a caption beside wide labels grows it
31
+ * (`axisGutterWidth`). `YScaleBar` grows its ticks and numbers away from the spine,
31
32
  * and `x = ±9`, `fontSize 10` put a label of ordinary width inside this many
32
33
  * px; the alignments coverage axis and the MAF band axes had each arrived at
33
34
  * the same number independently, so a change to the labels moved neither.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/display-ui",
3
- "version": "5.0.0-beta.8",
3
+ "version": "5.0.0-beta.9",
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": [
@@ -20,15 +20,18 @@
20
20
  "main": "esm/index.js",
21
21
  "exports": {
22
22
  ".": "./esm/index.js",
23
- "./yAxisConstants": "./esm/yAxisConstants.js"
23
+ "./axisPlacement": "./esm/axisPlacement.js",
24
+ "./embed": "./esm/embed/index.js",
25
+ "./yAxisConstants": "./esm/yAxisConstants.js",
26
+ "./yScaleTicks": "./esm/yScaleTicks.js"
24
27
  },
25
28
  "files": [
26
29
  "esm"
27
30
  ],
28
31
  "dependencies": {
29
- "@jbrowse/mobx-state-tree": "^6.5.1",
32
+ "@jbrowse/mobx-state-tree": "^6.5.2",
30
33
  "mobx-react": "^10.0.2",
31
- "@jbrowse/core": "^5.0.0-beta.8"
34
+ "@jbrowse/core": "^5.0.0-beta.9"
32
35
  },
33
36
  "peerDependencies": {
34
37
  "react": ">=19.0.0",
@@ -1 +0,0 @@
1
- export declare function formatScore(n: number): string;
@@ -1,14 +0,0 @@
1
- // Only the fractional padding toPrecision adds is noise; guard on the decimal
2
- // point because toPrecision can round UP out of the fractional form entirely —
3
- // 99.95 comes back as "100", where an unguarded trailing-zero strip eats two
4
- // significant digits and reports the score as 1.
5
- export function formatScore(n) {
6
- if (n === 0) {
7
- return '0';
8
- }
9
- if (Math.abs(n) >= 100) {
10
- return n.toFixed(0);
11
- }
12
- const s = n.toPrecision(3);
13
- return s.includes('.') ? s.replace(/\.?0+$/, '') : s;
14
- }