@jbrowse/plugin-wiggle 2.1.0 → 2.1.3

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 (141) hide show
  1. package/dist/BigWigAdapter/BigWigAdapter.js +74 -200
  2. package/dist/BigWigAdapter/BigWigAdapter.js.map +1 -1
  3. package/dist/BigWigAdapter/configSchema.js +1 -1
  4. package/dist/BigWigAdapter/configSchema.js.map +1 -1
  5. package/dist/BigWigAdapter/index.js +14 -16
  6. package/dist/BigWigAdapter/index.js.map +1 -1
  7. package/dist/CreateMultiWiggleExtension/ConfirmDialog.js +12 -29
  8. package/dist/CreateMultiWiggleExtension/ConfirmDialog.js.map +1 -1
  9. package/dist/CreateMultiWiggleExtension/index.js +23 -57
  10. package/dist/CreateMultiWiggleExtension/index.js.map +1 -1
  11. package/dist/DensityRenderer/DensityRenderer.js +6 -66
  12. package/dist/DensityRenderer/DensityRenderer.js.map +1 -1
  13. package/dist/DensityRenderer/configSchema.js +3 -3
  14. package/dist/DensityRenderer/configSchema.js.map +1 -1
  15. package/dist/DensityRenderer/index.js +11 -13
  16. package/dist/DensityRenderer/index.js.map +1 -1
  17. package/dist/LinePlotRenderer/LinePlotRenderer.js +11 -78
  18. package/dist/LinePlotRenderer/LinePlotRenderer.js.map +1 -1
  19. package/dist/LinePlotRenderer/configSchema.js +3 -3
  20. package/dist/LinePlotRenderer/configSchema.js.map +1 -1
  21. package/dist/LinePlotRenderer/index.js +11 -13
  22. package/dist/LinePlotRenderer/index.js.map +1 -1
  23. package/dist/LinearWiggleDisplay/components/SetColorDialog.js +18 -35
  24. package/dist/LinearWiggleDisplay/components/SetColorDialog.js.map +1 -1
  25. package/dist/LinearWiggleDisplay/components/SetMinMaxDialog.js +16 -32
  26. package/dist/LinearWiggleDisplay/components/SetMinMaxDialog.js.map +1 -1
  27. package/dist/LinearWiggleDisplay/components/Tooltip.js +15 -26
  28. package/dist/LinearWiggleDisplay/components/Tooltip.js.map +1 -1
  29. package/dist/LinearWiggleDisplay/components/WiggleDisplayComponent.js +15 -26
  30. package/dist/LinearWiggleDisplay/components/WiggleDisplayComponent.js.map +1 -1
  31. package/dist/LinearWiggleDisplay/components/YScaleBar.js +6 -18
  32. package/dist/LinearWiggleDisplay/components/YScaleBar.js.map +1 -1
  33. package/dist/LinearWiggleDisplay/index.js +12 -12
  34. package/dist/LinearWiggleDisplay/index.js.map +1 -1
  35. package/dist/LinearWiggleDisplay/models/configSchema.js +6 -6
  36. package/dist/LinearWiggleDisplay/models/configSchema.js.map +1 -1
  37. package/dist/LinearWiggleDisplay/models/model.js +378 -451
  38. package/dist/LinearWiggleDisplay/models/model.js.map +1 -1
  39. package/dist/MultiDensityRenderer/MultiDensityRenderer.js +32 -125
  40. package/dist/MultiDensityRenderer/MultiDensityRenderer.js.map +1 -1
  41. package/dist/MultiDensityRenderer/configSchema.js +3 -3
  42. package/dist/MultiDensityRenderer/configSchema.js.map +1 -1
  43. package/dist/MultiDensityRenderer/index.js +11 -13
  44. package/dist/MultiDensityRenderer/index.js.map +1 -1
  45. package/dist/MultiLineRenderer/MultiLineRenderer.js +21 -114
  46. package/dist/MultiLineRenderer/MultiLineRenderer.js.map +1 -1
  47. package/dist/MultiLineRenderer/configSchema.js +4 -4
  48. package/dist/MultiLineRenderer/configSchema.js.map +1 -1
  49. package/dist/MultiLineRenderer/index.js +11 -13
  50. package/dist/MultiLineRenderer/index.js.map +1 -1
  51. package/dist/MultiLinearWiggleDisplay/components/SetColorDialog.js +72 -120
  52. package/dist/MultiLinearWiggleDisplay/components/SetColorDialog.js.map +1 -1
  53. package/dist/MultiLinearWiggleDisplay/components/SetMinMaxDialog.js +16 -32
  54. package/dist/MultiLinearWiggleDisplay/components/SetMinMaxDialog.js.map +1 -1
  55. package/dist/MultiLinearWiggleDisplay/components/Tooltip.js +21 -50
  56. package/dist/MultiLinearWiggleDisplay/components/Tooltip.js.map +1 -1
  57. package/dist/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +2 -2
  58. package/dist/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.js +53 -92
  59. package/dist/MultiLinearWiggleDisplay/components/WiggleDisplayComponent.js.map +1 -1
  60. package/dist/MultiLinearWiggleDisplay/components/YScaleBar.js +6 -18
  61. package/dist/MultiLinearWiggleDisplay/components/YScaleBar.js.map +1 -1
  62. package/dist/MultiLinearWiggleDisplay/components/util.js +16 -18
  63. package/dist/MultiLinearWiggleDisplay/components/util.js.map +1 -1
  64. package/dist/MultiLinearWiggleDisplay/index.js +9 -9
  65. package/dist/MultiLinearWiggleDisplay/index.js.map +1 -1
  66. package/dist/MultiLinearWiggleDisplay/models/configSchema.js +8 -8
  67. package/dist/MultiLinearWiggleDisplay/models/configSchema.js.map +1 -1
  68. package/dist/MultiLinearWiggleDisplay/models/model.js +489 -566
  69. package/dist/MultiLinearWiggleDisplay/models/model.js.map +1 -1
  70. package/dist/MultiQuantitativeTrack/index.js +8 -8
  71. package/dist/MultiQuantitativeTrack/index.js.map +1 -1
  72. package/dist/MultiRowLineRenderer/MultiRowLineRenderer.js +29 -121
  73. package/dist/MultiRowLineRenderer/MultiRowLineRenderer.js.map +1 -1
  74. package/dist/MultiRowLineRenderer/configSchema.js +4 -4
  75. package/dist/MultiRowLineRenderer/configSchema.js.map +1 -1
  76. package/dist/MultiRowLineRenderer/index.js +11 -13
  77. package/dist/MultiRowLineRenderer/index.js.map +1 -1
  78. package/dist/MultiRowXYPlotRenderer/MultiRowXYPlotRenderer.js +35 -131
  79. package/dist/MultiRowXYPlotRenderer/MultiRowXYPlotRenderer.js.map +1 -1
  80. package/dist/MultiRowXYPlotRenderer/configSchema.js +4 -4
  81. package/dist/MultiRowXYPlotRenderer/configSchema.js.map +1 -1
  82. package/dist/MultiRowXYPlotRenderer/index.js +11 -13
  83. package/dist/MultiRowXYPlotRenderer/index.js.map +1 -1
  84. package/dist/MultiWiggleAdapter/MultiWiggleAdapter.d.ts +1 -0
  85. package/dist/MultiWiggleAdapter/MultiWiggleAdapter.js +80 -232
  86. package/dist/MultiWiggleAdapter/MultiWiggleAdapter.js.map +1 -1
  87. package/dist/MultiWiggleAdapter/configSchema.js +1 -1
  88. package/dist/MultiWiggleAdapter/configSchema.js.map +1 -1
  89. package/dist/MultiWiggleAdapter/index.js +14 -18
  90. package/dist/MultiWiggleAdapter/index.js.map +1 -1
  91. package/dist/MultiWiggleAddTrackWidget/AddTrackWorkflow.js +30 -56
  92. package/dist/MultiWiggleAddTrackWidget/AddTrackWorkflow.js.map +1 -1
  93. package/dist/MultiWiggleAddTrackWidget/index.js +10 -12
  94. package/dist/MultiWiggleAddTrackWidget/index.js.map +1 -1
  95. package/dist/MultiWiggleRendering.js +45 -109
  96. package/dist/MultiWiggleRendering.js.map +1 -1
  97. package/dist/MultiXYPlotRenderer/MultiXYPlotRenderer.js +24 -120
  98. package/dist/MultiXYPlotRenderer/MultiXYPlotRenderer.js.map +1 -1
  99. package/dist/MultiXYPlotRenderer/configSchema.js +4 -4
  100. package/dist/MultiXYPlotRenderer/configSchema.js.map +1 -1
  101. package/dist/MultiXYPlotRenderer/index.js +11 -13
  102. package/dist/MultiXYPlotRenderer/index.js.map +1 -1
  103. package/dist/QuantitativeTrack/index.js +8 -8
  104. package/dist/QuantitativeTrack/index.js.map +1 -1
  105. package/dist/Tooltip.js +26 -54
  106. package/dist/Tooltip.js.map +1 -1
  107. package/dist/WiggleBaseRenderer.d.ts +6 -6
  108. package/dist/WiggleBaseRenderer.js +34 -125
  109. package/dist/WiggleBaseRenderer.js.map +1 -1
  110. package/dist/WiggleRPC/rpcMethods.d.ts +2 -2
  111. package/dist/WiggleRPC/rpcMethods.js +101 -244
  112. package/dist/WiggleRPC/rpcMethods.js.map +1 -1
  113. package/dist/WiggleRendering.js +20 -69
  114. package/dist/WiggleRendering.js.map +1 -1
  115. package/dist/XYPlotRenderer/XYPlotRenderer.js +24 -121
  116. package/dist/XYPlotRenderer/XYPlotRenderer.js.map +1 -1
  117. package/dist/XYPlotRenderer/configSchema.js +4 -4
  118. package/dist/XYPlotRenderer/configSchema.js.map +1 -1
  119. package/dist/XYPlotRenderer/index.js +11 -13
  120. package/dist/XYPlotRenderer/index.js.map +1 -1
  121. package/dist/configSchema.js +2 -2
  122. package/dist/configSchema.js.map +1 -1
  123. package/dist/drawxy.js +192 -311
  124. package/dist/drawxy.js.map +1 -1
  125. package/dist/index.js +44 -62
  126. package/dist/index.js.map +1 -1
  127. package/dist/util.js +105 -168
  128. package/dist/util.js.map +1 -1
  129. package/esm/MultiWiggleAdapter/MultiWiggleAdapter.d.ts +1 -0
  130. package/esm/MultiWiggleAdapter/MultiWiggleAdapter.js +5 -3
  131. package/esm/MultiWiggleAdapter/MultiWiggleAdapter.js.map +1 -1
  132. package/esm/WiggleBaseRenderer.d.ts +6 -6
  133. package/esm/WiggleBaseRenderer.js +4 -3
  134. package/esm/WiggleBaseRenderer.js.map +1 -1
  135. package/esm/WiggleRPC/rpcMethods.d.ts +2 -2
  136. package/esm/WiggleRPC/rpcMethods.js.map +1 -1
  137. package/package.json +2 -3
  138. package/src/MultiWiggleAdapter/MultiWiggleAdapter.ts +7 -3
  139. package/src/WiggleBaseRenderer.tsx +4 -3
  140. package/src/WiggleRPC/rpcMethods.ts +8 -2
  141. package/src/declare.d.ts +0 -2
