nmrium 0.44.1-pre.1694759092 → 0.44.1-pre.1696502379
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/lib/component/2d/1d-tracer/HorizontalSliceChart.d.ts +9 -11
- package/lib/component/2d/1d-tracer/HorizontalSliceChart.js +22 -60
- package/lib/component/2d/1d-tracer/Left1DChart.d.ts +2 -2
- package/lib/component/2d/1d-tracer/Left1DChart.js +20 -36
- package/lib/component/2d/1d-tracer/Top1DChart.d.ts +2 -2
- package/lib/component/2d/1d-tracer/Top1DChart.js +19 -30
- package/lib/component/2d/1d-tracer/VerticalSliceChart.d.ts +9 -11
- package/lib/component/2d/1d-tracer/VerticalSliceChart.js +21 -61
- package/lib/component/2d/FooterBanner.js +17 -6
- package/lib/component/2d/SignalDeltaLine.d.ts +1 -1
- package/lib/component/2d/SignalDeltaLine.js +11 -8
- package/lib/component/2d/SlicingView.js +19 -29
- package/lib/component/2d/XAxis.js +3 -7
- package/lib/component/2d/YAxis.js +3 -3
- package/lib/component/2d/fid/FidCanvas.js +16 -9
- package/lib/component/2d/fid/FidContainer.js +3 -5
- package/lib/component/2d/ft/Contours.js +4 -5
- package/lib/component/2d/tools/XYLabelPointer.js +13 -25
- package/lib/component/2d/utilities/scale.d.ts +15 -13
- package/lib/component/2d/utilities/scale.js +30 -6
- package/lib/component/2d/zones/IndicationLines.d.ts +1 -1
- package/lib/component/2d/zones/IndicationLines.js +13 -12
- package/lib/component/2d/zones/Signal.js +3 -5
- package/lib/component/2d/zones/Zone.js +3 -5
- package/lib/component/EventsTrackers/BrushTracker.js +8 -7
- package/lib/component/elements/SVGGroup.js +7 -6
- package/lib/component/elements/draggable/SVGDraggable.js +2 -2
- package/lib/component/elements/draggable/useDraggable.d.ts +1 -1
- package/lib/component/elements/draggable/useDraggable.js +9 -9
- package/lib/component/elements/resizer/DivResizer.js +2 -2
- package/lib/component/elements/resizer/SVGResizer.js +2 -2
- package/lib/component/hooks/useActiveSpectrumRangesViewState.js +2 -2
- package/lib/component/main/NMRium.d.ts +2 -0
- package/lib/component/main/NMRium.js +2 -0
- package/lib/component/panels/MultipleSpectraAnalysisPanel/AnalysisChart.d.ts +6 -0
- package/lib/component/panels/MultipleSpectraAnalysisPanel/AnalysisChart.js +123 -0
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +5 -2
- package/lib/component/panels/RangesPanel/RangesHeader.js +4 -7
- package/lib/component/panels/RangesPanel/RangesPanel.d.ts +1 -1
- package/lib/component/panels/RangesPanel/RangesPanel.js +2 -2
- package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +1 -1
- package/lib/component/reducer/actions/DomainActions.js +19 -3
- package/lib/component/reducer/actions/ToolsActions.js +2 -3
- package/lib/component/utility/export.d.ts +3 -2
- package/lib/component/utility/export.js +9 -9
- package/lib/component/utility/getSpectraObjectPaths.d.ts +1 -1
- package/lib/component/utility/getSpectraObjectPaths.js +1 -2
- package/lib/data/data2d/Spectrum2D/getSlice.js +1 -2
- package/lib/versionInfo.js +1 -1
- package/package.json +31 -30
- package/lib/component/2d/utilities/SliceScale.d.ts +0 -16
- package/lib/component/2d/utilities/SliceScale.js +0 -32
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
interface
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
x: Float64Array;
|
|
6
|
-
re: Float64Array;
|
|
7
|
-
};
|
|
8
|
-
reverseScale?: boolean;
|
|
1
|
+
import { NmrData1D } from 'cheminfo-types';
|
|
2
|
+
interface BaseProps {
|
|
3
|
+
vericalMargin?: number;
|
|
4
|
+
reverse?: boolean;
|
|
9
5
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
interface HorizontalSliceChartProps extends BaseProps {
|
|
7
|
+
data: NmrData1D;
|
|
8
|
+
}
|
|
9
|
+
declare function HorizontalSliceChart(props: HorizontalSliceChartProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default HorizontalSliceChart;
|
|
@@ -1,68 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
-
const react_1 = require("react");
|
|
28
4
|
const ChartContext_1 = require("../../context/ChartContext");
|
|
29
|
-
const useXYReduce_1 = __importStar(require("../../hooks/useXYReduce"));
|
|
30
5
|
const PathBuilder_1 = require("../../utility/PathBuilder");
|
|
31
|
-
const SliceScale_1 = require("../utilities/SliceScale");
|
|
32
6
|
const scale_1 = require("../utilities/scale");
|
|
33
|
-
function
|
|
34
|
-
const {
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
for (let i = 1; i < pathPoints.x.length; i++) {
|
|
46
|
-
pathBuilder.lineTo(scaleX(pathPoints.x[i]), scaleY(pathPoints.y[i]));
|
|
47
|
-
}
|
|
48
|
-
return pathBuilder.toString();
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
}, [
|
|
54
|
-
data,
|
|
55
|
-
height,
|
|
56
|
-
marginProps,
|
|
57
|
-
originMargin,
|
|
58
|
-
reverseScale,
|
|
59
|
-
width,
|
|
60
|
-
xDomain,
|
|
61
|
-
xyReduce,
|
|
62
|
-
]);
|
|
63
|
-
if (!width || !height) {
|
|
64
|
-
return null;
|
|
7
|
+
function usePath(data, options) {
|
|
8
|
+
const { height = 100, vericalMargin = 10 } = options;
|
|
9
|
+
const { mode } = (0, ChartContext_1.useChartData)();
|
|
10
|
+
const scaleX = (0, scale_1.useScale2DX)();
|
|
11
|
+
if (!data)
|
|
12
|
+
return '';
|
|
13
|
+
const { x, re: y } = data;
|
|
14
|
+
const scaleY = (0, scale_1.getSliceYScale)(y, height, mode, vericalMargin);
|
|
15
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
16
|
+
pathBuilder.moveTo(scaleX(x[0]), scaleY(y[0]));
|
|
17
|
+
for (let i = 1; i < x.length; i++) {
|
|
18
|
+
pathBuilder.lineTo(scaleX(x[i]), scaleY(y[i]));
|
|
65
19
|
}
|
|
66
|
-
return
|
|
20
|
+
return pathBuilder.toString();
|
|
21
|
+
}
|
|
22
|
+
function HorizontalSliceChart(props) {
|
|
23
|
+
const { vericalMargin = 10, data, reverse = false } = props;
|
|
24
|
+
const { width, margin, displayerKey } = (0, ChartContext_1.useChartData)();
|
|
25
|
+
const height = margin.top;
|
|
26
|
+
const path = usePath(data, { height, reverse, vericalMargin });
|
|
27
|
+
const innerWidth = width - margin.left - margin.right;
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-top`, children: (0, jsx_runtime_1.jsx)("rect", { width: innerWidth, height: height, x: margin.left }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-top)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke: "red", fill: "none", d: path }) })] }));
|
|
67
29
|
}
|
|
68
|
-
exports.default =
|
|
30
|
+
exports.default = HorizontalSliceChart;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Spectrum1D } from 'nmr-load-save';
|
|
3
3
|
interface Left1DChartProps {
|
|
4
|
-
|
|
4
|
+
horizontalMargin?: number;
|
|
5
5
|
data: Spectrum1D;
|
|
6
6
|
}
|
|
7
|
-
declare function Left1DChart({
|
|
7
|
+
declare function Left1DChart({ horizontalMargin, data: spectrum, }: Left1DChartProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
8
|
declare const _default: import("react").MemoExoticComponent<typeof Left1DChart>;
|
|
9
9
|
export default _default;
|
|
@@ -29,43 +29,27 @@ const ChartContext_1 = require("../../context/ChartContext");
|
|
|
29
29
|
const useXYReduce_1 = __importStar(require("../../hooks/useXYReduce"));
|
|
30
30
|
const PathBuilder_1 = require("../../utility/PathBuilder");
|
|
31
31
|
const scale_1 = require("../utilities/scale");
|
|
32
|
-
function
|
|
33
|
-
const {
|
|
32
|
+
function usePath(spectrum, options) {
|
|
33
|
+
const { width, horizontalMargin = 10 } = options;
|
|
34
|
+
const scaleX = (0, scale_1.useScale2DY)();
|
|
35
|
+
const scaleY = (0, scale_1.use1DTraceYScale)(spectrum.id, width, horizontalMargin);
|
|
34
36
|
const xyReduce = (0, useXYReduce_1.default)(useXYReduce_1.XYReducerDomainAxis.YAxis);
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
return pathBuilder.toString();
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
}, [
|
|
57
|
-
height,
|
|
58
|
-
margin,
|
|
59
|
-
marginValue,
|
|
60
|
-
originHeight,
|
|
61
|
-
spectrum,
|
|
62
|
-
xyReduce,
|
|
63
|
-
yDomain,
|
|
64
|
-
yDomains,
|
|
65
|
-
]);
|
|
66
|
-
const mainHeight = originHeight - margin.bottom - margin.top;
|
|
67
|
-
if (!mainHeight || !height)
|
|
37
|
+
const { x, re: y } = spectrum.data;
|
|
38
|
+
const pathPoints = xyReduce({ x, y });
|
|
39
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
40
|
+
pathBuilder.moveTo(scaleY(pathPoints.y.at(-1)), scaleX(pathPoints.x.at(-1)));
|
|
41
|
+
for (let i = pathPoints.x.length - 2; i >= 0; i--) {
|
|
42
|
+
pathBuilder.lineTo(scaleY(pathPoints.y[i]), scaleX(pathPoints.x[i]));
|
|
43
|
+
}
|
|
44
|
+
return pathBuilder.toString();
|
|
45
|
+
}
|
|
46
|
+
function Left1DChart({ horizontalMargin = 10, data: spectrum, }) {
|
|
47
|
+
const { height, margin, displayerKey } = (0, ChartContext_1.useChartData)();
|
|
48
|
+
const width = margin.left;
|
|
49
|
+
const path = usePath(spectrum, { horizontalMargin, width });
|
|
50
|
+
const innerHeight = height - margin.bottom - margin.top;
|
|
51
|
+
if (!innerHeight || !width)
|
|
68
52
|
return null;
|
|
69
|
-
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${innerHeight + margin.top}`, width: width, height: innerHeight + margin.top, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-left`, children: (0, jsx_runtime_1.jsx)("rect", { width: width, height: innerHeight, x: "0", y: margin.top }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-left)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke: spectrum.display.color, fill: "none", d: path }) })] }));
|
|
70
54
|
}
|
|
71
55
|
exports.default = (0, react_1.memo)(Left1DChart);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Spectrum1D } from 'nmr-load-save';
|
|
3
3
|
interface Top1DChartProps {
|
|
4
|
-
|
|
4
|
+
verticalMargin?: number;
|
|
5
5
|
data: Spectrum1D;
|
|
6
6
|
}
|
|
7
|
-
declare function Top1DChart({
|
|
7
|
+
declare function Top1DChart({ verticalMargin, data: spectrum }: Top1DChartProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
8
|
declare const _default: import("react").MemoExoticComponent<typeof Top1DChart>;
|
|
9
9
|
export default _default;
|
|
@@ -29,39 +29,28 @@ const ChartContext_1 = require("../../context/ChartContext");
|
|
|
29
29
|
const useXYReduce_1 = __importStar(require("../../hooks/useXYReduce"));
|
|
30
30
|
const PathBuilder_1 = require("../../utility/PathBuilder");
|
|
31
31
|
const scale_1 = require("../utilities/scale");
|
|
32
|
-
function
|
|
33
|
-
const {
|
|
32
|
+
function usePath(spectrum, options) {
|
|
33
|
+
const { height, verticalMargin = 10 } = options;
|
|
34
|
+
const scaleX = (0, scale_1.useScale2DX)();
|
|
35
|
+
const scaleY = (0, scale_1.use1DTraceYScale)(spectrum.id, height, verticalMargin);
|
|
34
36
|
const xyReduce = (0, useXYReduce_1.default)(useXYReduce_1.XYReducerDomainAxis.XAxis);
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
}, [
|
|
53
|
-
height,
|
|
54
|
-
marginProps,
|
|
55
|
-
originMargin,
|
|
56
|
-
spectrum,
|
|
57
|
-
width,
|
|
58
|
-
xDomain,
|
|
59
|
-
xyReduce,
|
|
60
|
-
yDomains,
|
|
61
|
-
]);
|
|
37
|
+
const { x, re: y } = spectrum.data;
|
|
38
|
+
const pathPoints = xyReduce({ x, y });
|
|
39
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
40
|
+
pathBuilder.moveTo(scaleX(pathPoints.x[0]), scaleY(pathPoints.y[0]));
|
|
41
|
+
for (let i = 1; i < pathPoints.x.length; i++) {
|
|
42
|
+
pathBuilder.lineTo(scaleX(pathPoints.x[i]), scaleY(pathPoints.y[i]));
|
|
43
|
+
}
|
|
44
|
+
return pathBuilder.toString();
|
|
45
|
+
}
|
|
46
|
+
function Top1DChart({ verticalMargin = 10, data: spectrum }) {
|
|
47
|
+
const { width, margin, displayerKey } = (0, ChartContext_1.useChartData)();
|
|
48
|
+
const height = margin.top;
|
|
49
|
+
const path = usePath(spectrum, { height, verticalMargin });
|
|
62
50
|
if (!width || !height) {
|
|
63
51
|
return null;
|
|
64
52
|
}
|
|
65
|
-
|
|
53
|
+
const innerWidth = width - margin.left - margin.right;
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-top`, children: (0, jsx_runtime_1.jsx)("rect", { width: innerWidth, height: height, x: margin.left, y: `${0}` }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-top)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke: spectrum.display.color, fill: "none", strokeWidth: "1px", d: path }) })] }));
|
|
66
55
|
}
|
|
67
56
|
exports.default = (0, react_1.memo)(Top1DChart);
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
interface
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
x: Float64Array;
|
|
6
|
-
re: Float64Array;
|
|
7
|
-
};
|
|
8
|
-
reverseScale?: boolean;
|
|
1
|
+
import { NmrData1D } from 'cheminfo-types';
|
|
2
|
+
interface BaseProps {
|
|
3
|
+
reverse?: boolean;
|
|
4
|
+
horizontalMargin?: number;
|
|
9
5
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
interface VerticalSliceChartProps extends BaseProps {
|
|
7
|
+
data: NmrData1D;
|
|
8
|
+
}
|
|
9
|
+
declare function VerticalSliceChart(props: VerticalSliceChartProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default VerticalSliceChart;
|
|
@@ -1,68 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
-
const react_1 = require("react");
|
|
28
4
|
const ChartContext_1 = require("../../context/ChartContext");
|
|
29
|
-
const useXYReduce_1 = __importStar(require("../../hooks/useXYReduce"));
|
|
30
5
|
const PathBuilder_1 = require("../../utility/PathBuilder");
|
|
31
|
-
const SliceScale_1 = require("../utilities/SliceScale");
|
|
32
6
|
const scale_1 = require("../utilities/scale");
|
|
33
|
-
function
|
|
34
|
-
const {
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, [
|
|
54
|
-
data,
|
|
55
|
-
height,
|
|
56
|
-
margin,
|
|
57
|
-
marginValue,
|
|
58
|
-
originHeight,
|
|
59
|
-
reverseScale,
|
|
60
|
-
xyReduce,
|
|
61
|
-
yDomain,
|
|
62
|
-
]);
|
|
63
|
-
const mainHeight = originHeight - margin.bottom - margin.top;
|
|
64
|
-
if (!mainHeight || !height)
|
|
65
|
-
return null;
|
|
66
|
-
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${height} ${mainHeight + margin.top}`, width: height, height: mainHeight + margin.top, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-left`, children: (0, jsx_runtime_1.jsx)("rect", { width: height, height: mainHeight, x: "0", y: margin.top }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-left)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke: "red", fill: "none", d: paths }) })] }));
|
|
7
|
+
function usePath(data, props) {
|
|
8
|
+
const { reverse, width = 100, horizontalMargin = 10 } = props;
|
|
9
|
+
const { mode } = (0, ChartContext_1.useChartData)();
|
|
10
|
+
const scaleX = (0, scale_1.useScale2DY)(reverse);
|
|
11
|
+
const { x, re: y } = data;
|
|
12
|
+
const scaleY = (0, scale_1.getSliceYScale)(y, width, mode, horizontalMargin);
|
|
13
|
+
const pathBuilder = new PathBuilder_1.PathBuilder();
|
|
14
|
+
pathBuilder.moveTo(scaleY(y.at(-1)), scaleX(x.at(-1)));
|
|
15
|
+
for (let i = x.length - 2; i >= 0; i--) {
|
|
16
|
+
pathBuilder.lineTo(scaleY(y[i]), scaleX(x[i]));
|
|
17
|
+
}
|
|
18
|
+
return pathBuilder.toString();
|
|
19
|
+
}
|
|
20
|
+
function VerticalSliceChart(props) {
|
|
21
|
+
const { horizontalMargin = 10, data, reverse = false } = props;
|
|
22
|
+
const { height, margin, displayerKey } = (0, ChartContext_1.useChartData)();
|
|
23
|
+
const width = margin.left;
|
|
24
|
+
const path = usePath(data, { width, horizontalMargin, reverse });
|
|
25
|
+
const innerHeight = height - margin.bottom - margin.top;
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${height} ${height}`, width: height, height: height, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-left`, children: (0, jsx_runtime_1.jsx)("rect", { width: height, height: innerHeight, x: "0", y: margin.top }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-left)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke: "red", fill: "none", d: path }) })] }));
|
|
67
27
|
}
|
|
68
|
-
exports.default =
|
|
28
|
+
exports.default = VerticalSliceChart;
|
|
@@ -59,7 +59,7 @@ const styles = (0, react_1.css) `
|
|
|
59
59
|
function FooterBanner({ layout, data1D }) {
|
|
60
60
|
const position = (0, MouseTracker_1.useMouseTracker)();
|
|
61
61
|
const { startX, endX, startY, endY, step, mouseButton } = (0, BrushTracker_1.useBrushTracker)();
|
|
62
|
-
const { margin, width, height, xDomain, yDomain, yDomains, view: { spectra: { activeTab }, }, data, toolOptions: { selectedTool }, } = (0, ChartContext_1.useChartData)();
|
|
62
|
+
const { margin, width, height, xDomain, yDomain, yDomains, view: { spectra: { activeTab }, }, data, toolOptions: { selectedTool }, mode, } = (0, ChartContext_1.useChartData)();
|
|
63
63
|
const activeSpectrum = (0, useActiveSpectrum_1.useActiveSpectrum)();
|
|
64
64
|
const trackID = position &&
|
|
65
65
|
(0, DimensionLayout_1.getLayoutID)(layout, {
|
|
@@ -70,13 +70,13 @@ function FooterBanner({ layout, data1D }) {
|
|
|
70
70
|
const [formatX, formatY] = (0, useFormatNumberByNucleus_1.useFormatNumberByNucleus)(nuclei);
|
|
71
71
|
const scaleX = (0, react_2.useMemo)(() => {
|
|
72
72
|
if (!data1D || data1D.length === 0) {
|
|
73
|
-
return (0, scale_1.get2DXScale)({ width, margin, xDomain });
|
|
73
|
+
return (0, scale_1.get2DXScale)({ width, margin, xDomain, mode });
|
|
74
74
|
}
|
|
75
75
|
if (selectedTool !== ToolTypes_1.options.slicing.id) {
|
|
76
76
|
switch (trackID) {
|
|
77
77
|
case DimensionLayout_1.LAYOUT.TOP_1D:
|
|
78
78
|
case DimensionLayout_1.LAYOUT.CENTER_2D: {
|
|
79
|
-
return (0, scale_1.get2DXScale)({ width, margin, xDomain });
|
|
79
|
+
return (0, scale_1.get2DXScale)({ width, margin, xDomain, mode });
|
|
80
80
|
}
|
|
81
81
|
case DimensionLayout_1.LAYOUT.LEFT_1D: {
|
|
82
82
|
return (0, scale_1.get2DYScale)({ height, margin, yDomain });
|
|
@@ -86,7 +86,17 @@ function FooterBanner({ layout, data1D }) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
return null;
|
|
89
|
-
}, [
|
|
89
|
+
}, [
|
|
90
|
+
data1D,
|
|
91
|
+
height,
|
|
92
|
+
margin,
|
|
93
|
+
selectedTool,
|
|
94
|
+
trackID,
|
|
95
|
+
width,
|
|
96
|
+
xDomain,
|
|
97
|
+
yDomain,
|
|
98
|
+
mode,
|
|
99
|
+
]);
|
|
90
100
|
const scaleY = (0, react_2.useMemo)(() => {
|
|
91
101
|
if (!data1D || data1D.length === 0) {
|
|
92
102
|
return (0, scale_1.get2DYScale)({ height, margin, yDomain });
|
|
@@ -117,7 +127,8 @@ function FooterBanner({ layout, data1D }) {
|
|
|
117
127
|
position.y < 10 ||
|
|
118
128
|
position.x < 10 ||
|
|
119
129
|
position.x > width - margin.right ||
|
|
120
|
-
position.y > height - margin.bottom
|
|
130
|
+
position.y > height - margin.bottom ||
|
|
131
|
+
!data1D) {
|
|
121
132
|
return (0, jsx_runtime_1.jsx)("div", { css: styles });
|
|
122
133
|
}
|
|
123
134
|
const getRealYValue = (coordinate) => {
|
|
@@ -128,7 +139,7 @@ function FooterBanner({ layout, data1D }) {
|
|
|
128
139
|
else if (trackID === DimensionLayout_1.LAYOUT.LEFT_1D) {
|
|
129
140
|
index = 1;
|
|
130
141
|
}
|
|
131
|
-
if (index != null && scaleX != null) {
|
|
142
|
+
if (index != null && scaleX != null && data1D[index]) {
|
|
132
143
|
const datum = (0, get1DDataXY_1.get1DDataXY)(data1D[index]);
|
|
133
144
|
const xIndex = (0, ml_spectra_processing_1.xFindClosestIndex)(datum.x, scaleX.invert(coordinate));
|
|
134
145
|
return datum.y[xIndex];
|
|
@@ -3,5 +3,5 @@ interface SignalDeltaLineProps {
|
|
|
3
3
|
axis: 'X' | 'Y';
|
|
4
4
|
show: boolean;
|
|
5
5
|
}
|
|
6
|
-
declare function SignalDeltaLine({ delta, axis, show }: SignalDeltaLineProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function SignalDeltaLine({ delta, axis, show }: SignalDeltaLineProps): import("@emotion/react/jsx-runtime").JSX.Element | null | undefined;
|
|
7
7
|
export default SignalDeltaLine;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
4
4
|
/** @jsxImportSource @emotion/react */
|
|
5
5
|
const react_1 = require("@emotion/react");
|
|
6
|
-
const react_2 = require("react");
|
|
7
6
|
const ChartContext_1 = require("../context/ChartContext");
|
|
8
7
|
const scale_1 = require("./utilities/scale");
|
|
9
8
|
const lineStyle = (0, react_1.css) `
|
|
@@ -12,12 +11,16 @@ const lineStyle = (0, react_1.css) `
|
|
|
12
11
|
opacity: 0.5;
|
|
13
12
|
`;
|
|
14
13
|
function SignalDeltaLine({ delta, axis, show }) {
|
|
15
|
-
const {
|
|
16
|
-
const scaleX = (0, scale_1.
|
|
17
|
-
const scaleY = (0, scale_1.
|
|
18
|
-
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
const { xDomain, yDomain } = (0, ChartContext_1.useChartData)();
|
|
15
|
+
const scaleX = (0, scale_1.useScale2DX)();
|
|
16
|
+
const scaleY = (0, scale_1.useScale2DY)();
|
|
17
|
+
if (!show)
|
|
18
|
+
return null;
|
|
19
|
+
if (axis === 'X') {
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)("line", { css: lineStyle, x1: scaleX(delta), x2: scaleX(delta), y1: scaleY(yDomain[0]), y2: scaleY(yDomain[1]) }, `signalLine_${delta}_X`));
|
|
21
|
+
}
|
|
22
|
+
if (axis === 'Y') {
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)("line", { css: lineStyle, x1: scaleX(xDomain[0]), x2: scaleX(xDomain[1]), y1: scaleY(delta), y2: scaleY(delta) }, `signalLine_${delta}_Y`));
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
26
|
exports.default = SignalDeltaLine;
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const react_1 = require("react");
|
|
8
7
|
const Spectrum2D_1 = require("../../data/data2d/Spectrum2D");
|
|
9
8
|
const MouseTracker_1 = require("../EventsTrackers/MouseTracker");
|
|
10
9
|
const ChartContext_1 = require("../context/ChartContext");
|
|
@@ -13,37 +12,28 @@ const HorizontalSliceChart_1 = __importDefault(require("./1d-tracer/HorizontalSl
|
|
|
13
12
|
const VerticalSliceChart_1 = __importDefault(require("./1d-tracer/VerticalSliceChart"));
|
|
14
13
|
const scale_1 = require("./utilities/scale");
|
|
15
14
|
function SlicingView() {
|
|
16
|
-
const { width, height, margin, data: spectra
|
|
15
|
+
const { width, height, margin, data: spectra } = (0, ChartContext_1.useChartData)();
|
|
17
16
|
const position = (0, MouseTracker_1.useMouseTracker)();
|
|
18
17
|
const activeSpectrum = (0, useActiveSpectrum_1.useActiveSpectrum)();
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const scale2dX = (0, scale_1.get2DXScale)({ margin, width, xDomain });
|
|
23
|
-
const scale2dY = (0, scale_1.get2DYScale)({ margin, height, yDomain });
|
|
24
|
-
const data = (0, Spectrum2D_1.getSlice)(spectra[activeSpectrum.index], {
|
|
25
|
-
x: scale2dX.invert(x),
|
|
26
|
-
y: scale2dY.invert(y),
|
|
27
|
-
});
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, style: {
|
|
29
|
-
position: 'absolute',
|
|
30
|
-
backgroundColor: 'rgba(255,255,255,0.8)',
|
|
31
|
-
}, children: [data?.horizontal && ((0, jsx_runtime_1.jsx)(HorizontalSliceChart_1.default, { data: data.horizontal.data })), data?.vertical && ((0, jsx_runtime_1.jsx)(VerticalSliceChart_1.default, { data: data.vertical.data, reverseScale: true }))] }));
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
}, [
|
|
35
|
-
position,
|
|
36
|
-
activeSpectrum,
|
|
37
|
-
margin,
|
|
38
|
-
width,
|
|
39
|
-
xDomain,
|
|
40
|
-
height,
|
|
41
|
-
yDomain,
|
|
42
|
-
spectra,
|
|
43
|
-
]);
|
|
44
|
-
if (!position) {
|
|
18
|
+
const scale2dX = (0, scale_1.useScale2DX)();
|
|
19
|
+
const scale2dY = (0, scale_1.useScale2DY)();
|
|
20
|
+
if (!position || !activeSpectrum?.id) {
|
|
45
21
|
return null;
|
|
46
22
|
}
|
|
47
|
-
|
|
23
|
+
let { x, y } = position;
|
|
24
|
+
if (x - margin.left < 0) {
|
|
25
|
+
x = 0;
|
|
26
|
+
}
|
|
27
|
+
else if (y - margin.top < 0) {
|
|
28
|
+
y = 0;
|
|
29
|
+
}
|
|
30
|
+
const data = (0, Spectrum2D_1.getSlice)(spectra[activeSpectrum.index], {
|
|
31
|
+
x: scale2dX.invert(x),
|
|
32
|
+
y: scale2dY.invert(y),
|
|
33
|
+
});
|
|
34
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, style: {
|
|
35
|
+
position: 'absolute',
|
|
36
|
+
backgroundColor: 'rgba(255,255,255,0.8)',
|
|
37
|
+
}, children: [data?.horizontal && (0, jsx_runtime_1.jsx)(HorizontalSliceChart_1.default, { data: data.horizontal.data }), data?.vertical && (0, jsx_runtime_1.jsx)(VerticalSliceChart_1.default, { data: data.vertical.data })] }));
|
|
48
38
|
}
|
|
49
39
|
exports.default = SlicingView;
|
|
@@ -49,21 +49,17 @@ const axisStyles = (0, react_1.css) `
|
|
|
49
49
|
const defaultMargin = { right: 100, top: 0, left: 0, bottom: 0 };
|
|
50
50
|
function XAxis(props) {
|
|
51
51
|
const { show = true, margin: marginProps = defaultMargin } = props;
|
|
52
|
-
const {
|
|
52
|
+
const { height, width, margin } = (0, ChartContext_1.useChartData)();
|
|
53
53
|
const spectrum = (0, useSpectrum_1.default)();
|
|
54
|
+
const scaleX = (0, scale_1.useScale2DX)();
|
|
54
55
|
const refAxis = (0, react_2.useRef)(null);
|
|
55
56
|
(0, react_2.useEffect)(() => {
|
|
56
57
|
if (!show)
|
|
57
58
|
return;
|
|
58
|
-
const scaleX = (0, scale_1.get2DXScale)({
|
|
59
|
-
width,
|
|
60
|
-
margin,
|
|
61
|
-
xDomain,
|
|
62
|
-
});
|
|
63
59
|
const xAxis = d3.axisBottom(scaleX).ticks(8).tickFormat(d3.format('0'));
|
|
64
60
|
// @ts-expect-error actually well typed
|
|
65
61
|
d3.select(refAxis.current).call(xAxis);
|
|
66
|
-
}, [height, margin, show, spectrum, width
|
|
62
|
+
}, [height, margin, scaleX, show, spectrum, width]);
|
|
67
63
|
if (!width || !height) {
|
|
68
64
|
return null;
|
|
69
65
|
}
|
|
@@ -50,16 +50,16 @@ const defaultMargin = { right: 50, top: 0, bottom: 0, left: 0 };
|
|
|
50
50
|
function YAxis(props) {
|
|
51
51
|
const { show = true, label = '', margin: marginProps = defaultMargin, } = props;
|
|
52
52
|
const refAxis = (0, react_2.useRef)(null);
|
|
53
|
-
const { yDomain, width, height
|
|
53
|
+
const { yDomain, width, height } = (0, ChartContext_1.useChartData)();
|
|
54
|
+
const scaleY = (0, scale_1.useScale2DY)();
|
|
54
55
|
const spectrum = (0, useSpectrum_1.default)();
|
|
55
56
|
(0, react_2.useEffect)(() => {
|
|
56
57
|
if (!show || !yDomain)
|
|
57
58
|
return;
|
|
58
|
-
const scaleY = (0, scale_1.get2DYScale)({ height, yDomain, margin }, !!spectrum?.info?.isFid);
|
|
59
59
|
const axis = d3.axisRight(scaleY).ticks(8).tickFormat(d3.format('0'));
|
|
60
60
|
// @ts-expect-error well typed
|
|
61
61
|
d3.select(refAxis.current).call(axis);
|
|
62
|
-
}, [spectrum,
|
|
62
|
+
}, [spectrum, yDomain, show, scaleY]);
|
|
63
63
|
if (!width || !height) {
|
|
64
64
|
return null;
|
|
65
65
|
}
|