oncoprintjs 5.0.3 → 6.0.1

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 (100) hide show
  1. package/README.md +34 -0
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.es.js +14746 -0
  4. package/dist/index.es.js.map +1 -0
  5. package/dist/index.js +14760 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/js/CachedProperty.d.ts +10 -10
  8. package/dist/js/binarysearch.d.ts +1 -1
  9. package/dist/js/bucketsort.d.ts +16 -16
  10. package/dist/js/clustering.d.ts +14 -14
  11. package/dist/js/extractrgba.d.ts +4 -4
  12. package/dist/js/haselementsininterval.d.ts +1 -1
  13. package/dist/js/heatmapcolors.d.ts +5 -4
  14. package/dist/js/makesvgelement.d.ts +1 -1
  15. package/dist/js/modelutils.d.ts +7 -7
  16. package/dist/js/oncoprint.d.ts +168 -170
  17. package/dist/js/oncoprintheaderview.d.ts +23 -22
  18. package/dist/js/oncoprintlabelview.d.ts +79 -78
  19. package/dist/js/oncoprintlegendrenderer.d.ts +32 -31
  20. package/dist/js/oncoprintminimapview.d.ts +69 -68
  21. package/dist/js/oncoprintmodel.d.ts +403 -398
  22. package/dist/js/oncoprintruleset.d.ts +176 -177
  23. package/dist/js/oncoprintshape.d.ts +67 -67
  24. package/dist/js/oncoprintshapetosvg.d.ts +2 -2
  25. package/dist/js/oncoprintshapetovertexes.d.ts +5 -5
  26. package/dist/js/oncoprinttooltip.d.ts +23 -22
  27. package/dist/js/oncoprinttrackinfoview.d.ts +40 -39
  28. package/dist/js/oncoprinttrackoptionsview.d.ts +58 -57
  29. package/dist/js/oncoprintwebglcellview.d.ts +168 -167
  30. package/dist/js/oncoprintzoomslider.d.ts +28 -27
  31. package/dist/js/polyfill.d.ts +4 -4
  32. package/dist/js/precomputedcomparator.d.ts +13 -13
  33. package/dist/js/shaders.d.ts +2 -2
  34. package/dist/js/svgfactory.d.ts +24 -23
  35. package/dist/js/utils.d.ts +16 -16
  36. package/dist/js/workers/clustering-worker.d.ts +19 -20
  37. package/dist/test/gradientCategoricalRuleset.spec.d.ts +1 -1
  38. package/dist/test/monolith.spec.d.ts +1 -1
  39. package/jest.config.ts +2 -0
  40. package/package.json +20 -26
  41. package/rollup.config.ts +14 -0
  42. package/rules/geneticrules.ts +344 -305
  43. package/server.js +11 -0
  44. package/src/img/menudots.svg +9 -9
  45. package/src/img/zoomtofit.svg +12 -12
  46. package/src/index.tsx +13 -0
  47. package/src/js/CachedProperty.ts +6 -7
  48. package/src/js/binarysearch.ts +8 -3
  49. package/src/js/bucketsort.ts +89 -47
  50. package/src/js/clustering.ts +22 -10
  51. package/src/js/extractrgba.ts +16 -12
  52. package/src/js/haselementsininterval.ts +8 -4
  53. package/src/js/heatmapcolors.ts +515 -515
  54. package/src/js/main.js +1 -1
  55. package/src/js/makesvgelement.ts +2 -2
  56. package/src/js/modelutils.ts +11 -8
  57. package/src/js/oncoprint.ts +706 -385
  58. package/src/js/oncoprintheaderview.ts +165 -125
  59. package/src/js/oncoprintlabelview.ts +388 -170
  60. package/src/js/oncoprintlegendrenderer.ts +203 -72
  61. package/src/js/oncoprintminimapview.ts +965 -423
  62. package/src/js/oncoprintmodel.ts +905 -532
  63. package/src/js/oncoprintruleset.ts +694 -379
  64. package/src/js/oncoprintshape.ts +240 -97
  65. package/src/js/oncoprintshapetosvg.ts +77 -26
  66. package/src/js/oncoprintshapetovertexes.ts +153 -48
  67. package/src/js/oncoprinttooltip.ts +58 -27
  68. package/src/js/oncoprinttrackinfoview.ts +115 -59
  69. package/src/js/oncoprinttrackoptionsview.ts +354 -187
  70. package/src/js/oncoprintwebglcellview.ts +951 -415
  71. package/src/js/oncoprintzoomslider.ts +172 -107
  72. package/src/js/polyfill.ts +7 -3
  73. package/src/js/precomputedcomparator.ts +133 -50
  74. package/src/js/shaders.ts +2 -4
  75. package/src/js/svgfactory.ts +128 -73
  76. package/src/js/utils.ts +51 -31
  77. package/src/js/workers/clustering-worker.ts +50 -42
  78. package/src/test/gradientCategoricalRuleset.spec.ts +55 -38
  79. package/src/test/monolith.spec.ts +718 -285
  80. package/test/generate_data.py +108 -0
  81. package/test/glyphmap-data.js +1041 -0
  82. package/test/heatmap-data.js +1027 -0
  83. package/test/index.html +21 -0
  84. package/test/oncoprint-glyphmap.js +79 -0
  85. package/test/oncoprint-heatmap.js +123 -0
  86. package/tsconfig.json +4 -10
  87. package/tsconfig.test.json +11 -0
  88. package/.idea/misc.xml +0 -6
  89. package/.idea/modules.xml +0 -8
  90. package/.idea/oncoprintjs.iml +0 -12
  91. package/.idea/vcs.xml +0 -6
  92. package/.idea/workspace.xml +0 -105
  93. package/dist/.gitkeep +0 -0
  94. package/dist/js/minimaputils.d.ts +0 -0
  95. package/dist/oncoprint.bundle.js +0 -44313
  96. package/jest.config.js +0 -12
  97. package/src/js/minimaputils.ts +0 -0
  98. package/typings/custom.d.ts +0 -7
  99. package/typings/missing.d.ts +0 -7
  100. package/webpack.config.js +0 -43
