higlass 1.13.5 → 2.0.0

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.
Files changed (392) hide show
  1. package/README.md +48 -54
  2. package/app/globals.d.ts +1 -1
  3. package/app/missing-types.d.ts +4 -1
  4. package/app/scripts/AddTrackDialog.jsx +11 -4
  5. package/app/scripts/AddTrackPositionMenu.jsx +28 -7
  6. package/app/scripts/Annotations1dTrack.js +90 -251
  7. package/app/scripts/Annotations2dTrack.js +12 -7
  8. package/app/scripts/Autocomplete.jsx +13 -28
  9. package/app/scripts/AxisPixi.js +6 -10
  10. package/app/scripts/BarTrack.js +3 -3
  11. package/app/scripts/BedLikeTrack.js +556 -449
  12. package/app/scripts/Button.jsx +1 -1
  13. package/app/scripts/CNVIntervalTrack.js +1 -1
  14. package/app/scripts/CenterTrack.jsx +8 -7
  15. package/app/scripts/Chromosome2DAnnotations.js +1 -1
  16. package/app/scripts/Chromosome2DLabels.js +1 -1
  17. package/app/scripts/ChromosomeGrid.js +49 -38
  18. package/app/scripts/ChromosomeInfo.js +1 -1
  19. package/app/scripts/CombinedTrack.js +3 -1
  20. package/app/scripts/ConfigTrackMenu.jsx +1 -1
  21. package/app/scripts/ConfigViewMenu.jsx +2 -2
  22. package/app/scripts/ContextMenuContainer.jsx +4 -2
  23. package/app/scripts/ContextMenuItem.jsx +14 -2
  24. package/app/scripts/CrossRule.js +1 -1
  25. package/app/scripts/CustomTrackDialog.jsx +2 -2
  26. package/app/scripts/Dialog.jsx +2 -2
  27. package/app/scripts/DragListeningDiv.jsx +1 -1
  28. package/app/scripts/DraggableDiv.jsx +2 -3
  29. package/app/scripts/ExportLinkDialog.jsx +1 -1
  30. package/app/scripts/FilledLine.js +349 -0
  31. package/app/scripts/GalleryTracks.jsx +77 -78
  32. package/app/scripts/GenomePositionSearchBox.jsx +184 -482
  33. package/app/scripts/HeatmapOptions.jsx +4 -2
  34. package/app/scripts/HeatmapTiledPixiTrack.js +23 -32
  35. package/app/scripts/HiGlassComponent.jsx +515 -444
  36. package/app/scripts/HiGlassComponentContext.js +5 -0
  37. package/app/scripts/Horizontal1dHeatmapTrack.js +1 -1
  38. package/app/scripts/Horizontal2DDomainsTrack.js +1 -1
  39. package/app/scripts/HorizontalChromosomeLabels.js +28 -22
  40. package/app/scripts/HorizontalGeneAnnotationsTrack.js +1 -1
  41. package/app/scripts/HorizontalHeatmapTrack.js +2 -2
  42. package/app/scripts/HorizontalMultivecTrack.js +6 -7
  43. package/app/scripts/HorizontalRule.js +1 -2
  44. package/app/scripts/HorizontalTiled1DPixiTrack.js +4 -4
  45. package/app/scripts/HorizontalTiledPlot.jsx +9 -9
  46. package/app/scripts/LeftTrackModifier.js +4 -0
  47. package/app/scripts/ListWrapper.jsx +1 -2
  48. package/app/scripts/MapboxTilesTrack.js +1 -2
  49. package/app/scripts/Modal.jsx +2 -2
  50. package/app/scripts/MoveableTrack.jsx +10 -12
  51. package/app/scripts/NestedContextMenu.jsx +2 -1
  52. package/app/scripts/OSMTileIdsTrack.js +1 -1
  53. package/app/scripts/OverlayTrack.js +4 -4
  54. package/app/scripts/PixiTrack.js +27 -13
  55. package/app/scripts/PlotTypeChooser.jsx +3 -4
  56. package/app/scripts/SearchField.js +5 -5
  57. package/app/scripts/SeriesListItems.jsx +3 -4
  58. package/app/scripts/SeriesListMenu.jsx +95 -53
  59. package/app/scripts/SeriesListSubmenuMixin.jsx +2 -1
  60. package/app/scripts/SketchInlinePicker.jsx +2 -2
  61. package/app/scripts/SortableList.jsx +1 -1
  62. package/app/scripts/Tiled1DPixiTrack.js +4 -1
  63. package/app/scripts/TiledPixiTrack.js +244 -102
  64. package/app/scripts/TiledPlot.jsx +565 -118
  65. package/app/scripts/TilesetFinder.jsx +12 -4
  66. package/app/scripts/Track.js +1 -1
  67. package/app/scripts/TrackArea.jsx +4 -0
  68. package/app/scripts/TrackControl.jsx +2 -2
  69. package/app/scripts/TrackRenderer.jsx +32 -33
  70. package/app/scripts/ValueIntervalTrack.js +1 -1
  71. package/app/scripts/VerticalRule.js +2 -2
  72. package/app/scripts/VerticalTiledPlot.jsx +7 -7
  73. package/app/scripts/ViewConfigEditor.jsx +1 -1
  74. package/app/scripts/ViewContextMenu.jsx +53 -5
  75. package/app/scripts/ViewHeader.jsx +9 -9
  76. package/app/scripts/ViewportTracker2D.js +1 -1
  77. package/app/scripts/api.js +92 -12
  78. package/app/scripts/configs/available-track-types.js +1 -1
  79. package/app/scripts/configs/index.js +6 -1
  80. package/app/scripts/configs/positions-by-datatype.js +2 -2
  81. package/app/scripts/configs/primitives.js +2 -0
  82. package/app/scripts/configs/themes.js +0 -1
  83. package/app/scripts/configs/tracks-info-by-type.js +11 -8
  84. package/app/scripts/configs/tracks-info.js +3 -2
  85. package/app/scripts/d3-context-menu.js +3 -4
  86. package/app/scripts/data-fetchers/DataFetcher.js +35 -36
  87. package/app/scripts/data-fetchers/genbank-fetcher.js +13 -22
  88. package/app/scripts/data-fetchers/local-tile-fetcher.js +10 -8
  89. package/app/scripts/hglib.jsx +62 -71
  90. package/app/scripts/hocs/with-modal.jsx +32 -10
  91. package/app/scripts/hocs/with-pub-sub.js +12 -3
  92. package/app/scripts/hocs/with-theme.jsx +21 -14
  93. package/app/scripts/icons.jsx +3 -2
  94. package/app/scripts/mixwith.js +2 -2
  95. package/app/scripts/options-info.js +49 -11
  96. package/app/scripts/plugins/get-data-fetcher.js +2 -3
  97. package/app/scripts/services/chrom-info.js +32 -4
  98. package/app/scripts/services/element-resize-listener.js +2 -2
  99. package/app/scripts/services/index.js +0 -1
  100. package/app/scripts/services/tile-proxy.js +368 -285
  101. package/app/scripts/services/worker.js +31 -28
  102. package/app/scripts/test-helpers/index.js +2 -1
  103. package/app/scripts/test-helpers/test-helpers.jsx +157 -69
  104. package/app/scripts/types.ts +118 -47
  105. package/app/scripts/utils/LruCache.js +3 -2
  106. package/app/scripts/utils/assert.js +19 -0
  107. package/app/scripts/utils/background-task-scheduler.js +2 -0
  108. package/app/scripts/utils/color-domain-to-rgba-array.js +13 -3
  109. package/app/scripts/utils/copy-text-to-clipboard.js +36 -0
  110. package/app/scripts/utils/decompress.js +33 -0
  111. package/app/scripts/utils/default-tracks.js +46 -0
  112. package/app/scripts/utils/dict-items.js +1 -0
  113. package/app/scripts/utils/dict-keys.js +1 -0
  114. package/app/scripts/utils/dict-values.js +1 -0
  115. package/app/scripts/utils/expand-combined-tracks.js +11 -7
  116. package/app/scripts/utils/fill-in-min-widths.js +47 -21
  117. package/app/scripts/utils/flatten.js +0 -1
  118. package/app/scripts/utils/get-aggregation-function.js +1 -1
  119. package/app/scripts/utils/get-default-track-for-datatype.js +37 -10
  120. package/app/scripts/utils/get-default-tracks-for-datatype.ts +46 -0
  121. package/app/scripts/utils/get-higlass-components.js +27 -3
  122. package/app/scripts/utils/get-track-position-by-uid.js +8 -1
  123. package/app/scripts/utils/get-xylofon.js +12 -9
  124. package/app/scripts/utils/has-parent.js +5 -5
  125. package/app/scripts/utils/hex-string-to-int.js +1 -1
  126. package/app/scripts/utils/index.js +1 -0
  127. package/app/scripts/utils/interval-tree.js +222 -177
  128. package/app/scripts/utils/load-chrom-infos.js +4 -1
  129. package/app/scripts/utils/pixi-text-to-svg.js +5 -9
  130. package/app/scripts/utils/positioned-tracks-to-all-tracks.js +55 -0
  131. package/app/scripts/utils/range-query-2d.js +3 -3
  132. package/app/scripts/utils/reduce.js +12 -5
  133. package/app/scripts/utils/segments-to-rows.js +14 -11
  134. package/app/scripts/utils/svg-line.js +7 -8
  135. package/app/scripts/utils/type-guards.js +16 -7
  136. package/app/scripts/utils/visit-positioned-tracks.js +9 -4
  137. package/app/styles/AddTrackPositionMenu.module.scss +37 -0
  138. package/app/styles/HiGlass.module.scss +3 -1
  139. package/app/styles/d3-context-menu.css +0 -1
  140. package/app/styles/prism.css +1 -0
  141. package/dist/app/schema.json +525 -0
  142. package/dist/app/scripts/AddTrackDialog.d.ts +64 -0
  143. package/dist/app/scripts/AddTrackPositionMenu.d.ts +5 -0
  144. package/dist/app/scripts/Annotations1dTrack.d.ts +15 -0
  145. package/dist/app/scripts/Annotations2dTrack.d.ts +95 -0
  146. package/dist/app/scripts/ArrowheadDomainsTrack.d.ts +36 -0
  147. package/dist/app/scripts/Autocomplete.d.ts +102 -0
  148. package/dist/app/scripts/AxisPixi.d.ts +25 -0
  149. package/dist/app/scripts/BarTrack.d.ts +28 -0
  150. package/dist/app/scripts/BedLikeTrack.d.ts +84 -0
  151. package/dist/app/scripts/Button.d.ts +3 -0
  152. package/dist/app/scripts/CNVIntervalTrack.d.ts +12 -0
  153. package/dist/app/scripts/CenterTiledPlot.d.ts +3 -0
  154. package/dist/app/scripts/CenterTrack.d.ts +92 -0
  155. package/dist/app/scripts/Chromosome2DAnnotations.d.ts +10 -0
  156. package/dist/app/scripts/Chromosome2DLabels.d.ts +13 -0
  157. package/dist/app/scripts/ChromosomeGrid.d.ts +24 -0
  158. package/dist/app/scripts/ChromosomeInfo.d.ts +14 -0
  159. package/dist/app/scripts/CloseTrackMenu.d.ts +10 -0
  160. package/dist/app/scripts/CombinedTrack.d.ts +32 -0
  161. package/dist/app/scripts/ConfigTrackMenu.d.ts +10 -0
  162. package/dist/app/scripts/ConfigViewMenu.d.ts +34 -0
  163. package/dist/app/scripts/ConfigureSeriesMenu.d.ts +3 -0
  164. package/dist/app/scripts/ContextMenuContainer.d.ts +36 -0
  165. package/dist/app/scripts/ContextMenuItem.d.ts +34 -0
  166. package/dist/app/scripts/Cross.d.ts +3 -0
  167. package/dist/app/scripts/CrossRule.d.ts +24 -0
  168. package/dist/app/scripts/CustomTrackDialog.d.ts +17 -0
  169. package/dist/app/scripts/Dialog.d.ts +5 -0
  170. package/dist/app/scripts/DivergentBarTrack.d.ts +4 -0
  171. package/dist/app/scripts/DragListeningDiv.d.ts +32 -0
  172. package/dist/app/scripts/DraggableDiv.d.ts +63 -0
  173. package/dist/app/scripts/ExportLinkDialog.d.ts +21 -0
  174. package/dist/app/scripts/FilledLine.d.ts +5 -0
  175. package/dist/app/scripts/FixedTrack.d.ts +5 -0
  176. package/dist/app/scripts/GalleryTracks.d.ts +20 -0
  177. package/dist/app/scripts/GenomePositionSearchBox.d.ts +95 -0
  178. package/dist/app/scripts/HeatmapOptions.d.ts +30 -0
  179. package/dist/app/scripts/HeatmapTiledPixiTrack.d.ts +184 -0
  180. package/dist/app/scripts/HiGlassComponent.d.ts +762 -0
  181. package/dist/app/scripts/HiGlassComponentContext.d.ts +3 -0
  182. package/dist/app/scripts/HiGlassTrackComponent.d.ts +37 -0
  183. package/dist/app/scripts/Horizontal1dHeatmapTrack.d.ts +9 -0
  184. package/dist/app/scripts/Horizontal2DDomainsTrack.d.ts +21 -0
  185. package/dist/app/scripts/HorizontalChromosomeLabels.d.ts +47 -0
  186. package/dist/app/scripts/HorizontalGeneAnnotationsTrack.d.ts +25 -0
  187. package/dist/app/scripts/HorizontalHeatmapTrack.d.ts +12 -0
  188. package/dist/app/scripts/HorizontalItem.d.ts +3 -0
  189. package/dist/app/scripts/HorizontalLine1DPixiTrack.d.ts +23 -0
  190. package/dist/app/scripts/HorizontalMultivecTrack.d.ts +50 -0
  191. package/dist/app/scripts/HorizontalPoint1DPixiTrack.d.ts +5 -0
  192. package/dist/app/scripts/HorizontalRule.d.ts +22 -0
  193. package/dist/app/scripts/HorizontalTiled1DPixiTrack.d.ts +26 -0
  194. package/dist/app/scripts/HorizontalTiledPlot.d.ts +49 -0
  195. package/dist/app/scripts/HorizontalTrack.d.ts +6 -0
  196. package/dist/app/scripts/Id2DTiledPixiTrack.d.ts +10 -0
  197. package/dist/app/scripts/IdHorizontal1DTiledPixiTrack.d.ts +6 -0
  198. package/dist/app/scripts/IdVertical1DTiledPixiTrack.d.ts +7 -0
  199. package/dist/app/scripts/LeftAxisTrack.d.ts +9 -0
  200. package/dist/app/scripts/LeftTrackModifier.d.ts +29 -0
  201. package/dist/app/scripts/ListWrapper.d.ts +64 -0
  202. package/dist/app/scripts/MapboxTilesTrack.d.ts +9 -0
  203. package/dist/app/scripts/Modal.d.ts +5 -0
  204. package/dist/app/scripts/MoveableTrack.d.ts +18 -0
  205. package/dist/app/scripts/NestedContextMenu.d.ts +7 -0
  206. package/dist/app/scripts/OSMTileIdsTrack.d.ts +5 -0
  207. package/dist/app/scripts/OSMTilesTrack.d.ts +129 -0
  208. package/dist/app/scripts/OverlayTrack.d.ts +13 -0
  209. package/dist/app/scripts/PixiTrack.d.ts +174 -0
  210. package/dist/app/scripts/PlotTypeChooser.d.ts +25 -0
  211. package/dist/app/scripts/PopupMenu.d.ts +28 -0
  212. package/dist/app/scripts/RasterTilesTrack.d.ts +9 -0
  213. package/dist/app/scripts/RuleMixin.d.ts +2 -0
  214. package/dist/app/scripts/SVGTrack.d.ts +15 -0
  215. package/dist/app/scripts/SearchField.d.ts +13 -0
  216. package/dist/app/scripts/SeriesListItems.d.ts +2 -0
  217. package/dist/app/scripts/SeriesListMenu.d.ts +51 -0
  218. package/dist/app/scripts/SeriesListSubmenuMixin.d.ts +2 -0
  219. package/dist/app/scripts/SketchInlinePicker.d.ts +25 -0
  220. package/dist/app/scripts/SortableList.d.ts +22 -0
  221. package/dist/app/scripts/SquareMarkersTrack.d.ts +22 -0
  222. package/dist/app/scripts/Tiled1DPixiTrack.d.ts +60 -0
  223. package/dist/app/scripts/TiledPixiTrack.d.ts +369 -0
  224. package/dist/app/scripts/TiledPlot.d.ts +313 -0
  225. package/dist/app/scripts/TilesetFinder.d.ts +65 -0
  226. package/dist/app/scripts/TopAxisTrack.d.ts +9 -0
  227. package/dist/app/scripts/Track.d.ts +196 -0
  228. package/dist/app/scripts/TrackArea.d.ts +26 -0
  229. package/dist/app/scripts/TrackControl.d.ts +5 -0
  230. package/dist/app/scripts/TrackRenderer.d.ts +724 -0
  231. package/dist/app/scripts/UnknownPixiTrack.d.ts +7 -0
  232. package/dist/app/scripts/ValueIntervalTrack.d.ts +6 -0
  233. package/dist/app/scripts/VerticalItem.d.ts +3 -0
  234. package/dist/app/scripts/VerticalRule.d.ts +21 -0
  235. package/dist/app/scripts/VerticalTiled1DPixiTrack.d.ts +6 -0
  236. package/dist/app/scripts/VerticalTiledPlot.d.ts +50 -0
  237. package/dist/app/scripts/VerticalTrack.d.ts +6 -0
  238. package/dist/app/scripts/ViewConfigEditor.d.ts +53 -0
  239. package/dist/app/scripts/ViewContextMenu.d.ts +17 -0
  240. package/dist/app/scripts/ViewHeader.d.ts +75 -0
  241. package/dist/app/scripts/ViewportTracker2D.d.ts +17 -0
  242. package/dist/app/scripts/ViewportTracker2DPixi.d.ts +11 -0
  243. package/dist/app/scripts/ViewportTrackerHorizontal.d.ts +17 -0
  244. package/dist/app/scripts/ViewportTrackerVertical.d.ts +17 -0
  245. package/dist/app/scripts/api.d.ts +640 -0
  246. package/dist/app/scripts/configs/available-track-types.d.ts +2 -0
  247. package/dist/app/scripts/configs/colormaps.d.ts +2 -0
  248. package/dist/app/scripts/configs/datatype-to-track-type.d.ts +4 -0
  249. package/dist/app/scripts/configs/default-tracks-for-datatype.d.ts +38 -0
  250. package/dist/app/scripts/configs/dense-data-extrema-config.d.ts +2 -0
  251. package/dist/app/scripts/configs/globals.d.ts +5 -0
  252. package/dist/app/scripts/configs/index.d.ts +16 -0
  253. package/dist/app/scripts/configs/positions-by-datatype.d.ts +2 -0
  254. package/dist/app/scripts/configs/primitives.d.ts +20 -0
  255. package/dist/app/scripts/configs/themes.d.ts +3 -0
  256. package/dist/app/scripts/configs/tracks-info-by-type.d.ts +4 -0
  257. package/dist/app/scripts/configs/tracks-info.d.ts +24 -0
  258. package/dist/app/scripts/d3-context-menu.d.ts +2 -0
  259. package/dist/app/scripts/data-fetchers/DataFetcher.d.ts +151 -0
  260. package/dist/app/scripts/data-fetchers/genbank-fetcher.d.ts +86 -0
  261. package/dist/app/scripts/data-fetchers/index.d.ts +3 -0
  262. package/dist/app/scripts/data-fetchers/local-tile-fetcher.d.ts +47 -0
  263. package/dist/app/scripts/gosling-exports.d.ts +17 -0
  264. package/dist/app/scripts/hglib.d.ts +24 -0
  265. package/dist/app/scripts/hocs/with-modal.d.ts +19 -0
  266. package/dist/app/scripts/hocs/with-pub-sub.d.ts +22 -0
  267. package/dist/app/scripts/hocs/with-theme.d.ts +13 -0
  268. package/dist/app/scripts/icons.d.ts +161 -0
  269. package/dist/app/scripts/mixwith.d.ts +27 -0
  270. package/dist/app/scripts/options-info.d.ts +1355 -0
  271. package/dist/app/scripts/plugins/available-for-plugins.d.ts +2338 -0
  272. package/dist/app/scripts/plugins/get-data-fetcher.d.ts +2 -0
  273. package/dist/app/scripts/plugins/index.d.ts +2 -0
  274. package/dist/app/scripts/services/chrom-info.d.ts +10 -0
  275. package/dist/app/scripts/services/dom-event.d.ts +7 -0
  276. package/dist/app/scripts/services/element-resize-listener.d.ts +5 -0
  277. package/dist/app/scripts/services/index.d.ts +5 -0
  278. package/dist/app/scripts/services/tile-proxy.d.ts +180 -0
  279. package/dist/app/scripts/services/worker.d.ts +157 -0
  280. package/dist/app/scripts/symbol.d.ts +13 -0
  281. package/dist/app/scripts/test-helpers/index.d.ts +1 -0
  282. package/dist/app/scripts/test-helpers/test-helpers.d.ts +33 -0
  283. package/dist/app/scripts/track-utils.d.ts +73 -0
  284. package/dist/app/scripts/types.d.ts +199 -0
  285. package/dist/app/scripts/utils/DenseDataExtrema1D.d.ts +88 -0
  286. package/dist/app/scripts/utils/DenseDataExtrema2D.d.ts +97 -0
  287. package/dist/app/scripts/utils/LruCache.d.ts +44 -0
  288. package/dist/app/scripts/utils/abs-to-chr.d.ts +14 -0
  289. package/dist/app/scripts/utils/accessor-transposition.d.ts +14 -0
  290. package/dist/app/scripts/utils/add-arrays.d.ts +18 -0
  291. package/dist/app/scripts/utils/add-class.d.ts +8 -0
  292. package/dist/app/scripts/utils/add-event-listener-once.d.ts +11 -0
  293. package/dist/app/scripts/utils/assert.d.ts +17 -0
  294. package/dist/app/scripts/utils/background-task-scheduler.d.ts +47 -0
  295. package/dist/app/scripts/utils/base64-to-canvas.d.ts +9 -0
  296. package/dist/app/scripts/utils/chr-to-abs.d.ts +10 -0
  297. package/dist/app/scripts/utils/chrom-info-bisector.d.ts +4 -0
  298. package/dist/app/scripts/utils/clone-event.d.ts +12 -0
  299. package/dist/app/scripts/utils/color-domain-to-rgba-array.d.ts +13 -0
  300. package/dist/app/scripts/utils/color-to-hex.d.ts +9 -0
  301. package/dist/app/scripts/utils/color-to-rgba.d.ts +9 -0
  302. package/dist/app/scripts/utils/copy-text-to-clipboard.d.ts +2 -0
  303. package/dist/app/scripts/utils/data-to-genomic-loci.d.ts +11 -0
  304. package/dist/app/scripts/utils/debounce.d.ts +5 -0
  305. package/dist/app/scripts/utils/dec-to-hex-str.d.ts +8 -0
  306. package/dist/app/scripts/utils/decompress.d.ts +27 -0
  307. package/dist/app/scripts/utils/default-tracks.d.ts +3 -0
  308. package/dist/app/scripts/utils/dict-from-tuples.d.ts +11 -0
  309. package/dist/app/scripts/utils/dict-items.d.ts +18 -0
  310. package/dist/app/scripts/utils/dict-keys.d.ts +10 -0
  311. package/dist/app/scripts/utils/dict-values.d.ts +8 -0
  312. package/dist/app/scripts/utils/download.d.ts +7 -0
  313. package/dist/app/scripts/utils/expand-combined-tracks.d.ts +11 -0
  314. package/dist/app/scripts/utils/fake-pub-sub.d.ts +11 -0
  315. package/dist/app/scripts/utils/fill-in-min-widths.d.ts +44 -0
  316. package/dist/app/scripts/utils/flatten.d.ts +9 -0
  317. package/dist/app/scripts/utils/for-each.d.ts +9 -0
  318. package/dist/app/scripts/utils/forward-event.d.ts +7 -0
  319. package/dist/app/scripts/utils/genome-loci-to-pixels.d.ts +9 -0
  320. package/dist/app/scripts/utils/genomic-range-to-chromosome-chunks.d.ts +21 -0
  321. package/dist/app/scripts/utils/get-aggregation-function.d.ts +10 -0
  322. package/dist/app/scripts/utils/get-default-track-for-datatype.d.ts +21 -0
  323. package/dist/app/scripts/utils/get-default-tracks-for-datatype.d.ts +3 -0
  324. package/dist/app/scripts/utils/get-element-dim.d.ts +7 -0
  325. package/dist/app/scripts/utils/get-higlass-components.d.ts +7 -0
  326. package/dist/app/scripts/utils/get-track-by-uid.d.ts +7 -0
  327. package/dist/app/scripts/utils/get-track-conf-from-hgc.d.ts +10 -0
  328. package/dist/app/scripts/utils/get-track-obj-by-id.d.ts +2 -0
  329. package/dist/app/scripts/utils/get-track-position-by-uid.d.ts +13 -0
  330. package/dist/app/scripts/utils/get-xylofon.d.ts +2 -0
  331. package/dist/app/scripts/utils/gradient.d.ts +14 -0
  332. package/dist/app/scripts/utils/has-class.d.ts +8 -0
  333. package/dist/app/scripts/utils/has-parent.d.ts +9 -0
  334. package/dist/app/scripts/utils/hex-string-to-int.d.ts +14 -0
  335. package/dist/app/scripts/utils/index.d.ts +89 -0
  336. package/dist/app/scripts/utils/interval-tree.d.ts +109 -0
  337. package/dist/app/scripts/utils/into-the-void.d.ts +6 -0
  338. package/dist/app/scripts/utils/is-track-or-child-track.d.ts +7 -0
  339. package/dist/app/scripts/utils/is-track-range-selectable.d.ts +2 -0
  340. package/dist/app/scripts/utils/is-within.d.ts +12 -0
  341. package/dist/app/scripts/utils/lat-to-y.d.ts +9 -0
  342. package/dist/app/scripts/utils/lng-to-x.d.ts +8 -0
  343. package/dist/app/scripts/utils/load-chrom-infos.d.ts +8 -0
  344. package/dist/app/scripts/utils/map.d.ts +13 -0
  345. package/dist/app/scripts/utils/max-non-zero.d.ts +6 -0
  346. package/dist/app/scripts/utils/max.d.ts +10 -0
  347. package/dist/app/scripts/utils/min-non-zero.d.ts +6 -0
  348. package/dist/app/scripts/utils/min.d.ts +10 -0
  349. package/dist/app/scripts/utils/mod.d.ts +9 -0
  350. package/dist/app/scripts/utils/ndarray-assign.d.ts +2 -0
  351. package/dist/app/scripts/utils/ndarray-flatten.d.ts +2 -0
  352. package/dist/app/scripts/utils/ndarray-to-list.d.ts +2 -0
  353. package/dist/app/scripts/utils/numericify-version.d.ts +6 -0
  354. package/dist/app/scripts/utils/obj-vals.d.ts +8 -0
  355. package/dist/app/scripts/utils/or.d.ts +8 -0
  356. package/dist/app/scripts/utils/parse-chromsizes-rows.d.ts +34 -0
  357. package/dist/app/scripts/utils/pixi-text-to-svg.d.ts +2 -0
  358. package/dist/app/scripts/utils/positioned-tracks-to-all-tracks.d.ts +26 -0
  359. package/dist/app/scripts/utils/q.d.ts +18 -0
  360. package/dist/app/scripts/utils/rad-to-deg.d.ts +7 -0
  361. package/dist/app/scripts/utils/range-query-2d.d.ts +17 -0
  362. package/dist/app/scripts/utils/reduce.d.ts +14 -0
  363. package/dist/app/scripts/utils/rel-to-abs-chrom-pos.d.ts +10 -0
  364. package/dist/app/scripts/utils/remove-class.d.ts +7 -0
  365. package/dist/app/scripts/utils/reset-d3-brush-style.d.ts +10 -0
  366. package/dist/app/scripts/utils/rgb-to-hex.d.ts +8 -0
  367. package/dist/app/scripts/utils/scales-center-and-k.d.ts +12 -0
  368. package/dist/app/scripts/utils/scales-to-genome-loci.d.ts +3 -0
  369. package/dist/app/scripts/utils/segments-to-rows.d.ts +15 -0
  370. package/dist/app/scripts/utils/selected-items-to-cum-weights.d.ts +12 -0
  371. package/dist/app/scripts/utils/selected-items-to-size.d.ts +13 -0
  372. package/dist/app/scripts/utils/show-mouse-position.d.ts +54 -0
  373. package/dist/app/scripts/utils/some.d.ts +10 -0
  374. package/dist/app/scripts/utils/sum.d.ts +8 -0
  375. package/dist/app/scripts/utils/svg-line.d.ts +2 -0
  376. package/dist/app/scripts/utils/throttle-and-debounce.d.ts +33 -0
  377. package/dist/app/scripts/utils/tile-to-canvas.d.ts +9 -0
  378. package/dist/app/scripts/utils/timeout.d.ts +3 -0
  379. package/dist/app/scripts/utils/to-void.d.ts +3 -0
  380. package/dist/app/scripts/utils/total-track-pixel-height.d.ts +27 -0
  381. package/dist/app/scripts/utils/trim-trailing-slash.d.ts +7 -0
  382. package/dist/app/scripts/utils/type-guards.d.ts +36 -0
  383. package/dist/app/scripts/utils/value-to-color.d.ts +12 -0
  384. package/dist/app/scripts/utils/visit-positioned-tracks.d.ts +18 -0
  385. package/dist/app/scripts/utils/visit-tracks.d.ts +9 -0
  386. package/dist/esm.html +1 -3
  387. package/dist/hglib.js +86315 -100592
  388. package/dist/hglib.min.js +123 -131
  389. package/dist/higlass.mjs +88861 -103138
  390. package/dist/index.html +1 -3
  391. package/dist/package.json +134 -0
  392. package/package.json +25 -27
