Skip to content

Commit 33b7a7e

Browse files
authored
Merge pull request #490 from vgteam/better-region-markings
Better region markings
2 parents ad62f98 + 2330b71 commit 33b7a7e

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

src/server.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,11 @@ function processRegionFile(req, res, next) {
16661666
console.log("Rename " + subpathName + " to " + arr[0] + " and mark start as " + arr[1]);
16671667
p.name = arr[0];
16681668
p.indexOfFirstBase = arr[1];
1669+
} else if (p.name === arr[0]) {
1670+
// We might be looking at a pre-extracted region that predates real
1671+
// subpath support (like the Lancet paper data), in which case we
1672+
// need to grab the real start point from the regions file.
1673+
p.indexOfFirstBase = arr[1];
16691674
}
16701675
});
16711676
});

src/util/tubemap.js

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3740,8 +3740,8 @@ function drawRuler() {
37403740
});
37413741
ticks = separatedTicks;
37423742

3743-
// plot ticks highlighting the region
3744-
ticks_region.forEach((tick) => drawRulerMarkingRegion(tick[0], tick[1]));
3743+
// plot ticks highlighting the region (if it is filled in)
3744+
drawRulerMarkingRegion(ticks_region);
37453745

37463746
// draw horizontal line for each interval
37473747

@@ -3822,14 +3822,45 @@ function drawRulerMarking(sequencePosition, xCoordinate, align) {
38223822
.attr("stroke", "black")
38233823
}
38243824

3825-
function drawRulerMarkingRegion(sequencePosition, xCoordinate) {
3825+
/// Draw ruler markings for the given requested region.
3826+
///
3827+
/// The requested region should be an array of 2 items, each of which is an
3828+
/// array of a sequence position and an image X coordinate. If the array is not
3829+
/// 2 items, no connecting line is drawn.
3830+
function drawRulerMarkingRegion(ticks_region) {
3831+
// Each tick is a base coordinate and an image coordinate
3832+
ticks_region.forEach((tick) => drawRulerMarkingEndpoint(tick[0], tick[1]));
3833+
3834+
let lineY = minYCoordinate - NODE_MARGIN - 6;
3835+
3836+
if (ticks_region && ticks_region.length === 2) {
3837+
svg
3838+
.append("line")
3839+
.attr("x1", ticks_region[0][1])
3840+
.attr("y1", lineY)
3841+
.attr("x2", ticks_region[1][1])
3842+
.attr("y2", lineY)
3843+
.attr("stroke-width", 4)
3844+
.attr("stroke", "#FFFE3A");
3845+
}
3846+
}
3847+
3848+
function drawRulerMarkingEndpoint(sequencePosition, xCoordinate) {
3849+
3850+
let pointX = xCoordinate;
3851+
let pointY = minYCoordinate - NODE_MARGIN - 1;
3852+
let arrowWidth = 8;
3853+
let arrowHeight = 10;
3854+
38263855
svg
3827-
.append("circle")
3828-
.attr("cx", xCoordinate + 3)
3829-
.attr("cy", minYCoordinate - 13)
3830-
.attr("r", 10)
3831-
.attr("opacity", 0.5)
3832-
.attr("fill", "yellow")
3856+
.append("path")
3857+
.attr("d", `M${pointX - arrowWidth} ${pointY - arrowHeight}`
3858+
+ ` L${pointX} ${pointY}`
3859+
+ ` L${pointX + arrowWidth} ${pointY - arrowHeight}`
3860+
)
3861+
.attr("stroke-width", 0)
3862+
.attr("fill", "#FFFE3A")
3863+
.attr("stroke", "none")
38333864
.style("pointer-events", "none");
38343865
}
38353866

0 commit comments

Comments
 (0)