@complat/react-spectra-editor 1.7.0 → 1.8.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 (111) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE +21 -662
  3. package/README.md +5 -0
  4. package/dist/__tests__/fixtures/lc_ms_jcamp.js +2329 -0
  5. package/dist/__tests__/fixtures/lc_ms_jcamp_2.js +2874 -0
  6. package/dist/__tests__/fixtures/lc_ms_jcamp_mz_chemstation.js +3242 -0
  7. package/dist/__tests__/fixtures/lc_ms_jcamp_tic_chemstation.js +854 -0
  8. package/dist/__tests__/fixtures/lc_ms_jcamp_tic_neg.js +1233 -0
  9. package/dist/__tests__/fixtures/lc_ms_jcamp_tic_pos.js +1233 -0
  10. package/dist/__tests__/fixtures/lc_ms_jcamp_uvvis.js +48908 -0
  11. package/dist/__tests__/fixtures/lc_ms_jcamp_uvvis_chemstation.js +15424 -0
  12. package/dist/__tests__/units/components/cmd_bar/r05_submit_btn.test.js +158 -3
  13. package/dist/__tests__/units/components/d3_line_rect.test.js +85 -0
  14. package/dist/__tests__/units/components/d3_multi/multi_focus.test.js +43 -0
  15. package/dist/__tests__/units/components/hplc_viewer.test.js +123 -0
  16. package/dist/__tests__/units/components/panel/info.test.js +55 -15
  17. package/dist/__tests__/units/features/lc-ms/parsing/lcmsCategory.test.js +73 -0
  18. package/dist/__tests__/units/features/lc-ms/submit/peaks.test.js +310 -0
  19. package/dist/actions/curve.js +5 -2
  20. package/dist/actions/hplc_ms.js +66 -0
  21. package/dist/actions/integration.js +17 -2
  22. package/dist/actions/ui.js +39 -11
  23. package/dist/app.js +21 -8
  24. package/dist/components/cmd_bar/01_viewer.js +15 -11
  25. package/dist/components/cmd_bar/03_peak.js +25 -16
  26. package/dist/components/cmd_bar/04_integration.js +116 -17
  27. package/dist/components/cmd_bar/08_peak_group.js +83 -0
  28. package/dist/components/cmd_bar/collapsible_toolbar_group.js +101 -0
  29. package/dist/components/cmd_bar/common.js +4 -3
  30. package/dist/components/cmd_bar/index.js +76 -18
  31. package/dist/components/cmd_bar/r01_layout.js +6 -0
  32. package/dist/components/cmd_bar/r02_scan.js +15 -11
  33. package/dist/components/cmd_bar/r03_threshold.js +19 -3
  34. package/dist/components/cmd_bar/r04_submit.js +61 -6
  35. package/dist/components/cmd_bar/r05_submit_btn.js +60 -13
  36. package/dist/components/cmd_bar/r06_predict_btn.js +4 -4
  37. package/dist/components/cmd_bar/r07_wavelength_btn.js +10 -9
  38. package/dist/components/cmd_bar/r09_detector.js +2 -2
  39. package/dist/components/cmd_bar/tri_btn.js +4 -1
  40. package/dist/components/common/draw.js +6 -5
  41. package/dist/components/d3_line/index.js +70 -15
  42. package/dist/components/d3_line/line_focus.js +104 -67
  43. package/dist/components/d3_line_rect/index.js +836 -0
  44. package/dist/components/d3_line_rect/line_focus.js +526 -0
  45. package/dist/components/d3_line_rect/multi_focus.js +433 -0
  46. package/dist/components/d3_line_rect/rect_focus.js +247 -0
  47. package/dist/components/d3_multi/index.js +154 -163
  48. package/dist/components/d3_multi/multi_focus.js +117 -68
  49. package/dist/components/d3_rect/index.js +6 -0
  50. package/dist/components/d3_rect/rect_focus.js +17 -5
  51. package/dist/components/hplc_viewer.js +169 -0
  52. package/dist/components/lc_ms_uv_tools_bar.js +175 -0
  53. package/dist/components/multi_jcamps_viewer.js +17 -5
  54. package/dist/components/panel/compare.js +84 -62
  55. package/dist/components/panel/cyclic_voltamery_data.js +15 -14
  56. package/dist/components/panel/graph_selection.js +32 -30
  57. package/dist/components/panel/index.js +28 -22
  58. package/dist/components/panel/info.js +90 -31
  59. package/dist/constants/action_type.js +23 -2
  60. package/dist/constants/list_graph.js +16 -0
  61. package/dist/constants/list_layout.js +2 -1
  62. package/dist/constants/list_ui.js +5 -2
  63. package/dist/features/lc-ms/entities/extractEntityLCMS.js +187 -0
  64. package/dist/features/lc-ms/parsing/chemstation.js +108 -0
  65. package/dist/features/lc-ms/parsing/index.js +46 -0
  66. package/dist/features/lc-ms/parsing/lcmsCategory.js +44 -0
  67. package/dist/features/lc-ms/parsing/lcmsJcampInfo.js +18 -0
  68. package/dist/features/lc-ms/parsing/lcmsMsPage.js +241 -0
  69. package/dist/features/lc-ms/parsing/pageValue.js +27 -0
  70. package/dist/features/lc-ms/submit/index.js +24 -0
  71. package/dist/features/lc-ms/submit/peaks.js +66 -0
  72. package/dist/features/lc-ms/ui/wavelengthSelect.js +54 -0
  73. package/dist/fn.js +4 -1
  74. package/dist/helpers/brush.js +74 -19
  75. package/dist/helpers/calc.js +4 -2
  76. package/dist/helpers/cfg.js +5 -4
  77. package/dist/helpers/chem.js +449 -71
  78. package/dist/helpers/compass.js +181 -17
  79. package/dist/helpers/extractEntityLCMS.js +24 -0
  80. package/dist/helpers/extractParams.js +118 -33
  81. package/dist/helpers/extractPeaksEdit.js +29 -9
  82. package/dist/helpers/format.js +189 -4
  83. package/dist/helpers/init.js +25 -5
  84. package/dist/helpers/integration.js +130 -17
  85. package/dist/helpers/integration_draft.js +43 -0
  86. package/dist/helpers/integration_focus.js +155 -0
  87. package/dist/helpers/integration_jcamp.js +68 -0
  88. package/dist/helpers/integration_split.js +202 -0
  89. package/dist/helpers/mount.js +8 -1
  90. package/dist/helpers/sweep.js +39 -0
  91. package/dist/index.js +284 -26
  92. package/dist/layer_content.js +17 -3
  93. package/dist/layer_init.js +124 -14
  94. package/dist/layer_prism.js +31 -5
  95. package/dist/reducers/index.js +3 -1
  96. package/dist/reducers/reducer_curve.js +54 -36
  97. package/dist/reducers/reducer_hplc_ms/hydrate.js +289 -0
  98. package/dist/reducers/reducer_hplc_ms/index.js +122 -0
  99. package/dist/reducers/reducer_hplc_ms/persistence.js +74 -0
  100. package/dist/reducers/reducer_hplc_ms/tic.js +70 -0
  101. package/dist/reducers/reducer_hplc_ms/utils.js +70 -0
  102. package/dist/reducers/reducer_hplc_ms/uvvis.js +377 -0
  103. package/dist/reducers/reducer_integration.js +265 -7
  104. package/dist/reducers/reducer_layout.js +1 -1
  105. package/dist/reducers/reducer_submit.js +2 -1
  106. package/dist/reducers/reducer_ui.js +149 -13
  107. package/dist/reducers/undo_redo_config.js +2 -2
  108. package/dist/sagas/saga_lcms_ui.js +85 -0
  109. package/dist/sagas/saga_ui.js +177 -74
  110. package/dist/setupTests.js +5 -5
  111. package/package.json +10 -7
