@@ -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