package/dist/drawxy.js CHANGED
@@ -1,47 +1,9 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __read = (this && this.__read) || function (o, n) {
14
- var m = typeof Symbol === "function" && o[Symbol.iterator];
15
- if (!m) return o;
16
- var i = m.call(o), r, ar = [], e;
17
- try {
18
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
- }
20
- catch (error) { e = { error: error }; }
21
- finally {
22
- try {
23
- if (r && !r.done && (m = i["return"])) m.call(i);
24
- }
25
- finally { if (e) throw e.error; }
26
- }
27
- return ar;
28
- };
29
- var __values = (this && this.__values) || function(o) {
30
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
31
- if (m) return m.call(o);
32
- if (o && typeof o.length === "number") return {
33
- next: function () {
34
- if (o && i >= o.length) o = void 0;
35
- return { value: o && o[i++], done: !o };
36
- }
37
- };
38
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
39
- };
40
2
  Object.defineProperty(exports, "__esModule", { value: true });
41
3
  exports.drawDensity = exports.drawLine = exports.drawXY = void 0;
42
- var configuration_1 = require("@jbrowse/core/configuration");
43
- var util_1 = require("@jbrowse/core/util");
44
- var util_2 = require("./util");
4
+ const configuration_1 = require("@jbrowse/core/configuration");
5
+ const util_1 = require("@jbrowse/core/util");
6
+ const util_2 = require("./util");
45
7
  function fillRectCtx(x, y, width, height, ctx, color) {
46
8
  if (width < 0) {
47
9
  x += width;
@@ -56,160 +18,119 @@ function fillRectCtx(x, y, width, height, ctx, color) {
56
18
  }
57
19
  ctx.fillRect(x, y, width, height);
58
20
  }
59
- var fudgeFactor = 0.4;
60
- var clipHeight = 2;
21
+ const fudgeFactor = 0.4;
22
+ const clipHeight = 2;
61
23
  function drawXY(ctx, props) {
62
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
63
- var features = props.features, bpPerPx = props.bpPerPx, regions = props.regions, scaleOpts = props.scaleOpts, unadjustedHeight = props.height, config = props.config, ticks = props.ticks, displayCrossHatches = props.displayCrossHatches, _f = props.offset, offset = _f === void 0 ? 0 : _f, colorCallback = props.colorCallback, Color = props.Color;
64
- var _g = __read(regions, 1), region = _g[0];
65
- var width = (region.end - region.start) / bpPerPx;
24
+ const { features, bpPerPx, regions, scaleOpts, height: unadjustedHeight, config, ticks, displayCrossHatches, offset = 0, colorCallback, Color, } = props;
25
+ const [region] = regions;
26
+ const width = (region.end - region.start) / bpPerPx;
66
27
  // the adjusted height takes into account YSCALEBAR_LABEL_OFFSET from the
67
28
  // wiggle display, and makes the height of the actual drawn area add
68
29
  // "padding" to the top and bottom of the display
69
- var height = unadjustedHeight - offset * 2;
70
- var filled = (0, configuration_1.readConfObject)(config, 'filled');
71
- var clipColor = (0, configuration_1.readConfObject)(config, 'clipColor');
72
- var summaryScoreMode = (0, configuration_1.readConfObject)(config, 'summaryScoreMode');
73
- var pivotValue = (0, configuration_1.readConfObject)(config, 'bicolorPivotValue');
74
- var minSize = (0, configuration_1.readConfObject)(config, 'minSize');
75
- var scale = (0, util_2.getScale)(__assign(__assign({}, scaleOpts), { range: [0, height] }));
76
- var originY = (0, util_2.getOrigin)(scaleOpts.scaleType);
77
- var _h = __read(scale.domain(), 2), niceMin = _h[0], niceMax = _h[1];
78
- var toY = function (n) { return (0, util_1.clamp)(height - (scale(n) || 0), 0, height) + offset; };
79
- var toOrigin = function (n) { return toY(originY) - toY(n); };
80
- var getHeight = function (n) { return (filled ? toOrigin(n) : Math.max(minSize, 1)); };
81
- var hasClipping = false;
82
- var prevLeftPx = 0;
83
- var reducedFeatures = [];
84
- var crossingOrigin = niceMin < pivotValue && niceMax > pivotValue;
30
+ const height = unadjustedHeight - offset * 2;
31
+ const filled = (0, configuration_1.readConfObject)(config, 'filled');
32
+ const clipColor = (0, configuration_1.readConfObject)(config, 'clipColor');
33
+ const summaryScoreMode = (0, configuration_1.readConfObject)(config, 'summaryScoreMode');
34
+ const pivotValue = (0, configuration_1.readConfObject)(config, 'bicolorPivotValue');
35
+ const minSize = (0, configuration_1.readConfObject)(config, 'minSize');
36
+ const scale = (0, util_2.getScale)({ ...scaleOpts, range: [0, height] });
37
+ const originY = (0, util_2.getOrigin)(scaleOpts.scaleType);
38
+ const [niceMin, niceMax] = scale.domain();
39
+ const toY = (n) => (0, util_1.clamp)(height - (scale(n) || 0), 0, height) + offset;
40
+ const toOrigin = (n) => toY(originY) - toY(n);
41
+ const getHeight = (n) => (filled ? toOrigin(n) : Math.max(minSize, 1));
42
+ let hasClipping = false;
43
+ let prevLeftPx = 0;
44
+ const reducedFeatures = [];
45
+ const crossingOrigin = niceMin < pivotValue && niceMax > pivotValue;
85
46
  // we handle whiskers separately to render max row, min row, and avg in three
86
47
  // passes. this reduces subpixel rendering issues. note: for stylistic
87
48
  // reasons, clipping indicator is only drawn for score, not min/max score
88
49
  if (summaryScoreMode === 'whiskers') {
89
- var lastCol = void 0;
90
- var lastMix = void 0;
91
- try {
92
- for (var _j = __values(features.values()), _k = _j.next(); !_k.done; _k = _j.next()) {
93
- var feature = _k.value;
94
- var _l = __read((0, util_1.featureSpanPx)(feature, region, bpPerPx), 2), leftPx = _l[0], rightPx = _l[1];
95
- if (feature.get('summary')) {
96
- var w = rightPx - leftPx + fudgeFactor;
97
- var max = feature.get('maxScore');
98
- var c = colorCallback(feature, max);
99
- var effectiveC = crossingOrigin
100
- ? c
101
- : c === lastCol
102
- ? lastMix
103
- : (lastMix = Color(c).lighten(0.4).toString());
104
- fillRectCtx(leftPx, toY(max), w, getHeight(max), ctx, effectiveC);
105
- lastCol = c;
106
- }
107
- }
108
- }
109
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
110
- finally {
111
- try {
112
- if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
113
- }
114
- finally { if (e_1) throw e_1.error; }
115
- }
116
- lastMix = undefined;
117
- lastCol = undefined;
118
- try {
119
- for (var _m = __values(features.values()), _o = _m.next(); !_o.done; _o = _m.next()) {
120
- var feature = _o.value;
121
- var _p = __read((0, util_1.featureSpanPx)(feature, region, bpPerPx), 2), leftPx = _p[0], rightPx = _p[1];
122
- var score = feature.get('score');
123
- var max = feature.get('maxScore');
124
- var min = feature.get('minScore');
125
- var summary = feature.get('summary');
126
- var c = colorCallback(feature, score);
127
- var effectiveC = crossingOrigin && summary
128
- ? c === lastCol
50
+ let lastCol;
51
+ let lastMix;
52
+ for (const feature of features.values()) {
53
+ const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
54
+ if (feature.get('summary')) {
55
+ const w = rightPx - leftPx + fudgeFactor;
56
+ const max = feature.get('maxScore');
57
+ const c = colorCallback(feature, max);
58
+ const effectiveC = crossingOrigin
59
+ ? c
60
+ : c === lastCol
129
61
  ? lastMix
130
- : (lastMix = Color(colorCallback(feature, max))
131
- .mix(Color(colorCallback(feature, min)))
132
- .toString())
133
- : c;
134
- var w = Math.max(rightPx - leftPx + fudgeFactor, minSize);
135
- // create reduced features, avoiding multiple features per px
136
- if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
137
- reducedFeatures.push(feature);
138
- prevLeftPx = leftPx;
139
- }
140
- hasClipping = hasClipping || score < niceMin || score > niceMax;
141
- fillRectCtx(leftPx, toY(score), w, getHeight(score), ctx, effectiveC);
62
+ : (lastMix = Color(c).lighten(0.4).toString());
63
+ fillRectCtx(leftPx, toY(max), w, getHeight(max), ctx, effectiveC);
142
64
  lastCol = c;
143
65
  }
144
66
  }
145
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
146
- finally {
147
- try {
148
- if (_o && !_o.done && (_b = _m.return)) _b.call(_m);
149
- }
150
- finally { if (e_2) throw e_2.error; }
151
- }
152
67
  lastMix = undefined;
153
68
  lastCol = undefined;
154
- try {
155
- for (var _q = __values(features.values()), _r = _q.next(); !_r.done; _r = _q.next()) {
156
- var feature = _r.value;
157
- var _s = __read((0, util_1.featureSpanPx)(feature, region, bpPerPx), 2), leftPx = _s[0], rightPx = _s[1];
158
- if (feature.get('summary')) {
159
- var min = feature.get('minScore');
160
- var c = colorCallback(feature, min);
161
- var w = Math.max(rightPx - leftPx + fudgeFactor, minSize);
162
- var effectiveC = crossingOrigin
163
- ? c
164
- : c === lastCol
165
- ? lastMix
166
- : (lastMix = Color(c).darken(0.4).toString());
167
- fillRectCtx(leftPx, toY(min), w, getHeight(min), ctx, effectiveC);
168
- lastCol = c;
169
- }
69
+ for (const feature of features.values()) {
70
+ const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
71
+ const score = feature.get('score');
72
+ const max = feature.get('maxScore');
73
+ const min = feature.get('minScore');
74
+ const summary = feature.get('summary');
75
+ const c = colorCallback(feature, score);
76
+ const effectiveC = crossingOrigin && summary
77
+ ? c === lastCol
78
+ ? lastMix
79
+ : (lastMix = Color(colorCallback(feature, max))
80
+ .mix(Color(colorCallback(feature, min)))
81
+ .toString())
82
+ : c;
83
+ const w = Math.max(rightPx - leftPx + fudgeFactor, minSize);
84
+ // create reduced features, avoiding multiple features per px
85
+ if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
86
+ reducedFeatures.push(feature);
87
+ prevLeftPx = leftPx;
170
88
  }
89
+ hasClipping = hasClipping || score < niceMin || score > niceMax;
90
+ fillRectCtx(leftPx, toY(score), w, getHeight(score), ctx, effectiveC);
91
+ lastCol = c;
171
92
  }
172
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
173
- finally {
174
- try {
175
- if (_r && !_r.done && (_c = _q.return)) _c.call(_q);
93
+ lastMix = undefined;
94
+ lastCol = undefined;
95
+ for (const feature of features.values()) {
96
+ const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
97
+ if (feature.get('summary')) {
98
+ const min = feature.get('minScore');
99
+ const c = colorCallback(feature, min);
100
+ const w = Math.max(rightPx - leftPx + fudgeFactor, minSize);
101
+ const effectiveC = crossingOrigin
102
+ ? c
103
+ : c === lastCol
104
+ ? lastMix
105
+ : (lastMix = Color(c).darken(0.4).toString());
106
+ fillRectCtx(leftPx, toY(min), w, getHeight(min), ctx, effectiveC);
107
+ lastCol = c;
176
108
  }
177
- finally { if (e_3) throw e_3.error; }
178
109
  }
179
110
  }
180
111
  else {
181
- try {
182
- for (var _t = __values(features.values()), _u = _t.next(); !_u.done; _u = _t.next()) {
183
- var feature = _u.value;
184
- var _v = __read((0, util_1.featureSpanPx)(feature, region, bpPerPx), 2), leftPx = _v[0], rightPx = _v[1];
185
- // create reduced features, avoiding multiple features per px
186
- if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
187
- reducedFeatures.push(feature);
188
- prevLeftPx = leftPx;
189
- }
190
- var score = feature.get('score');
191
- var c = colorCallback(feature, score);
192
- hasClipping = hasClipping || score < niceMin || score > niceMax;
193
- var w = Math.max(rightPx - leftPx + fudgeFactor, minSize);
194
- if (summaryScoreMode === 'max') {
195
- var s = feature.get('summary') ? feature.get('maxScore') : score;
196
- fillRectCtx(leftPx, toY(s), w, getHeight(s), ctx, c);
197
- }
198
- else if (summaryScoreMode === 'min') {
199
- var s = feature.get('summary') ? feature.get('minScore') : score;
200
- fillRectCtx(leftPx, toY(s), w, getHeight(s), ctx, c);
201
- }
202
- else {
203
- fillRectCtx(leftPx, toY(score), w, getHeight(score), ctx, c);
204
- }
112
+ for (const feature of features.values()) {
113
+ const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
114
+ // create reduced features, avoiding multiple features per px
115
+ if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
116
+ reducedFeatures.push(feature);
117
+ prevLeftPx = leftPx;
205
118
  }
206
- }
207
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
208
- finally {
209
- try {
210
- if (_u && !_u.done && (_d = _t.return)) _d.call(_t);
119
+ const score = feature.get('score');
120
+ const c = colorCallback(feature, score);
121
+ hasClipping = hasClipping || score < niceMin || score > niceMax;
122
+ const w = Math.max(rightPx - leftPx + fudgeFactor, minSize);
123
+ if (summaryScoreMode === 'max') {
124
+ const s = feature.get('summary') ? feature.get('maxScore') : score;
125
+ fillRectCtx(leftPx, toY(s), w, getHeight(s), ctx, c);
126
+ }
127
+ else if (summaryScoreMode === 'min') {
128
+ const s = feature.get('summary') ? feature.get('minScore') : score;
129
+ fillRectCtx(leftPx, toY(s), w, getHeight(s), ctx, c);
130
+ }
131
+ else {
132
+ fillRectCtx(leftPx, toY(score), w, getHeight(score), ctx, c);
211
133
  }
212
- finally { if (e_4) throw e_4.error; }
213
134
  }
214
135
  }
215
136
  // second pass: draw clipping
@@ -217,195 +138,155 @@ function drawXY(ctx, props) {
217
138
  ctx.save();
218
139
  if (hasClipping) {
219
140
  ctx.fillStyle = clipColor;
220
- try {
221
- for (var _w = __values(features.values()), _x = _w.next(); !_x.done; _x = _w.next()) {
222
- var feature = _x.value;
223
- var _y = __read((0, util_1.featureSpanPx)(feature, region, bpPerPx), 2), leftPx = _y[0], rightPx = _y[1];
224
- var w = rightPx - leftPx + fudgeFactor;
225
- var score = feature.get('score');
226
- if (score > niceMax) {
227
- fillRectCtx(leftPx, offset, w, clipHeight, ctx);
228
- }
229
- else if (score < niceMin && scaleOpts.scaleType !== 'log') {
230
- fillRectCtx(leftPx, unadjustedHeight, w, clipHeight, ctx);
231
- }
141
+ for (const feature of features.values()) {
142
+ const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
143
+ const w = rightPx - leftPx + fudgeFactor;
144
+ const score = feature.get('score');
145
+ if (score > niceMax) {
146
+ fillRectCtx(leftPx, offset, w, clipHeight, ctx);
232
147
  }
233
- }
234
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
235
- finally {
236
- try {
237
- if (_x && !_x.done && (_e = _w.return)) _e.call(_w);
148
+ else if (score < niceMin && scaleOpts.scaleType !== 'log') {
149
+ fillRectCtx(leftPx, unadjustedHeight, w, clipHeight, ctx);
238
150
  }
239
- finally { if (e_5) throw e_5.error; }
240
151
  }
241
152
  }
242
153
  ctx.restore();
243
154
  if (displayCrossHatches) {
244
155
  ctx.lineWidth = 1;
245
156
  ctx.strokeStyle = 'rgba(200,200,200,0.5)';
246
- ticks.values.forEach(function (tick) {
157
+ ticks.values.forEach(tick => {
247
158
  ctx.beginPath();
248
159
  ctx.moveTo(0, Math.round(toY(tick)));
249
160
  ctx.lineTo(width, Math.round(toY(tick)));
250
161
  ctx.stroke();
251
162
  });
252
163
  }
253
- return { reducedFeatures: reducedFeatures };
164
+ return { reducedFeatures };
254
165
  }
255
166
  exports.drawXY = drawXY;
256
167
  function drawLine(ctx, props) {
257
- var e_6, _a;
258
- var features = props.features, regions = props.regions, bpPerPx = props.bpPerPx, scaleOpts = props.scaleOpts, unadjustedHeight = props.height, values = props.ticks.values, displayCrossHatches = props.displayCrossHatches, colorCallback = props.colorCallback, config = props.config, _b = props.offset, offset = _b === void 0 ? 0 : _b;
259
- var _c = __read(regions, 1), region = _c[0];
260
- var width = (region.end - region.start) / bpPerPx;
168
+ const { features, regions, bpPerPx, scaleOpts, height: unadjustedHeight, ticks: { values }, displayCrossHatches, colorCallback, config, offset = 0, } = props;
169
+ const [region] = regions;
170
+ const width = (region.end - region.start) / bpPerPx;
261
171
  // the adjusted height takes into account YSCALEBAR_LABEL_OFFSET from the
262
172
  // wiggle display, and makes the height of the actual drawn area add
263
173
  // "padding" to the top and bottom of the display
264
- var height = unadjustedHeight - offset * 2;
265
- var clipColor = (0, configuration_1.readConfObject)(config, 'clipColor');
266
- var scale = (0, util_2.getScale)(__assign(__assign({}, scaleOpts), { range: [0, height] }));
267
- var _d = __read(scale.domain(), 2), niceMin = _d[0], niceMax = _d[1];
268
- var toY = function (n) { return (0, util_1.clamp)(height - (scale(n) || 0), 0, height) + offset; };
269
- var lastVal;
270
- var prevLeftPx = 0;
271
- var reducedFeatures = [];
272
- try {
273
- for (var _e = __values(features.values()), _f = _e.next(); !_f.done; _f = _e.next()) {
274
- var feature = _f.value;
275
- var _g = __read((0, util_1.featureSpanPx)(feature, region, bpPerPx), 2), leftPx = _g[0], rightPx = _g[1];
276
- // create reduced features, avoiding multiple features per px
277
- if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
278
- reducedFeatures.push(feature);
279
- prevLeftPx = leftPx;
280
- }
281
- var score = feature.get('score');
282
- var lowClipping = score < niceMin;
283
- var highClipping = score > niceMax;
284
- var w = rightPx - leftPx + fudgeFactor;
285
- var c = colorCallback(feature, score);
286
- ctx.beginPath();
287
- ctx.strokeStyle = c;
288
- var startPos = typeof lastVal !== 'undefined' ? lastVal : score;
289
- if (!region.reversed) {
290
- ctx.moveTo(leftPx, toY(startPos));
291
- ctx.lineTo(leftPx, toY(score));
292
- ctx.lineTo(rightPx, toY(score));
293
- }
294
- else {
295
- ctx.moveTo(rightPx, toY(startPos));
296
- ctx.lineTo(rightPx, toY(score));
297
- ctx.lineTo(leftPx, toY(score));
298
- }
299
- ctx.stroke();
300
- lastVal = score;
301
- if (highClipping) {
302
- ctx.fillStyle = clipColor;
303
- ctx.fillRect(leftPx, offset, w, clipHeight);
304
- }
305
- else if (lowClipping && scaleOpts.scaleType !== 'log') {
306
- ctx.fillStyle = clipColor;
307
- ctx.fillRect(leftPx, height - clipHeight, w, height);
308
- }
174
+ const height = unadjustedHeight - offset * 2;
175
+ const clipColor = (0, configuration_1.readConfObject)(config, 'clipColor');
176
+ const scale = (0, util_2.getScale)({ ...scaleOpts, range: [0, height] });
177
+ const [niceMin, niceMax] = scale.domain();
178
+ const toY = (n) => (0, util_1.clamp)(height - (scale(n) || 0), 0, height) + offset;
179
+ let lastVal;
180
+ let prevLeftPx = 0;
181
+ const reducedFeatures = [];
182
+ for (const feature of features.values()) {
183
+ const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
184
+ // create reduced features, avoiding multiple features per px
185
+ if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
186
+ reducedFeatures.push(feature);
187
+ prevLeftPx = leftPx;
309
188
  }
310
- }
311
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
312
- finally {
313
- try {
314
- if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
189
+ const score = feature.get('score');
190
+ const lowClipping = score < niceMin;
191
+ const highClipping = score > niceMax;
192
+ const w = rightPx - leftPx + fudgeFactor;
193
+ const c = colorCallback(feature, score);
194
+ ctx.beginPath();
195
+ ctx.strokeStyle = c;
196
+ const startPos = typeof lastVal !== 'undefined' ? lastVal : score;
197
+ if (!region.reversed) {
198
+ ctx.moveTo(leftPx, toY(startPos));
199
+ ctx.lineTo(leftPx, toY(score));
200
+ ctx.lineTo(rightPx, toY(score));
201
+ }
202
+ else {
203
+ ctx.moveTo(rightPx, toY(startPos));
204
+ ctx.lineTo(rightPx, toY(score));
205
+ ctx.lineTo(leftPx, toY(score));
206
+ }
207
+ ctx.stroke();
208
+ lastVal = score;
209
+ if (highClipping) {
210
+ ctx.fillStyle = clipColor;
211
+ ctx.fillRect(leftPx, offset, w, clipHeight);
212
+ }
213
+ else if (lowClipping && scaleOpts.scaleType !== 'log') {
214
+ ctx.fillStyle = clipColor;
215
+ ctx.fillRect(leftPx, height - clipHeight, w, height);
315
216
  }
316
- finally { if (e_6) throw e_6.error; }
317
217
  }
318
218
  if (displayCrossHatches) {
319
219
  ctx.lineWidth = 1;
320
220
  ctx.strokeStyle = 'rgba(200,200,200,0.5)';
321
- values.forEach(function (tick) {
221
+ values.forEach(tick => {
322
222
  ctx.beginPath();
323
223
  ctx.moveTo(0, Math.round(toY(tick)));
324
224
  ctx.lineTo(width, Math.round(toY(tick)));
325
225
  ctx.stroke();
326
226
  });
327
227
  }
328
- return { reducedFeatures: reducedFeatures };
228
+ return { reducedFeatures };
329
229
  }
330
230
  exports.drawLine = drawLine;
331
231
  function drawDensity(ctx, props) {
332
- var e_7, _a, e_8, _b;
333
- var features = props.features, regions = props.regions, bpPerPx = props.bpPerPx, scaleOpts = props.scaleOpts, height = props.height, config = props.config;
334
- var _c = __read(regions, 1), region = _c[0];
335
- var pivot = (0, configuration_1.readConfObject)(config, 'bicolorPivot');
336
- var pivotValue = (0, configuration_1.readConfObject)(config, 'bicolorPivotValue');
337
- var negColor = (0, configuration_1.readConfObject)(config, 'negColor');
338
- var posColor = (0, configuration_1.readConfObject)(config, 'posColor');
339
- var color = (0, configuration_1.readConfObject)(config, 'color');
340
- var clipColor = (0, configuration_1.readConfObject)(config, 'clipColor');
341
- var crossing = pivot !== 'none' && scaleOpts.scaleType !== 'log';
342
- var scale = (0, util_2.getScale)(__assign(__assign({}, scaleOpts), { pivotValue: crossing ? pivotValue : undefined, range: crossing ? [negColor, 'white', posColor] : ['white', posColor] }));
343
- var scale2 = (0, util_2.getScale)(__assign(__assign({}, scaleOpts), { range: [0, height] }));
344
- var cb;
232
+ const { features, regions, bpPerPx, scaleOpts, height, config } = props;
233
+ const [region] = regions;
234
+ const pivot = (0, configuration_1.readConfObject)(config, 'bicolorPivot');
235
+ const pivotValue = (0, configuration_1.readConfObject)(config, 'bicolorPivotValue');
236
+ const negColor = (0, configuration_1.readConfObject)(config, 'negColor');
237
+ const posColor = (0, configuration_1.readConfObject)(config, 'posColor');
238
+ const color = (0, configuration_1.readConfObject)(config, 'color');
239
+ const clipColor = (0, configuration_1.readConfObject)(config, 'clipColor');
240
+ const crossing = pivot !== 'none' && scaleOpts.scaleType !== 'log';
241
+ const scale = (0, util_2.getScale)({
242
+ ...scaleOpts,
243
+ pivotValue: crossing ? pivotValue : undefined,
244
+ range: crossing ? [negColor, 'white', posColor] : ['white', posColor],
245
+ });
246
+ const scale2 = (0, util_2.getScale)({ ...scaleOpts, range: [0, height] });
247
+ let cb;
345
248
  if (color === '#f0f') {
346
- cb = function (_feature, score) { return scale(score); };
249
+ cb = (_feature, score) => scale(score);
347
250
  }
348
251
  else {
349
- cb = function (feature, score) {
350
- return (0, configuration_1.readConfObject)(config, 'color', { feature: feature, score: score });
351
- };
252
+ cb = (feature, score) => (0, configuration_1.readConfObject)(config, 'color', { feature, score });
352
253
  }
353
- var _d = __read(scale2.domain(), 2), niceMin = _d[0], niceMax = _d[1];
354
- var prevLeftPx = 0;
355
- var hasClipping = false;
356
- var reducedFeatures = [];
357
- try {
358
- for (var _e = __values(features.values()), _f = _e.next(); !_f.done; _f = _e.next()) {
359
- var feature = _f.value;
360
- var _g = __read((0, util_1.featureSpanPx)(feature, region, bpPerPx), 2), leftPx = _g[0], rightPx = _g[1];
361
- // create reduced features, avoiding multiple features per px
362
- if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
363
- reducedFeatures.push(feature);
364
- prevLeftPx = leftPx;
365
- }
366
- var score = feature.get('score');
367
- hasClipping = hasClipping || score > niceMax || score < niceMin;
368
- var w = rightPx - leftPx + fudgeFactor;
369
- ctx.fillStyle = cb(feature, score);
370
- ctx.fillRect(leftPx, 0, w, height);
254
+ const [niceMin, niceMax] = scale2.domain();
255
+ let prevLeftPx = 0;
256
+ let hasClipping = false;
257
+ const reducedFeatures = [];
258
+ for (const feature of features.values()) {
259
+ const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
260
+ // create reduced features, avoiding multiple features per px
261
+ if (Math.floor(leftPx) !== Math.floor(prevLeftPx)) {
262
+ reducedFeatures.push(feature);
263
+ prevLeftPx = leftPx;
371
264
  }
372
- }
373
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
374
- finally {
375
- try {
376
- if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
377
- }
378
- finally { if (e_7) throw e_7.error; }
265
+ const score = feature.get('score');
266
+ hasClipping = hasClipping || score > niceMax || score < niceMin;
267
+ const w = rightPx - leftPx + fudgeFactor;
268
+ ctx.fillStyle = cb(feature, score);
269
+ ctx.fillRect(leftPx, 0, w, height);
379
270
  }
380
271
  // second pass: draw clipping
381
272
  // avoid persisting the red fillstyle with save/restore
382
273
  ctx.save();
383
274
  if (hasClipping) {
384
275
  ctx.fillStyle = clipColor;
385
- try {
386
- for (var _h = __values(features.values()), _j = _h.next(); !_j.done; _j = _h.next()) {
387
- var feature = _j.value;
388
- var _k = __read((0, util_1.featureSpanPx)(feature, region, bpPerPx), 2), leftPx = _k[0], rightPx = _k[1];
389
- var w = rightPx - leftPx + fudgeFactor;
390
- var score = feature.get('score');
391
- if (score > niceMax) {
392
- fillRectCtx(leftPx, 0, w, clipHeight, ctx);
393
- }
394
- else if (score < niceMin && scaleOpts.scaleType !== 'log') {
395
- fillRectCtx(leftPx, 0, w, clipHeight, ctx);
396
- }
276
+ for (const feature of features.values()) {
277
+ const [leftPx, rightPx] = (0, util_1.featureSpanPx)(feature, region, bpPerPx);
278
+ const w = rightPx - leftPx + fudgeFactor;
279
+ const score = feature.get('score');
280
+ if (score > niceMax) {
281
+ fillRectCtx(leftPx, 0, w, clipHeight, ctx);
397
282
  }
398
- }
399
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
400
- finally {
401
- try {
402
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
283
+ else if (score < niceMin && scaleOpts.scaleType !== 'log') {
284
+ fillRectCtx(leftPx, 0, w, clipHeight, ctx);
403
285
  }
404
- finally { if (e_8) throw e_8.error; }
405
286
  }
406
287
  }
407
288
  ctx.restore();
408
- return { reducedFeatures: reducedFeatures };
289
+ return { reducedFeatures };
409
290
  }
410
291
  exports.drawDensity = drawDensity;
411
292
  //# sourceMappingURL=drawxy.js.map