@@ -1,12 +1,12 @@
1
1
  // @ts-nocheck
2
+
2
3
  import boxIntersect from 'box-intersect';
3
4
  import { median, range } from 'd3-array';
4
5
  import { scaleBand, scaleLinear } from 'd3-scale';
5
- import classifyPoint from 'robust-point-in-polygon';
6
6
  import { zoomIdentity } from 'd3-zoom';
7
+ import classifyPoint from 'robust-point-in-polygon';
7
8
 
8
9
  import HorizontalTiled1DPixiTrack from './HorizontalTiled1DPixiTrack';
9
- import trackUtils from './track-utils';
10
10
 
11
11
  // Services
12
12
  import { tileProxy } from './services';
@@ -15,6 +15,7 @@ import {
15
15
  colorDomainToRgbaArray,
16
16
  colorToHex,
17
17
  segmentsToRows,
18
+ trackUtils,
18
19
  valueToColor,
19
20
  } from './utils';
20
21
 
@@ -29,6 +30,7 @@ const FONT_SIZE = 14;
29
30
  // the label text should have a white outline so that it's more
30
31
  // visible against a similar colored background
31
32
  const TEXT_STYLE = {
33
+ align: 'center',
32
34
  fontSize: `${FONT_SIZE}px`,
33
35
  fontFamily: 'Arial',
34
36
  stroke: 'white',
@@ -40,11 +42,245 @@ const TEXT_STYLE = {
40
42
  dropShadowBlur: 2,
41
43
  };
42
44
 
45
+ /** Scale a polygon * */
46
+ export const polyToPoly = (poly, kx, px, ky, py) => {
47
+ const newArr = [];
48
+
49
+ while (poly.length) {
50
+ const [x, y] = poly.splice(0, 2);
51
+ newArr.push([x * kx + px, y * ky + py]);
52
+ }
53
+
54
+ return newArr;
55
+ };
56
+
57
+ const hashFunc = (s) => {
58
+ let hash = 0;
59
+ if (s.length === 0) {
60
+ return hash;
61
+ }
62
+ for (let i = 0; i < s.length; i++) {
63
+ const char = s.charCodeAt(i);
64
+ hash = (hash << 5) - hash + char;
65
+ hash &= hash; // Convert to 32bit integer
66
+ }
67
+ return hash;
68
+ };
69
+
70
+ const scaleScalableGraphics = (graphics, xScale, drawnAtScale) => {
71
+ const tileK =
72
+ (drawnAtScale.domain()[1] - drawnAtScale.domain()[0]) /
73
+ (xScale.domain()[1] - xScale.domain()[0]);
74
+ const newRange = xScale.domain().map(drawnAtScale);
75
+
76
+ const posOffset = newRange[0];
77
+ graphics.scale.x = tileK;
78
+ graphics.position.x = -posOffset * tileK;
79
+ };
80
+
81
+ export const uniqueify = (elements) => {
82
+ const byUid = {};
83
+ for (let i = 0; i < elements.length; i++) {
84
+ byUid[elements[i].uid] = elements[i];
85
+ }
86
+
87
+ return Object.values(byUid);
88
+ };
89
+
90
+ export class TextManager {
91
+ constructor(track) {
92
+ this.track = track;
93
+ this.texts = {};
94
+
95
+ // store a list of already created texts so that we don't
96
+ // have to recreate new ones each time
97
+ this.textsList = [];
98
+
99
+ this.textWidths = {};
100
+ this.textHeights = {};
101
+
102
+ this.textGraphics = new GLOBALS.PIXI.Graphics();
103
+ this.track.pMain.addChild(this.textGraphics);
104
+
105
+ // Some default font size that will get overwriten when
106
+ // this.textWidths and this.textHeights are set
107
+ this.fontSize = 9;
108
+ }
109
+
110
+ hideOverlaps() {
111
+ const [allBoxes, allTexts] = [this.allBoxes, this.allTexts];
112
+ // Calculate overlaps from the bounding boxes of the texts
113
+
114
+ boxIntersect(allBoxes, (i, j) => {
115
+ if (allTexts[i].importance > allTexts[j].importance) {
116
+ if (allTexts[i].text.visible) {
117
+ allTexts[j].text.visible = false;
118
+ }
119
+ } else if (allTexts[j].text.visible) {
120
+ allTexts[i].text.visible = false;
121
+ }
122
+ });
123
+ }
124
+
125
+ startDraw() {
126
+ this.allBoxes = [];
127
+ this.allTexts = [];
128
+ }
129
+
130
+ lightUpdateSingleText(td, xMiddle, yMiddle, textInfo) {
131
+ if (!this.texts[td.uid]) return;
132
+ if (!this.track.options.showTexts) return;
133
+
134
+ const text = this.texts[td.uid];
135
+
136
+ const TEXT_MARGIN = 3;
137
+
138
+ text.position.x = xMiddle;
139
+ text.position.y = yMiddle;
140
+
141
+ text.visible = true;
142
+ this.allBoxes.push([
143
+ text.position.x - TEXT_MARGIN,
144
+ text.position.y - this.textHeights[td.uid] / 2,
145
+ text.position.x + this.textWidths[td.uid] + TEXT_MARGIN,
146
+ text.position.y + this.textHeights[td.uid] / 2,
147
+ ]);
148
+
149
+ this.allTexts.push({
150
+ text,
151
+ ...textInfo,
152
+ });
153
+ }
154
+
155
+ updateSingleText(td, xMiddle, yMiddle, textText) {
156
+ if (!this.texts[td.uid]) return;
157
+
158
+ const text = this.texts[td.uid];
159
+
160
+ text.position.x = xMiddle;
161
+ text.position.y = yMiddle;
162
+ text.nominalY = yMiddle;
163
+
164
+ const fontColor =
165
+ this.track.options.fontColor !== undefined
166
+ ? colorToHex(this.track.options.fontColor)
167
+ : 'black';
168
+
169
+ const newFontSize = +this.track.options.fontSize || TEXT_STYLE.fontSize;
170
+ if (newFontSize !== this.fontSize) {
171
+ // New font size means different text widths and heights
172
+ this.fontSize = newFontSize;
173
+ this.textWidths = {};
174
+ this.textHeights = {};
175
+ }
176
+
177
+ text.style = {
178
+ ...TEXT_STYLE,
179
+ fill: fontColor,
180
+ fontSize: this.fontSize,
181
+ };
182
+ text.text = textText;
183
+
184
+ if (!(td.uid in this.textWidths)) {
185
+ text.updateTransform();
186
+ const textWidth = text.getBounds().width;
187
+ const textHeight = text.getBounds().height;
188
+
189
+ // the text size adjustment compensates for the extra
190
+ // size that the show gives it
191
+ const TEXT_SIZE_ADJUSTMENT = 5;
192
+
193
+ this.textWidths[td.uid] = textWidth;
194
+ this.textHeights[td.uid] = textHeight - TEXT_SIZE_ADJUSTMENT;
195
+ }
196
+ }
197
+
198
+ updateTexts() {
199
+ if (this.track.options.showTexts) {
200
+ this.texts = {};
201
+
202
+ let yRange = [
203
+ (0 - this.track.vertY) / (this.track.vertK * this.track.prevK),
204
+ (this.track.dimensions[1] - this.track.vertY) /
205
+ (this.track.vertK * this.track.prevK),
206
+ ];
207
+
208
+ const yRangeWidth = yRange[1] - yRange[0];
209
+ yRange = [yRange[0] - yRangeWidth * 0.8, yRange[1] + yRangeWidth * 0.8];
210
+
211
+ const relevantSegments = this.track.uniqueSegments.filter(
212
+ (x) => !x.yMiddle || (x.yMiddle > yRange[0] && x.yMiddle < yRange[1]),
213
+ );
214
+
215
+ relevantSegments.forEach((td, i) => {
216
+ // don't draw too many texts so they don't bog down the frame rate
217
+ if (i >= (+this.track.options.maxTexts || MAX_TEXTS)) {
218
+ return;
219
+ }
220
+
221
+ let text = this.textsList[i];
222
+
223
+ if (!text) {
224
+ text = new GLOBALS.PIXI.Text();
225
+ this.textsList.push(text);
226
+ this.textGraphics.addChild(text);
227
+ }
228
+
229
+ text.style = {
230
+ ...TEXT_STYLE,
231
+ fontSize: +this.track.options.fontSize || TEXT_STYLE.fontSize,
232
+ };
233
+
234
+ // geneInfo[3] is the gene symbol
235
+
236
+ if (this.track.isLeftModified) {
237
+ text.scale.x = -1;
238
+ }
239
+
240
+ text.anchor.x = 0.5;
241
+ text.anchor.y = 0.5;
242
+
243
+ this.texts[td.uid] = text;
244
+ });
245
+
246
+ while (
247
+ this.textsList.length >
248
+ Math.min(
249
+ relevantSegments.length,
250
+ +this.track.options.maxTexts || MAX_TEXTS,
251
+ )
252
+ ) {
253
+ const text = this.textsList.pop();
254
+ this.textGraphics.removeChild(text);
255
+ }
256
+ }
257
+ }
258
+ }
259
+
43
260
  class BedLikeTrack extends HorizontalTiled1DPixiTrack {
44
261
  constructor(context, options) {
45
262
  super(context, options);
46
263
 
47
264
  this.valueScaleTransform = zoomIdentity;
265
+
266
+ this.textManager = new TextManager(this);
267
+
268
+ this.vertY = 1;
269
+ this.vertK = 0;
270
+ this.prevY = 0;
271
+ this.prevK = 1;
272
+
273
+ // we're setting these functions to null so that value scale
274
+ // locking doesn't try to get values from them
275
+ this.minRawValue = null;
276
+ this.maxRawValue = null;
277
+
278
+ this.rectGraphics = new GLOBALS.PIXI.Graphics();
279
+ this.pMain.addChild(this.rectGraphics);
280
+
281
+ this.selectedRect = null;
282
+
283
+ this.uniqueSegments = [];
48
284
  }
49
285
 
50
286
  /** Factor out some initialization code for the track. This is
@@ -71,118 +307,102 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
71
307
  this.initialized = true;
72
308
  }
73
309
 
74
- initTile(tile) {
75
- // create texts
76
- tile.texts = {};
77
-
78
- tile.rectGraphics = new GLOBALS.PIXI.Graphics();
79
- tile.textGraphics = new GLOBALS.PIXI.Graphics();
80
-
81
- tile.graphics.addChild(tile.rectGraphics);
82
- tile.graphics.addChild(tile.textGraphics);
310
+ updateExistingGraphics() {
311
+ const errors = this._checkForErrors();
83
312
 
84
313
  let plusStrandRows = [];
85
314
  let minusStrandRows = [];
86
315
 
87
- if (tile.tileData && tile.tileData.length) {
88
- tile.tileData.sort((a, b) => b.importance - a.importance);
89
- // tile.tileData = tile.tileData.slice(0, MAX_TILE_ENTRIES);
90
-
91
- if (!this.options || !this.options.valueColumn) {
92
- // no value column so we can break entries up into separate
93
- // plus and minus strand segments
94
- const segments = tile.tileData.map((x) => {
95
- const chrOffset = +x.chrOffset;
96
-
97
- return {
98
- from: +x.fields[1] + chrOffset,
99
- to: +x.fields[2] + chrOffset,
100
- value: x,
101
- text: x.fields[3],
102
- strand: x.fields.length >= 6 && x.fields[5] === '-' ? '-' : '+',
103
- };
104
- });
105
-
106
- plusStrandRows = segmentsToRows(
107
- segments.filter((x) => x.strand === '+'),
108
- );
109
- minusStrandRows = segmentsToRows(
110
- segments.filter((x) => x.strand === '-'),
111
- );
112
- } else {
113
- plusStrandRows = [tile.tileData.map((x) => ({ value: x }))];
316
+ if (errors.length > 0) {
317
+ this.draw();
318
+ return;
319
+ }
320
+
321
+ // Object.values(this.fetchedTiles
322
+
323
+ this.uniqueSegments = uniqueify(
324
+ Object.values(this.fetchedTiles)
325
+ .filter((x) => x.tileData.length)
326
+ .flatMap((x) => x.tileData),
327
+ );
328
+
329
+ this.uniqueSegments.forEach((td) => {
330
+ // A random importance helps with selective hiding
331
+ // of overlapping texts
332
+ if (!td.importance) {
333
+ td.importance = hashFunc(td.uid.toString());
114
334
  }
335
+ });
115
336
 
116
- tile.plusStrandRows = plusStrandRows;
117
- tile.minusStrandRows = minusStrandRows;
337
+ this.uniqueSegments.sort((a, b) => b.importance - a.importance);
118
338
 
119
- if (this.options.showTexts) {
120
- tile.tileData.forEach((td, i) => {
121
- const geneInfo = td.fields;
339
+ if (!this.options || !this.options.valueColumn) {
340
+ // no value column so we can break entries up into separate
341
+ // plus and minus strand segments
342
+ const segments = this.uniqueSegments.map((x) => {
343
+ const chrOffset = +x.chrOffset;
122
344
 
123
- // A random importance helps with selective hiding
124
- // of overlapping texts
125
- if (!td.importance) {
126
- td.importance = Math.random();
127
- }
128
- tile.textWidths = {};
129
- tile.textHeights = {};
345
+ return {
346
+ from: +x.fields[1] + chrOffset,
347
+ to: +x.fields[2] + chrOffset,
348
+ value: x,
349
+ text: x.fields[3],
350
+ strand: x.fields.length >= 6 && x.fields[5] === '-' ? '-' : '+',
351
+ };
352
+ });
130
353
 
131
- // don't draw too many texts so they don't bog down the frame rate
132
- if (i >= (+this.options.maxTexts || MAX_TEXTS)) {
133
- return;
134
- }
354
+ plusStrandRows = segmentsToRows(segments.filter((x) => x.strand === '+'));
355
+ minusStrandRows = segmentsToRows(
356
+ segments.filter((x) => x.strand === '-'),
357
+ );
358
+ } else {
359
+ plusStrandRows = [this.uniqueSegments.map((x) => ({ value: x }))];
360
+ }
135
361
 
136
- // geneInfo[3] is the gene symbol
137
- const text = new GLOBALS.PIXI.Text(geneInfo[3], {
138
- ...TEXT_STYLE,
139
- fontSize: +this.options.fontSize || TEXT_STYLE.fontSize,
140
- });
141
- if (this.flipText) {
142
- text.scale.x = -1;
143
- }
362
+ this.plusStrandRows = plusStrandRows;
363
+ this.minusStrandRows = minusStrandRows;
144
364
 
145
- text.anchor.x = 0.5;
146
- text.anchor.y = 0.5;
365
+ this.textManager.updateTexts();
366
+ this.render();
367
+ }
147
368
 
148
- tile.texts[td.uid] = text; // index by geneName
369
+ selectRect(uid) {
370
+ this.selectedRect = uid;
149
371
 
150
- tile.textGraphics.addChild(text);
151
- });
152
- }
153
- }
372
+ this.render();
373
+ this.animate();
374
+ }
154
375
 
155
- tile.initialized = true;
376
+ /** There was a click outside the track so unselect the
377
+ * the current selection */
378
+ clickOutside() {
379
+ this.selectRect(null);
156
380
  }
157
381
 
382
+ initTile(tile) {}
383
+
158
384
  /**
159
385
  * Remove the tile's rectangles from the list of drawnRects so that they
160
386
  * can be drawn again.
161
387
  */
162
- removeTileRects(tile) {
163
- const zoomLevel = +tile.tileId.split('.')[0];
164
- tile.rectGraphics.clear();
165
- tile.rendered = false;
166
-
167
- if (tile.tileData && tile.tileData.length) {
168
- tile.tileData.forEach((td, i) => {
169
- if (this.drawnRects[zoomLevel] && this.drawnRects[zoomLevel][td.uid]) {
170
- if (this.drawnRects[zoomLevel][td.uid][2] === tile.tileId) {
171
- // this was the tile that drew that rectangle
172
- delete this.drawnRects[zoomLevel][td.uid];
173
- }
174
- }
175
- });
176
- }
177
- }
178
-
179
- destroyTile(tile) {
180
- // remove texts
181
- this.removeTileRects(tile);
182
-
183
- tile.graphics.removeChild(tile.textGraphics);
184
- tile.graphics.removeChild(tile.rectGraphics);
185
- }
388
+ // removeTileRects(tile) {
389
+ // const zoomLevel = +tile.tileId.split('.')[0];
390
+ // tile.rectGraphics.clear();
391
+ // tile.rendered = false;
392
+
393
+ // if (tile.tileData && tile.tileData.length) {
394
+ // tile.tileData.forEach((td, i) => {
395
+ // if (this.drawnRects[zoomLevel] && this.drawnRects[zoomLevel][td.uid]) {
396
+ // if (this.drawnRects[zoomLevel][td.uid][2] === tile.tileId) {
397
+ // // this was the tile that drew that rectangle
398
+ // delete this.drawnRects[zoomLevel][td.uid];
399
+ // }
400
+ // }
401
+ // });
402
+ // }
403
+ // }
404
+
405
+ destroyTile(tile) {}
186
406
 
187
407
  removeTiles(toRemoveIds) {
188
408
  super.removeTiles(toRemoveIds);
@@ -196,7 +416,7 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
196
416
  }
197
417
 
198
418
  drawTile(tile) {
199
- if (this.options && this.options.valueColumn) {
419
+ if (this.options?.valueColumn) {
200
420
  // there might no be a value scale if no valueColumn was specified
201
421
  if (this.valueScale) this.drawAxis(this.valueScale);
202
422
  }
@@ -215,20 +435,16 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
215
435
  this.colorScale = HEATED_OBJECT_MAP;
216
436
  }
217
437
 
218
- for (const tile of this.visibleAndFetchedTiles()) {
219
- this.destroyTile(tile);
220
- this.initTile(tile);
221
- this.renderTile(tile);
222
- }
438
+ this.updateExistingGraphics();
223
439
  }
224
440
 
225
441
  updateTile(tile) {
226
442
  // this.destroyTile(tile);
227
- if (this.areAllVisibleTilesLoaded()) {
228
- // this.destroyTile(tile);
229
- // this.initTile(tile);
230
- this.renderTile(tile);
231
- }
443
+ // if (this.areAllVisibleTilesLoaded()) {
444
+ // this.destroyTile(tile);
445
+ // this.initTile(tile);
446
+ // this.renderTile(tile);
447
+ // }
232
448
  }
233
449
 
234
450
  /**
@@ -276,7 +492,7 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
276
492
  return allRects;
277
493
  }
278
494
 
279
- drawSegmentStyle(tile, xStartPos, xEndPos, rectY, rectHeight, strand) {
495
+ drawSegmentStyle(xStartPos, xEndPos, rectY, rectHeight, strand) {
280
496
  const hw = 0.1; // half width of the line
281
497
 
282
498
  const centerY = rectY + rectHeight / 2;
@@ -308,16 +524,15 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
308
524
  rectY + rectHeight,
309
525
  ];
310
526
 
311
- tile.rectGraphics.drawPolygon(poly);
527
+ this.rectGraphics.drawPolygon(poly);
312
528
  return poly;
313
529
  }
314
530
 
315
- drawPoly(tile, xStartPos, xEndPos, rectY, rectHeight, strand) {
531
+ drawPoly(xStartPos, xEndPos, rectY, rectHeight, strand) {
316
532
  let drawnPoly = null;
317
533
 
318
534
  if (this.options.annotationStyle === 'segment') {
319
535
  return this.drawSegmentStyle(
320
- tile,
321
536
  xStartPos,
322
537
  xEndPos,
323
538
  rectY,
@@ -341,7 +556,7 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
341
556
  ];
342
557
 
343
558
  if (strand === '+') {
344
- tile.rectGraphics.drawPolygon(drawnPoly);
559
+ this.rectGraphics.drawPolygon(drawnPoly);
345
560
  } else {
346
561
  drawnPoly = [
347
562
  xEndPos,
@@ -351,7 +566,7 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
351
566
  xEndPos,
352
567
  rectY + rectHeight, // bottom
353
568
  ];
354
- tile.rectGraphics.drawPolygon(drawnPoly);
569
+ this.rectGraphics.drawPolygon(drawnPoly);
355
570
  }
356
571
  } else {
357
572
  if (strand === '+') {
@@ -393,7 +608,7 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
393
608
  ];
394
609
  }
395
610
 
396
- tile.rectGraphics.drawPolygon(drawnPoly);
611
+ this.rectGraphics.drawPolygon(drawnPoly);
397
612
  }
398
613
 
399
614
  return drawnPoly;
@@ -404,7 +619,7 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
404
619
  setValueScale() {
405
620
  this.valueScale = null;
406
621
 
407
- if (this.options && this.options.valueColumn) {
622
+ if (this.options?.valueColumn) {
408
623
  /**
409
624
  * These intervals come with some y-value that we want to plot
410
625
  */
@@ -431,8 +646,7 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
431
646
  this.colorValueScale = null;
432
647
 
433
648
  if (
434
- this.options &&
435
- this.options.colorEncoding &&
649
+ this.options?.colorEncoding &&
436
650
  this.options.colorEncoding !== 'itemRgb'
437
651
  ) {
438
652
  const min = this.options.colorEncodingRange
@@ -446,16 +660,14 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
446
660
  }
447
661
  }
448
662
 
449
- renderRows(tile, rows, maxRows, startY, endY, fill) {
450
- const zoomLevel = +tile.tileId.split('.')[0];
663
+ renderRows(rows, maxRows, startY, endY, fill) {
451
664
  let maxValue = Number.MIN_SAFE_INTEGER;
452
665
 
453
666
  this.initialize();
454
667
 
455
- const rowScale = scaleBand()
456
- .domain(range(maxRows))
457
- .range([startY, endY])
458
- .paddingInner(0.3);
668
+ const rowScale = scaleBand().domain(range(maxRows)).range([startY, endY]);
669
+ // .paddingOuter(0.2);
670
+ // .paddingInner(0.3)
459
671
 
460
672
  this.allVisibleRects();
461
673
  let allRects = null;
@@ -470,15 +682,12 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
470
682
  const td = rows[j][i].value;
471
683
  const geneInfo = td.fields;
472
684
 
473
- // the returned positions are chromosome-based and they need to
474
- // be converted to genome-based
475
- const chrOffset = +td.chrOffset;
476
- const txStart = +geneInfo[1] + chrOffset;
477
- const txEnd = +geneInfo[2] + chrOffset;
685
+ const txStart = +td.xStart;
686
+ const txEnd = +td.xEnd;
478
687
  const txMiddle = (txStart + txEnd) / 2;
479
- let yMiddle = rowScale(j) + rowScale.step() / 2;
688
+ let yMiddle = rowScale(j) + rowScale.bandwidth() / 2;
480
689
 
481
- let rectHeight = this.options.annotationHeight || GENE_RECT_HEIGHT;
690
+ let rectHeight = this.options.annotationHeight || 'scaled';
482
691
 
483
692
  if (rectHeight === 'scaled') {
484
693
  rectHeight = rowScale.bandwidth();
@@ -496,7 +705,12 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
496
705
  this.options.colorEncoding === 'itemRgb' &&
497
706
  td.fields[8]
498
707
  ) {
499
- const parts = td.fields[8].split(',');
708
+ let parts = [];
709
+
710
+ try {
711
+ parts = td.fields[8].split(',');
712
+ // eslint-disable-next-line
713
+ } catch {}
500
714
 
501
715
  if (parts.length === 3) {
502
716
  const color = `rgb(${td.fields[8]})`;
@@ -511,6 +725,18 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
511
725
  -Number.MIN_VALUE,
512
726
  )(+geneInfo[+this.options.colorEncoding - 1]);
513
727
  fill = `rgba(${rgb.join(',')})`;
728
+ } else if (
729
+ this.options &&
730
+ this.options.colorEncoding === 'itemRgb' &&
731
+ td.fields[8]
732
+ ) {
733
+ const parts = td.fields[8].split(',');
734
+
735
+ if (parts.length === 3) {
736
+ const color = `rgb(${td.fields[8]})`;
737
+
738
+ fill = color;
739
+ }
514
740
  }
515
741
 
516
742
  if (this.valueScale) {
@@ -518,13 +744,18 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
518
744
  if (value > maxValue) {
519
745
  maxValue = value;
520
746
  }
521
-
522
747
  yMiddle = this.valueScale(value);
523
748
  }
524
749
 
525
750
  const opacity = this.options.fillOpacity || 0.3;
526
- tile.rectGraphics.lineStyle(1, colorToHex(fill), opacity);
527
- tile.rectGraphics.beginFill(colorToHex(fill), opacity);
751
+
752
+ if (this.selectedRect === td.uid) {
753
+ this.rectGraphics.lineStyle(3, 0, 0.75);
754
+ } else {
755
+ this.rectGraphics.lineStyle(1, colorToHex(fill), opacity);
756
+ }
757
+
758
+ this.rectGraphics.beginFill(colorToHex(fill), opacity);
528
759
 
529
760
  let rectY = yMiddle - rectHeight / 2;
530
761
  const xStartPos = this._xScale(txStart);
@@ -539,114 +770,58 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
539
770
  rectY += STAGGERED_OFFSET / 2;
540
771
  }
541
772
  }
773
+ const drawnPoly = this.drawPoly(
774
+ xStartPos,
775
+ xEndPos,
776
+ rectY * this.prevK,
777
+ rectHeight * this.prevK,
778
+ geneInfo[5],
779
+ );
542
780
 
543
- let alreadyDrawn = true;
544
-
545
- // don't draw anything that has already been drawn
546
- if (
547
- !(
548
- zoomLevel in this.drawnRects && td.uid in this.drawnRects[zoomLevel]
549
- )
550
- ) {
551
- alreadyDrawn = false;
552
-
553
- if (!this.drawnRects[zoomLevel]) this.drawnRects[zoomLevel] = {};
781
+ this.drawnRects[td.uid] = [
782
+ drawnPoly,
783
+ {
784
+ start: txStart,
785
+ end: txEnd,
786
+ value: td,
787
+ fill,
788
+ },
789
+ ];
554
790
 
555
- const drawnPoly = this.drawPoly(
556
- tile,
557
- xStartPos,
558
- xEndPos,
559
- rectY * this.prevK,
560
- rectHeight * this.prevK,
561
- geneInfo[5],
562
- );
791
+ td.yMiddle = yMiddle;
563
792
 
564
- this.drawnRects[zoomLevel][td.uid] = [
565
- drawnPoly,
566
- {
567
- start: txStart,
568
- end: txEnd,
569
- value: td,
570
- tile,
571
- fill,
572
- },
573
- tile.tileId,
574
- ];
793
+ if (!this.options.showTexts) {
794
+ continue;
575
795
  }
576
796
 
577
- if (!this.options.showTexts) continue;
578
-
579
- // tile probably hasn't been initialized yet
580
- if (!tile.texts) return;
581
-
582
797
  // don't draw too many texts so they don't bog down the frame rate
583
798
  if (i >= (+this.options.maxTexts || MAX_TEXTS)) continue;
584
799
 
585
- if (!tile.texts[td.uid]) continue;
586
-
587
- const text = tile.texts[td.uid];
588
-
589
- text.position.x = this._xScale(txMiddle);
590
- text.position.y = rectY + rectHeight / 2;
591
- text.nominalY = rectY + rectHeight / 2;
592
-
593
- if (alreadyDrawn) {
594
- text.alreadyDrawn = true;
595
- }
596
-
597
- const fontColor =
598
- this.options.fontColor !== undefined
599
- ? colorToHex(this.options.fontColor)
600
- : fill;
601
-
602
- text.style = {
603
- ...TEXT_STYLE,
604
- fill: fontColor,
605
- fontSize: +this.options.fontSize || TEXT_STYLE.fontSize,
606
- };
607
-
608
- if (!(geneInfo[3] in tile.textWidths)) {
609
- text.updateTransform();
610
- const textWidth = text.getBounds().width;
611
- const textHeight = text.getBounds().height;
612
-
613
- // the text size adjustment compensates for the extra
614
- // size that the show gives it
615
- const TEXT_SIZE_ADJUSTMENT = 5;
616
-
617
- tile.textWidths[geneInfo[3]] = textWidth;
618
- tile.textHeights[geneInfo[3]] = textHeight - TEXT_SIZE_ADJUSTMENT;
619
- }
800
+ this.textManager.updateSingleText(
801
+ td,
802
+ this._xScale(txMiddle),
803
+ rectY + rectHeight / 2,
804
+ td.fields[3],
805
+ );
620
806
  }
621
807
  }
