@genome-spy/core 0.18.1 → 0.20.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/dist/index.js +46 -119
- package/dist/schema.json +213 -22
- package/package.json +4 -3
- package/src/data/collector.js +9 -4
- package/src/data/collector.test.js +2 -0
- package/src/data/dataFlow.test.js +2 -0
- package/src/data/flow.test.js +1 -0
- package/src/data/flowNode.test.js +1 -0
- package/src/data/flowOptimizer.js +6 -0
- package/src/data/flowOptimizer.test.js +1 -0
- package/src/data/formats/fasta.test.js +1 -0
- package/src/data/sources/inlineSource.test.js +1 -0
- package/src/data/sources/sequenceSource.test.js +1 -0
- package/src/data/transforms/clone.test.js +1 -0
- package/src/data/transforms/coverage.test.js +1 -0
- package/src/data/transforms/filter.test.js +1 -0
- package/src/data/transforms/flattenDelimited.test.js +1 -0
- package/src/data/transforms/flattenSequence.test.js +1 -0
- package/src/data/transforms/formula.test.js +1 -0
- package/src/data/transforms/identifier.test.js +1 -0
- package/src/data/transforms/pileup.test.js +1 -0
- package/src/data/transforms/project.test.js +1 -0
- package/src/data/transforms/regexExtract.test.js +1 -0
- package/src/data/transforms/regexFold.test.js +1 -0
- package/src/data/transforms/sample.test.js +1 -0
- package/src/data/transforms/stack.test.js +1 -0
- package/src/encoder/accessor.test.js +1 -0
- package/src/encoder/encoder.test.js +1 -0
- package/src/genome/genome.js +14 -2
- package/src/genome/genome.test.js +36 -0
- package/src/genome/scaleIndex.js +3 -2
- package/src/genome/scaleIndex.test.js +23 -6
- package/src/genome/scaleLocus.test.js +1 -0
- package/src/genomeSpy.js +16 -11
- package/src/gl/dataToVertices.js +9 -6
- package/src/gl/includes/common.glsl +3 -3
- package/src/gl/includes/scales.glsl +33 -2
- package/src/gl/point.vertex.glsl +0 -2
- package/src/gl/rule.vertex.glsl +1 -1
- package/src/gl/webGLHelper.js +0 -3
- package/src/marks/mark.js +15 -14
- package/src/scale/glslScaleGenerator.js +56 -17
- package/src/scale/scale.test.js +1 -0
- package/src/scale/ticks.test.js +1 -0
- package/src/spec/scale.d.ts +0 -9
- package/src/spec/title.d.ts +102 -0
- package/src/spec/view.d.ts +6 -4
- package/src/tooltip/dataTooltipHandler.js +3 -2
- package/src/utils/addBaseUrl.test.js +1 -0
- package/src/utils/cloner.test.js +1 -0
- package/src/utils/coalesce.test.js +1 -0
- package/src/utils/concatIterables.test.js +1 -0
- package/src/utils/domainArray.test.js +1 -0
- package/src/utils/indexer.test.js +1 -0
- package/src/utils/iterateNestedMaps.test.js +1 -0
- package/src/utils/kWayMerge.test.js +1 -0
- package/src/utils/layout/flexLayout.js +35 -3
- package/src/utils/layout/flexLayout.test.js +15 -0
- package/src/utils/layout/grid.js +95 -0
- package/src/utils/layout/grid.test.js +71 -0
- package/src/utils/layout/padding.js +13 -0
- package/src/utils/layout/rectangle.js +6 -0
- package/src/utils/layout/rectangle.test.js +1 -0
- package/src/utils/mergeObjects.test.js +1 -0
- package/src/utils/numberExtractor.test.js +1 -0
- package/src/utils/propertyCacher.test.js +1 -0
- package/src/utils/propertyCoalescer.test.js +1 -0
- package/src/utils/reservationMap.test.js +1 -0
- package/src/utils/topK.test.js +1 -0
- package/src/utils/variableTools.test.js +1 -0
- package/src/view/axisResolution.test.js +1 -0
- package/src/view/axisView.js +3 -1
- package/src/view/concatView.js +24 -275
- package/src/view/flowBuilder.test.js +1 -0
- package/src/view/gridView.js +774 -0
- package/src/view/implicitRootView.js +14 -0
- package/src/view/layerView.js +15 -1
- package/src/view/scaleResolution.js +5 -11
- package/src/view/scaleResolution.test.js +1 -0
- package/src/view/title.js +165 -0
- package/src/view/unitView.js +17 -9
- package/src/view/view.js +35 -14
- package/src/view/view.test.js +1 -0
- package/src/view/viewContext.d.ts +6 -1
- package/src/view/viewFactory.test.js +1 -0
- package/src/view/viewUtils.js +1 -93
- package/src/view/zoom.js +89 -0
- package/src/gl/includes/fp64-arithmetic.glsl +0 -187
- package/src/gl/includes/fp64-utils.js +0 -142
- package/src/gl/includes/scales_fp64.glsl +0 -30
- package/src/view/decoratorView.js +0 -513
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Adapted from
|
|
3
|
+
* https://github.com/vega/vega/blob/main/packages/vega-typings/types/spec/title.d.ts
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015-2018, University of Washington Interactive Data Lab
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* BSD-3-Clause License: https://github.com/vega/vega-lite/blob/master/LICENSE
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Align, Baseline, FontStyle, FontWeight } from "./font";
|
|
12
|
+
|
|
13
|
+
export type TitleOrient = "none" | "left" | "right" | "top" | "bottom";
|
|
14
|
+
export type TitleAnchor = null | "start" | "middle" | "end";
|
|
15
|
+
export type TitleFrame = "bounds" | "group";
|
|
16
|
+
|
|
17
|
+
export interface Title {
|
|
18
|
+
/**
|
|
19
|
+
* The title text.
|
|
20
|
+
*/
|
|
21
|
+
text: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A mark style property to apply to the title text mark. If not specified, a default style of `"group-title"` is applied.
|
|
25
|
+
*/
|
|
26
|
+
style?: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The anchor position for placing the title and subtitle text. One of `"start"`, `"middle"`, or `"end"`. For example, with an orientation of top these anchor positions map to a left-, center-, or right-aligned title.
|
|
30
|
+
*/
|
|
31
|
+
anchor?: TitleAnchor;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The reference frame for the anchor position, one of `"bounds"` (to anchor relative to the full bounding box) or `"group"` (to anchor relative to the group width or height).
|
|
35
|
+
*/
|
|
36
|
+
frame?: TitleFrame;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The orthogonal offset in pixels by which to displace the title group from its position along the edge of the chart.
|
|
40
|
+
*/
|
|
41
|
+
offset?: number;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Default title orientation (`"top"`, `"bottom"`, `"left"`, or `"right"`)
|
|
45
|
+
*/
|
|
46
|
+
orient?: TitleOrient;
|
|
47
|
+
|
|
48
|
+
// ---------- Shared Text Properties ----------
|
|
49
|
+
/**
|
|
50
|
+
* Horizontal text alignment for title text. One of `"left"`, `"center"`, or `"right"`.
|
|
51
|
+
*/
|
|
52
|
+
align?: Align;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Angle in degrees of title and subtitle text.
|
|
56
|
+
*/
|
|
57
|
+
angle?: number;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Vertical text baseline for title and subtitle text. One of `"alphabetic"` (default), `"top"`, `"middle"`, or `"bottom"`.
|
|
61
|
+
*/
|
|
62
|
+
baseline?: Baseline;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Delta offset for title and subtitle text x-coordinate.
|
|
66
|
+
*/
|
|
67
|
+
dx?: number;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Delta offset for title and subtitle text y-coordinate.
|
|
71
|
+
*/
|
|
72
|
+
dy?: number;
|
|
73
|
+
|
|
74
|
+
// ---------- Title Text ----------
|
|
75
|
+
/**
|
|
76
|
+
* Text color for title text.
|
|
77
|
+
*/
|
|
78
|
+
color?: string;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Font name for title text.
|
|
82
|
+
*/
|
|
83
|
+
font?: string;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Font size in pixels for title text.
|
|
87
|
+
*
|
|
88
|
+
* @minimum 0
|
|
89
|
+
*/
|
|
90
|
+
fontSize?: number;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Font style for title text.
|
|
94
|
+
*/
|
|
95
|
+
fontStyle?: FontStyle;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Font weight for title text.
|
|
99
|
+
* This can be either a string (e.g `"bold"`, `"normal"`) or a number (`100`, `200`, `300`, ..., `900` where `"normal"` = `400` and `"bold"` = `700`).
|
|
100
|
+
*/
|
|
101
|
+
fontWeight?: FontWeight;
|
|
102
|
+
}
|
package/src/spec/view.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
MarkType,
|
|
15
15
|
RectProps,
|
|
16
16
|
} from "./mark";
|
|
17
|
+
import { Title } from "./title";
|
|
17
18
|
|
|
18
19
|
export interface SizeDef {
|
|
19
20
|
/** Size in pixels */
|
|
@@ -55,7 +56,7 @@ export type Paddings = Partial<Record<Side, number>>;
|
|
|
55
56
|
|
|
56
57
|
export type PaddingConfig = Paddings | number;
|
|
57
58
|
|
|
58
|
-
export interface
|
|
59
|
+
export interface ViewBackground extends RectProps, FillAndStrokeProps {
|
|
59
60
|
// TODO: style?: string | string[];
|
|
60
61
|
|
|
61
62
|
// TODO: Move to FillAndStrokeProps or something
|
|
@@ -78,7 +79,7 @@ export interface ViewSpecBase extends ResolveSpec {
|
|
|
78
79
|
data?: Data;
|
|
79
80
|
transform?: TransformParams[];
|
|
80
81
|
encoding?: Encoding;
|
|
81
|
-
title?: string;
|
|
82
|
+
title?: string | Title;
|
|
82
83
|
|
|
83
84
|
/**
|
|
84
85
|
* A description of the view. Multiple lines can be provided as an array.
|
|
@@ -115,7 +116,7 @@ export interface ViewSpecBase extends ResolveSpec {
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
export interface UnitSpec extends ViewSpecBase, AggregateSamplesSpec {
|
|
118
|
-
view?:
|
|
119
|
+
view?: ViewBackground;
|
|
119
120
|
mark: MarkType | MarkConfigAndType;
|
|
120
121
|
}
|
|
121
122
|
|
|
@@ -125,7 +126,7 @@ export interface AggregateSamplesSpec {
|
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
export interface LayerSpec extends ViewSpecBase, AggregateSamplesSpec {
|
|
128
|
-
view?:
|
|
129
|
+
view?: ViewBackground;
|
|
129
130
|
layer: (LayerSpec | UnitSpec)[];
|
|
130
131
|
}
|
|
131
132
|
|
|
@@ -218,4 +219,5 @@ export interface HConcatSpec extends ConcatBase {
|
|
|
218
219
|
|
|
219
220
|
export interface ConcatSpec extends ConcatBase {
|
|
220
221
|
concat: (ViewSpec | ImportSpec)[];
|
|
222
|
+
columns: number;
|
|
221
223
|
}
|
|
@@ -47,10 +47,11 @@ export default async function dataTooltipHandler(datum, mark, params) {
|
|
|
47
47
|
</table>
|
|
48
48
|
`;
|
|
49
49
|
|
|
50
|
-
const
|
|
50
|
+
const titleText = mark.unitView.getTitleText();
|
|
51
|
+
const title = titleText
|
|
51
52
|
? html`
|
|
52
53
|
<div class="title">
|
|
53
|
-
<strong>${
|
|
54
|
+
<strong>${titleText}</strong>
|
|
54
55
|
</div>
|
|
55
56
|
`
|
|
56
57
|
: "";
|
package/src/utils/cloner.test.js
CHANGED
|
@@ -133,7 +133,7 @@ export function mapToPixelCoords(
|
|
|
133
133
|
/**
|
|
134
134
|
* Returns the minimum size (the sum of pixels sizes) for the flex items
|
|
135
135
|
*
|
|
136
|
-
* @param {SizeDef
|
|
136
|
+
* @param {Iterable<SizeDef>} items
|
|
137
137
|
* @param {FlexOptions} [options]
|
|
138
138
|
*/
|
|
139
139
|
export function getMinimumSize(items, { spacing } = { spacing: 0 }) {
|
|
@@ -144,6 +144,21 @@ export function getMinimumSize(items, { spacing } = { spacing: 0 }) {
|
|
|
144
144
|
return Math.max(0, minimumSize - spacing);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* @param {Iterable<SizeDef>} items
|
|
149
|
+
* @returns {SizeDef}
|
|
150
|
+
*/
|
|
151
|
+
export function getLargestSize(items) {
|
|
152
|
+
let px = 0;
|
|
153
|
+
let grow = 0;
|
|
154
|
+
for (const s of items) {
|
|
155
|
+
px = Math.max(px, s.px ?? 0);
|
|
156
|
+
grow = Math.max(grow, s.grow ?? 0);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return { px, grow };
|
|
160
|
+
}
|
|
161
|
+
|
|
147
162
|
/**
|
|
148
163
|
* Returns true if relative (stretching) elements are present
|
|
149
164
|
* @param {SizeDef[]} items
|
|
@@ -172,13 +187,30 @@ export class FlexDimensions {
|
|
|
172
187
|
* @param {import("./padding").default} padding
|
|
173
188
|
*/
|
|
174
189
|
addPadding(padding) {
|
|
190
|
+
return this.#addPx(padding.width, padding.height);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Subtracts padding from absolute (px) dimensions
|
|
195
|
+
*
|
|
196
|
+
* @param {import("./padding").default} padding
|
|
197
|
+
*/
|
|
198
|
+
subtractPadding(padding) {
|
|
199
|
+
return this.#addPx(-padding.width, -padding.height);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* @param {number} width
|
|
204
|
+
* @param {number} height
|
|
205
|
+
*/
|
|
206
|
+
#addPx(width, height) {
|
|
175
207
|
return new FlexDimensions(
|
|
176
208
|
{
|
|
177
|
-
px: (this.width.px
|
|
209
|
+
px: (this.width.px ?? 0) + width,
|
|
178
210
|
grow: this.width.grow,
|
|
179
211
|
},
|
|
180
212
|
{
|
|
181
|
-
px: (this.height.px
|
|
213
|
+
px: (this.height.px ?? 0) + height,
|
|
182
214
|
grow: this.height.grow,
|
|
183
215
|
}
|
|
184
216
|
);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
1
2
|
import {
|
|
2
3
|
mapToPixelCoords,
|
|
3
4
|
getMinimumSize,
|
|
5
|
+
getLargestSize,
|
|
4
6
|
isStretching,
|
|
5
7
|
parseSizeDef,
|
|
6
8
|
} from "./flexLayout";
|
|
@@ -289,6 +291,19 @@ describe("Utility fuctions", () => {
|
|
|
289
291
|
expect(getMinimumSize(items, { spacing: 10 })).toEqual(330);
|
|
290
292
|
});
|
|
291
293
|
|
|
294
|
+
test("getLargestSize", () => {
|
|
295
|
+
const items = [
|
|
296
|
+
{ px: 100 },
|
|
297
|
+
{ px: 0, grow: 0 },
|
|
298
|
+
{ grow: 1 },
|
|
299
|
+
{ grow: 9 },
|
|
300
|
+
{ px: 200 },
|
|
301
|
+
{ px: 50 },
|
|
302
|
+
];
|
|
303
|
+
|
|
304
|
+
expect(getLargestSize(items)).toEqual({ px: 200, grow: 9 });
|
|
305
|
+
});
|
|
306
|
+
|
|
292
307
|
test("isStretching", () => {
|
|
293
308
|
expect(isStretching([{ grow: 1 }])).toBeTruthy();
|
|
294
309
|
expect(isStretching([{ px: 1 }])).toBeFalsy();
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An utility class for indexing cells in a wrapping grid layout
|
|
3
|
+
*/
|
|
4
|
+
export default class Grid {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {number} nChildren
|
|
8
|
+
* @param {number} [maxCols]
|
|
9
|
+
*/
|
|
10
|
+
constructor(nChildren, maxCols) {
|
|
11
|
+
this.n = nChildren;
|
|
12
|
+
this.maxCols = maxCols ?? Infinity;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get nRows() {
|
|
16
|
+
return this.maxCols == Infinity ? 1 : Math.ceil(this.n / this.maxCols);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get nCols() {
|
|
20
|
+
return Math.min(this.n, this.maxCols);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get rowIndices() {
|
|
24
|
+
/** @type {number[][]} */
|
|
25
|
+
const rows = [];
|
|
26
|
+
|
|
27
|
+
const nCols = this.nCols;
|
|
28
|
+
const nRows = this.nRows;
|
|
29
|
+
|
|
30
|
+
for (let row = 0; row < nRows; row++) {
|
|
31
|
+
/** @type {number[]} */
|
|
32
|
+
const arr = [];
|
|
33
|
+
rows.push(arr);
|
|
34
|
+
for (let col = 0; col < nCols; col++) {
|
|
35
|
+
const i = row * nCols + col;
|
|
36
|
+
if (i < this.n) {
|
|
37
|
+
arr.push(i);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return rows;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get colIndices() {
|
|
45
|
+
/** @type {number[][]} */
|
|
46
|
+
const cols = [];
|
|
47
|
+
|
|
48
|
+
const nCols = this.nCols;
|
|
49
|
+
const nRows = this.nRows;
|
|
50
|
+
|
|
51
|
+
for (let col = 0; col < nCols; col++) {
|
|
52
|
+
/** @type {number[]} */
|
|
53
|
+
const arr = [];
|
|
54
|
+
cols.push(arr);
|
|
55
|
+
for (let row = 0; row < nRows; row++) {
|
|
56
|
+
const i = row * nCols + col;
|
|
57
|
+
if (i < this.n) {
|
|
58
|
+
arr.push(i);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return cols;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @param {number} col
|
|
67
|
+
* @param {number} row
|
|
68
|
+
*/
|
|
69
|
+
getCellIndex(col, row) {
|
|
70
|
+
let i = 0;
|
|
71
|
+
|
|
72
|
+
if (this.maxCols == Infinity) {
|
|
73
|
+
i = row == 0 ? col : undefined;
|
|
74
|
+
} else if (col >= this.maxCols) {
|
|
75
|
+
return undefined;
|
|
76
|
+
} else {
|
|
77
|
+
i = row * this.nCols + col;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return i < this.n ? i : undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* @param {number} index
|
|
86
|
+
* @returns {[number, number]}
|
|
87
|
+
*/
|
|
88
|
+
getCellCoords(index) {
|
|
89
|
+
if (index < 0 || index >= this.n) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return [index % this.nCols, Math.floor(index / this.nCols)];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { expect, test, describe } from "vitest";
|
|
2
|
+
|
|
3
|
+
import Grid from "./grid";
|
|
4
|
+
|
|
5
|
+
describe("Grid indexing", () => {
|
|
6
|
+
test("Single row", () => {
|
|
7
|
+
const g = new Grid(3);
|
|
8
|
+
|
|
9
|
+
expect(g.maxCols).toEqual(Infinity);
|
|
10
|
+
expect(g.nCols).toEqual(3);
|
|
11
|
+
expect(g.nRows).toEqual(1);
|
|
12
|
+
expect(g.colIndices).toEqual([[0], [1], [2]]);
|
|
13
|
+
expect(g.rowIndices).toEqual([[0, 1, 2]]);
|
|
14
|
+
expect(g.getCellIndex(1, 0)).toEqual(1);
|
|
15
|
+
expect(g.getCellIndex(1, 1)).toBeUndefined();
|
|
16
|
+
expect(g.getCellCoords(1)).toEqual([1, 0]);
|
|
17
|
+
expect(g.getCellCoords(-1)).toBeUndefined();
|
|
18
|
+
expect(g.getCellCoords(3)).toBeUndefined();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("Single column", () => {
|
|
22
|
+
const g = new Grid(3, 1);
|
|
23
|
+
|
|
24
|
+
expect(g.maxCols).toEqual(1);
|
|
25
|
+
expect(g.nCols).toEqual(1);
|
|
26
|
+
expect(g.nRows).toEqual(3);
|
|
27
|
+
expect(g.colIndices).toEqual([[0, 1, 2]]);
|
|
28
|
+
expect(g.rowIndices).toEqual([[0], [1], [2]]);
|
|
29
|
+
expect(g.getCellIndex(0, 1)).toEqual(1);
|
|
30
|
+
expect(g.getCellIndex(1, 1)).toBeUndefined();
|
|
31
|
+
expect(g.getCellCoords(1)).toEqual([0, 1]);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("Two columns", () => {
|
|
35
|
+
const g = new Grid(6, 2);
|
|
36
|
+
|
|
37
|
+
expect(g.maxCols).toEqual(2);
|
|
38
|
+
expect(g.nCols).toEqual(2);
|
|
39
|
+
expect(g.nRows).toEqual(3);
|
|
40
|
+
expect(g.colIndices).toEqual([
|
|
41
|
+
[0, 2, 4],
|
|
42
|
+
[1, 3, 5],
|
|
43
|
+
]);
|
|
44
|
+
expect(g.rowIndices).toEqual([
|
|
45
|
+
[0, 1],
|
|
46
|
+
[2, 3],
|
|
47
|
+
[4, 5],
|
|
48
|
+
]);
|
|
49
|
+
expect(g.getCellIndex(1, 0)).toEqual(1);
|
|
50
|
+
expect(g.getCellIndex(0, 1)).toEqual(2);
|
|
51
|
+
expect(g.getCellIndex(1, 1)).toEqual(3);
|
|
52
|
+
expect(g.getCellCoords(3)).toEqual([1, 1]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("Two columns, second is partial", () => {
|
|
56
|
+
const g = new Grid(5, 2);
|
|
57
|
+
|
|
58
|
+
expect(g.maxCols).toEqual(2);
|
|
59
|
+
expect(g.nCols).toEqual(2);
|
|
60
|
+
expect(g.nRows).toEqual(3);
|
|
61
|
+
expect(g.colIndices).toEqual([
|
|
62
|
+
[0, 2, 4],
|
|
63
|
+
[1, 3],
|
|
64
|
+
]);
|
|
65
|
+
expect(g.rowIndices).toEqual([[0, 1], [2, 3], [4]]);
|
|
66
|
+
expect(g.getCellIndex(1, 0)).toEqual(1);
|
|
67
|
+
expect(g.getCellIndex(0, 1)).toEqual(2);
|
|
68
|
+
expect(g.getCellIndex(1, 2)).toBeUndefined();
|
|
69
|
+
expect(g.getCellCoords(3)).toEqual([1, 1]);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -61,6 +61,19 @@ export default class Padding {
|
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param {Padding} padding padding to subtract
|
|
67
|
+
*/
|
|
68
|
+
subtract(padding) {
|
|
69
|
+
return new Padding(
|
|
70
|
+
this.top - padding.top,
|
|
71
|
+
this.right - padding.right,
|
|
72
|
+
this.bottom - padding.bottom,
|
|
73
|
+
this.left - padding.left
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
64
77
|
/**
|
|
65
78
|
*
|
|
66
79
|
* @param {PaddingConfig} config
|
|
@@ -31,6 +31,8 @@ export default class Rectangle {
|
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
static ZERO = Rectangle.create(0, 0, 0, 0);
|
|
35
|
+
|
|
34
36
|
/**
|
|
35
37
|
* @param {Prop} prop
|
|
36
38
|
* @param {number | function():number} value
|
|
@@ -279,4 +281,8 @@ export default class Rectangle {
|
|
|
279
281
|
y: (y - this.y) / this.height,
|
|
280
282
|
};
|
|
281
283
|
}
|
|
284
|
+
|
|
285
|
+
toString() {
|
|
286
|
+
return `Rectangle: x: ${this.x}, y: ${this.y}, width: ${this.width}, height: ${this.height}`;
|
|
287
|
+
}
|
|
282
288
|
}
|
package/src/utils/topK.test.js
CHANGED
package/src/view/axisView.js
CHANGED
|
@@ -31,7 +31,7 @@ function getPerpendicularChannel(channel) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/** @type {Record<PositionalChannel, AxisOrient[]>} */
|
|
34
|
-
const CHANNEL_ORIENTS = {
|
|
34
|
+
export const CHANNEL_ORIENTS = {
|
|
35
35
|
x: ["bottom", "top"],
|
|
36
36
|
y: ["left", "right"],
|
|
37
37
|
};
|
|
@@ -120,6 +120,8 @@ export default class AxisView extends LayerView {
|
|
|
120
120
|
this.findChildByName(CHROM_LAYER_NAME).getDynamicDataSource = () =>
|
|
121
121
|
new DynamicCallbackSource(() => genome.chromosomes);
|
|
122
122
|
}
|
|
123
|
+
|
|
124
|
+
this.blockEncodingInheritance = true;
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
getOrient() {
|