higlass 2.2.0 → 2.2.2

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.
@@ -22,3 +22,9 @@ declare module 'pub-sub-es' {
22
22
  export function createPubSub(): PubSub;
23
23
  export const globalPubSub: PubSub;
24
24
  }
25
+
26
+ // see ../scripts/virtual-stylesheet-plugin.mjs
27
+ declare module 'virtual:stylesheet' {
28
+ const styles: string;
29
+ export default styles;
30
+ }
@@ -491,7 +491,7 @@ class HiGlassComponent extends React.Component {
491
491
 
492
492
  const thisElement = this.topDivRef.current;
493
493
 
494
- if (thisElement && document.body.contains(thisElement)) {
494
+ if (thisElement?.getRootNode().contains(thisElement)) {
495
495
  callback();
496
496
  } else {
497
497
  requestAnimationFrame(() => this.waitForDOMAttachment(callback));
@@ -1,5 +1,6 @@
1
1
  // @ts-nocheck
2
2
  import { axisLeft } from 'd3-axis';
3
+ import { format } from 'd3-format';
3
4
 
4
5
  import SVGTrack from './SVGTrack';
5
6
 
@@ -25,6 +26,17 @@ class LeftAxisTrack extends SVGTrack {
25
26
 
26
27
  draw() {
27
28
  this.axis.scale(this._yScale);
29
+
30
+ if (
31
+ this.options.reverseAxis === 'yes' ||
32
+ this.options.reverseAxis === true
33
+ ) {
34
+ const defaultFormat = format(',');
35
+ this.axis.tickFormat((d) => defaultFormat(-d));
36
+ } else {
37
+ this.axis.tickFormat(null);
38
+ }
39
+
28
40
  this.gAxis.call(this.axis);
29
41
 
30
42
  return this;
@@ -101,7 +101,7 @@ export function getValueScale(
101
101
  * @typedef TiledPixiTrackContextBase
102
102
  * @property {DataFetcher} dataFetcher
103
103
  * @property {t.DataConfig} dataConfig
104
- * @property {function} animate A function to redraw this track. Typically called when an
104
+ * @property {Function} animate A function to redraw this track. Typically called when an
105
105
  * asynchronous event occurs (i.e. tiles loaded)
106
106
  * @property {() => void} onValueScaleChanged The range of values has changed so we need to inform
107
107
  * the higher ups that the value scale has changed. Only occurs on tracks with ``dense`` data.
@@ -174,7 +174,7 @@ class TiledPixiTrack extends PixiTrack {
174
174
  this.fetchedTiles = {};
175
175
 
176
176
  // the graphics that have already been drawn for this track
177
- /** @type {Object.<string, import('pixi.js').DisplayObject>} */
177
+ /** @type {Record<string, import('pixi.js').DisplayObject>} */
178
178
  this.tileGraphics = {};
179
179
 
180
180
  /** @type {number} */
@@ -359,7 +359,7 @@ class TiledPixiTrack extends PixiTrack {
359
359
  * event is ``dataChanged``.
360
360
  *
361
361
  * @param {string} event The event to listen for
362
- * @param {function} callback The callback to call when the event occurs. The
362
+ * @param {Function} callback The callback to call when the event occurs. The
363
363
  * parameters for the event depend on the event called.
364
364
  *
365
365
  * @example
@@ -378,7 +378,7 @@ class TiledPixiTrack extends PixiTrack {
378
378
 
379
379
  /**
380
380
  * @param {string} event The event to listen for
381
- * @param {function} callback The callback to call when the event occurs. The
381
+ * @param {Function} callback The callback to call when the event occurs. The
382
382
  * parameters for the event depend on the event called.
383
383
  */
384
384
  off(event, callback) {
@@ -188,7 +188,7 @@ export class TiledPlot extends React.Component {
188
188
 
189
189
  const thisElement = this.divTiledPlot;
190
190
 
191
- if (document.body.contains(thisElement)) {
191
+ if (thisElement?.getRootNode().contains(thisElement)) {
192
192
  callback();
193
193
  } else {
194
194
  requestAnimationFrame(() => this.waitForDOMAttachment(callback));
@@ -108,9 +108,10 @@ export const TRACKS_INFO = [
108
108
  orientation: '1d-vertical',
109
109
  name: 'Left Axis',
110
110
  thumbnail: svgVertical1DAxisIcon,
111
- availableOptions: ['minWidth'],
111
+ availableOptions: ['minWidth', 'reverseAxis'],
112
112
  defaultOptions: {
113
113
  minWidth: 100,
114
+ reverseAxis: false,
114
115
  },
115
116
  },
116
117
  {
@@ -7,6 +7,23 @@ import HorizontalGeneAnnotationsTrack from './HorizontalGeneAnnotationsTrack';
7
7
  import SVGTrack from './SVGTrack';
8
8
  import TiledPixiTrack from './TiledPixiTrack';
9
9
 
10
+ import CSS from 'virtual:stylesheet';
11
+
12
+ // Auto-inject styles into document.head for backwards compatibility.
13
+ // Uses a data attribute to prevent duplicate injection.
14
+ if (
15
+ CSS &&
16
+ typeof document !== 'undefined' &&
17
+ !document.querySelector('[data-higlass-styles]')
18
+ ) {
19
+ const style = document.createElement('style');
20
+ style.setAttribute('data-higlass-styles', '');
21
+ style.textContent = CSS;
22
+ document.head.appendChild(style);
23
+ }
24
+
25
+ export { CSS };
26
+
10
27
  export { default as ChromosomeInfo } from './ChromosomeInfo';
11
28
  export { default as HiGlassComponent } from './HiGlassComponent';
12
29
  export {
@@ -521,6 +521,11 @@ export const OPTIONS_INFO = {
521
521
  inlineOptions: sizesInPx([0, 10, 20, 30, 40, 50, 100, 200, 400], 'px'),
522
522
  },
523
523
 
524
+ reverseAxis: {
525
+ name: 'Reverse Axis',
526
+ inlineOptions: YES_NO,
527
+ },
528
+
524
529
  colorbarPosition: {
525
530
  name: 'Colorbar Position',
526
531
  inlineOptions: {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Convert a 1D numerical array into a canvas image
3
- * @param {Uint8ClampedArray} pixData - 1D data array
3
+ * @param {Uint8ClampedArray<ArrayBuffer>} pixData - 1D data array
4
4
  * @param {number} w - Width
5
5
  * @param {number} h - Height
6
6
  * @return {object} Canvas object
@@ -115,7 +115,7 @@ export type ExtendedTiledPixiTrackOptions<T> = T & TiledPixiTrackOptions;
115
115
  * @typedef TiledPixiTrackContextBase
116
116
  * @property {DataFetcher} dataFetcher
117
117
  * @property {t.DataConfig} dataConfig
118
- * @property {function} animate A function to redraw this track. Typically called when an
118
+ * @property {Function} animate A function to redraw this track. Typically called when an
119
119
  * asynchronous event occurs (i.e. tiles loaded)
120
120
  * @property {() => void} onValueScaleChanged The range of values has changed so we need to inform
121
121
  * the higher ups that the value scale has changed. Only occurs on tracks with ``dense`` data.
@@ -165,10 +165,8 @@ declare class TiledPixiTrack<Options extends ExtendedTiledPixiTrackOptions<{
165
165
  fetchedTiles: {
166
166
  [id: string]: Tile;
167
167
  };
168
- /** @type {Object.<string, import('pixi.js').DisplayObject>} */
169
- tileGraphics: {
170
- [x: string]: import("pixi.js").DisplayObject;
171
- };
168
+ /** @type {Record<string, import('pixi.js').DisplayObject>} */
169
+ tileGraphics: Record<string, import("pixi.js").DisplayObject>;
172
170
  /** @type {number} */
173
171
  maxZoom: number;
174
172
  medianVisibleValue: number | null | undefined;
@@ -229,7 +227,7 @@ declare class TiledPixiTrack<Options extends ExtendedTiledPixiTrackOptions<{
229
227
  * event is ``dataChanged``.
230
228
  *
231
229
  * @param {string} event The event to listen for
232
- * @param {function} callback The callback to call when the event occurs. The
230
+ * @param {Function} callback The callback to call when the event occurs. The
233
231
  * parameters for the event depend on the event called.
234
232
  *
235
233
  * @example
@@ -241,7 +239,7 @@ declare class TiledPixiTrack<Options extends ExtendedTiledPixiTrackOptions<{
241
239
  on(event: string, callback: Function): void;
242
240
  /**
243
241
  * @param {string} event The event to listen for
244
- * @param {function} callback The callback to call when the event occurs. The
242
+ * @param {Function} callback The callback to call when the event occurs. The
245
243
  * parameters for the event depend on the event called.
246
244
  */
247
245
  off(event: string, callback: Function): void;
@@ -147,5 +147,4 @@ import type { HandleTilesetInfoFinished } from '../types';
147
147
  import type { DataConfig } from '../types';
148
148
  import DenseDataExtrema1D from '../utils/DenseDataExtrema1D';
149
149
  import DenseDataExtrema2D from '../utils/DenseDataExtrema2D';
150
- import type { DataConfig as DataConfig_1 } from '../types';
151
150
  import type { TilesetInfo } from '../types';
@@ -1,3 +1,4 @@
1
+ export { CSS };
1
2
  export { default as ChromosomeInfo } from "./ChromosomeInfo";
2
3
  export { default as HiGlassComponent } from "./HiGlassComponent";
3
4
  export namespace tracks {
@@ -14,6 +15,7 @@ export * as hggos from "./gosling-exports";
14
15
  export type HiGlassApi = api.HiGlassApi["public"];
15
16
  export type HiGlassOptions = types.HiGlassOptions;
16
17
  export type HiGlassViewConfig = types.HiGlassViewConfig;
18
+ import CSS from 'virtual:stylesheet';
17
19
  import SVGTrack from './SVGTrack';
18
20
  import TiledPixiTrack from './TiledPixiTrack';
19
21
  import HorizontalGeneAnnotationsTrack from './HorizontalGeneAnnotationsTrack';