622
- }
623
-
624
- renderTile(tile) {
625
- let maxPlusRows = tile.plusStrandRows ? tile.plusStrandRows.length : 1;
626
- let maxMinusRows = tile.minusStrandRows ? tile.minusStrandRows.length : 1;
627
808
 
628
- // const visibleAndFetchedTiles = this.visibleAndFetchedTiles();
809
+ this.textManager.updateTexts();
810
+ }
629
811
 
630
- // if (!visibleAndFetchedTiles.length) return;
812
+ render() {
813
+ const maxPlusRows = this.plusStrandRows ? this.plusStrandRows.length : 1;
814
+ const maxMinusRows = this.minusStrandRows ? this.minusStrandRows.length : 1;
631
815
 
632
- for (const otherTile of this.visibleAndFetchedTiles()) {
633
- if (!otherTile.initialized) return;
634
- if (!otherTile.plusStrandRows && !otherTile.minusStrandRows) continue;
816
+ this.prevVertY = this.vertY;
635
817
 
636
- maxPlusRows = Math.max(otherTile.plusStrandRows.length, maxPlusRows);
637
- maxMinusRows = Math.max(otherTile.minusStrandRows.length, maxMinusRows);
638
- }
818
+ const oldRectGraphics = this.rectGraphics;
819
+ this.rectGraphics = new GLOBALS.PIXI.Graphics();
639
820
 
640
821
  // store the scale at while the tile was drawn at so that
641
822
  // we only resize it when redrawing
642
823
 
643
- if (tile.rendered) {
644
- this.removeTileRects(tile);
645
- }
646
-
647
- tile.drawnAtScale = this._xScale.copy();
648
- tile.rendered = true;
649
-
824
+ this.drawnAtScale = this._xScale.copy();
650
825
  // configure vertical positioning of annotations if
651
826
  // this.options.valueColumn is set
652
827
  this.setValueScale();
@@ -655,44 +830,39 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
655
830
  // this.options.colorEncoding is set
656
831
  this.setColorValueScale();
657
832
 
658
- if (tile.tileData && tile.tileData.length) {
659
- const fill =
660
- this.options.plusStrandColor || this.options.fillColor || 'blue';
661
- const minusStrandFill =
662
- this.options.minusStrandColor || this.options.fillColor || 'purple';
663
-
664
- const MIDDLE_SPACE = 0;
665
- let plusHeight = 0;
833
+ const fill =
834
+ this.options.plusStrandColor || this.options.fillColor || 'blue';
835
+ const minusStrandFill =
836
+ this.options.minusStrandColor || this.options.fillColor || 'purple';
666
837
 
667
- if (this.options.separatePlusMinusStrands) {
668
- plusHeight =
669
- (maxPlusRows * this.dimensions[1]) / (maxPlusRows + maxMinusRows) -
670
- MIDDLE_SPACE / 2;
671
- } else {
672
- plusHeight = this.dimensions[1];
673
- }
838
+ const MIDDLE_SPACE = 0;
839
+ let plusHeight = 0;
674
840
 
675
- this.renderRows(
676
- tile,
677
- tile.plusStrandRows,
678
- maxPlusRows,
679
- 0,
680
- plusHeight,
681
- fill,
682
- );
683
- this.renderRows(
684
- tile,
685
- tile.minusStrandRows,
686
- maxMinusRows,
687
- this.options.separatePlusMinusStrands
688
- ? plusHeight + MIDDLE_SPACE / 2
689
- : 0,
690
- this.dimensions[1],
691
- minusStrandFill,
692
- );
841
+ if (this.options.separatePlusMinusStrands) {
842
+ plusHeight =
843
+ (maxPlusRows * this.dimensions[1]) / (maxPlusRows + maxMinusRows) -
844
+ MIDDLE_SPACE / 2;
845
+ } else {
846
+ plusHeight = this.dimensions[1];
693
847
  }
694
848
 
695
- trackUtils.stretchRects(this, [(x) => x.rectGraphics]);
849
+ this.renderRows(this.plusStrandRows, maxPlusRows, 0, plusHeight, fill);
850
+ this.renderRows(
851
+ this.minusStrandRows,
852
+ maxMinusRows,
853
+ this.options.separatePlusMinusStrands ? plusHeight + MIDDLE_SPACE / 2 : 0,
854
+ this.dimensions[1],
855
+ minusStrandFill,
856
+ );
857
+
858
+ this.pMain.removeChild(oldRectGraphics);
859
+ // this.pMain.removeChild(oldTextGraphics);
860
+
861
+ this.pMain.addChild(this.rectGraphics);
862
+ // this.pMain.addChild(this.textGraphics);
863
+
864
+ scaleScalableGraphics(this.rectGraphics, this._xScale, this.drawnAtScale);
865
+ // scaleScalableGraphics(this.textGraphics, this._xScale, this.drawnAtScale);
696
866
  }
697
867
 
698
868
  calculateZoomLevel() {
@@ -721,7 +891,7 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
721
891
  null,
722
892
  visibleAndFetchedIds
723
893
  .map((x) => this.fetchedTiles[x])
724
- .filter((x) => x.tileData && x.tileData.length)
894
+ .filter((x) => x.tileData?.length)
725
895
  .map((x) =>
726
896
  Math.min.apply(
727
897
  null,
@@ -753,7 +923,7 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
753
923
  null,
754
924
  visibleAndFetchedIds
755
925
  .map((x) => this.fetchedTiles[x])
756
- .filter((x) => x.tileData && x.tileData.length)
926
+ .filter((x) => x.tileData?.length)
757
927
  .map((x) =>
758
928
  Math.max.apply(
759
929
  null,
@@ -789,7 +959,7 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
789
959
  .concat(
790
960
  ...visibleAndFetchedIds
791
961
  .map((x) => this.fetchedTiles[x])
792
- .filter((x) => x.tileData && x.tileData.length)
962
+ .filter((x) => x.tileData?.length)
793
963
  .map((x) =>
794
964
  x.tileData
795
965
  .sort((a, b) => b.importance - a.importance)
@@ -805,97 +975,45 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
805
975
  draw() {
806
976
  super.draw();
807
977
 
808
- this.allTexts = [];
809
- this.allBoxes = [];
810
-
811
- for (const fetchedTileId in this.fetchedTiles) {
812
- const tile = this.fetchedTiles[fetchedTileId];
813
-
814
- // these values control vertical scaling and they
815
- // need to be set in the draw method otherwise when
816
- // the window is resized, the zoomedY method won't
817
- // be called
818
- tile.rectGraphics.scale.y = this.vertK;
819
- tile.rectGraphics.position.y = this.vertY;
820
-
821
- // hasn't been rendered yet
822
- if (!tile.drawnAtScale) {
823
- return;
824
- }
825
-
826
- trackUtils.stretchRects(this, [(x) => x.rectGraphics]);
978
+ this.textManager.startDraw();
827
979
 
828
- // move the texts
980
+ // these values control vertical scaling and they
981
+ // need to be set in the draw method otherwise when
982
+ // the window is resized, the zoomedY method won't
983
+ // be called
984
+ this.rectGraphics.scale.y = this.vertK;
985
+ this.rectGraphics.position.y = this.vertY;
829
986
 
830
- const parentInFetched = this.parentInFetched(tile);
831
-
832
- if (!tile.initialized) {
833
- continue;
834
- }
835
-
836
- if (tile.tileData && tile.tileData.length) {
837
- tile.tileData.forEach((td) => {
838
- if (!tile.texts) {
839
- // tile probably hasn't been initialized yet
840
- return;
841
- }
842
-
843
- const geneInfo = td.fields;
844
- const geneName = geneInfo[3];
845
- const text = tile.texts[td.uid];
846
-
847
- if (!text) {
848
- return;
849
- }
850
-
851
- const chrOffset = +td.chrOffset;
852
- const txStart = +geneInfo[1] + chrOffset;
853
- const txEnd = +geneInfo[2] + chrOffset;
854
- const txMiddle = (txStart + txEnd) / 2;
855
-
856
- text.position.x = this._xScale(txMiddle);
857
- text.position.y =
858
- text.nominalY * (this.vertK * this.prevK) + this.vertY;
859
-
860
- if (!parentInFetched && !text.alreadyDrawn) {
861
- text.visible = true;
862
- // TODO, change the line below to true if texts are desired in the future
863
- // text.visible = false;
864
- const TEXT_MARGIN = 3;
865
- this.allBoxes.push([
866
- text.position.x - TEXT_MARGIN,
867
- text.position.y - tile.textHeights[geneInfo[3]] / 2,
868
- text.position.x + tile.textWidths[geneInfo[3]] + TEXT_MARGIN,
869
- text.position.y + tile.textHeights[geneInfo[3]] / 2,
870
- ]);
871
- this.allTexts.push({
872
- importance: td.importance,
873
- text,
874
- caption: geneName,
875
- strand: geneInfo[5],
876
- });
877
- } else {
878
- text.visible = false;
879
- }
880
- });
881
- }
987
+ // hasn't been rendered yet
988
+ if (!this.drawnAtScale) {
989
+ return;
882
990
  }
883
991
 
884
- this.hideOverlaps(this.allBoxes, this.allTexts);
885
- }
886
-
887
- hideOverlaps(allBoxes, allTexts) {
888
- // Calculate overlaps from the bounding boxes of the texts
992
+ scaleScalableGraphics(this.rectGraphics, this._xScale, this.drawnAtScale);
993
+ // scaleScalableGraphics(this.textGraphics, this._xScale, this.drawnAtScale);
889
994
 
890
- boxIntersect(allBoxes, (i, j) => {
891
- if (allTexts[i].importance > allTexts[j].importance) {
892
- if (allTexts[i].text.visible) {
893
- allTexts[j].text.visible = false;
995
+ if (this.uniqueSegments?.length) {
996
+ this.uniqueSegments.forEach((td) => {
997
+ const geneInfo = td.fields;
998
+ const geneName = geneInfo[3];
999
+
1000
+ const xMiddle = this._xScale((td.xStart + td.xEnd) / 2);
1001
+ if (this.textManager.texts[td.uid]) {
1002
+ const yMiddle =
1003
+ this.textManager.texts[td.uid].nominalY *
1004
+ (this.vertK * this.prevK) +
1005
+ this.vertY;
1006
+
1007
+ this.textManager.lightUpdateSingleText(td, xMiddle, yMiddle, {
1008
+ importance: td.importance,
1009
+ caption: geneName,
1010
+ strand: geneInfo[5],
1011
+ });
894
1012
  }
895
- } else if (allTexts[j].text.visible) {
896
- allTexts[i].text.visible = false;
897
- }
898
- });
1013
+ });
1014
+ }
1015
+
1016
+ this.textManager.hideOverlaps();
899
1017
  }
900
1018
 
901
1019
  setPosition(newPosition) {
@@ -940,101 +1058,93 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
940
1058
  output.appendChild(rectOutput);
941
1059
  output.appendChild(textOutput);
942
1060
 
943
- for (const tile of this.visibleAndFetchedTiles()) {
944
- if (!tile.tileData.length) {
945
- continue;
946
- }
947
-
948
- tile.tileData.forEach((td) => {
949
- const zoomLevel = +tile.tileId.split('.')[0];
1061
+ this.uniqueSegments.forEach((td) => {
1062
+ const gTile = document.createElement('g');
1063
+ gTile.setAttribute(
1064
+ 'transform',
1065
+ `translate(${this.rectGraphics.position.x},${this.rectGraphics.position.y})scale(${this.rectGraphics.scale.x},${this.rectGraphics.scale.y})`,
1066
+ );
1067
+ rectOutput.appendChild(gTile);
950
1068
 
951
- const gTile = document.createElement('g');
952
- gTile.setAttribute(
953
- 'transform',
954
- `translate(${tile.rectGraphics.position.x},${tile.rectGraphics.position.y})scale(${tile.rectGraphics.scale.x},${tile.rectGraphics.scale.y})`,
955
- );
956
- rectOutput.appendChild(gTile);
1069
+ if (this.drawnRects && td.uid in this.drawnRects) {
1070
+ const rect = this.drawnRects[td.uid][0];
1071
+ const r = document.createElement('path');
957
1072
 
958
- if (
959
- this.drawnRects[zoomLevel] &&
960
- td.uid in this.drawnRects[zoomLevel]
961
- ) {
962
- const rect = this.drawnRects[zoomLevel][td.uid][0];
963
- const r = document.createElement('path');
964
- let d = `M ${rect[0]} ${rect[1]}`;
1073
+ let d = `M ${rect[0]} ${rect[1]}`;
965
1074
 
966
- for (let i = 2; i < rect.length; i += 2) {
967
- d += ` L ${rect[i]} ${rect[i + 1]}`;
968
- }
1075
+ for (let i = 2; i < rect.length; i += 2) {
1076
+ d += ` L ${rect[i]} ${rect[i + 1]}`;
1077
+ }
969
1078
 
970
- const fill = this.drawnRects[zoomLevel][td.uid][1].fill;
971
- const fontColor =
972
- this.options.fontColor !== undefined
973
- ? colorToHex(this.options.fontColor)
974
- : fill;
1079
+ const fill = this.drawnRects[td.uid][1].fill;
1080
+ const fontColor =
1081
+ this.options.fontColor !== undefined
1082
+ ? colorToHex(this.options.fontColor)
1083
+ : fill;
975
1084
 
976
- r.setAttribute('d', d);
977
- r.setAttribute('fill', fill);
978
- r.setAttribute('opacity', 0.3);
1085
+ r.setAttribute('d', d);
1086
+ r.setAttribute('fill', fill);
1087
+ r.setAttribute('opacity', 0.3);
979
1088
 
980
- r.style.stroke = fill;
981
- r.style.strokeWidth = '1px';
1089
+ r.style.stroke = fill;
1090
+ r.style.strokeWidth = '1px';
982
1091
 
983
- gTile.appendChild(r);
1092
+ gTile.appendChild(r);
984
1093
 
985
- if (tile.texts[td.uid]) {
986
- const text = tile.texts[td.uid];
1094
+ if (this.textManager.texts[td.uid]) {
1095
+ const text = this.textManager.texts[td.uid];
987
1096
 
988
- if (!text.visible) {
989
- return;
990
- }
1097
+ if (!text.visible) {
1098
+ return;
1099
+ }
991
1100
 
992
- const g = document.createElement('g');
993
- const t = document.createElement('text');
1101
+ const g = document.createElement('g');
1102
+ const t = document.createElement('text');
994
1103
 
995
- textOutput.appendChild(g);
996
- g.appendChild(t);
997
- g.setAttribute(
998
- 'transform',
999
- `translate(${text.x},${text.y})scale(${text.scale.x},1)`,
1000
- );
1104
+ textOutput.appendChild(g);
1105
+ g.appendChild(t);
1106
+ g.setAttribute(
1107
+ 'transform',
1108
+ `translate(${text.x},${text.y})scale(${text.scale.x},1)`,
1109
+ );
1001
1110
 
1002
- t.setAttribute('text-anchor', 'middle');
1003
- t.setAttribute('font-family', TEXT_STYLE.fontFamily);
1004
- t.setAttribute(
1005
- 'font-size',
1006
- +this.options.fontSize || TEXT_STYLE.fontSize,
1007
- );
1008
- t.setAttribute('font-weight', 'bold');
1009
- t.setAttribute('dy', '5px');
1010
- t.setAttribute('fill', fontColor);
1011
- t.setAttribute('stroke', TEXT_STYLE.stroke);
1012
- t.setAttribute('stroke-width', '0.4');
1013
- t.setAttribute('text-shadow', '0px 0px 2px grey');
1014
-
1015
- t.innerHTML = text.text;
1016
- }
1111
+ t.setAttribute('text-anchor', 'middle');
1112
+ t.setAttribute('font-family', TEXT_STYLE.fontFamily);
1113
+ t.setAttribute(
1114
+ 'font-size',
1115
+ +this.options.fontSize || TEXT_STYLE.fontSize,
1116
+ );
1117
+ t.setAttribute('font-weight', 'bold');
1118
+ t.setAttribute('dy', '5px');
1119
+ t.setAttribute('fill', fontColor);
1120
+ t.setAttribute('stroke', TEXT_STYLE.stroke);
1121
+ t.setAttribute('stroke-width', '0.4');
1122
+ t.setAttribute('text-shadow', '0px 0px 2px grey');
1123
+
1124
+ t.innerHTML = text.text;
1017
1125
  }
1018
- });
1019
- }
1126
+ }
1127
+ });
1020
1128
 
1021
1129
  return [base, base];
1022
1130
  }
1023
1131
 
1024
1132
  /** Move event for the y-axis */
1025
1133
  movedY(dY) {
1026
- Object.values(this.fetchedTiles).forEach((tile) => {
1027
- const vst = this.valueScaleTransform;
1028
- const { y, k } = vst;
1029
- const height = this.dimensions[1];
1030
- // clamp at the bottom and top
1031
- if (y + dY / k > -(k - 1) * height && y + dY / k < 0) {
1032
- this.valueScaleTransform = vst.translate(0, dY / k);
1033
- }
1034
- tile.rectGraphics.position.y = this.valueScaleTransform.y;
1035
- this.vertY = this.valueScaleTransform.y;
1036
- });
1134
+ const vst = this.valueScaleTransform;
1135
+ const { y, k } = vst;
1136
+ const height = this.dimensions[1];
1137
+ // clamp at the bottom and top
1138
+ if (y + dY / k > -(k - 1) * height && y + dY / k < 0) {
1139
+ this.valueScaleTransform = vst.translate(0, dY / k);
1140
+ }
1141
+ this.rectGraphics.position.y = this.valueScaleTransform.y;
1142
+ this.vertY = this.valueScaleTransform.y;
1037
1143
  this.animate();
1144
+
1145
+ if (this.vertY - this.prevVertY > this.dimensions[1] / 2) {
1146
+ this.render();
1147
+ }
1038
1148
  }
1039
1149
 
1040
1150
  /** Zoomed along the y-axis */
@@ -1066,13 +1176,14 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
1066
1176
  this.vertK = k1;
1067
1177
  this.vertY = t1;
1068
1178
 
1069
- Object.values(this.fetchedTiles).forEach((tile) => {
1070
- if (toStretch) this.renderTile(tile);
1071
-
1072
- tile.rectGraphics.scale.y = k1;
1073
- tile.rectGraphics.position.y = t1;
1074
- });
1179
+ if (toStretch) {
1180
+ this.render();
1181
+ }
1182
+ this.rectGraphics.scale.y = k1;
1183
+ this.rectGraphics.position.y = t1;
1075
1184
 
1185
+ // this.textGraphics.scale.y = k1;
1186
+ // this.textGraphics.position.y = t1;
1076
1187
  this.draw();
1077
1188
  this.animate();
1078
1189
  }
@@ -1082,40 +1193,36 @@ class BedLikeTrack extends HorizontalTiled1DPixiTrack {
1082
1193
  return '';
1083
1194
  }
1084
1195
 
1085
- const zoomLevel = this.calculateZoomLevel();
1086
- const point = [trackX, trackY];
1087
-
1088
- if (this.drawnRects[zoomLevel]) {
1089
- const visibleRects = Object.values(this.drawnRects[zoomLevel]);
1090
-
1091
- for (let i = 0; i < visibleRects.length; i++) {
1092
- const rect = visibleRects[i][0].slice(0);
1196
+ if (!this.drawnRects) {
1197
+ return '';
1198
+ }
1093
1199
 
1094
- // graphics have been scaled so we need to scale the points themselves
1095
- const tileKx = visibleRects[i][1].tile.rectGraphics.scale.x;
1096
- const tilePx = visibleRects[i][1].tile.rectGraphics.position.x;
1200
+ const closestText = '';
1201
+ const point = [trackX, trackY];
1097
1202
 
1098
- const tileKy = visibleRects[i][1].tile.rectGraphics.scale.y;
1099
- const tilePy = visibleRects[i][1].tile.rectGraphics.position.y;
1203
+ const visibleRects = Object.values(this.drawnRects);
1100
1204
 
1101
- const newArr = [];
1205
+ for (let i = 0; i < visibleRects.length; i++) {
1206
+ const rect = visibleRects[i][0].slice(0);
1102
1207
 
1103
- while (rect.length) {
1104
- const [x, y] = rect.splice(0, 2);
1105
- newArr.push([x * tileKx + tilePx, y * tileKy + tilePy]);
1106
- }
1208
+ const newArr = polyToPoly(
1209
+ rect,
1210
+ this.rectGraphics.scale.x,
1211
+ this.rectGraphics.position.x,
1212
+ this.rectGraphics.scale.y,
1213
+ this.rectGraphics.position.y,
1214
+ );
1107
1215
 
1108
- const pc = classifyPoint(newArr, point);
1216
+ const pc = classifyPoint(newArr, point);
1109
1217
 
1110
- if (pc === -1) {
1111
- const parts = visibleRects[i][1].value.fields;
1218
+ if (pc === -1) {
1219
+ const parts = visibleRects[i][1].value.fields;
1112
1220
 
1113
- return parts.join(' ');
1114
- }
1221
+ return parts.join(' ');
1115
1222
  }
1116
1223
  }
1117
1224
 
1118
- return '';
1225
+ return closestText;
1119
1226
  }
1120
1227
  }
1121
1228