@@ -0,0 +1,526 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _init = require("../../helpers/init");
9
+ var _mount = require("../../helpers/mount");
10
+ var _brush = _interopRequireDefault(require("../../helpers/brush"));
11
+ var _compass = require("../../helpers/compass");
12
+ var _list_layout = require("../../constants/list_layout");
13
+ var _list_graph = require("../../constants/list_graph");
14
+ var _calc = require("../../helpers/calc");
15
+ var _focus = require("../../helpers/focus");
16
+ var _cfg = _interopRequireDefault(require("../../helpers/cfg"));
17
+ var _format = _interopRequireDefault(require("../../helpers/format"));
18
+ var _integration = require("../../helpers/integration");
19
+ var _list_ui = require("../../constants/list_ui");
20
+ /* eslint-disable prefer-object-spread, no-mixed-operators */
21
+
22
+ const d3 = require('d3');
23
+ class LineFocus {
24
+ constructor(props) {
25
+ const {
26
+ W,
27
+ H,
28
+ clickUiTargetAct,
29
+ selectUiSweepAct,
30
+ scrollUiWheelAct,
31
+ graphIndex,
32
+ uiSt
33
+ } = props;
34
+ this.graphIndex = graphIndex;
35
+ this.uiSt = uiSt;
36
+ this.rootKlass = `.${_list_graph.LIST_ROOT_SVG_GRAPH.LINE}`;
37
+ this.margin = {
38
+ t: 5,
39
+ b: 40,
40
+ l: 60,
41
+ r: 5
42
+ };
43
+ this.w = W - this.margin.l - this.margin.r;
44
+ this.h = H - this.margin.t - this.margin.b;
45
+ this.clickUiTargetAct = clickUiTargetAct;
46
+ this.selectUiSweepAct = selectUiSweepAct;
47
+ this.scrollUiWheelAct = scrollUiWheelAct;
48
+ this.brush = d3.brush();
49
+ this.brushX = d3.brushX();
50
+ this.axis = null;
51
+ this.path = null;
52
+ this.grid = null;
53
+ this.tags = null;
54
+ this.data = [];
55
+ this.tTrEndPts = null;
56
+ this.root = null;
57
+ this.svg = null;
58
+ this.axisCall = (0, _init.InitAxisCall)(5);
59
+ this.pathCall = null;
60
+ this.tip = null;
61
+ this.factor = 0.125;
62
+ this.currentExtent = null;
63
+ this.shouldUpdate = {};
64
+ this.layout = _list_layout.LIST_LAYOUT.H1;
65
+ this.getShouldUpdate = this.getShouldUpdate.bind(this);
66
+ this.resetShouldUpdate = this.resetShouldUpdate.bind(this);
67
+ this.setTip = this.setTip.bind(this);
68
+ this.setDataParams = this.setDataParams.bind(this);
69
+ this.create = this.create.bind(this);
70
+ this.update = this.update.bind(this);
71
+ this.setConfig = this.setConfig.bind(this);
72
+ this.drawLine = this.drawLine.bind(this);
73
+ this.drawGrid = this.drawGrid.bind(this);
74
+ this.onClickTarget = this.onClickTarget.bind(this);
75
+ this.drawAUC = this.drawAUC.bind(this);
76
+ this.drawInteg = this.drawInteg.bind(this);
77
+ this.isFirefox = typeof InstallTrigger !== 'undefined';
78
+ }
79
+ getShouldUpdate(hplcMsSt) {
80
+ const {
81
+ prevXt,
82
+ prevYt,
83
+ prevLySt,
84
+ prevItSt,
85
+ prevTePt,
86
+ prevData,
87
+ prevDataSig,
88
+ prevIntegrationSig,
89
+ prevSpectrumKey
90
+ } = this.shouldUpdate;
91
+ const {
92
+ xt,
93
+ yt
94
+ } = (0, _compass.TfRescale)(this);
95
+ const sameXY = xt(1.1) === prevXt && prevYt === yt(1.1);
96
+ const sameLySt = prevLySt === this.layout;
97
+ const sameTePt = prevTePt === this.tTrEndPts.length;
98
+ const currentSpectrum = hplcMsSt?.uvvis?.currentSpectrum;
99
+ const sameItSt = prevItSt === currentSpectrum?.integrations?.length;
100
+ const sameData = prevData === this.data.length;
101
+ const firstPt = this.data[0];
102
+ const lastPt = this.data[this.data.length - 1];
103
+ const dataSig = `${this.data.length}-${firstPt?.y ?? ''}-${lastPt?.y ?? ''}`;
104
+ const sameDataSig = prevDataSig === dataSig;
105
+ const spectrumKey = currentSpectrum?.pageValue ?? hplcMsSt?.uvvis?.selectedWaveLength ?? '';
106
+ const sameSpectrumKey = prevSpectrumKey === spectrumKey;
107
+ const integrations = currentSpectrum?.integrations || [];
108
+ const firstIntegration = integrations[0];
109
+ const lastIntegration = integrations[integrations.length - 1];
110
+ const integrationSig = `${integrations.length}-${firstIntegration?.xL ?? ''}-${firstIntegration?.xU ?? ''}-${lastIntegration?.xL ?? ''}-${lastIntegration?.xU ?? ''}-${currentSpectrum?.refArea ?? ''}-${currentSpectrum?.refFactor ?? ''}`;
111
+ const sameIntegrationSig = prevIntegrationSig === integrationSig;
112
+ this.shouldUpdate = Object.assign({}, this.shouldUpdate, {
113
+ sameXY,
114
+ sameLySt,
115
+ // eslint-disable-line
116
+ sameTePt,
117
+ sameData,
118
+ sameItSt,
119
+ sameDataSig,
120
+ sameIntegrationSig,
121
+ sameSpectrumKey,
122
+ // eslint-disable-line
123
+ dataSig,
124
+ integrationSig,
125
+ spectrumKey // eslint-disable-line
126
+ });
127
+ }
128
+ resetShouldUpdate(hplcMsSt) {
129
+ const {
130
+ xt,
131
+ yt
132
+ } = (0, _compass.TfRescale)(this);
133
+ const prevXt = xt(1.1);
134
+ const prevYt = yt(1.1);
135
+ const prevTePt = this.tTrEndPts.length;
136
+ const prevData = this.data.length;
137
+ const prevLySt = this.layout;
138
+ const currentSpectrum = hplcMsSt?.uvvis?.currentSpectrum;
139
+ const prevItSt = currentSpectrum?.integrations?.length;
140
+ const firstPt = this.data[0];
141
+ const lastPt = this.data[this.data.length - 1];
142
+ const prevDataSig = `${this.data.length}-${firstPt?.y ?? ''}-${lastPt?.y ?? ''}`;
143
+ const spectrumKey = currentSpectrum?.pageValue ?? hplcMsSt?.uvvis?.selectedWaveLength ?? '';
144
+ const integrations = currentSpectrum?.integrations || [];
145
+ const firstIntegration = integrations[0];
146
+ const lastIntegration = integrations[integrations.length - 1];
147
+ const prevIntegrationSig = `${integrations.length}-${firstIntegration?.xL ?? ''}-${firstIntegration?.xU ?? ''}-${lastIntegration?.xL ?? ''}-${lastIntegration?.xU ?? ''}-${currentSpectrum?.refArea ?? ''}-${currentSpectrum?.refFactor ?? ''}`;
148
+ this.shouldUpdate = Object.assign({}, this.shouldUpdate, {
149
+ prevXt,
150
+ prevYt,
151
+ prevLySt,
152
+ // eslint-disable-line
153
+ prevTePt,
154
+ prevData,
155
+ prevItSt,
156
+ prevDataSig,
157
+ prevIntegrationSig,
158
+ prevSpectrumKey: spectrumKey // eslint-disable-line
159
+ });
160
+ }
161
+ setTip() {
162
+ this.tip = (0, _init.InitTip)();
163
+ this.root.call(this.tip);
164
+ }
165
+ setDataParams(data, tTrEndPts, layout, editPeakSt) {
166
+ this.data = [...data];
167
+ this.tTrEndPts = tTrEndPts;
168
+ if (layout) {
169
+ this.layout = layout;
170
+ }
171
+ this.editPeakSt = editPeakSt;
172
+ this.xOnlyBrush = this.layout === _list_layout.LIST_LAYOUT.LC_MS;
173
+ }
174
+ updatePathCall(xt, yt) {
175
+ this.pathCall = d3.line().x(d => xt(d.x)).y(d => yt(d.y));
176
+ }
177
+ setConfig(sweepExtentSt) {
178
+ // Domain Calculate
179
+ let {
180
+ xExtent,
181
+ yExtent
182
+ } = sweepExtentSt || {
183
+ xExtent: false,
184
+ yExtent: false
185
+ };
186
+ if (!xExtent) {
187
+ const xes = d3.extent(this.data, d => d.x).sort((a, b) => a - b);
188
+ xExtent = {
189
+ xL: xes[0],
190
+ xU: xes[1]
191
+ };
192
+ }
193
+ if (!yExtent) {
194
+ const btm = d3.min(this.data, d => d.y);
195
+ const top = d3.max(this.data, d => d.y);
196
+ const height = top - btm;
197
+ yExtent = {
198
+ yL: btm - this.factor * height,
199
+ yU: top + this.factor * height
200
+ };
201
+ }
202
+ this.scales.x.domain([xExtent.xL, xExtent.xU]);
203
+ this.scales.y.domain([yExtent.yL, yExtent.yU]);
204
+
205
+ // rescale for zoom
206
+ const {
207
+ xt,
208
+ yt
209
+ } = (0, _compass.TfRescale)(this);
210
+
211
+ // Axis Call
212
+ this.axisCall.x.scale(xt);
213
+ this.axisCall.y.scale(yt);
214
+ this.currentExtent = {
215
+ xExtent,
216
+ yExtent
217
+ };
218
+ }
219
+ drawLine() {
220
+ if (!this.path) return;
221
+ const {
222
+ sameXY,
223
+ sameDataSig
224
+ } = this.shouldUpdate;
225
+ if (sameXY && sameDataSig) return;
226
+ const {
227
+ xt,
228
+ yt
229
+ } = (0, _compass.TfRescale)(this);
230
+ this.updatePathCall(xt, yt);
231
+ this.path.attr('d', this.pathCall(this.data));
232
+ }
233
+ drawGrid() {
234
+ const {
235
+ sameXY
236
+ } = this.shouldUpdate;
237
+ if (sameXY || !this.grid || !this.axisCall) return;
238
+ if (this.grid.x && this.axisCall.x) {
239
+ this.grid.x.call(this.axisCall.x.tickSize(-this.h, 0, 0)).selectAll('line').attr('stroke', '#ddd').attr('stroke-opacity', 0.6).attr('fill', 'none');
240
+ }
241
+ if (this.grid.y && this.axisCall.y) {
242
+ this.grid.y.call(this.axisCall.y.tickSize(-this.w, 0, 0)).selectAll('line').attr('stroke', '#ddd').attr('stroke-opacity', 0.6).attr('fill', 'none');
243
+ }
244
+ }
245
+ drawPageMarker(hplcMsSt) {
246
+ if (!this.root || !_format.default.isLCMsLayout(this.layout)) return;
247
+ const currentPageValue = hplcMsSt?.tic?.currentPageValue;
248
+ const hasValue = Number.isFinite(currentPageValue);
249
+ const marker = this.root.selectAll('.uvvis-page-marker').data(hasValue ? [currentPageValue] : []);
250
+ marker.exit().remove();
251
+ if (!hasValue) return;
252
+ const {
253
+ xt
254
+ } = (0, _compass.TfRescale)(this);
255
+ marker.enter().append('line').attr('class', 'uvvis-page-marker').attr('stroke', 'red').attr('stroke-width', 1).attr('stroke-opacity', 0.8).merge(marker).attr('x1', xt(currentPageValue)).attr('x2', xt(currentPageValue)).attr('y1', 0).attr('y2', this.h);
256
+ }
257
+ onClickTarget(event, data) {
258
+ event.stopPropagation();
259
+ event.preventDefault();
260
+ if (_format.default.isLCMsLayout(this.layout) && this.graphIndex === 0 && this.uiSt?.sweepType === _list_ui.LIST_UI_SWEEP_TYPE.PEAK_GROUP_SELECT) {
261
+ return;
262
+ }
263
+ const onPeak = true;
264
+ this.clickUiTargetAct(data, onPeak);
265
+ }
266
+ drawAUC(stack) {
267
+ const {
268
+ xt,
269
+ yt
270
+ } = (0, _compass.TfRescale)(this);
271
+ const auc = this.tags.aucPath.selectAll('path').data(stack, d => (0, _focus.itgIdTag)(d));
272
+ auc.exit().attr('class', 'exit').remove();
273
+ const integCurve = border => {
274
+ const {
275
+ xL,
276
+ xU
277
+ } = border.xExtent;
278
+ const ps = this.data.filter(d => d.x > xL && d.x < xU);
279
+ if (!ps[0]) return null;
280
+ const point1 = ps[0];
281
+ const point2 = ps[ps.length - 1];
282
+ const slope = (0, _calc.calcSlope)(point1.x, point1.y, point2.x, point2.y);
283
+ let lastDY = point1.y;
284
+ return d3.area().x(d => xt(d.x)).y0((d, index) => {
285
+ if (index > 0) {
286
+ const lastD = ps[index - 1];
287
+ const y = slope * (d.x - lastD.x) + lastDY;
288
+ lastDY = y;
289
+ return yt(y);
290
+ }
291
+ return yt(0);
292
+ }).y1(d => yt(d.y))(ps);
293
+ };
294
+ auc.enter().append('path').attr('class', 'auc').attr('fill', 'red').attr('stroke', 'none').attr('fill-opacity', 0.2).attr('stroke-width', 2).merge(auc).attr('d', d => integCurve(d)).attr('id', d => `auc${(0, _focus.itgIdTag)(d)}`).on('mouseover', function handleAucMouseover() {
295
+ d3.select(this).attr('stroke', 'blue').style('fill', 'blue');
296
+ }).on('mouseout', function handleAucMouseout() {
297
+ d3.select(this).attr('stroke', 'none').style('fill', 'red').style('fill-opacity', 0.2);
298
+ }).on('click', (event, d) => this.onClickTarget(event, d));
299
+ }
300
+ drawInteg(hplcMsSt) {
301
+ if (!this.tags || !this.tags.igbPath || !this.tags.igcPath || !this.tags.igtPath) return;
302
+ const {
303
+ sameXY,
304
+ sameLySt,
305
+ sameItSt,
306
+ sameData,
307
+ sameIntegrationSig,
308
+ sameSpectrumKey
309
+ } = this.shouldUpdate;
310
+ if (sameXY && sameLySt && sameItSt && sameData && sameIntegrationSig && sameSpectrumKey) return;
311
+ const isDisable = _cfg.default.btnCmdIntg(this.layout);
312
+ const ignoreRef = _format.default.isLCMsLayout(this.layout);
313
+ const currentSpectrum = hplcMsSt?.uvvis?.currentSpectrum;
314
+ const currentIntegrations = currentSpectrum?.integrations || [];
315
+ const currentRefArea = currentSpectrum?.refArea || 0;
316
+ const currentRefFactor = currentSpectrum?.refFactor || 1;
317
+ const igbp = this.tags.igbPath.selectAll('path').data(currentIntegrations, d => (0, _focus.itgIdTag)(d));
318
+ igbp.exit().attr('class', 'exit').remove();
319
+ const igcp = this.tags.igcPath.selectAll('path').data(currentIntegrations, d => (0, _focus.itgIdTag)(d));
320
+ igcp.exit().attr('class', 'exit').remove();
321
+ const igtp = this.tags.igtPath.selectAll('text').data(currentIntegrations, d => (0, _focus.itgIdTag)(d));
322
+ igtp.exit().attr('class', 'exit').remove();
323
+ if (currentIntegrations.length === 0 || isDisable) {
324
+ // remove drawn area under curve
325
+ const auc = this.tags.aucPath.selectAll('path').data(currentIntegrations);
326
+ auc.exit().attr('class', 'exit').remove();
327
+ auc.merge(auc);
328
+ return;
329
+ }
330
+ if (ignoreRef) {
331
+ this.drawAUC(currentIntegrations);
332
+ } else {
333
+ // rescale for zoom
334
+ const {
335
+ xt
336
+ } = (0, _compass.TfRescale)(this);
337
+ const dh = 50;
338
+ const integBar = data => {
339
+ const points = [[xt(data.xL), dh], [xt(data.xL), dh - 10], [xt(data.xL), dh - 5], [xt(data.xU), dh - 5], [xt(data.xU), dh - 10], [xt(data.xU), dh]];
340
+ return d3.line()(points);
341
+ };
342
+ igbp.enter().append('path').attr('class', 'igbp').attr('fill', 'none').attr('stroke', '#228B22').attr('stroke-width', 2).merge(igbp).attr('id', d => `igbp${(0, _focus.itgIdTag)(d)}`).attr('d', d => integBar(d)).on('mouseover', (event, d) => {
343
+ d3.select(`#igbp${(0, _focus.itgIdTag)(d)}`).attr('stroke', 'blue');
344
+ d3.select(`#igbc${(0, _focus.itgIdTag)(d)}`).attr('stroke', 'blue');
345
+ d3.select(`#igtp${(0, _focus.itgIdTag)(d)}`).style('fill', 'blue');
346
+ }).on('mouseout', (event, d) => {
347
+ d3.select(`#igbp${(0, _focus.itgIdTag)(d)}`).attr('stroke', '#228B22');
348
+ d3.select(`#igbc${(0, _focus.itgIdTag)(d)}`).attr('stroke', '#228B22');
349
+ d3.select(`#igtp${(0, _focus.itgIdTag)(d)}`).style('fill', '#228B22');
350
+ }).on('click', (event, d) => this.onClickTarget(event, d));
351
+ const integCurve = border => {
352
+ const {
353
+ xL,
354
+ xU
355
+ } = border;
356
+ const ps = this.data.filter(d => d.x > xL && d.x < xU);
357
+ const kMax = this.data[this.data.length - 1].k;
358
+ if (!ps[0]) return null;
359
+ const kRef = ps[0].k;
360
+ if (!this.reverseXAxis(this.layout)) {
361
+ return d3.line().x(d => xt(d.x)).y(d => 100 - (kRef - d.k) * 400 / kMax)(ps);
362
+ }
363
+ return d3.line().x(d => xt(d.x)).y(d => 300 - (d.k - kRef) * 400 / kMax)(ps);
364
+ };
365
+ igcp.enter().append('path').attr('class', 'igcp').attr('fill', 'none').attr('stroke', '#228B22').attr('stroke-width', 2).merge(igcp).attr('id', d => `igbc${(0, _focus.itgIdTag)(d)}`).attr('d', d => integCurve(d)).on('mouseover', (event, d) => {
366
+ d3.select(`#igbp${(0, _focus.itgIdTag)(d)}`).attr('stroke', 'blue');
367
+ d3.select(`#igbc${(0, _focus.itgIdTag)(d)}`).attr('stroke', 'blue');
368
+ d3.select(`#igtp${(0, _focus.itgIdTag)(d)}`).style('fill', 'blue');
369
+ }).on('mouseout', (event, d) => {
370
+ d3.select(`#igbp${(0, _focus.itgIdTag)(d)}`).attr('stroke', '#228B22');
371
+ d3.select(`#igbc${(0, _focus.itgIdTag)(d)}`).attr('stroke', '#228B22');
372
+ d3.select(`#igtp${(0, _focus.itgIdTag)(d)}`).style('fill', '#228B22');
373
+ }).on('click', (event, d) => this.onClickTarget(event, d));
374
+ igtp.enter().append('text').attr('class', 'igtp').attr('font-family', 'Helvetica').style('font-size', '12px').attr('fill', '#228B22').style('text-anchor', 'middle').merge(igtp).attr('id', d => `igtp${(0, _focus.itgIdTag)(d)}`).text(d => (0, _integration.calcArea)(d, currentRefArea, currentRefFactor, ignoreRef)).attr('transform', d => {
375
+ const x = xt((d.xL + d.xU) / 2);
376
+ const y = dh - 12;
377
+ return `translate(${x}, ${y})`;
378
+ }).on('mouseover', (event, d) => {
379
+ d3.select(`#igbp${(0, _focus.itgIdTag)(d)}`).attr('stroke', 'blue');
380
+ d3.select(`#igbc${(0, _focus.itgIdTag)(d)}`).attr('stroke', 'blue');
381
+ d3.select(`#igtp${(0, _focus.itgIdTag)(d)}`).style('fill', 'blue');
382
+ }).on('mouseout', (event, d) => {
383
+ d3.select(`#igbp${(0, _focus.itgIdTag)(d)}`).attr('stroke', '#228B22');
384
+ d3.select(`#igbc${(0, _focus.itgIdTag)(d)}`).attr('stroke', '#228B22');
385
+ d3.select(`#igtp${(0, _focus.itgIdTag)(d)}`).style('fill', '#228B22');
386
+ }).on('click', (event, d) => this.onClickTarget(event, d));
387
+ }
388
+ }
389
+ mergedPeaks(hplcMsSt) {
390
+ const currentSpectrum = hplcMsSt?.uvvis?.currentSpectrum;
391
+ if (!currentSpectrum || !currentSpectrum.peaks) return [];
392
+ return currentSpectrum.peaks;
393
+ }
394
+ drawPeaks(hplcMsSt) {
395
+ if (!this.tags || !this.tags.pPath) return;
396
+ const {
397
+ sameXY,
398
+ sameEpSt,
399
+ sameDtPk,
400
+ sameSfPk
401
+ } = this.shouldUpdate;
402
+ if (sameXY && sameEpSt && sameDtPk && sameSfPk) return;
403
+ const {
404
+ xt,
405
+ yt
406
+ } = (0, _compass.TfRescale)(this);
407
+ const dPks = this.mergedPeaks(hplcMsSt);
408
+ const mpp = this.tags.pPath.selectAll('path').data(dPks);
409
+ mpp.exit().remove();
410
+ const linePath = [{
411
+ x: -0.5,
412
+ y: 10
413
+ }, {
414
+ x: -0.5,
415
+ y: -20
416
+ }, {
417
+ x: 0.5,
418
+ y: -20
419
+ }, {
420
+ x: 0.5,
421
+ y: 10
422
+ }];
423
+ const lineSymbol = d3.line().x(d => d.x).y(d => d.y)(linePath);
424
+ mpp.enter().append('path').attr('d', lineSymbol).attr('class', 'enter-peak').attr('fill', 'red').attr('stroke', 'pink').attr('stroke-width', 3).attr('stroke-opacity', 0.0).merge(mpp).attr('id', d => `mpp${Math.round(1000 * d.x)}`).attr('transform', d => `translate(${xt(d.x)}, ${yt(d.y)})`).on('mouseover', (event, d) => {
425
+ d3.select(`#mpp${Math.round(1000 * d.x)}`).attr('stroke-opacity', '1.0');
426
+ const tipParams = {
427
+ d,
428
+ layout: this.layout
429
+ };
430
+ this.tip.show(tipParams, event.target);
431
+ }).on('mouseout', (event, d) => {
432
+ d3.select(`#mpp${Math.round(1000 * d.x)}`).attr('stroke-opacity', '0.0');
433
+ const tipParams = {
434
+ d,
435
+ layout: this.layout
436
+ };
437
+ this.tip.hide(tipParams, event.target);
438
+ }).on('click', (event, d) => this.onClickTarget(event, d));
439
+ if (_format.default.isLCMsLayout(this.layout)) {
440
+ const bpTxt = this.tags.bpTxt.selectAll('text').data(dPks);
441
+ bpTxt.exit().remove();
442
+ bpTxt.enter().append('text').attr('class', 'peak-text').attr('font-family', 'Helvetica').style('font-size', '12px').attr('fill', '#228B22').style('text-anchor', 'middle').merge(bpTxt).attr('id', d => `txt${Math.round(1000 * d.x)}`).text(d => d.x.toFixed(2)).attr('transform', d => `translate(${xt(d.x)}, ${yt(d.y) - 25})`).on('click', (event, d) => this.onClickTarget(event, d));
443
+ }
444
+ }
445
+ create({
446
+ filterSeed,
447
+ tTrEndPts,
448
+ layoutSt,
449
+ sweepExtentSt,
450
+ isUiAddIntgSt,
451
+ isUiNoBrushSt,
452
+ hplcMsSt,
453
+ editPeakSt
454
+ }) {
455
+ this.svg = d3.select('.d3Svg');
456
+ (0, _mount.MountMainFrame)(this, 'focus');
457
+ (0, _mount.MountClip)(this);
458
+ this.root = d3.select(this.rootKlass).selectAll('.focus-main');
459
+ if (!this.root || this.root.empty()) return;
460
+ this.scales = (0, _init.InitScale)(this, false);
461
+ this.setTip();
462
+ this.setDataParams(filterSeed, tTrEndPts, layoutSt, editPeakSt);
463
+ (0, _compass.MountCompass)(this);
464
+ this.axis = (0, _mount.MountAxis)(this);
465
+ this.path = (0, _mount.MountPath)(this, 'steelblue');
466
+ this.grid = (0, _mount.MountGrid)(this);
467
+ this.tags = (0, _mount.MountTags)(this);
468
+ (0, _mount.MountAxisLabelX)(this);
469
+ (0, _mount.MountAxisLabelY)(this);
470
+ if (this.data && this.data.length > 0) {
471
+ this.setConfig(sweepExtentSt);
472
+ this.drawLine();
473
+ this.drawPeaks(hplcMsSt);
474
+ this.drawGrid();
475
+ this.drawPageMarker(hplcMsSt);
476
+ this.drawInteg(hplcMsSt);
477
+ }
478
+ (0, _brush.default)(this, isUiAddIntgSt, isUiNoBrushSt);
479
+ this.resetShouldUpdate(hplcMsSt);
480
+ }
481
+ reverseXAxis(layoutSt) {
482
+ return [_list_layout.LIST_LAYOUT.UVVIS, _list_layout.LIST_LAYOUT.HPLC_UVVIS, _list_layout.LIST_LAYOUT.TGA, _list_layout.LIST_LAYOUT.DSC, _list_layout.LIST_LAYOUT.XRD, _list_layout.LIST_LAYOUT.CYCLIC_VOLTAMMETRY, _list_layout.LIST_LAYOUT.CDS, _list_layout.LIST_LAYOUT.DLS_ACF, _list_layout.LIST_LAYOUT.SEC, _list_layout.LIST_LAYOUT.GC, _list_layout.LIST_LAYOUT.EMISSIONS, _list_layout.LIST_LAYOUT.DLS_INTENSITY].indexOf(layoutSt) < 0;
483
+ }
484
+ update({
485
+ filterSeed,
486
+ tTrEndPts,
487
+ layoutSt,
488
+ sweepExtentSt,
489
+ isUiAddIntgSt,
490
+ isUiNoBrushSt,
491
+ uiSt,
492
+ hplcMsSt,
493
+ editPeakSt
494
+ }) {
495
+ this.root = d3.select(this.rootKlass).selectAll('.focus-main');
496
+ this.scales = (0, _init.InitScale)(this, false);
497
+ this.setDataParams(filterSeed, tTrEndPts, layoutSt, editPeakSt);
498
+ this.uiSt = uiSt;
499
+ const isInitialized = !!(this.root && !this.root.empty() && this.path && this.grid && this.tags);
500
+ if (!isInitialized) {
501
+ this.create({
502
+ filterSeed,
503
+ tTrEndPts,
504
+ layoutSt,
505
+ sweepExtentSt,
506
+ isUiAddIntgSt,
507
+ isUiNoBrushSt,
508
+ hplcMsSt,
509
+ editPeakSt
510
+ });
511
+ return;
512
+ }
513
+ if (this.data && this.data.length > 0) {
514
+ this.setConfig(sweepExtentSt);
515
+ this.getShouldUpdate(hplcMsSt);
516
+ this.drawLine();
517
+ this.drawGrid();
518
+ this.drawPageMarker(hplcMsSt);
519
+ this.drawPeaks(hplcMsSt);
520
+ this.drawInteg(hplcMsSt);
521
+ }
522
+ (0, _brush.default)(this, isUiAddIntgSt, isUiNoBrushSt);
523
+ this.resetShouldUpdate(hplcMsSt);
524
+ }
525
+ }
526
+ var _default = exports.default = LineFocus;