@@ -1,42 +1,49 @@
1
- import $ from "jquery";
1
+ import $ from 'jquery';
2
2
  import MouseMoveEvent = JQuery.MouseMoveEvent;
3
3
  import MouseDownEvent = JQuery.MouseDownEvent;
4
4
 
5
- const VERTICAL = "v";
6
- const HORIZONTAL = "h";
5
+ const VERTICAL = 'v';
6
+ const HORIZONTAL = 'h';
7
7
 
8
- function clamp(x:number) {
8
+ function clamp(x: number) {
9
9
  return Math.max(Math.min(x, 1), 0);
10
10
  }
11
11
 
12
12
  export type OncoprintZoomSliderParams = {
13
- btn_size: number,
14
- horizontal?: boolean,
15
- width?:number,
13
+ btn_size: number;
14
+ horizontal?: boolean;
15
+ width?: number;
16
16
 
17
- vertical?:boolean, // either horizontal and width, or vertical and height, must be set
18
- height?:number,
17
+ vertical?: boolean; // either horizontal and width, or vertical and height, must be set
18
+ height?: number;
19
19
 
20
- init_val: number,
21
- left:number,
22
- top:number,
23
- onChange:(val:number)=>void
20
+ init_val: number;
21
+ left: number;
22
+ top: number;
23
+ onChange: (val: number) => void;
24
24
  };
25
25
 
26
26
  export default class OncoprintZoomSlider {
27
- private $div:JQuery;
28
- private onChange:OncoprintZoomSliderParams["onChange"];
29
- private value:number;
30
- private slider_bar_size:number;
31
- private orientation:"v"|"h";
32
- private $slider:JQuery;
33
- private $plus_btn:JQuery;
34
- private $minus_btn:JQuery;
35
-
36
- constructor($container:JQuery, params?:Partial<OncoprintZoomSliderParams>) {
37
- this.$div = $('<div>').css({'position':'absolute',
38
- 'top': params.top || 0,
39
- 'left': params.left || 0}).appendTo($container);
27
+ private $div: JQuery;
28
+ private onChange: OncoprintZoomSliderParams['onChange'];
29
+ private value: number;
30
+ private slider_bar_size: number;
31
+ private orientation: 'v' | 'h';
32
+ private $slider: JQuery;
33
+ private $plus_btn: JQuery;
34
+ private $minus_btn: JQuery;
35
+
36
+ constructor(
37
+ $container: JQuery,
38
+ params?: Partial<OncoprintZoomSliderParams>
39
+ ) {
40
+ this.$div = $('<div>')
41
+ .css({
42
+ position: 'absolute',
43
+ top: params.top || 0,
44
+ left: params.left || 0,
45
+ })
46
+ .appendTo($container);
40
47
  params = params || {};
41
48
  params.btn_size = params.btn_size || 13;
42
49
  this.onChange = params.onChange || function() {};
@@ -44,72 +51,110 @@ export default class OncoprintZoomSlider {
44
51
  this.initialize(params as OncoprintZoomSliderParams);
45
52
 
46
53
  this.value = params.init_val === undefined ? 0.5 : params.init_val;
47
- this.slider_bar_size = (this.orientation === VERTICAL ? params.height : params.width) - 2*params.btn_size;
54
+ this.slider_bar_size =
55
+ (this.orientation === VERTICAL ? params.height : params.width) -
56
+ 2 * params.btn_size;
48
57
  this.updateSliderPos();
49
58
  }
50
59
 
51
- private initialize(params:OncoprintZoomSliderParams) {
60
+ private initialize(params: OncoprintZoomSliderParams) {
52
61
  var $ctr = this.$div;
53
62
  var icon_size = Math.round(params.btn_size * 0.7);
54
- var icon_padding = Math.round((params.btn_size - icon_size)/2);
55
- var $slider_bar = $('<div>').css({'position':'absolute',
56
- 'background-color':'#ffffff',
57
- 'outline': 'solid 1px black'}).appendTo($ctr);
58
- var $slider = $('<div>').css({'position':'absolute',
59
- 'background-color':'#ffffff',
60
- 'border': 'solid 1px black',
61
- 'border-radius': '3px',
62
- 'cursor': 'pointer'}).appendTo($ctr);
63
-
64
- var $plus_btn = $('<div>').css({'position':'absolute',
65
- 'min-height': params.btn_size,
66
- 'min-width': params.btn_size,
67
- 'background-color':'#ffffff',
68
- 'border': 'solid 1px black',
69
- 'border-radius': '3px',
70
- 'cursor': 'pointer'})
63
+ var icon_padding = Math.round((params.btn_size - icon_size) / 2);
64
+ var $slider_bar = $('<div>')
65
+ .css({
66
+ position: 'absolute',
67
+ 'background-color': '#ffffff',
68
+ outline: 'solid 1px black',
69
+ })
70
+ .appendTo($ctr);
71
+ var $slider = $('<div>')
72
+ .css({
73
+ position: 'absolute',
74
+ 'background-color': '#ffffff',
75
+ border: 'solid 1px black',
76
+ 'border-radius': '3px',
77
+ cursor: 'pointer',
78
+ })
71
79
  .appendTo($ctr);
72
- $('<span>').addClass("icon fa fa-plus").css({'position':'absolute',
73
- 'top':icon_padding,
74
- 'left':icon_padding,
75
- 'min-width':icon_size,
76
- 'min-height':icon_size})
80
+
81
+ var $plus_btn = $('<div>')
82
+ .css({
83
+ position: 'absolute',
84
+ 'min-height': params.btn_size,
85
+ 'min-width': params.btn_size,
86
+ 'background-color': '#ffffff',
87
+ border: 'solid 1px black',
88
+ 'border-radius': '3px',
89
+ cursor: 'pointer',
90
+ })
91
+ .appendTo($ctr);
92
+ $('<span>')
93
+ .addClass('icon fa fa-plus')
94
+ .css({
95
+ position: 'absolute',
96
+ top: icon_padding,
97
+ left: icon_padding,
98
+ 'min-width': icon_size,
99
+ 'min-height': icon_size,
100
+ })
77
101
  .appendTo($plus_btn);
78
- var $minus_btn = $('<div>').css({'position':'absolute',
79
- 'min-height': params.btn_size,
80
- 'min-width': params.btn_size,
81
- 'background-color':'#ffffff',
82
- 'border': 'solid 1px black',
83
- 'border-radius': '3px',
84
- 'cursor': 'pointer'})
102
+ var $minus_btn = $('<div>')
103
+ .css({
104
+ position: 'absolute',
105
+ 'min-height': params.btn_size,
106
+ 'min-width': params.btn_size,
107
+ 'background-color': '#ffffff',
108
+ border: 'solid 1px black',
109
+ 'border-radius': '3px',
110
+ cursor: 'pointer',
111
+ })
85
112
  .appendTo($ctr);
86
- $('<span>').addClass("icon fa fa-minus").css({'position':'absolute',
87
- 'top':icon_padding,
88
- 'left':icon_padding,
89
- 'min-width':icon_size,
90
- 'min-height':icon_size})
113
+ $('<span>')
114
+ .addClass('icon fa fa-minus')
115
+ .css({
116
+ position: 'absolute',
117
+ top: icon_padding,
118
+ left: icon_padding,
119
+ 'min-width': icon_size,
120
+ 'min-height': icon_size,
121
+ })
91
122
  .appendTo($minus_btn);
92
123
  if (params.vertical) {
93
- $slider_bar.css({'min-height': params.height - 2 * params.btn_size,
94
- 'min-width': Math.round(params.btn_size / 5)});
95
- $slider.css({'min-height': Math.round(params.btn_size / 2),
96
- 'min-width': params.btn_size});
97
-
98
- $plus_btn.css({'top': 0, 'left': 0});
99
- $minus_btn.css({'top': params.height - params.btn_size, 'left': 0});
100
- $slider_bar.css({'top': params.btn_size, 'left': 0.4 * params.btn_size});
101
- $slider.css({'left': 0});
124
+ $slider_bar.css({
125
+ 'min-height': params.height - 2 * params.btn_size,
126
+ 'min-width': Math.round(params.btn_size / 5),
127
+ });
128
+ $slider.css({
129
+ 'min-height': Math.round(params.btn_size / 2),
130
+ 'min-width': params.btn_size,
131
+ });
132
+
133
+ $plus_btn.css({ top: 0, left: 0 });
134
+ $minus_btn.css({ top: params.height - params.btn_size, left: 0 });
135
+ $slider_bar.css({
136
+ top: params.btn_size,
137
+ left: 0.4 * params.btn_size,
138
+ });
139
+ $slider.css({ left: 0 });
102
140
  this.orientation = VERTICAL;
103
141
  } else {
104
- $slider_bar.css({'min-height': Math.round(params.btn_size / 5),
105
- 'min-width': params.width - 2 * params.btn_size});
106
- $slider.css({'min-height': params.btn_size,
107
- 'min-width': Math.round(params.btn_size / 2)});
108
-
109
- $plus_btn.css({'top': 0, 'left': params.width - params.btn_size});
110
- $minus_btn.css({'top': 0, 'left': 0});
111
- $slider_bar.css({'top': 0.4*params.btn_size, 'left': params.btn_size});
112
- $slider.css({'top': 0});
142
+ $slider_bar.css({
143
+ 'min-height': Math.round(params.btn_size / 5),
144
+ 'min-width': params.width - 2 * params.btn_size,
145
+ });
146
+ $slider.css({
147
+ 'min-height': params.btn_size,
148
+ 'min-width': Math.round(params.btn_size / 2),
149
+ });
150
+
151
+ $plus_btn.css({ top: 0, left: params.width - params.btn_size });
152
+ $minus_btn.css({ top: 0, left: 0 });
153
+ $slider_bar.css({
154
+ top: 0.4 * params.btn_size,
155
+ left: params.btn_size,
156
+ });
157
+ $slider.css({ top: 0 });
113
158
  this.orientation = HORIZONTAL;
114
159
  }
115
160
 
@@ -124,23 +169,26 @@ export default class OncoprintZoomSlider {
124
169
  params.onChange(self.value);
125
170
  });
126
171
 
127
- [$slider, $plus_btn, $minus_btn].map(function($btn) { $btn.hover(function() {
128
- $(this).css({'background-color':'#cccccc'});
129
- }, function() {
130
- $(this).css({'background-color': '#ffffff'});
131
- }); });
132
-
133
-
172
+ [$slider, $plus_btn, $minus_btn].map(function($btn) {
173
+ $btn.hover(
174
+ function() {
175
+ $(this).css({ 'background-color': '#cccccc' });
176
+ },
177
+ function() {
178
+ $(this).css({ 'background-color': '#ffffff' });
179
+ }
180
+ );
181
+ });
134
182
 
135
183
  this.$slider = $slider;
136
184
  this.$plus_btn = $plus_btn;
137
185
  this.$minus_btn = $minus_btn;
138
186
 
139
187
  (function setUpSliderDrag() {
140
- let start_mouse:number;
141
- let start_val:number;
142
- let dragging:boolean;
143
- function handleSliderDrag(evt:MouseMoveEvent) {
188
+ let start_mouse: number;
189
+ let start_val: number;
190
+ let dragging: boolean;
191
+ function handleSliderDrag(evt: MouseMoveEvent) {
144
192
  evt.stopPropagation();
145
193
  evt.preventDefault();
146
194
  let delta_mouse;
@@ -158,7 +206,7 @@ export default class OncoprintZoomSlider {
158
206
  }
159
207
  dragging = false;
160
208
  }
161
- self.$slider.on("mousedown", function (evt:MouseDownEvent) {
209
+ self.$slider.on('mousedown', function(evt: MouseDownEvent) {
162
210
  if (self.orientation === VERTICAL) {
163
211
  start_mouse = evt.pageY;
164
212
  } else {
@@ -166,38 +214,55 @@ export default class OncoprintZoomSlider {
166
214
  }
167
215
  start_val = self.value;
168
216
  dragging = true;
169
- $(document).on("mousemove", handleSliderDrag);
217
+ $(document).on('mousemove', handleSliderDrag);
170
218
  });
171
- $(document).on("mouseup click", function () {
172
- $(document).off("mousemove", handleSliderDrag);
219
+ $(document).on('mouseup click', function() {
220
+ $(document).off('mousemove', handleSliderDrag);
173
221
  stopSliderDrag();
174
222
  });
175
- })()
176
- };
223
+ })();
224
+ }
177
225
 
178
226
  private updateSliderPos() {
179
227
  const proportion = this.value;
180
228
  var $slider = this.$slider;
181
229
  var bounds = this.getSliderBounds();
182
230
  if (this.orientation === VERTICAL) {
183
- $slider.css('top', bounds.bottom*(1-proportion) + bounds.top*proportion);
231
+ $slider.css(
232
+ 'top',
233
+ bounds.bottom * (1 - proportion) + bounds.top * proportion
234
+ );
184
235
  } else if (this.orientation === HORIZONTAL) {
185
- $slider.css('left', bounds.left*(1-proportion) + bounds.right*proportion);
236
+ $slider.css(
237
+ 'left',
238
+ bounds.left * (1 - proportion) + bounds.right * proportion
239
+ );
186
240
  }
187
- };
241
+ }
188
242
 
189
243
  private getSliderBounds() {
190
244
  if (this.orientation === VERTICAL) {
191
- return {bottom: parseInt(this.$minus_btn.css('top'), 10) - parseInt(this.$slider.css('min-height'), 10),
192
- top: parseInt(this.$plus_btn.css('top'), 10) + parseInt(this.$plus_btn.css('min-height'), 10)};
245
+ return {
246
+ bottom:
247
+ parseInt(this.$minus_btn.css('top'), 10) -
248
+ parseInt(this.$slider.css('min-height'), 10),
249
+ top:
250
+ parseInt(this.$plus_btn.css('top'), 10) +
251
+ parseInt(this.$plus_btn.css('min-height'), 10),
252
+ };
193
253
  } else {
194
- return {left: parseInt(this.$minus_btn.css('left'), 10) + parseInt(this.$minus_btn.css('min-width'), 10),
195
- right: parseInt(this.$plus_btn.css('left'), 10) - parseInt(this.$slider.css('min-width'), 10)};
254
+ return {
255
+ left:
256
+ parseInt(this.$minus_btn.css('left'), 10) +
257
+ parseInt(this.$minus_btn.css('min-width'), 10),
258
+ right:
259
+ parseInt(this.$plus_btn.css('left'), 10) -
260
+ parseInt(this.$slider.css('min-width'), 10),
261
+ };
196
262
  }
197
- };
198
-
263
+ }
199
264
 
200
- public setSliderValue(proportion:number) {
265
+ public setSliderValue(proportion: number) {
201
266
  this.value = clamp(proportion);
202
267
  this.updateSliderPos();
203
268
  }
@@ -30,7 +30,11 @@
30
30
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31
31
  */
32
32
 
33
- export type OMath = Math & { log2:(x:number)=>number };
34
- export const OMath:OMath = (Math as any);
33
+ export type OMath = Math & { log2: (x: number) => number };
34
+ export const OMath: OMath = Math as any;
35
35
 
36
- OMath.log2 = OMath.log2 || function(x:number) { return Math.log(x) / Math.LN2; };
36
+ OMath.log2 =
37
+ OMath.log2 ||
38
+ function(x: number) {
39
+ return Math.log(x) / Math.LN2;
40
+ };
@@ -1,48 +1,71 @@
1
- import * as BucketSort from "./bucketsort";
2
- import binarysearch from "./binarysearch";
3
- import hasElementsInInterval from "./haselementsininterval";
1
+ import * as BucketSort from './bucketsort';
2
+ import binarysearch from './binarysearch';
3
+ import hasElementsInInterval from './haselementsininterval';
4
4
  import {
5
5
  ColumnId,
6
6
  TrackSortComparator,
7
7
  TrackSortDirection,
8
8
  TrackSortSpecification,
9
- TrackSortSpecificationComparators, TrackSortSpecificationVectors, TrackSortVector
10
- } from "./oncoprintmodel";
11
- import {SortingVector} from "./bucketsort";
9
+ TrackSortSpecificationComparators,
10
+ TrackSortSpecificationVectors,
11
+ TrackSortVector,
12
+ } from './oncoprintmodel';
13
+ import { SortingVector } from './bucketsort';
12
14
 
13
15
  type DatumWithVectors<T> = {
14
- d:T;
15
- preferred_vector:SortingVector;
16
- mandatory_vector:SortingVector;
16
+ d: T;
17
+ preferred_vector: SortingVector;
18
+ mandatory_vector: SortingVector;
17
19
  };
18
20
 
19
21
  export default class PrecomputedComparator<T> {
22
+ private preferred_change_points: number[];
23
+ private mandatory_change_points: number[];
24
+ private id_to_index: { [columnId: string]: number };
20
25
 
21
- private preferred_change_points:number[];
22
- private mandatory_change_points:number[];
23
- private id_to_index:{[columnId:string]:number};
24
-
25
- constructor(list:T[], comparator:TrackSortSpecification<T>, sort_direction:TrackSortDirection, element_identifier_key:string&keyof T) {
26
+ constructor(
27
+ list: T[],
28
+ comparator: TrackSortSpecification<T>,
29
+ sort_direction: TrackSortDirection,
30
+ element_identifier_key: string & keyof T
31
+ ) {
26
32
  if (comparator.isVector) {
27
- this.initializeVector(list, comparator, sort_direction, element_identifier_key);
33
+ this.initializeVector(
34
+ list,
35
+ comparator,
36
+ sort_direction,
37
+ element_identifier_key
38
+ );
28
39
  } else {
29
- this.initializeComparator(list, comparator as TrackSortSpecificationComparators<T>, sort_direction, element_identifier_key);
40
+ this.initializeComparator(
41
+ list,
42
+ comparator as TrackSortSpecificationComparators<T>,
43
+ sort_direction,
44
+ element_identifier_key
45
+ );
30
46
  }
31
47
  }
32
48
 
33
- private initializeComparator(list:T[], comparator:TrackSortComparator<T> | TrackSortSpecificationComparators<T>, sort_direction:TrackSortDirection, element_identifier_key:keyof T) {
49
+ private initializeComparator(
50
+ list: T[],
51
+ comparator:
52
+ | TrackSortComparator<T>
53
+ | TrackSortSpecificationComparators<T>,
54
+ sort_direction: TrackSortDirection,
55
+ element_identifier_key: keyof T
56
+ ) {
34
57
  // initializeComparator initializes the PrecomputedComparator in the case that
35
58
  // the sort order is given using a comparator
36
59
  let preferred, mandatory;
37
- if (typeof comparator === "function") {
60
+ if (typeof comparator === 'function') {
38
61
  preferred = comparator;
39
62
  mandatory = comparator;
40
63
  } else {
41
64
  preferred = comparator.preferred;
42
65
  mandatory = comparator.mandatory;
43
66
  }
44
- function makeDirectedComparator(cmp:TrackSortComparator<T>) {
45
- return function (d1:T, d2:T) {
67
+ function makeDirectedComparator(cmp: TrackSortComparator<T>) {
68
+ return function(d1: T, d2: T) {
46
69
  if (sort_direction === 0) {
47
70
  return 0;
48
71
  }
@@ -65,51 +88,70 @@ export default class PrecomputedComparator<T> {
65
88
  this.mandatory_change_points = [0]; // i is a mandatory change pt iff its a change pt with comp = mandatoryComparator
66
89
 
67
90
  // note that by the following process, preferred_change_points and mandatory_change_points are sorted
68
- for (let i=1; i<sorted_list.length; i++) {
69
- if (mandatoryComparator(sorted_list[i-1], sorted_list[i]) !== 0) {
91
+ for (let i = 1; i < sorted_list.length; i++) {
92
+ if (mandatoryComparator(sorted_list[i - 1], sorted_list[i]) !== 0) {
70
93
  this.mandatory_change_points.push(i);
71
- } else if (preferredComparator(sorted_list[i-1], sorted_list[i]) !== 0) {
94
+ } else if (
95
+ preferredComparator(sorted_list[i - 1], sorted_list[i]) !== 0
96
+ ) {
72
97
  this.preferred_change_points.push(i);
73
98
  }
74
99
  }
75
100
  this.id_to_index = {};
76
- for (let i=0; i<sorted_list.length; i++) {
77
- this.id_to_index[sorted_list[i][element_identifier_key] as any as string] = i;
101
+ for (let i = 0; i < sorted_list.length; i++) {
102
+ this.id_to_index[
103
+ (sorted_list[i][element_identifier_key] as any) as string
104
+ ] = i;
78
105
  }
79
106
  }
80
107
 
81
- private initializeVector(list:T[], getVector:TrackSortSpecificationVectors<T>, sort_direction:TrackSortDirection, element_identifier_key:keyof T) {
108
+ private initializeVector(
109
+ list: T[],
110
+ getVector: TrackSortSpecificationVectors<T>,
111
+ sort_direction: TrackSortDirection,
112
+ element_identifier_key: keyof T
113
+ ) {
82
114
  // initializeVector initializes the PrecomputedComparator in the case that the sort order is specified by vectors for bucket sort
83
- function makeDirectedVector(vec:TrackSortVector<T>) {
115
+ function makeDirectedVector(vec: TrackSortVector<T>) {
84
116
  if (sort_direction === 0) {
85
- return function(d:T) { return 0; };
117
+ return function(d: T) {
118
+ return 0;
119
+ };
86
120
  } else {
87
- return function(d:T) {
88
- return vec(d).map(function(n:number|string) {
89
- if (typeof n === "number") {
121
+ return function(d: T) {
122
+ return vec(d).map(function(n: number | string) {
123
+ if (typeof n === 'number') {
90
124
  return n * sort_direction;
91
125
  } else {
92
126
  return n;
93
127
  }
94
128
  });
95
- }
129
+ };
96
130
  }
97
131
  }
98
132
  const preferredVector = makeDirectedVector(getVector.preferred);
99
133
  const mandatoryVector = makeDirectedVector(getVector.mandatory);
100
134
 
101
135
  // associate each data to its vector and sort them together
102
- const list_with_vectors:DatumWithVectors<T>[] = list.map(function(d) {
103
- return { d: d, preferred_vector: preferredVector(d), mandatory_vector: mandatoryVector(d) };
136
+ const list_with_vectors: DatumWithVectors<T>[] = list.map(function(d) {
137
+ return {
138
+ d: d,
139
+ preferred_vector: preferredVector(d),
140
+ mandatory_vector: mandatoryVector(d),
141
+ };
104
142
  }) as DatumWithVectors<T>[];
105
143
  // sort by preferred vector
106
144
  const _compareEquals = getVector.compareEquals;
107
- const compareEquals = _compareEquals ? function(d1:DatumWithVectors<T>, d2:DatumWithVectors<T>) {
108
- return _compareEquals(d1.d, d2.d);
109
- } : undefined;
145
+ const compareEquals = _compareEquals
146
+ ? function(d1: DatumWithVectors<T>, d2: DatumWithVectors<T>) {
147
+ return _compareEquals(d1.d, d2.d);
148
+ }
149
+ : undefined;
110
150
  const sorted_list = BucketSort.bucketSort(
111
151
  list_with_vectors,
112
- function(d) { return d.preferred_vector; },
152
+ function(d) {
153
+ return d.preferred_vector;
154
+ },
113
155
  compareEquals
114
156
  );
115
157
 
@@ -118,37 +160,78 @@ export default class PrecomputedComparator<T> {
118
160
  this.mandatory_change_points = [0]; // i (besides 0) is a mandatory change pt iff its a change pt with comp = mandatoryComparator
119
161
 
120
162
  // note that by the following process, preferred_change_points and mandatory_change_points are sorted
121
- const getMandatoryVector = function(d:{ mandatory_vector:(number|string)[]}) { return d.mandatory_vector; };
122
- const getPreferredVector = function(d:{ preferred_vector:(number|string)[]}) { return d.preferred_vector; };
123
- for (let i=1; i<sorted_list.length; i++) {
124
- if (BucketSort.compareFull(sorted_list[i-1], sorted_list[i], getMandatoryVector) !== 0) {
163
+ const getMandatoryVector = function(d: {
164
+ mandatory_vector: (number | string)[];
165
+ }) {
166
+ return d.mandatory_vector;
167
+ };
168
+ const getPreferredVector = function(d: {
169
+ preferred_vector: (number | string)[];
170
+ }) {
171
+ return d.preferred_vector;
172
+ };
173
+ for (let i = 1; i < sorted_list.length; i++) {
174
+ if (
175
+ BucketSort.compareFull(
176
+ sorted_list[i - 1],
177
+ sorted_list[i],
178
+ getMandatoryVector
179
+ ) !== 0
180
+ ) {
125
181
  this.mandatory_change_points.push(i);
126
- } else if (BucketSort.compareFull(sorted_list[i-1], sorted_list[i], getPreferredVector, compareEquals) !== 0) {
182
+ } else if (
183
+ BucketSort.compareFull(
184
+ sorted_list[i - 1],
185
+ sorted_list[i],
186
+ getPreferredVector,
187
+ compareEquals
188
+ ) !== 0
189
+ ) {
127
190
  this.preferred_change_points.push(i);
128
191
  }
129
192
  }
130
193
 
131
194
  this.id_to_index = {};
132
- for (let i=0; i<sorted_list.length; i++) {
133
- this.id_to_index[sorted_list[i].d[element_identifier_key] as any as string] = i;
195
+ for (let i = 0; i < sorted_list.length; i++) {
196
+ this.id_to_index[
197
+ (sorted_list[i].d[element_identifier_key] as any) as string
198
+ ] = i;
134
199
  }
135
200
  }
136
201
 
137
- public getSortValue(id:ColumnId) {
202
+ public getSortValue(id: ColumnId) {
138
203
  const index = this.id_to_index[id];
139
204
  // find greatest lower change points - thats where this should be sorted by
140
205
  // because everything between change points has same sort value
141
206
  let mandatory = 0;
142
207
  let preferred = 0;
143
208
  if (this.mandatory_change_points.length) {
144
- mandatory = this.mandatory_change_points[binarysearch(this.mandatory_change_points, index, function(ind) { return ind; }, true)];
209
+ mandatory = this.mandatory_change_points[
210
+ binarysearch(
211
+ this.mandatory_change_points,
212
+ index,
213
+ function(ind) {
214
+ return ind;
215
+ },
216
+ true
217
+ )
218
+ ];
145
219
  }
146
220
  if (this.preferred_change_points.length) {
147
- preferred = this.preferred_change_points[binarysearch(this.preferred_change_points, index, function(ind) { return ind; }, true)];
221
+ preferred = this.preferred_change_points[
222
+ binarysearch(
223
+ this.preferred_change_points,
224
+ index,
225
+ function(ind) {
226
+ return ind;
227
+ },
228
+ true
229
+ )
230
+ ];
148
231
  }
149
232
  return {
150
233
  mandatory: mandatory,
151
- preferred: preferred
234
+ preferred: preferred,
152
235
  };
153
236
  }
154
- }
237
+ }
package/src/js/shaders.ts CHANGED
@@ -1,6 +1,4 @@
1
- export function getVertexShaderSource(
2
- columnsRightAfterGapsSize:number,
3
- ) {
1
+ export function getVertexShaderSource(columnsRightAfterGapsSize: number) {
4
2
  return `precision highp float;
5
3
  attribute float aPosVertex;
6
4
  attribute float aColVertex;
@@ -103,4 +101,4 @@ export function getFragmentShaderSource() {
103
101
  void main(void) {
104
102
  gl_FragColor = texture2D(uSampler, vec2(texCoord, 0.5));
105
103
  }`;
106
- }
104
+ }