@complat/react-spectra-editor 1.5.4 → 1.7.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/__tests__/units/components/cmd_bar/r05_submit_btn.test.js +217 -0
- package/dist/actions/cyclic_voltammetry.js +21 -2
- package/dist/components/cmd_bar/index.js +35 -26
- package/dist/components/cmd_bar/r01_layout.js +31 -2
- package/dist/components/cmd_bar/r05_submit_btn.js +188 -21
- package/dist/components/cmd_bar/r08_change_axes.js +28 -9
- package/dist/components/cmd_bar/r10_cv_density.js +180 -0
- package/dist/components/d3_multi/index.js +160 -1
- package/dist/components/d3_multi/multi_focus.js +51 -9
- package/dist/components/multi_jcamps_viewer.js +52 -10
- package/dist/components/panel/cyclic_voltamery_data.js +271 -180
- package/dist/components/panel/index.js +5 -3
- package/dist/components/panel/info.js +42 -13
- package/dist/constants/action_type.js +4 -1
- package/dist/constants/list_shift.js +62 -62
- package/dist/helpers/chem.js +5 -2
- package/dist/helpers/format.js +6 -0
- package/dist/helpers/init.js +5 -4
- package/dist/index.js +72 -42
- package/dist/reducers/reducer_voltammetry.js +34 -1
- package/dist/sagas/saga_multi_entities.js +60 -0
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _reactRedux = require("react-redux");
|
|
11
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -17,6 +17,7 @@ var _list_layout = require("../../constants/list_layout");
|
|
|
17
17
|
var _list_axes = require("../../constants/list_axes");
|
|
18
18
|
var _axes = require("../../actions/axes");
|
|
19
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
20
21
|
/* eslint-disable prefer-object-spread, react/jsx-one-expression-per-line,
|
|
21
22
|
react/function-component-definition,
|
|
22
23
|
max-len, no-unused-vars, no-multiple-empty-lines */
|
|
@@ -99,18 +100,18 @@ const axisY = (classes, layoutSt, axesUnitsSt, updateYAxisAct, curveSt) => {
|
|
|
99
100
|
yUnit: ''
|
|
100
101
|
};
|
|
101
102
|
}
|
|
102
|
-
const
|
|
103
|
-
yUnit
|
|
104
|
-
} = selectedAxes;
|
|
103
|
+
const yUnit = '';
|
|
105
104
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
106
105
|
className: (0, _classnames.default)(classes.fieldLayout),
|
|
107
106
|
variant: "outlined",
|
|
107
|
+
disabled: true,
|
|
108
108
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Select, {
|
|
109
109
|
labelId: "select-y-axis-label",
|
|
110
110
|
label: "y-Axis",
|
|
111
111
|
value: yUnit,
|
|
112
112
|
onChange: onChange,
|
|
113
113
|
className: (0, _classnames.default)(classes.selectInput, 'input-sv-bar-layout'),
|
|
114
|
+
disabled: true,
|
|
114
115
|
children: options.map(item => {
|
|
115
116
|
// eslint-disable-line
|
|
116
117
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
@@ -143,11 +144,29 @@ const ChangeAxes = ({
|
|
|
143
144
|
axesUnitsSt,
|
|
144
145
|
updateXAxisAct,
|
|
145
146
|
updateYAxisAct
|
|
146
|
-
}) =>
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
}) => {
|
|
148
|
+
const {
|
|
149
|
+
curveIdx
|
|
150
|
+
} = curveSt;
|
|
151
|
+
const axes = axesUnitsSt?.axes || [];
|
|
152
|
+
(0, _react.useEffect)(() => {
|
|
153
|
+
if (layoutSt !== _list_layout.LIST_LAYOUT.CYCLIC_VOLTAMMETRY) return;
|
|
154
|
+
const selectedAxes = axes[curveIdx] || {
|
|
155
|
+
yUnit: ''
|
|
156
|
+
};
|
|
157
|
+
if (selectedAxes.yUnit !== '') {
|
|
158
|
+
updateYAxisAct({
|
|
159
|
+
value: '',
|
|
160
|
+
curveIndex: curveIdx
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}, [layoutSt, axes, curveIdx, updateYAxisAct]);
|
|
164
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
165
|
+
className: classes.groupRight,
|
|
166
|
+
"data-testid": "ChangeAxes",
|
|
167
|
+
children: showSelect(classes, layoutSt, curveSt, axesUnitsSt, updateXAxisAct, updateYAxisAct)
|
|
168
|
+
});
|
|
169
|
+
};
|
|
151
170
|
const mapStateToProps = (state, props) => (
|
|
152
171
|
// eslint-disable-line
|
|
153
172
|
{
|
|
@@ -0,0 +1,180 @@
|
|
|
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 _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _reactRedux = require("react-redux");
|
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
+
var _redux = require("redux");
|
|
13
|
+
var _material = require("@mui/material");
|
|
14
|
+
var _withStyles = _interopRequireDefault(require("@mui/styles/withStyles"));
|
|
15
|
+
var _list_layout = require("../../constants/list_layout");
|
|
16
|
+
var _common = require("./common");
|
|
17
|
+
var _cyclic_voltammetry = require("../../actions/cyclic_voltammetry");
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
/* eslint-disable react/function-component-definition, react/jsx-one-expression-per-line,
|
|
20
|
+
react/jsx-boolean-value */
|
|
21
|
+
|
|
22
|
+
const styles = () => ({
|
|
23
|
+
..._common.commonStyle,
|
|
24
|
+
fieldArea: {
|
|
25
|
+
width: 100
|
|
26
|
+
},
|
|
27
|
+
fieldUnit: {
|
|
28
|
+
width: 75
|
|
29
|
+
},
|
|
30
|
+
toggleGroup: {
|
|
31
|
+
height: 30,
|
|
32
|
+
marginLeft: 8
|
|
33
|
+
},
|
|
34
|
+
toggleBtn: {
|
|
35
|
+
fontSize: 10,
|
|
36
|
+
padding: '0 6px',
|
|
37
|
+
height: 30,
|
|
38
|
+
minHeight: 30,
|
|
39
|
+
lineHeight: '30px',
|
|
40
|
+
textTransform: 'none'
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const units = ['cm²', 'mm²'];
|
|
44
|
+
const CvDensityControls = ({
|
|
45
|
+
classes,
|
|
46
|
+
layoutSt,
|
|
47
|
+
areaValue,
|
|
48
|
+
areaUnit,
|
|
49
|
+
useCurrentDensity,
|
|
50
|
+
setAreaValueAct,
|
|
51
|
+
setAreaUnitAct,
|
|
52
|
+
toggleDensityAct
|
|
53
|
+
}) => {
|
|
54
|
+
if (layoutSt !== _list_layout.LIST_LAYOUT.CYCLIC_VOLTAMMETRY) return /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {});
|
|
55
|
+
const handleAreaChange = e => {
|
|
56
|
+
const raw = e.target.value;
|
|
57
|
+
if (raw === '') {
|
|
58
|
+
setAreaValueAct('');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const val = parseFloat(raw);
|
|
62
|
+
if (Number.isNaN(val)) return;
|
|
63
|
+
if (val < 0) return;
|
|
64
|
+
setAreaValueAct(val);
|
|
65
|
+
};
|
|
66
|
+
const handleAreaBlur = e => {
|
|
67
|
+
const raw = e.target.value;
|
|
68
|
+
const val = parseFloat(raw);
|
|
69
|
+
if (raw === '' || Number.isNaN(val) || val <= 0) {
|
|
70
|
+
setAreaValueAct(1.0);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const handleUnitChange = e => {
|
|
74
|
+
const newUnit = e.target.value;
|
|
75
|
+
const currVal = areaValue;
|
|
76
|
+
if (currVal !== '' && Number.isFinite(Number(currVal))) {
|
|
77
|
+
const num = Number(currVal);
|
|
78
|
+
const from = areaUnit;
|
|
79
|
+
const to = newUnit;
|
|
80
|
+
let converted = num;
|
|
81
|
+
if (from === 'cm²' && to === 'mm²') converted = num * 100.0;
|
|
82
|
+
if (from === 'mm²' && to === 'cm²') converted = num / 100.0;
|
|
83
|
+
setAreaValueAct(converted);
|
|
84
|
+
}
|
|
85
|
+
setAreaUnitAct(newUnit);
|
|
86
|
+
};
|
|
87
|
+
const handleToggle = (_, val) => {
|
|
88
|
+
if (val === null) return;
|
|
89
|
+
const shouldBeDensity = val === 'density';
|
|
90
|
+
if (shouldBeDensity !== useCurrentDensity) {
|
|
91
|
+
toggleDensityAct();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
95
|
+
className: classes.group,
|
|
96
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
97
|
+
className: (0, _classnames.default)(classes.fieldArea),
|
|
98
|
+
variant: "outlined",
|
|
99
|
+
disabled: !useCurrentDensity,
|
|
100
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
101
|
+
htmlFor: "cv-area",
|
|
102
|
+
className: (0, _classnames.default)(classes.selectLabel, 'select-sv-bar-label'),
|
|
103
|
+
children: "WE-ECSA"
|
|
104
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.OutlinedInput, {
|
|
105
|
+
id: "cv-area",
|
|
106
|
+
label: "WE-ECSA",
|
|
107
|
+
type: "number",
|
|
108
|
+
inputProps: {
|
|
109
|
+
step: '0.0001',
|
|
110
|
+
min: '0'
|
|
111
|
+
},
|
|
112
|
+
value: areaValue,
|
|
113
|
+
onChange: handleAreaChange,
|
|
114
|
+
onBlur: handleAreaBlur,
|
|
115
|
+
className: (0, _classnames.default)(classes.txtInput, 'input-sv-bar-layout'),
|
|
116
|
+
disabled: !useCurrentDensity
|
|
117
|
+
})]
|
|
118
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
119
|
+
className: (0, _classnames.default)(classes.fieldUnit),
|
|
120
|
+
variant: "outlined",
|
|
121
|
+
disabled: !useCurrentDensity,
|
|
122
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
123
|
+
id: "cv-area-unit",
|
|
124
|
+
className: (0, _classnames.default)(classes.selectLabel, 'select-sv-bar-label'),
|
|
125
|
+
children: "Unit"
|
|
126
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Select, {
|
|
127
|
+
value: areaUnit,
|
|
128
|
+
onChange: handleUnitChange,
|
|
129
|
+
labelId: "cv-area-unit",
|
|
130
|
+
label: "Unit",
|
|
131
|
+
className: (0, _classnames.default)(classes.selectInput, 'input-sv-bar-layout'),
|
|
132
|
+
disabled: !useCurrentDensity,
|
|
133
|
+
children: units.map(u => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
134
|
+
value: u,
|
|
135
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
136
|
+
className: (0, _classnames.default)(classes.txtOpt, 'option-sv-bar-layout'),
|
|
137
|
+
children: u
|
|
138
|
+
})
|
|
139
|
+
}, u))
|
|
140
|
+
})]
|
|
141
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.ToggleButtonGroup, {
|
|
142
|
+
exclusive: true,
|
|
143
|
+
size: "small",
|
|
144
|
+
value: useCurrentDensity ? 'density' : 'current',
|
|
145
|
+
onChange: handleToggle,
|
|
146
|
+
className: (0, _classnames.default)(classes.selectInput, classes.toggleGroup, 'input-sv-bar-layout'),
|
|
147
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ToggleButton, {
|
|
148
|
+
value: "current",
|
|
149
|
+
className: (0, _classnames.default)(classes.txtOpt, classes.toggleBtn),
|
|
150
|
+
children: "Current"
|
|
151
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ToggleButton, {
|
|
152
|
+
value: "density",
|
|
153
|
+
className: (0, _classnames.default)(classes.txtOpt, classes.toggleBtn),
|
|
154
|
+
children: "Current / Area"
|
|
155
|
+
})]
|
|
156
|
+
})]
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
CvDensityControls.propTypes = {
|
|
160
|
+
classes: _propTypes.default.object.isRequired,
|
|
161
|
+
layoutSt: _propTypes.default.string.isRequired,
|
|
162
|
+
areaValue: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
163
|
+
areaUnit: _propTypes.default.string.isRequired,
|
|
164
|
+
useCurrentDensity: _propTypes.default.bool.isRequired,
|
|
165
|
+
setAreaValueAct: _propTypes.default.func.isRequired,
|
|
166
|
+
setAreaUnitAct: _propTypes.default.func.isRequired,
|
|
167
|
+
toggleDensityAct: _propTypes.default.func.isRequired
|
|
168
|
+
};
|
|
169
|
+
const mapStateToProps = state => ({
|
|
170
|
+
layoutSt: state.layout,
|
|
171
|
+
areaValue: state.cyclicvolta.areaValue,
|
|
172
|
+
areaUnit: state.cyclicvolta.areaUnit,
|
|
173
|
+
useCurrentDensity: state.cyclicvolta.useCurrentDensity
|
|
174
|
+
});
|
|
175
|
+
const mapDispatchToProps = dispatch => (0, _redux.bindActionCreators)({
|
|
176
|
+
setAreaValueAct: _cyclic_voltammetry.setCyclicVoltaAreaValue,
|
|
177
|
+
setAreaUnitAct: _cyclic_voltammetry.setCyclicVoltaAreaUnit,
|
|
178
|
+
toggleDensityAct: _cyclic_voltammetry.toggleCyclicVoltaDensity
|
|
179
|
+
}, dispatch);
|
|
180
|
+
var _default = exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)((0, _withStyles.default)(styles)(CvDensityControls));
|
|
@@ -10,6 +10,7 @@ var _reactRedux = require("react-redux");
|
|
|
10
10
|
var _redux = require("redux");
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
12
|
var _chem = require("../../helpers/chem");
|
|
13
|
+
var _format = _interopRequireDefault(require("../../helpers/format"));
|
|
13
14
|
var _manager = require("../../actions/manager");
|
|
14
15
|
var _ui = require("../../actions/ui");
|
|
15
16
|
var _list_ui = require("../../constants/list_ui");
|
|
@@ -33,6 +34,9 @@ class ViewerMulti extends _react.default.Component {
|
|
|
33
34
|
scrollUiWheelAct
|
|
34
35
|
} = this.props;
|
|
35
36
|
this.rootKlass = '.d3Line';
|
|
37
|
+
this.containerRef = /*#__PURE__*/_react.default.createRef();
|
|
38
|
+
this.currentSize = null;
|
|
39
|
+
this.resizeObserver = null;
|
|
36
40
|
this.focus = new _multi_focus.default({
|
|
37
41
|
W,
|
|
38
42
|
H,
|
|
@@ -42,8 +46,11 @@ class ViewerMulti extends _react.default.Component {
|
|
|
42
46
|
scrollUiWheelAct
|
|
43
47
|
});
|
|
44
48
|
this.normChange = this.normChange.bind(this);
|
|
49
|
+
this.handleResize = this.handleResize.bind(this);
|
|
45
50
|
}
|
|
46
51
|
componentDidMount() {
|
|
52
|
+
this.renderChart(this.props, true);
|
|
53
|
+
this.setupResizeObserver();
|
|
47
54
|
const {
|
|
48
55
|
curveSt,
|
|
49
56
|
seed,
|
|
@@ -90,6 +97,11 @@ class ViewerMulti extends _react.default.Component {
|
|
|
90
97
|
xxLabel = xUnit === '' ? xLabel : xUnit;
|
|
91
98
|
yyLabel = yUnit === '' ? yLabel : yUnit;
|
|
92
99
|
}
|
|
100
|
+
if (cyclicvoltaSt && cyclicvoltaSt.useCurrentDensity) {
|
|
101
|
+
const areaUnit = cyclicvoltaSt.areaUnit || 'cm²';
|
|
102
|
+
const baseUnit = /mA/i.test(String(yyLabel)) ? 'mA' : 'A';
|
|
103
|
+
yyLabel = `Current density in ${baseUnit}/${areaUnit}`;
|
|
104
|
+
}
|
|
93
105
|
const filterSeed = seed;
|
|
94
106
|
const filterPeak = peak;
|
|
95
107
|
(0, _draw.drawMain)(this.rootKlass, W, H);
|
|
@@ -156,8 +168,16 @@ class ViewerMulti extends _react.default.Component {
|
|
|
156
168
|
xxLabel = xUnit === '' ? xLabel : xUnit;
|
|
157
169
|
yyLabel = yUnit === '' ? yLabel : yUnit;
|
|
158
170
|
}
|
|
171
|
+
if (cyclicvoltaSt && cyclicvoltaSt.useCurrentDensity) {
|
|
172
|
+
const areaUnit = cyclicvoltaSt.areaUnit || 'cm²';
|
|
173
|
+
const baseUnit = /mA/i.test(String(yyLabel)) ? 'mA' : 'A';
|
|
174
|
+
yyLabel = `Current density in ${baseUnit}/${areaUnit}`;
|
|
175
|
+
}
|
|
159
176
|
const filterSeed = seed;
|
|
160
177
|
const filterPeak = peak;
|
|
178
|
+
if (_format.default.isCyclicVoltaLayout(layoutSt)) {
|
|
179
|
+
this.handleResize();
|
|
180
|
+
}
|
|
161
181
|
this.focus.update({
|
|
162
182
|
entities,
|
|
163
183
|
curveSt,
|
|
@@ -179,6 +199,53 @@ class ViewerMulti extends _react.default.Component {
|
|
|
179
199
|
}
|
|
180
200
|
componentWillUnmount() {
|
|
181
201
|
(0, _draw.drawDestroy)(this.rootKlass);
|
|
202
|
+
this.teardownResizeObserver();
|
|
203
|
+
}
|
|
204
|
+
handleResize() {
|
|
205
|
+
const {
|
|
206
|
+
layoutSt
|
|
207
|
+
} = this.props;
|
|
208
|
+
if (!_format.default.isCyclicVoltaLayout(layoutSt)) return;
|
|
209
|
+
const size = this.getContainerSize();
|
|
210
|
+
if (!size) return;
|
|
211
|
+
if (!this.currentSize || size.width !== this.currentSize.width || size.height !== this.currentSize.height) {
|
|
212
|
+
this.renderChart(this.props, false);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
getContainerSize() {
|
|
216
|
+
const node = this.containerRef.current;
|
|
217
|
+
if (!node) return null;
|
|
218
|
+
const {
|
|
219
|
+
clientWidth,
|
|
220
|
+
clientHeight
|
|
221
|
+
} = node;
|
|
222
|
+
if (!clientWidth || !clientHeight) return null;
|
|
223
|
+
return {
|
|
224
|
+
width: clientWidth,
|
|
225
|
+
height: clientHeight
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
getTargetSize(layoutSt) {
|
|
229
|
+
if (_format.default.isCyclicVoltaLayout(layoutSt)) {
|
|
230
|
+
const size = this.getContainerSize();
|
|
231
|
+
if (size) return size;
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
width: W,
|
|
235
|
+
height: H
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
setupResizeObserver() {
|
|
239
|
+
if (typeof ResizeObserver === 'undefined') return;
|
|
240
|
+
if (!this.containerRef.current || this.resizeObserver) return;
|
|
241
|
+
this.resizeObserver = new ResizeObserver(this.handleResize);
|
|
242
|
+
this.resizeObserver.observe(this.containerRef.current);
|
|
243
|
+
}
|
|
244
|
+
teardownResizeObserver() {
|
|
245
|
+
if (this.resizeObserver) {
|
|
246
|
+
this.resizeObserver.disconnect();
|
|
247
|
+
this.resizeObserver = null;
|
|
248
|
+
}
|
|
182
249
|
}
|
|
183
250
|
normChange(prevProps) {
|
|
184
251
|
const {
|
|
@@ -191,9 +258,101 @@ class ViewerMulti extends _react.default.Component {
|
|
|
191
258
|
resetAllAct(feature);
|
|
192
259
|
}
|
|
193
260
|
}
|
|
261
|
+
renderChart(props, shouldReset) {
|
|
262
|
+
const {
|
|
263
|
+
curveSt,
|
|
264
|
+
seed,
|
|
265
|
+
peak,
|
|
266
|
+
cLabel,
|
|
267
|
+
xLabel,
|
|
268
|
+
yLabel,
|
|
269
|
+
feature,
|
|
270
|
+
tTrEndPts,
|
|
271
|
+
tSfPeaks,
|
|
272
|
+
editPeakSt,
|
|
273
|
+
layoutSt,
|
|
274
|
+
sweepExtentSt,
|
|
275
|
+
isUiNoBrushSt,
|
|
276
|
+
isHidden,
|
|
277
|
+
resetAllAct,
|
|
278
|
+
cyclicvoltaSt,
|
|
279
|
+
integationSt,
|
|
280
|
+
mtplySt,
|
|
281
|
+
axesUnitsSt,
|
|
282
|
+
entities,
|
|
283
|
+
clickUiTargetAct,
|
|
284
|
+
selectUiSweepAct,
|
|
285
|
+
scrollUiWheelAct
|
|
286
|
+
} = props;
|
|
287
|
+
const size = this.getTargetSize(layoutSt);
|
|
288
|
+
this.currentSize = size;
|
|
289
|
+
(0, _draw.drawDestroy)(this.rootKlass);
|
|
290
|
+
if (shouldReset) {
|
|
291
|
+
resetAllAct(feature);
|
|
292
|
+
}
|
|
293
|
+
let xxLabel = xLabel;
|
|
294
|
+
let yyLabel = yLabel;
|
|
295
|
+
if (axesUnitsSt) {
|
|
296
|
+
const {
|
|
297
|
+
curveIdx
|
|
298
|
+
} = curveSt;
|
|
299
|
+
const {
|
|
300
|
+
axes
|
|
301
|
+
} = axesUnitsSt;
|
|
302
|
+
let selectedAxes = axes[curveIdx];
|
|
303
|
+
if (!selectedAxes) {
|
|
304
|
+
selectedAxes = {
|
|
305
|
+
xUnit: '',
|
|
306
|
+
yUnit: ''
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
const {
|
|
310
|
+
xUnit,
|
|
311
|
+
yUnit
|
|
312
|
+
} = selectedAxes;
|
|
313
|
+
xxLabel = xUnit === '' ? xLabel : xUnit;
|
|
314
|
+
yyLabel = yUnit === '' ? yLabel : yUnit;
|
|
315
|
+
}
|
|
316
|
+
const filterSeed = seed;
|
|
317
|
+
const filterPeak = peak;
|
|
318
|
+
this.focus = new _multi_focus.default({
|
|
319
|
+
W: size.width,
|
|
320
|
+
H: size.height,
|
|
321
|
+
entities,
|
|
322
|
+
clickUiTargetAct,
|
|
323
|
+
selectUiSweepAct,
|
|
324
|
+
scrollUiWheelAct
|
|
325
|
+
});
|
|
326
|
+
(0, _draw.drawMain)(this.rootKlass, size.width, size.height);
|
|
327
|
+
this.focus.create({
|
|
328
|
+
curveSt,
|
|
329
|
+
filterSeed,
|
|
330
|
+
filterPeak,
|
|
331
|
+
tTrEndPts,
|
|
332
|
+
tSfPeaks,
|
|
333
|
+
editPeakSt,
|
|
334
|
+
layoutSt,
|
|
335
|
+
sweepExtentSt,
|
|
336
|
+
isUiNoBrushSt,
|
|
337
|
+
cyclicvoltaSt,
|
|
338
|
+
integationSt,
|
|
339
|
+
mtplySt
|
|
340
|
+
});
|
|
341
|
+
(0, _draw.drawLabel)(this.rootKlass, cLabel, xxLabel, yyLabel);
|
|
342
|
+
(0, _draw.drawDisplay)(this.rootKlass, isHidden);
|
|
343
|
+
(0, _draw.drawArrowOnCurve)(this.rootKlass, isHidden);
|
|
344
|
+
}
|
|
194
345
|
render() {
|
|
346
|
+
const {
|
|
347
|
+
layoutSt
|
|
348
|
+
} = this.props;
|
|
349
|
+
const isCyclicVolta = _format.default.isCyclicVoltaLayout(layoutSt);
|
|
195
350
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
196
|
-
className: "d3Line"
|
|
351
|
+
className: "d3Line",
|
|
352
|
+
ref: this.containerRef,
|
|
353
|
+
style: isCyclicVolta ? {
|
|
354
|
+
height: '100%'
|
|
355
|
+
} : undefined
|
|
197
356
|
});
|
|
198
357
|
}
|
|
199
358
|
}
|
|
@@ -96,6 +96,7 @@ class MultiFocus {
|
|
|
96
96
|
this.onClickPecker = this.onClickPecker.bind(this);
|
|
97
97
|
this.isFirefox = typeof InstallTrigger !== 'undefined';
|
|
98
98
|
this.cyclicvoltaSt = null;
|
|
99
|
+
this.yTransformFactor = 1.0;
|
|
99
100
|
}
|
|
100
101
|
getShouldUpdate(nextEpSt) {
|
|
101
102
|
const {
|
|
@@ -106,7 +107,8 @@ class MultiFocus {
|
|
|
106
107
|
prevTePt,
|
|
107
108
|
prevDtPk,
|
|
108
109
|
prevSfPk,
|
|
109
|
-
prevData
|
|
110
|
+
prevData,
|
|
111
|
+
prevYFactor
|
|
110
112
|
} = this.shouldUpdate;
|
|
111
113
|
const {
|
|
112
114
|
xt,
|
|
@@ -119,6 +121,7 @@ class MultiFocus {
|
|
|
119
121
|
const sameDtPk = prevDtPk === this.dataPks.length;
|
|
120
122
|
const sameSfPk = JSON.stringify(prevSfPk) === JSON.stringify(this.tSfPeaks);
|
|
121
123
|
const sameData = prevData === this.data.length;
|
|
124
|
+
const sameYFactor = prevYFactor === this.yTransformFactor;
|
|
122
125
|
this.shouldUpdate = Object.assign({}, this.shouldUpdate, {
|
|
123
126
|
sameXY,
|
|
124
127
|
sameEpSt,
|
|
@@ -127,7 +130,8 @@ class MultiFocus {
|
|
|
127
130
|
sameTePt,
|
|
128
131
|
sameDtPk,
|
|
129
132
|
sameSfPk,
|
|
130
|
-
sameData
|
|
133
|
+
sameData,
|
|
134
|
+
sameYFactor // eslint-disable-line
|
|
131
135
|
});
|
|
132
136
|
}
|
|
133
137
|
resetShouldUpdate(prevEpSt) {
|
|
@@ -142,6 +146,7 @@ class MultiFocus {
|
|
|
142
146
|
const prevSfPk = this.tSfPeaks;
|
|
143
147
|
const prevData = this.data.length;
|
|
144
148
|
const prevLySt = this.layout;
|
|
149
|
+
const prevYFactor = this.yTransformFactor;
|
|
145
150
|
this.shouldUpdate = Object.assign({}, this.shouldUpdate, {
|
|
146
151
|
prevXt,
|
|
147
152
|
prevYt,
|
|
@@ -151,17 +156,41 @@ class MultiFocus {
|
|
|
151
156
|
prevTePt,
|
|
152
157
|
prevDtPk,
|
|
153
158
|
prevSfPk,
|
|
154
|
-
prevData
|
|
159
|
+
prevData,
|
|
160
|
+
prevYFactor // eslint-disable-line
|
|
155
161
|
});
|
|
156
162
|
}
|
|
157
163
|
setTip() {
|
|
158
164
|
this.tip = (0, _init.InitTip)();
|
|
159
165
|
this.root.call(this.tip);
|
|
160
166
|
}
|
|
167
|
+
computeYTransformFactor(layout, cyclicvoltaSt, feature) {
|
|
168
|
+
let factor = 1.0;
|
|
169
|
+
if (layout === _list_layout.LIST_LAYOUT.CYCLIC_VOLTAMMETRY && cyclicvoltaSt && cyclicvoltaSt.useCurrentDensity) {
|
|
170
|
+
const rawArea = (cyclicvoltaSt.areaValue === '' ? 1.0 : cyclicvoltaSt.areaValue) || 1.0;
|
|
171
|
+
const areaUnit = cyclicvoltaSt.areaUnit || 'cm²';
|
|
172
|
+
const safeArea = rawArea > 0 ? rawArea : 1.0;
|
|
173
|
+
const areaInCm2 = areaUnit === 'mm²' ? safeArea / 100.0 : safeArea;
|
|
174
|
+
factor = 1.0 / areaInCm2;
|
|
175
|
+
const baseY = feature && feature.yUnit ? String(feature.yUnit) : 'A';
|
|
176
|
+
if (/mA/i.test(baseY)) {
|
|
177
|
+
factor *= 1000.0;
|
|
178
|
+
}
|
|
179
|
+
if (areaUnit === 'mm²') {
|
|
180
|
+
factor /= 100.0;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return factor;
|
|
184
|
+
}
|
|
185
|
+
transformYValue(y) {
|
|
186
|
+
return y * this.yTransformFactor;
|
|
187
|
+
}
|
|
161
188
|
setDataParams(filterSeed, peaks, tTrEndPts, tSfPeaks, layout, cyclicvoltaSt, jcampIdx = 0) {
|
|
162
189
|
this.data = [];
|
|
163
190
|
this.otherLineData = [];
|
|
164
191
|
let filterSubLayoutValue = null;
|
|
192
|
+
const currFeature = this.entities && this.entities[0] ? this.entities[0].feature : null;
|
|
193
|
+
this.yTransformFactor = this.computeYTransformFactor(layout, cyclicvoltaSt, currFeature);
|
|
165
194
|
this.entities.forEach((entry, idx) => {
|
|
166
195
|
const {
|
|
167
196
|
topic,
|
|
@@ -205,6 +234,11 @@ class MultiFocus {
|
|
|
205
234
|
updatePathCall(xt, yt) {
|
|
206
235
|
this.pathCall = d3.line().x(d => xt(d.x)).y(d => yt(d.y));
|
|
207
236
|
}
|
|
237
|
+
setYAxisTickFormat() {
|
|
238
|
+
const f = this.yTransformFactor || 1;
|
|
239
|
+
const format = d3.format('.2n');
|
|
240
|
+
this.axisCall.y.tickFormat(v => format(v * f));
|
|
241
|
+
}
|
|
208
242
|
setConfig(sweepExtentSt) {
|
|
209
243
|
// Domain Calculate
|
|
210
244
|
let {
|
|
@@ -246,6 +280,9 @@ class MultiFocus {
|
|
|
246
280
|
// Axis Call
|
|
247
281
|
this.axisCall.x.scale(xt);
|
|
248
282
|
this.axisCall.y.scale(yt);
|
|
283
|
+
if (this.layout === _list_layout.LIST_LAYOUT.CYCLIC_VOLTAMMETRY) {
|
|
284
|
+
this.setYAxisTickFormat();
|
|
285
|
+
}
|
|
249
286
|
this.currentExtent = {
|
|
250
287
|
xExtent,
|
|
251
288
|
yExtent
|
|
@@ -299,9 +336,10 @@ class MultiFocus {
|
|
|
299
336
|
}
|
|
300
337
|
drawGrid() {
|
|
301
338
|
const {
|
|
302
|
-
sameXY
|
|
339
|
+
sameXY,
|
|
340
|
+
sameYFactor
|
|
303
341
|
} = this.shouldUpdate;
|
|
304
|
-
if (sameXY) return;
|
|
342
|
+
if (sameXY && sameYFactor) return;
|
|
305
343
|
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');
|
|
306
344
|
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');
|
|
307
345
|
}
|
|
@@ -473,7 +511,8 @@ class MultiFocus {
|
|
|
473
511
|
d3.select(`#bpt${Math.round(1000 * d.x)}`).style('fill', 'blue');
|
|
474
512
|
const tipParams = {
|
|
475
513
|
d,
|
|
476
|
-
layout: this.layout
|
|
514
|
+
layout: this.layout,
|
|
515
|
+
yFactor: this.yTransformFactor
|
|
477
516
|
};
|
|
478
517
|
this.tip.show(tipParams, event.target);
|
|
479
518
|
}).on('mouseout', (event, d) => {
|
|
@@ -481,7 +520,8 @@ class MultiFocus {
|
|
|
481
520
|
d3.select(`#bpt${Math.round(1000 * d.x)}`).style('fill', 'red');
|
|
482
521
|
const tipParams = {
|
|
483
522
|
d,
|
|
484
|
-
layout: this.layout
|
|
523
|
+
layout: this.layout,
|
|
524
|
+
yFactor: this.yTransformFactor
|
|
485
525
|
};
|
|
486
526
|
this.tip.hide(tipParams, event.target);
|
|
487
527
|
}).on('click', (event, d) => this.onClickTarget(event, d));
|
|
@@ -534,7 +574,8 @@ class MultiFocus {
|
|
|
534
574
|
d3.select(`#bpt${Math.round(1000 * d.x)}`).style('fill', 'blue');
|
|
535
575
|
const tipParams = {
|
|
536
576
|
d,
|
|
537
|
-
layout: this.layout
|
|
577
|
+
layout: this.layout,
|
|
578
|
+
yFactor: this.yTransformFactor
|
|
538
579
|
};
|
|
539
580
|
this.tip.show(tipParams, event.target);
|
|
540
581
|
}).on('mouseout', (event, d) => {
|
|
@@ -542,7 +583,8 @@ class MultiFocus {
|
|
|
542
583
|
d3.select(`#bpt${Math.round(1000 * d.x)}`).style('fill', '#228B22');
|
|
543
584
|
const tipParams = {
|
|
544
585
|
d,
|
|
545
|
-
layout: this.layout
|
|
586
|
+
layout: this.layout,
|
|
587
|
+
yFactor: this.yTransformFactor
|
|
546
588
|
};
|
|
547
589
|
this.tip.hide(tipParams, event.target);
|
|
548
590
|
}).on('click', (event, d) => this.onClickPecker(event, d));
|