@@ -3,6 +3,7 @@ import FeatureSource from "../feature/featureSource.js"
3
3
import TrackBase from "../trackBase.js"
4
4
import IGVGraphics from "../igv-canvas.js"
5
5
import ShoeboxColorScale from "./shoeboxColorScale.js"
6
+ import paintAxis from "../util/paintAxis.js"
6
7
7
8
/**
8
9
* Configurable properties
@@ -33,12 +34,6 @@ class ShoeboxTrack extends TrackBase {
33
34
34
35
this . type = "shoebox"
35
36
36
- // Hardcoded -- todo, perhaps, get from track line
37
- this . sampleKeys = [ ]
38
- for ( let i = 1 ; i <= this . rowCount ; i ++ ) {
39
- this . sampleKeys . push ( i )
40
- }
41
-
42
37
if ( config . max ) {
43
38
this . dataRange = {
44
39
min : config . min || 0 ,
@@ -49,9 +44,12 @@ class ShoeboxTrack extends TrackBase {
49
44
const configCopy = Object . assign ( { } , this . config )
50
45
configCopy . format = 'shoebox' // bit of a hack
51
46
this . featureSource = FeatureSource ( configCopy , this . browser . genome )
47
+
48
+ this . paintAxis = paintAxis
52
49
}
53
50
54
51
async postInit ( ) {
52
+
55
53
if ( typeof this . featureSource . getHeader === "function" ) {
56
54
this . header = await this . featureSource . getHeader ( )
57
55
if ( this . disposed ) return // This track was removed during async load
@@ -62,6 +60,8 @@ class ShoeboxTrack extends TrackBase {
62
60
this . header . scale = Number . parseFloat ( this . header . scale )
63
61
}
64
62
this . setTrackProperties ( this . header )
63
+
64
+ this . rowCount = this . header . firstFeature ? this . header . firstFeature . values . length : 100
65
65
}
66
66
67
67
// Must do the following after setting track properties as they can be overriden via a track line
@@ -76,10 +76,6 @@ class ShoeboxTrack extends TrackBase {
76
76
77
77
}
78
78
79
- get rowCount ( ) {
80
- return 100 // TODO Hardcoded, get from data
81
- }
82
-
83
79
get color ( ) {
84
80
return this . _color || "rgb(0,0,255)"
85
81
}
@@ -91,6 +87,14 @@ class ShoeboxTrack extends TrackBase {
91
87
}
92
88
}
93
89
90
+ get axisMin ( ) {
91
+ return 1
92
+ }
93
+
94
+ get axisMax ( ) {
95
+ return this . rowCount
96
+ }
97
+
94
98
menuItemList ( ) {
95
99
96
100
const menuItems = [ ]
@@ -99,6 +103,7 @@ class ShoeboxTrack extends TrackBase {
99
103
let object = $ ( '<div>' )
100
104
object . text ( 'Set row height' )
101
105
106
+ const browser = this . browser
102
107
function dialogHandler ( e ) {
103
108
104
109
const callback = ( ) => {
@@ -107,6 +112,8 @@ class ShoeboxTrack extends TrackBase {
107
112
108
113
if ( undefined !== number ) {
109
114
115
+ browser . sampleNameViewportWidth = undefined // TODO, a better way to trigger this
116
+
110
117
const tracks = [ ]
111
118
if ( this . trackView . track . selected ) {
112
119
tracks . push ( ...( this . trackView . browser . getSelectedTrackViews ( ) . map ( ( { track} ) => track ) ) )
@@ -116,7 +123,7 @@ class ShoeboxTrack extends TrackBase {
116
123
117
124
for ( const track of tracks ) {
118
125
track . rowHeight = number
119
- if ( track . rowHeight * track . rowCount < track . height ) {
126
+ if ( track . rowHeight * track . rowCount < track . height ) {
120
127
track . trackView . setTrackHeight ( track . rowHeight * track . rowCount , true )
121
128
}
122
129
track . trackView . checkContentHeight ( )
@@ -165,23 +172,12 @@ class ShoeboxTrack extends TrackBase {
165
172
this . trackView . repaintViews ( )
166
173
}
167
174
168
- hasSamples ( ) {
169
- return true // by definition
170
- }
171
-
172
- getSamples ( ) {
173
- return {
174
- names : this . sampleKeys ,
175
- height : this . rowHeight ,
176
- yOffset : 0
177
- }
178
- }
179
-
180
175
async getFeatures ( chr , start , end , bpPerPixel ) {
181
176
const visibilityWindow = this . visibilityWindow
182
- return this . featureSource . getFeatures ( { chr, start, end, bpPerPixel, visibilityWindow} )
183
- }
177
+ const features = await this . featureSource . getFeatures ( { chr, start, end, bpPerPixel, visibilityWindow} )
184
178
179
+ return features
180
+ }
185
181
186
182
draw ( { context, pixelTop, pixelWidth, pixelHeight, features, bpPerPixel, bpStart} ) {
187
183
@@ -254,7 +250,6 @@ class ShoeboxTrack extends TrackBase {
254
250
const rect = feature . pixelRect
255
251
return rect && y >= rect . y && y <= ( rect . y + rect . h )
256
252
} )
257
-
258
253
}
259
254
260
255
hoverText ( clickState ) {
0 commit comments