Slicing tool scales 1D slices with the global 2D maximum instead of the zoomed region
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 39/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- react, typescript
- Lĩnh vực
- data-visualization
Hướng nghiên cứu
Read src/component/2d/utilities/scale.ts and the horizontal and vertical slice chart callers named in the issue; compare how SlicingView.tsx gets the pointer position with how the current zoom domains are available. Check the related issue #3432 and the phase correction trace callers before choosing the scope. Done means slices in a zoomed region scale to visible intensities, with the maximum calculation and per render cost checked.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
When a 2D spectrum is zoomed, the 1D slices drawn by the slicing tool keep a y-scale computed from the global maximum of the whole 2D data set, ignoring the current zoom region. Peaks inside the zoomed region are therefore rendered flat / almost invisible, which makes the tool useless for weak regions.
The slice should be scaled against the visible (zoomed) region.
Evidence

How to reproduce
- Open a 2D spectrum.
- Zoom into a region whose intensities are much lower than the global maximum.
- Activate the slicing tool and move the pointer over the zoomed region.
Actual: the 1D slices are flat lines (or barely visible bumps), because their y-scale still spans the global maximum.
Expected: the 1D slices are scaled against the visible region, so peaks inside the zoom are clearly resolved.
Root cause
src/component/2d/utilities/scale.ts (line 95):
function getMax(data: NmrData2D): number {
let max;
for (const { minZ, maxZ } of Object.values(data)) {
const innerMax = Math.max(Math.abs(minZ), Math.abs(maxZ));
if (max === undefined || max > innerMax) {
max = innerMax;
}
}
assert(typeof max === 'number');
return max;
}
function getSliceYScale(
data: NmrData2D,
size: number,
mode: SpectraDirection,
options: SliceYScaleOptions = {},
) {
const { margin = 10, scaleRatio = 1 } = options;
const max = getMax(data); // <-- whole data set, zoom is never taken into account
size = mode === 'RTL' ? size : size / 2;
return scaleLinear([0, max * scaleRatio] as number[], [size - margin, margin]);
}
getMax only reads minZ / maxZ, which are precomputed over the entire matrix, and none of the callers pass the current xDomain / yDomain:
src/component/2d/1d-tracer/HorizontalSliceChart.tsx:31src/component/2d/1d-tracer/VerticalSliceChart.tsx:34
The same helper is also used by the phase-correction traces (src/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.tsx:41,56), so they share the behaviour.
SlicingView.tsx already computes the slice for the pointed position (getSlice(spectrum, { x: scale2dX.invert(x), y: scale2dY.invert(y) })) but the y-scale of the rendered slice is still global.
Suggested fix
Make the slice y-scale aware of the visible region, e.g. pass the current zoom domain (or the displayed sub-matrix) into getSliceYScale and compute the max from that window instead of from minZ / maxZ of the whole data set.
Two related details worth checking while in there:
if (max === undefined || max > innerMax)keeps the smallest of the per-block maxima (max > innerMaxlooks inverted if a true maximum is intended).getSliceYScaleis called on every render withdatafromspectrum.data; deriving the zoomed max will need to be memoized to avoid recomputing it per pointer move.
Related
Same defect as #3432 ("slicing tool should adapt the slice with respect to the zoom region", opened 2025-04-15). Recorded separately with fresh evidence and the root cause above; feel free to close one of them as a duplicate.
Environment
- nmrium 3.1.0, commit
5989ec6d
- Ngôn ngữ chính
- TypeScript
- Star
- 84
- Fork
- 35
- Merge trung bình
- 4 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của cheminfo/nmrium
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 3 ngày
-
cutting a spectrum and vertical scale of 1DCó thể đã có người làm @hamed-musallam đã nhận 4 ngày trước. Đang mở
cheminfo/nmrium#4424 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
cheminfo/nmrium#4422 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của cheminfo/nmrium
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
earendil-works/pi-claude-code#36 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Resources: New work of jabodetabekCó thể đã có người làm @rmt-svc đã nhận hôm nay. Đang mởresources
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
railmapgen/rmp-gallery#4167 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
documentation p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
microsoft/monaco-editor#5577 ·
Maintainer thường phản hồi trong vòng 1 ngày