@@ -21,7 +21,8 @@ class ShoeboxTrack extends TrackBase {
21
21
max : 3 ,
22
22
scale : 1.0 ,
23
23
visibilityWindow : 10000 ,
24
- supportHiDPI : false
24
+ supportHiDPI : false ,
25
+ rowStepSize : 1 // Stepsize for each row in bp for footprint radius
25
26
}
26
27
27
28
constructor ( config , browser ) {
@@ -45,9 +46,10 @@ class ShoeboxTrack extends TrackBase {
45
46
configCopy . format = 'shoebox' // bit of a hack
46
47
this . featureSource = FeatureSource ( configCopy , this . browser . genome )
47
48
48
- this . paintAxis = paintAxis
49
+ // this.paintAxis = paintAxis
49
50
}
50
51
52
+
51
53
async postInit ( ) {
52
54
53
55
if ( typeof this . featureSource . getHeader === "function" ) {
@@ -87,13 +89,6 @@ class ShoeboxTrack extends TrackBase {
87
89
}
88
90
}
89
91
90
- get axisMin ( ) {
91
- return 1
92
- }
93
-
94
- get axisMax ( ) {
95
- return this . rowCount
96
- }
97
92
98
93
menuItemList ( ) {
99
94
@@ -104,6 +99,7 @@ class ShoeboxTrack extends TrackBase {
104
99
object . text ( 'Set row height' )
105
100
106
101
const browser = this . browser
102
+
107
103
function dialogHandler ( e ) {
108
104
109
105
const callback = ( ) => {
@@ -230,6 +226,32 @@ class ShoeboxTrack extends TrackBase {
230
226
231
227
}
232
228
229
+ paintAxis ( ctx , pixelWidth , pixelHeight ) {
230
+
231
+ //IGVGraphics.fillRect(ctx, 0, 0, pixelWidth, pixelHeight, {'fillStyle': "rgb(255, 255, 255)"})
232
+ var font = {
233
+ 'font' : 'normal 10px Arial' ,
234
+ 'textAlign' : 'right' ,
235
+ 'strokeStyle' : "black"
236
+ }
237
+
238
+ const max = 2 * ( this . rowCount + 1 ) //2x for size in diameter, rather than radius
239
+ const min = 0
240
+ const yScale = ( max - min ) / pixelHeight
241
+
242
+ const n = 50
243
+ for ( let p = n ; p <= max ; p += n ) {
244
+ const yp = Math . max ( 10 , pixelHeight - Math . round ( ( p - min ) / yScale ) )
245
+ IGVGraphics . strokeLine ( ctx , 35 , yp , 40 , yp , font )
246
+ if ( p > min ) {
247
+ IGVGraphics . fillText ( ctx , prettyPrint ( p ) , 30 , yp + 4 , font ) // Offset numbers down by 2 pixels;
248
+ }
249
+ }
250
+ font [ 'textAlign' ] = 'center'
251
+ font [ 'font' ] = 'normal 10px Arial'
252
+ IGVGraphics . fillText ( ctx , "Footprint size (bp)" , 10 , pixelHeight / 2 , font , { rotate : { angle : - 90 } } )
253
+ }
254
+
233
255
/**
234
256
* Optional method to compute pixel height to accomodate the list of features.
235
257
*
@@ -301,4 +323,21 @@ class ShoeboxTrack extends TrackBase {
301
323
}
302
324
303
325
326
+ function prettyPrint ( number ) {
327
+
328
+ if ( Number . isInteger ( number ) ) {
329
+ return number
330
+ } else if ( number % 1 === 0 ) { // Number can be represented exactly as an integer
331
+ return number
332
+ } else if ( Math . abs ( number ) >= 10 ) {
333
+ return number . toFixed ( )
334
+ } else if ( Math . abs ( number ) >= 1 ) {
335
+ return number . toFixed ( 1 )
336
+ } else if ( Math . abs ( number ) >= 0.1 ) {
337
+ return number . toFixed ( 2 )
338
+ } else {
339
+ return number . toExponential ( 1 )
340
+ }
341
+ }
342
+
304
343
export default ShoeboxTrack
0 commit comments