@complat/react-spectra-editor 0.11.3 → 0.11.4-beta.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.
- package/dist/components/d3_line/line_focus_bk.js +860 -0
- package/dist/components/d3_multi/index_bk.js +240 -0
- package/dist/components/d3_multi/multi_focus_bk.js +550 -0
- package/dist/components/panel/compare_bk.js +370 -0
- package/dist/components/panel/info_bk.js +341 -0
- package/dist/components/panel/multiplicity_bk.js +405 -0
- package/dist/helpers/chem_bk.js +779 -0
- package/dist/helpers/converter_bk.js +106 -0
- package/dist/helpers/format_bk.js +462 -0
- package/dist/index_bk.js +760 -0
- package/dist/layer_content_bk.js +128 -0
- package/dist/layer_prism_bk.js +186 -0
- package/dist/reducers/reducer_edit_peak_bk.js +111 -0
- package/dist/reducers/reducer_integration_bk.js +137 -0
- package/dist/reducers/reducer_jcamp_bk.js +74 -0
- package/dist/reducers/reducer_multiplicity_bk.js +131 -0
- package/dist/reducers/reducer_shift_bk.js +99 -0
- package/dist/sagas/saga_edit_peak_bk.js +84 -0
- package/dist/sagas/saga_multiplicity_bk.js +387 -0
- package/dist/sagas/saga_ui_bk.js +488 -0
- package/package.json +3 -2
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
8
|
+
|
|
9
|
+
var ToXY = function ToXY(data) {
|
|
10
|
+
var length = data ? data.length : 0;
|
|
11
|
+
if (length === 0) return [];
|
|
12
|
+
var peaks = [];
|
|
13
|
+
var i = 0;
|
|
14
|
+
for (i = 0; i < length; i += 1) {
|
|
15
|
+
var _data$i = data[i],
|
|
16
|
+
x = _data$i.x,
|
|
17
|
+
y = _data$i.y;
|
|
18
|
+
|
|
19
|
+
peaks = [].concat(_toConsumableArray(peaks), [[x, y]]);
|
|
20
|
+
}
|
|
21
|
+
return peaks;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
var IsSame = function IsSame(one, two) {
|
|
25
|
+
return Math.abs((one - two) * 10000000) < 1.0;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var pksRmNeg = function pksRmNeg(dataPks, editPeakSt) {
|
|
29
|
+
var neg = editPeakSt.neg;
|
|
30
|
+
|
|
31
|
+
var negXs = neg.map(function (n) {
|
|
32
|
+
return n.x;
|
|
33
|
+
});
|
|
34
|
+
var result = dataPks.map(function (p) {
|
|
35
|
+
var idx = negXs.findIndex(function (nx) {
|
|
36
|
+
return IsSame(nx, p.x);
|
|
37
|
+
});
|
|
38
|
+
return idx >= 0 ? null : p;
|
|
39
|
+
}).filter(function (r) {
|
|
40
|
+
return r != null;
|
|
41
|
+
});
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var pksAddPos = function pksAddPos(dataPks, editPeakSt) {
|
|
46
|
+
var pos = editPeakSt.pos;
|
|
47
|
+
|
|
48
|
+
var posXs = pos.map(function (p) {
|
|
49
|
+
return p.x;
|
|
50
|
+
});
|
|
51
|
+
var posPks = dataPks.map(function (p) {
|
|
52
|
+
var idx = posXs.findIndex(function (px) {
|
|
53
|
+
return px === p.x;
|
|
54
|
+
});
|
|
55
|
+
return idx >= 0 ? null : p;
|
|
56
|
+
}).filter(function (r) {
|
|
57
|
+
return r != null;
|
|
58
|
+
});
|
|
59
|
+
var result = [].concat(_toConsumableArray(posPks), _toConsumableArray(pos));
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var PksEdit = function PksEdit(dataPks, editPeakSt) {
|
|
64
|
+
var voltammetryPeak = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
65
|
+
|
|
66
|
+
if (voltammetryPeak && voltammetryPeak.length > 0) {
|
|
67
|
+
var modDataPks = [];
|
|
68
|
+
voltammetryPeak.forEach(function (peak) {
|
|
69
|
+
if (peak.max) {
|
|
70
|
+
modDataPks = [].concat(_toConsumableArray(modDataPks), [peak.max]);
|
|
71
|
+
}
|
|
72
|
+
if (peak.min) {
|
|
73
|
+
modDataPks = [].concat(_toConsumableArray(modDataPks), [peak.min]);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
modDataPks = modDataPks.sort(function (a, b) {
|
|
77
|
+
return a.x - b.x;
|
|
78
|
+
});
|
|
79
|
+
return modDataPks;
|
|
80
|
+
} else {
|
|
81
|
+
var _modDataPks = pksAddPos(dataPks, editPeakSt);
|
|
82
|
+
_modDataPks = pksRmNeg(_modDataPks, editPeakSt);
|
|
83
|
+
_modDataPks = _modDataPks.sort(function (a, b) {
|
|
84
|
+
return a.x - b.x;
|
|
85
|
+
});
|
|
86
|
+
return _modDataPks;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
var PeckersEdit = function PeckersEdit(voltammetryPeak) {
|
|
91
|
+
var modDataPeckers = [];
|
|
92
|
+
voltammetryPeak.forEach(function (peak) {
|
|
93
|
+
if (peak.pecker) {
|
|
94
|
+
modDataPeckers = [].concat(_toConsumableArray(modDataPeckers), [peak.pecker]);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
modDataPeckers = modDataPeckers.sort(function (a, b) {
|
|
98
|
+
return a.x - b.x;
|
|
99
|
+
});
|
|
100
|
+
return modDataPeckers;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
exports.ToXY = ToXY;
|
|
104
|
+
exports.PksEdit = PksEdit;
|
|
105
|
+
exports.IsSame = IsSame;
|
|
106
|
+
exports.PeckersEdit = PeckersEdit;
|
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _spectraOps;
|
|
8
|
+
|
|
9
|
+
var _converter = require('./converter');
|
|
10
|
+
|
|
11
|
+
var _list_layout = require('../constants/list_layout');
|
|
12
|
+
|
|
13
|
+
var _multiplicity_calc = require('./multiplicity_calc');
|
|
14
|
+
|
|
15
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
16
|
+
|
|
17
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
|
|
19
|
+
var spectraDigit = function spectraDigit(layout) {
|
|
20
|
+
switch (layout) {
|
|
21
|
+
case _list_layout.LIST_LAYOUT.IR:
|
|
22
|
+
case _list_layout.LIST_LAYOUT.RAMAN:
|
|
23
|
+
case _list_layout.LIST_LAYOUT.UVVIS:
|
|
24
|
+
case _list_layout.LIST_LAYOUT.HPLC_UVVIS:
|
|
25
|
+
case _list_layout.LIST_LAYOUT.TGA:
|
|
26
|
+
case _list_layout.LIST_LAYOUT.XRD:
|
|
27
|
+
case _list_layout.LIST_LAYOUT.CYCLIC_VOLTAMMETRY:
|
|
28
|
+
case _list_layout.LIST_LAYOUT.MS:
|
|
29
|
+
return 0;
|
|
30
|
+
case _list_layout.LIST_LAYOUT.C13:
|
|
31
|
+
return 1;
|
|
32
|
+
case _list_layout.LIST_LAYOUT.H1:
|
|
33
|
+
case _list_layout.LIST_LAYOUT.F19:
|
|
34
|
+
case _list_layout.LIST_LAYOUT.P31:
|
|
35
|
+
case _list_layout.LIST_LAYOUT.N15:
|
|
36
|
+
case _list_layout.LIST_LAYOUT.Si29:
|
|
37
|
+
case _list_layout.LIST_LAYOUT.PLAIN:
|
|
38
|
+
default:
|
|
39
|
+
return 2;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var fixDigit = function fixDigit(input, precision) {
|
|
44
|
+
var output = input || 0.0;
|
|
45
|
+
return output.toFixed(precision);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
var buildData = function buildData(entity) {
|
|
49
|
+
if (!entity) return { isExist: false };
|
|
50
|
+
var sp = entity && entity.spectrum;
|
|
51
|
+
var xLabel = sp ? 'X (' + sp.xUnit + ')' : '';
|
|
52
|
+
var yLabel = sp ? 'Y (' + sp.yUnit + ')' : '';
|
|
53
|
+
return {
|
|
54
|
+
entity: entity, xLabel: xLabel, yLabel: yLabel, isExist: true
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var toPeakStr = function toPeakStr(peaks) {
|
|
59
|
+
var arr = peaks.map(function (p) {
|
|
60
|
+
return p.x + ',' + p.y;
|
|
61
|
+
});
|
|
62
|
+
var str = arr.join('#');
|
|
63
|
+
return str;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var spectraOps = (_spectraOps = {}, _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.PLAIN, { head: '', tail: '.' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.H1, { head: '1H', tail: '.' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.C13, { head: '13C', tail: '.' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.F19, { head: '19F', tail: '.' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.P31, { head: '31P', tail: '.' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.N15, { head: '15N', tail: '.' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.Si29, { head: '29Si', tail: '.' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.IR, { head: 'IR', tail: ' cm-1' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.RAMAN, { head: 'RAMAN', tail: ' cm-1' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.UVVIS, { head: 'UV-VIS (absorption, solvent), λmax', tail: ' nm' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.HPLC_UVVIS, { head: 'HPLC UV/VIS (transmittance)', tail: '' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.TGA, { head: 'THERMOGRAVIMETRIC ANALYSIS', tail: ' SECONDS' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.MS, { head: 'MASS', tail: ' m/z' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.XRD, { head: 'X-RAY DIFFRACTION', tail: '.' }), _defineProperty(_spectraOps, _list_layout.LIST_LAYOUT.CYCLIC_VOLTAMMETRY, { head: 'CYCLIC VOLTAMMETRY', tail: '.' }), _spectraOps);
|
|
67
|
+
|
|
68
|
+
var rmRef = function rmRef(peaks, shift) {
|
|
69
|
+
var refValue = shift.ref.value || shift.peak.x;
|
|
70
|
+
return peaks.map(function (p) {
|
|
71
|
+
return (0, _converter.IsSame)(p.x, refValue) ? null : p;
|
|
72
|
+
}).filter(function (r) {
|
|
73
|
+
return r != null;
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var formatedMS = function formatedMS(peaks, maxY) {
|
|
78
|
+
var decimal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
|
|
79
|
+
var isAscend = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
80
|
+
|
|
81
|
+
var ascendFunc = function ascendFunc(a, b) {
|
|
82
|
+
return parseFloat(a) - parseFloat(b);
|
|
83
|
+
};
|
|
84
|
+
var descendFunc = function descendFunc(a, b) {
|
|
85
|
+
return parseFloat(b) - parseFloat(a);
|
|
86
|
+
};
|
|
87
|
+
var sortFunc = isAscend ? ascendFunc : descendFunc;
|
|
88
|
+
var ordered = {};
|
|
89
|
+
|
|
90
|
+
peaks.forEach(function (p) {
|
|
91
|
+
var x = fixDigit(p.x, decimal);
|
|
92
|
+
var better = !ordered[x] || p.y > ordered[x];
|
|
93
|
+
if (better) {
|
|
94
|
+
ordered = Object.assign({}, ordered, _defineProperty({}, x, p.y));
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
ordered = Object.keys(ordered).sort(sortFunc).map(function (k) {
|
|
99
|
+
return { x: k, y: ordered[k] };
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return ordered.map(function (o) {
|
|
103
|
+
return o.x + ' (' + parseInt(100 * o.y / maxY, 10) + ')';
|
|
104
|
+
}).join(', ');
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
var emLevel = function emLevel(boundary, val, lowerIsStronger) {
|
|
108
|
+
var maxY = boundary.maxY,
|
|
109
|
+
minY = boundary.minY;
|
|
110
|
+
|
|
111
|
+
var ratio = lowerIsStronger ? 100 * (val - minY) / (maxY - minY) : 100 * (maxY - val) / (maxY - minY);
|
|
112
|
+
if (ratio > 85) return 'vw';
|
|
113
|
+
if (ratio > 60) return 'w';
|
|
114
|
+
if (ratio > 45) return 'm';
|
|
115
|
+
if (ratio > 30) return 's';
|
|
116
|
+
return 'vs';
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
var formatedEm = function formatedEm(peaks, maxY) {
|
|
120
|
+
var decimal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
|
|
121
|
+
var isAscend = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
122
|
+
var isIntensity = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
123
|
+
var boundary = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
124
|
+
var lowerIsStronger = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
125
|
+
|
|
126
|
+
var ascendFunc = function ascendFunc(a, b) {
|
|
127
|
+
return parseFloat(a) - parseFloat(b);
|
|
128
|
+
};
|
|
129
|
+
var descendFunc = function descendFunc(a, b) {
|
|
130
|
+
return parseFloat(b) - parseFloat(a);
|
|
131
|
+
};
|
|
132
|
+
var sortFunc = isAscend ? ascendFunc : descendFunc;
|
|
133
|
+
var ordered = {};
|
|
134
|
+
|
|
135
|
+
peaks.forEach(function (p) {
|
|
136
|
+
var x = fixDigit(p.x, decimal);
|
|
137
|
+
var better = !ordered[x] || p.y > ordered[x];
|
|
138
|
+
if (better) {
|
|
139
|
+
ordered = Object.assign({}, ordered, _defineProperty({}, x, p.y));
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
ordered = Object.keys(ordered).sort(sortFunc).map(function (k) {
|
|
144
|
+
return { x: k, y: ordered[k] };
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
if (isIntensity) {
|
|
148
|
+
return ordered.map(function (o) {
|
|
149
|
+
return o.x + ' (' + emLevel(boundary, o.y, lowerIsStronger) + ')';
|
|
150
|
+
}).join(', ');
|
|
151
|
+
}
|
|
152
|
+
return ordered.map(function (o) {
|
|
153
|
+
return '' + o.x;
|
|
154
|
+
}).join(', ');
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
var formatedUvVis = function formatedUvVis(peaks, maxY) {
|
|
158
|
+
var decimal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
|
|
159
|
+
var isAscend = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
160
|
+
var isIntensity = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
161
|
+
var boundary = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
162
|
+
var lowerIsStronger = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
163
|
+
|
|
164
|
+
var ascendFunc = function ascendFunc(a, b) {
|
|
165
|
+
return parseFloat(a) - parseFloat(b);
|
|
166
|
+
};
|
|
167
|
+
var descendFunc = function descendFunc(a, b) {
|
|
168
|
+
return parseFloat(b) - parseFloat(a);
|
|
169
|
+
};
|
|
170
|
+
var sortFunc = isAscend ? ascendFunc : descendFunc;
|
|
171
|
+
var ordered = {};
|
|
172
|
+
|
|
173
|
+
peaks.forEach(function (p) {
|
|
174
|
+
var x = fixDigit(p.x, decimal);
|
|
175
|
+
var better = !ordered[x] || p.y > ordered[x];
|
|
176
|
+
if (better) {
|
|
177
|
+
ordered = Object.assign({}, ordered, _defineProperty({}, x, p.y));
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
ordered = Object.keys(ordered).sort(sortFunc).map(function (k) {
|
|
182
|
+
return { x: k, y: ordered[k] };
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// return ordered.map(o => `${o.x} (${o.y.toFixed(2)})`)
|
|
186
|
+
// .join(', ');
|
|
187
|
+
return ordered.map(function (o) {
|
|
188
|
+
return '' + o.x;
|
|
189
|
+
}).join(', ');
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
var formatedHplcUvVis = function formatedHplcUvVis(peaks) {
|
|
193
|
+
var decimal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
194
|
+
var integration = arguments[2];
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
var stack = [];
|
|
198
|
+
if (integration) {
|
|
199
|
+
stack = integration.stack;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
var ordered = {};
|
|
203
|
+
|
|
204
|
+
peaks.forEach(function (p) {
|
|
205
|
+
var x = fixDigit(p.x, decimal);
|
|
206
|
+
var better = !ordered[x] || p.y > ordered[x];
|
|
207
|
+
if (better) {
|
|
208
|
+
ordered = Object.assign({}, ordered, _defineProperty({}, x, p.y));
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
ordered = Object.keys(ordered).map(function (k) {
|
|
213
|
+
return { x: k, y: ordered[k] };
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
var arrResult = [];
|
|
217
|
+
ordered.forEach(function (o) {
|
|
218
|
+
var pStr = o.x + ' (' + o.y.toFixed(2) + ')';
|
|
219
|
+
if (stack) {
|
|
220
|
+
stack.forEach(function (s) {
|
|
221
|
+
if (s.xL <= o.x && s.xU >= o.x) {
|
|
222
|
+
pStr = o.x + ' (' + o.y.toFixed(2) + ', AUC=' + s.absoluteArea + ')';
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
arrResult.push(pStr);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
return arrResult.join(', ');
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
var rmShiftFromPeaks = function rmShiftFromPeaks(peaks, shift) {
|
|
233
|
+
var peaksXY = (0, _converter.ToXY)(peaks);
|
|
234
|
+
// const digit = spectraDigit(layout);
|
|
235
|
+
var rmShiftX = shift.ref.value || shift.peak.x;
|
|
236
|
+
var result = peaksXY.map(function (p) {
|
|
237
|
+
var srcX = parseFloat(p[0]);
|
|
238
|
+
var x = (0, _converter.IsSame)(srcX, rmShiftX) ? null : srcX;
|
|
239
|
+
if (!x) return null;
|
|
240
|
+
var y = parseFloat(p[1]);
|
|
241
|
+
return { x: x, y: y };
|
|
242
|
+
}).filter(function (r) {
|
|
243
|
+
return r != null;
|
|
244
|
+
});
|
|
245
|
+
return result;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
var peaksBody = function peaksBody(_ref) {
|
|
249
|
+
var peaks = _ref.peaks,
|
|
250
|
+
layout = _ref.layout,
|
|
251
|
+
decimal = _ref.decimal,
|
|
252
|
+
shift = _ref.shift,
|
|
253
|
+
isAscend = _ref.isAscend,
|
|
254
|
+
_ref$isIntensity = _ref.isIntensity,
|
|
255
|
+
isIntensity = _ref$isIntensity === undefined ? false : _ref$isIntensity,
|
|
256
|
+
_ref$boundary = _ref.boundary,
|
|
257
|
+
boundary = _ref$boundary === undefined ? {} : _ref$boundary,
|
|
258
|
+
integration = _ref.integration;
|
|
259
|
+
|
|
260
|
+
var result = rmShiftFromPeaks(peaks, shift);
|
|
261
|
+
|
|
262
|
+
var ascendFunc = function ascendFunc(a, b) {
|
|
263
|
+
return parseFloat(a.x) - parseFloat(b.x);
|
|
264
|
+
};
|
|
265
|
+
var descendFunc = function descendFunc(a, b) {
|
|
266
|
+
return parseFloat(b.x) - parseFloat(a.x);
|
|
267
|
+
};
|
|
268
|
+
var sortFunc = isAscend ? ascendFunc : descendFunc;
|
|
269
|
+
var ordered = result.sort(sortFunc);
|
|
270
|
+
var maxY = Math.max.apply(Math, _toConsumableArray(ordered.map(function (o) {
|
|
271
|
+
return o.y;
|
|
272
|
+
})));
|
|
273
|
+
|
|
274
|
+
if (layout === _list_layout.LIST_LAYOUT.MS) {
|
|
275
|
+
return formatedMS(ordered, maxY, decimal, isAscend);
|
|
276
|
+
}
|
|
277
|
+
if (layout === _list_layout.LIST_LAYOUT.IR) {
|
|
278
|
+
return formatedEm(ordered, maxY, decimal, isAscend, isIntensity, boundary, true);
|
|
279
|
+
}
|
|
280
|
+
if (layout === _list_layout.LIST_LAYOUT.RAMAN) {
|
|
281
|
+
return formatedEm(ordered, maxY, decimal, isAscend, isIntensity, boundary, false);
|
|
282
|
+
}
|
|
283
|
+
if (layout === _list_layout.LIST_LAYOUT.UVVIS) {
|
|
284
|
+
return formatedUvVis(ordered, maxY, decimal, isAscend, isIntensity, boundary, false);
|
|
285
|
+
}
|
|
286
|
+
if (layout === _list_layout.LIST_LAYOUT.HPLC_UVVIS) {
|
|
287
|
+
return formatedHplcUvVis(ordered, decimal, integration);
|
|
288
|
+
}
|
|
289
|
+
if (layout === _list_layout.LIST_LAYOUT.TGA) {
|
|
290
|
+
return formatedEm(ordered, maxY, decimal, isAscend, isIntensity, boundary, false);
|
|
291
|
+
}
|
|
292
|
+
if (layout === _list_layout.LIST_LAYOUT.XRD) {
|
|
293
|
+
return formatedEm(ordered, maxY, decimal, isAscend, isIntensity, boundary, false);
|
|
294
|
+
}
|
|
295
|
+
if (layout === _list_layout.LIST_LAYOUT.CYCLIC_VOLTAMMETRY) {
|
|
296
|
+
return formatedEm(ordered, maxY, decimal, isAscend, isIntensity, boundary, false);
|
|
297
|
+
}
|
|
298
|
+
return ordered.map(function (o) {
|
|
299
|
+
return fixDigit(o.x, decimal);
|
|
300
|
+
}).join(', ');
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
var peaksWrapper = function peaksWrapper(layout, shift) {
|
|
304
|
+
var solvTxt = '';
|
|
305
|
+
if (shift.ref.label) {
|
|
306
|
+
solvTxt = ' (' + shift.ref.label + ')';
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (layout === _list_layout.LIST_LAYOUT.PLAIN) {
|
|
310
|
+
return { head: '', tail: '' };
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
var ops = spectraOps[layout];
|
|
314
|
+
return { head: '' + ops.head + solvTxt + ' = ', tail: ops.tail };
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
var isNmrLayout = function isNmrLayout(layoutSt) {
|
|
318
|
+
return [_list_layout.LIST_LAYOUT.H1, _list_layout.LIST_LAYOUT.C13, _list_layout.LIST_LAYOUT.F19, _list_layout.LIST_LAYOUT.P31, _list_layout.LIST_LAYOUT.N15, _list_layout.LIST_LAYOUT.Si29].indexOf(layoutSt) >= 0;
|
|
319
|
+
};
|
|
320
|
+
var is29SiLayout = function is29SiLayout(layoutSt) {
|
|
321
|
+
return _list_layout.LIST_LAYOUT.Si29 === layoutSt;
|
|
322
|
+
};
|
|
323
|
+
var is15NLayout = function is15NLayout(layoutSt) {
|
|
324
|
+
return _list_layout.LIST_LAYOUT.N15 === layoutSt;
|
|
325
|
+
};
|
|
326
|
+
var is31PLayout = function is31PLayout(layoutSt) {
|
|
327
|
+
return _list_layout.LIST_LAYOUT.P31 === layoutSt;
|
|
328
|
+
};
|
|
329
|
+
var is19FLayout = function is19FLayout(layoutSt) {
|
|
330
|
+
return _list_layout.LIST_LAYOUT.F19 === layoutSt;
|
|
331
|
+
};
|
|
332
|
+
var is13CLayout = function is13CLayout(layoutSt) {
|
|
333
|
+
return _list_layout.LIST_LAYOUT.C13 === layoutSt;
|
|
334
|
+
};
|
|
335
|
+
var is1HLayout = function is1HLayout(layoutSt) {
|
|
336
|
+
return _list_layout.LIST_LAYOUT.H1 === layoutSt;
|
|
337
|
+
};
|
|
338
|
+
var isMsLayout = function isMsLayout(layoutSt) {
|
|
339
|
+
return _list_layout.LIST_LAYOUT.MS === layoutSt;
|
|
340
|
+
};
|
|
341
|
+
var isIrLayout = function isIrLayout(layoutSt) {
|
|
342
|
+
return [_list_layout.LIST_LAYOUT.IR, 'INFRARED'].indexOf(layoutSt) >= 0;
|
|
343
|
+
};
|
|
344
|
+
var isRamanLayout = function isRamanLayout(layoutSt) {
|
|
345
|
+
return _list_layout.LIST_LAYOUT.RAMAN === layoutSt;
|
|
346
|
+
};
|
|
347
|
+
var isUvVisLayout = function isUvVisLayout(layoutSt) {
|
|
348
|
+
return _list_layout.LIST_LAYOUT.UVVIS === layoutSt;
|
|
349
|
+
};
|
|
350
|
+
var isHplcUvVisLayout = function isHplcUvVisLayout(layoutSt) {
|
|
351
|
+
return _list_layout.LIST_LAYOUT.HPLC_UVVIS === layoutSt;
|
|
352
|
+
};
|
|
353
|
+
var isTGALayout = function isTGALayout(layoutSt) {
|
|
354
|
+
return _list_layout.LIST_LAYOUT.TGA === layoutSt;
|
|
355
|
+
};
|
|
356
|
+
var isXRDLayout = function isXRDLayout(layoutSt) {
|
|
357
|
+
return _list_layout.LIST_LAYOUT.XRD === layoutSt;
|
|
358
|
+
};
|
|
359
|
+
var isCyclicVoltaLayout = function isCyclicVoltaLayout(layoutSt) {
|
|
360
|
+
return _list_layout.LIST_LAYOUT.CYCLIC_VOLTAMMETRY === layoutSt;
|
|
361
|
+
};
|
|
362
|
+
var isEmWaveLayout = function isEmWaveLayout(layoutSt) {
|
|
363
|
+
return [_list_layout.LIST_LAYOUT.IR, _list_layout.LIST_LAYOUT.RAMAN, _list_layout.LIST_LAYOUT.UVVIS, _list_layout.LIST_LAYOUT.HPLC_UVVIS].indexOf(layoutSt) >= 0;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
var getNmrTyp = function getNmrTyp(layout) {
|
|
367
|
+
switch (layout) {
|
|
368
|
+
case _list_layout.LIST_LAYOUT.H1:
|
|
369
|
+
return 'H';
|
|
370
|
+
case _list_layout.LIST_LAYOUT.C13:
|
|
371
|
+
return 'C';
|
|
372
|
+
case _list_layout.LIST_LAYOUT.F19:
|
|
373
|
+
return 'F';
|
|
374
|
+
case _list_layout.LIST_LAYOUT.P31:
|
|
375
|
+
return 'P';
|
|
376
|
+
case _list_layout.LIST_LAYOUT.N15:
|
|
377
|
+
return 'N';
|
|
378
|
+
case _list_layout.LIST_LAYOUT.Si29:
|
|
379
|
+
return 'Si';
|
|
380
|
+
default:
|
|
381
|
+
return '';
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
var formatPeaksByPrediction = function formatPeaksByPrediction(peaks, layout, isAscend, decimal) {
|
|
386
|
+
var predictions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
387
|
+
|
|
388
|
+
var pDict = {};
|
|
389
|
+
peaks.forEach(function (p) {
|
|
390
|
+
pDict[p.x.toFixed(decimal)] = 0;
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
predictions.forEach(function (p) {
|
|
394
|
+
var key = p.real.toFixed(decimal);
|
|
395
|
+
if (typeof pDict[key] === 'number') {
|
|
396
|
+
pDict[key] += 1;
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
var typ = getNmrTyp(layout);
|
|
401
|
+
|
|
402
|
+
var ascendFunc = function ascendFunc(a, b) {
|
|
403
|
+
return parseFloat(a.k) - parseFloat(b.k);
|
|
404
|
+
};
|
|
405
|
+
var descendFunc = function descendFunc(a, b) {
|
|
406
|
+
return parseFloat(b.k) - parseFloat(a.k);
|
|
407
|
+
};
|
|
408
|
+
var sortFunc = isAscend ? ascendFunc : descendFunc;
|
|
409
|
+
var pArr = Object.keys(pDict).map(function (k) {
|
|
410
|
+
if (pDict[k] === 1) return { k: k, v: k };
|
|
411
|
+
return { k: k, v: k + ' (' + pDict[k] + typ + ')' };
|
|
412
|
+
}).sort(sortFunc);
|
|
413
|
+
|
|
414
|
+
var body = pArr.map(function (p) {
|
|
415
|
+
return p.v;
|
|
416
|
+
}).join(', ');
|
|
417
|
+
return body;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
var compareColors = function compareColors(idx) {
|
|
421
|
+
return ['#ABB2B9', '#EDBB99', '#ABEBC6', '#D2B4DE', '#F9E79F'][idx % 5];
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
var mutiEntitiesColors = function mutiEntitiesColors(idx) {
|
|
425
|
+
return ['#fa8231', '#f7b731', '#0fb9b1', '#2d98da', '#3867d6', '#8854d0', '#4b6584'][idx % 7];
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
var Format = {
|
|
429
|
+
toPeakStr: toPeakStr,
|
|
430
|
+
buildData: buildData,
|
|
431
|
+
spectraDigit: spectraDigit,
|
|
432
|
+
spectraOps: spectraOps,
|
|
433
|
+
peaksBody: peaksBody,
|
|
434
|
+
peaksWrapper: peaksWrapper,
|
|
435
|
+
rmRef: rmRef,
|
|
436
|
+
rmShiftFromPeaks: rmShiftFromPeaks,
|
|
437
|
+
isNmrLayout: isNmrLayout,
|
|
438
|
+
is13CLayout: is13CLayout,
|
|
439
|
+
is1HLayout: is1HLayout,
|
|
440
|
+
is19FLayout: is19FLayout,
|
|
441
|
+
is31PLayout: is31PLayout,
|
|
442
|
+
is15NLayout: is15NLayout,
|
|
443
|
+
is29SiLayout: is29SiLayout,
|
|
444
|
+
isMsLayout: isMsLayout,
|
|
445
|
+
isIrLayout: isIrLayout,
|
|
446
|
+
isRamanLayout: isRamanLayout,
|
|
447
|
+
isUvVisLayout: isUvVisLayout,
|
|
448
|
+
isHplcUvVisLayout: isHplcUvVisLayout,
|
|
449
|
+
isTGALayout: isTGALayout,
|
|
450
|
+
isXRDLayout: isXRDLayout,
|
|
451
|
+
isCyclicVoltaLayout: isCyclicVoltaLayout,
|
|
452
|
+
isEmWaveLayout: isEmWaveLayout,
|
|
453
|
+
fixDigit: fixDigit,
|
|
454
|
+
formatPeaksByPrediction: formatPeaksByPrediction,
|
|
455
|
+
formatedMS: formatedMS,
|
|
456
|
+
formatedEm: formatedEm,
|
|
457
|
+
calcMpyCenter: _multiplicity_calc.calcMpyCenter,
|
|
458
|
+
compareColors: compareColors,
|
|
459
|
+
mutiEntitiesColors: mutiEntitiesColors
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
exports.default = Format;
|