gosling.js 2.0.0-alpha.3 → 2.0.0-alpha.4
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/demo/gosling-component.d.ts +4 -1
- package/dist/demo/gosling-component.d.ts.map +1 -1
- package/dist/demo/track-def/dummy.d.ts.map +1 -1
- package/dist/demo/track-def/types.d.ts +1 -1
- package/dist/demo/track-def/types.d.ts.map +1 -1
- package/dist/{exported-utils-bd94e9c8.js → exported-utils-b3cf08ff.js} +12 -16
- package/dist/{exported-utils-bd94e9c8.js.map → exported-utils-b3cf08ff.js.map} +1 -1
- package/dist/gosling.js +63 -18
- package/dist/gosling.js.map +1 -1
- package/dist/src/compiler/bounding-box.d.ts.map +1 -1
- package/dist/src/compiler/spec-preprocess.d.ts.map +1 -1
- package/dist/src/compiler/views-and-tracks.d.ts.map +1 -1
- package/dist/src/tracks/dummy-track/dummy-track.d.ts +4 -1
- package/dist/src/tracks/dummy-track/dummy-track.d.ts.map +1 -1
- package/dist/utils.js +2 -2
- package/package.json +1 -1
package/dist/gosling.js
CHANGED
|
@@ -35,7 +35,7 @@ import { scaleLinear, scaleLog, scaleQuantile, scaleSequential, scaleOrdinal, sc
|
|
|
35
35
|
import { drag } from "d3-drag";
|
|
36
36
|
import { sampleSize, isEqual, uniqBy } from "lodash-es";
|
|
37
37
|
import { interpolateViridis } from "d3-scale-chromatic";
|
|
38
|
-
import { A as Ajv, r as resolveSuperposedTracks, I as IsChannelDeep, t as traverseTracks, a as IsTemplateTrack, D as DEWFAULT_TITLE_PADDING_ON_TOP_AND_BOTTOM, b as traverseTracksAndViews, c as traverseViewArrangements, d as DEFAULT_AXIS_SIZE, e as Is2DTrack, f as DEFAULT_VIEW_SPACING, g as DEFAULT_INNER_RADIUS_PROP, h as
|
|
38
|
+
import { A as Ajv, r as resolveSuperposedTracks, I as IsChannelDeep, t as traverseTracks, a as IsTemplateTrack, D as DEWFAULT_TITLE_PADDING_ON_TOP_AND_BOTTOM, b as traverseTracksAndViews, c as traverseViewArrangements, d as DEFAULT_AXIS_SIZE, e as Is2DTrack, f as DEFAULT_VIEW_SPACING, g as DEFAULT_INNER_RADIUS_PROP, h as IsOverlaidTrack, i as IsXAxis, j as IsYAxis, k as DEFAULT_CIRCULAR_VIEW_PADDING, u as uuid, l as traverseToFixSpecDownstream, m as absToChr, n as colorToHex, o as getTextStyle, p as computeChromSizes, q as cartesianToPolar, s as IsDummyTrack, v as getHiGlassColorRange, R as RADIAN_GAP, w as valueToRadian, x as pointsToDegree, y as commonjsGlobal, z as RemoteFile, B as chrToAbs, C as IsOneOfFilter, E as IsRangeFilter, F as IsIncludeFilter, G as getChannelKeysByAggregateFnc, H as getChannelKeysByType, J as sanitizeChrName, K as filterUsingGenoPos, L as IsDataDeepTileset, M as IsDomainChr, N as IsDomainInterval, O as IsDomainChrInterval, S as SUPPORTED_CHANNELS, P as IsChannelValue, Q as getValueUsingChannel, T as rectProperty, U as pointProperty, V as barProperty, W as IsStackedChannel, X as IsDomainArray, Y as PREDEFINED_COLOR_STR_MAP, Z as IsRangeArray, _ as isTabularDataFetcher, $ as drawPreEmbellishment, a0 as drawMark, a1 as drawPostEmbellishment, a2 as getRelativeGenomicPosition, a3 as hasDataTransform, a4 as IsMouseEventsDeep, a5 as flatArrayToPairArray, a6 as IsSingleView, a7 as IsMultipleViews, a8 as GenomicPositionHelper } from "./exported-utils-b3cf08ff.js";
|
|
39
39
|
import React, { useState, useImperativeHandle, useEffect } from "react";
|
|
40
40
|
import { format, precisionPrefix, formatPrefix } from "d3-format";
|
|
41
41
|
import slugid from "slugid";
|
|
@@ -55,7 +55,7 @@ import { createNanoEvents } from "nanoevents";
|
|
|
55
55
|
import PubSub$1 from "pubsub-js";
|
|
56
56
|
import { zoom, ZoomTransform } from "d3-zoom";
|
|
57
57
|
const name = "gosling.js";
|
|
58
|
-
const version = "2.0.0-alpha.
|
|
58
|
+
const version = "2.0.0-alpha.4";
|
|
59
59
|
const $ref$1 = "#/definitions/GoslingSpec";
|
|
60
60
|
const $schema$1 = "http://json-schema.org/draft-07/schema#";
|
|
61
61
|
const definitions$1 = {
|
|
@@ -11491,9 +11491,6 @@ function traverseAndCollectTrackInfo(spec, output, dx = 0, dy = 0, circularRootN
|
|
|
11491
11491
|
const TOTAL_RING_SIZE = TOTAL_RADIUS * (1 - INNER_RADIUS);
|
|
11492
11492
|
cTracks.forEach((t, i) => {
|
|
11493
11493
|
var _a, _b;
|
|
11494
|
-
if (IsDummyTrack(t.track)) {
|
|
11495
|
-
return;
|
|
11496
|
-
}
|
|
11497
11494
|
const circularTrack = t.track;
|
|
11498
11495
|
circularTrack.layout = "circular";
|
|
11499
11496
|
circularTrack.outerRadius = TOTAL_RADIUS - PADDING - (t.boundingBox.y - dy) / cumHeight * TOTAL_RING_SIZE;
|
|
@@ -11619,8 +11616,6 @@ function collectViewsAndTracks(spec, trackInfos, theme) {
|
|
|
11619
11616
|
let isLinear = false;
|
|
11620
11617
|
if ("layout" in d.track && d.track.layout === "linear") {
|
|
11621
11618
|
isLinear = true;
|
|
11622
|
-
} else if (IsDummyTrack(d.track)) {
|
|
11623
|
-
isLinear = true;
|
|
11624
11619
|
}
|
|
11625
11620
|
return {
|
|
11626
11621
|
id: d.track.id,
|
|
@@ -16669,8 +16664,35 @@ const defaultOptions$2 = {
|
|
|
16669
16664
|
textFontWeight: "normal",
|
|
16670
16665
|
textStroke: "#000",
|
|
16671
16666
|
textStrokeWidth: 0.1,
|
|
16672
|
-
outline: "#fff"
|
|
16667
|
+
outline: "#fff",
|
|
16668
|
+
layout: "linear",
|
|
16669
|
+
outerRadius: 0,
|
|
16670
|
+
innerRadius: 0
|
|
16673
16671
|
};
|
|
16672
|
+
function makeArc(width, height, innerRadius, outerRadius) {
|
|
16673
|
+
const startAngle = -Math.PI / 2;
|
|
16674
|
+
const endAngle = -Math.PI / 2 + 2 * Math.PI - 1e-6;
|
|
16675
|
+
const startX = width / 2 + outerRadius * Math.cos(startAngle);
|
|
16676
|
+
const startY = height / 2 + outerRadius * Math.sin(startAngle);
|
|
16677
|
+
const endX = width / 2 + outerRadius * Math.cos(endAngle);
|
|
16678
|
+
const endY = height / 2 + outerRadius * Math.sin(endAngle);
|
|
16679
|
+
const innerStartX = width / 2 + innerRadius * Math.cos(startAngle);
|
|
16680
|
+
const innerStartY = height / 2 + innerRadius * Math.sin(startAngle);
|
|
16681
|
+
const innerEndX = width / 2 + innerRadius * Math.cos(endAngle);
|
|
16682
|
+
const innerEndY = height / 2 + innerRadius * Math.sin(endAngle);
|
|
16683
|
+
const pathData = [
|
|
16684
|
+
`M ${startX} ${startY}`,
|
|
16685
|
+
`A ${outerRadius} ${outerRadius} 0 1 1 ${endX} ${endY}`,
|
|
16686
|
+
// Draw outer arc
|
|
16687
|
+
`L ${innerEndX} ${innerEndY}`,
|
|
16688
|
+
// Draw a line to the ending point of the inner arc
|
|
16689
|
+
`A ${innerRadius} ${innerRadius} 0 1 0 ${innerStartX} ${innerStartY}`,
|
|
16690
|
+
// Draw inner arc
|
|
16691
|
+
"Z"
|
|
16692
|
+
// Close the path
|
|
16693
|
+
].join(" ");
|
|
16694
|
+
return pathData;
|
|
16695
|
+
}
|
|
16674
16696
|
class DummyTrackClass extends SVGTrack {
|
|
16675
16697
|
constructor(context, options) {
|
|
16676
16698
|
super(context, options);
|
|
@@ -16680,6 +16702,7 @@ class DummyTrackClass extends SVGTrack {
|
|
|
16680
16702
|
*/
|
|
16681
16703
|
__privateAdd(this, _drawText);
|
|
16682
16704
|
this.options = { ...defaultOptions$2, ...options };
|
|
16705
|
+
console.warn(this.options);
|
|
16683
16706
|
this.clipRect.attr("width", this.options.width).attr("height", this.options.height);
|
|
16684
16707
|
__privateMethod(this, _drawBackground, drawBackground_fn).call(this);
|
|
16685
16708
|
__privateMethod(this, _drawText, drawText_fn).call(this);
|
|
@@ -16687,11 +16710,24 @@ class DummyTrackClass extends SVGTrack {
|
|
|
16687
16710
|
}
|
|
16688
16711
|
_drawBackground = new WeakSet();
|
|
16689
16712
|
drawBackground_fn = function() {
|
|
16690
|
-
|
|
16713
|
+
if (this.options.layout === "linear") {
|
|
16714
|
+
this.gMain.append("rect").attr("fill", this.options.background).attr("x", 0).attr("y", 0).attr("width", this.options.width).attr("height", this.options.height).style("stroke", this.options.outline);
|
|
16715
|
+
} else {
|
|
16716
|
+
this.gMain.append("path").attr(
|
|
16717
|
+
"d",
|
|
16718
|
+
makeArc(
|
|
16719
|
+
this.options.width,
|
|
16720
|
+
this.options.height,
|
|
16721
|
+
this.options.innerRadius,
|
|
16722
|
+
this.options.outerRadius
|
|
16723
|
+
)
|
|
16724
|
+
).attr("fill", this.options.background).attr("stroke", this.options.outline).attr("x", 0).attr("y", 0);
|
|
16725
|
+
}
|
|
16691
16726
|
};
|
|
16692
16727
|
_drawText = new WeakSet();
|
|
16693
16728
|
drawText_fn = function() {
|
|
16694
|
-
|
|
16729
|
+
const height = this.options.layout === "linear" ? (this.options.height + this.options.textFontSize) / 2 : this.options.height / 2 - this.options.innerRadius - this.options.textFontSize;
|
|
16730
|
+
this.gMain.append("text").attr("x", this.options.width / 2).attr("y", height).style("text-anchor", "middle").style("font-size", `${this.options.textFontSize}px`).style("font-weight", this.options.textFontWeight).style("stroke", this.options.textStroke).style("stroke-width", this.options.textStrokeWidth).text(this.options.title);
|
|
16695
16731
|
};
|
|
16696
16732
|
class DummyTrack extends DummyTrackClass {
|
|
16697
16733
|
constructor(options, overlayDiv) {
|
|
@@ -18218,6 +18254,9 @@ function processDummyTrack(track, boundingBox, theme) {
|
|
|
18218
18254
|
options: {
|
|
18219
18255
|
width: boundingBox.width,
|
|
18220
18256
|
height: boundingBox.height,
|
|
18257
|
+
layout: track.layout,
|
|
18258
|
+
outerRadius: "outerRadius" in track ? track.outerRadius : void 0,
|
|
18259
|
+
innerRadius: "innerRadius" in track ? track.innerRadius : void 0,
|
|
18221
18260
|
...track.style,
|
|
18222
18261
|
title: (_a = track.title) != null ? _a : ""
|
|
18223
18262
|
}
|
|
@@ -30248,9 +30287,9 @@ function createApiV2(compileResult) {
|
|
|
30248
30287
|
if (!compileResult) {
|
|
30249
30288
|
return createEmptyApi();
|
|
30250
30289
|
}
|
|
30251
|
-
const {
|
|
30290
|
+
const { theme, pixiManager, plots } = compileResult;
|
|
30252
30291
|
const getTracksAndViews = () => {
|
|
30253
|
-
return [...tracksAndViews];
|
|
30292
|
+
return [...compileResult.tracksAndViews];
|
|
30254
30293
|
};
|
|
30255
30294
|
const getTracks = () => {
|
|
30256
30295
|
return [...getTracksAndViews().filter((d) => d.type === "track")];
|
|
@@ -30385,6 +30424,8 @@ function GoslingComponent(props) {
|
|
|
30385
30424
|
theme = "light",
|
|
30386
30425
|
ref,
|
|
30387
30426
|
visualized = () => {
|
|
30427
|
+
},
|
|
30428
|
+
resized = () => {
|
|
30388
30429
|
}
|
|
30389
30430
|
} = props;
|
|
30390
30431
|
const [compiledResults, setCompiledResults] = useState();
|
|
@@ -30408,12 +30449,12 @@ function GoslingComponent(props) {
|
|
|
30408
30449
|
padding,
|
|
30409
30450
|
background: getTheme(theme).root.background
|
|
30410
30451
|
});
|
|
30411
|
-
const compileResult = renderGosling(spec, plotElement, pixiManager2, theme, urlToFetchOptions);
|
|
30452
|
+
const compileResult = renderGosling(spec, plotElement, pixiManager2, theme, urlToFetchOptions, resized);
|
|
30412
30453
|
setCompiledResults(compileResult);
|
|
30413
30454
|
setPixiManager(pixiManager2);
|
|
30414
30455
|
} else {
|
|
30415
30456
|
pixiManager.clearAll();
|
|
30416
|
-
const compileResult = renderGosling(spec, plotElement, pixiManager, theme, urlToFetchOptions);
|
|
30457
|
+
const compileResult = renderGosling(spec, plotElement, pixiManager, theme, urlToFetchOptions, resized);
|
|
30417
30458
|
setCompiledResults(compileResult);
|
|
30418
30459
|
}
|
|
30419
30460
|
}, [spec]);
|
|
@@ -30426,18 +30467,18 @@ function GoslingComponent(props) {
|
|
|
30426
30467
|
}
|
|
30427
30468
|
);
|
|
30428
30469
|
}
|
|
30429
|
-
function renderGosling(gs, container, pixiManager, theme, urlToFetchOptions) {
|
|
30470
|
+
function renderGosling(gs, container, pixiManager, theme, urlToFetchOptions, resized) {
|
|
30430
30471
|
const themeDeep = getTheme(theme);
|
|
30431
30472
|
let plots = {};
|
|
30432
30473
|
const compileResult = compile(gs, [], themeDeep, {});
|
|
30433
|
-
const { trackInfos, gs: processedSpec } = compileResult;
|
|
30474
|
+
const { trackInfos, gs: processedSpec, theme: themeComplete } = compileResult;
|
|
30434
30475
|
const linkedEncodings = getLinkedEncodings(processedSpec);
|
|
30476
|
+
const result = { ...compileResult, plots, pixiManager };
|
|
30435
30477
|
const { isResponsiveWidth, isResponsiveHeight } = checkResponsiveSpec(processedSpec);
|
|
30436
30478
|
if (isResponsiveWidth || isResponsiveHeight) {
|
|
30437
30479
|
const resizeObserver = new ResizeObserver(
|
|
30438
30480
|
debounce((entries) => {
|
|
30439
30481
|
const { width: containerWidth, height: containerHeight } = entries[0].contentRect;
|
|
30440
|
-
console.warn("Resizing to", containerWidth, containerHeight);
|
|
30441
30482
|
pixiManager.clearAll();
|
|
30442
30483
|
const rescaledTracks = rescaleTrackInfos(
|
|
30443
30484
|
trackInfos,
|
|
@@ -30448,10 +30489,14 @@ function renderGosling(gs, container, pixiManager, theme, urlToFetchOptions) {
|
|
|
30448
30489
|
isResponsiveWidth,
|
|
30449
30490
|
isResponsiveHeight
|
|
30450
30491
|
);
|
|
30492
|
+
const updatedResult = collectViewsAndTracks(processedSpec, rescaledTracks, themeComplete);
|
|
30493
|
+
result.tracksAndViews = updatedResult.tracksAndViews;
|
|
30494
|
+
result.size = updatedResult.size;
|
|
30451
30495
|
const trackDefs = createTrackDefs(rescaledTracks, themeDeep);
|
|
30452
30496
|
plots = renderTrackDefs(trackDefs, linkedEncodings, pixiManager, urlToFetchOptions);
|
|
30453
30497
|
const { width, height } = calculateWidthHeight(rescaledTracks);
|
|
30454
30498
|
pixiManager.resize(width, height);
|
|
30499
|
+
resized == null ? void 0 : resized();
|
|
30455
30500
|
}, 300)
|
|
30456
30501
|
);
|
|
30457
30502
|
resizeObserver.observe(container);
|
|
@@ -30461,7 +30506,7 @@ function renderGosling(gs, container, pixiManager, theme, urlToFetchOptions) {
|
|
|
30461
30506
|
const { width, height } = calculateWidthHeight(trackInfos);
|
|
30462
30507
|
pixiManager.resize(width, height);
|
|
30463
30508
|
}
|
|
30464
|
-
return
|
|
30509
|
+
return result;
|
|
30465
30510
|
}
|
|
30466
30511
|
function debounce(f, delay) {
|
|
30467
30512
|
let timer = 0;
|