diff --git a/sfm/event_browser.html b/sfm/event_browser.html index 357e718..5d7a493 100644 --- a/sfm/event_browser.html +++ b/sfm/event_browser.html @@ -629,6 +629,22 @@ function renderWaveform(data) { return (Number.isInteger(v) ? String(v) : v.toFixed(1)) + xAxisUnit; }; + // Y-axis bounds. Geophone waveforms render symmetric around zero + // (seismograph convention — zero line in the middle, signal goes + // up AND down). Mic + histograms keep default auto-scale (always + // positive values; zero at the bottom). + let yBounds = {}; + const isGeoWaveform = !isHistogram && ch !== 'MicL'; + if (isGeoWaveform) { + let absMax = 0; + for (const v of values) { + const a = Math.abs(v); + if (a > absMax) absMax = a; + } + const padded = (absMax || 1) * 1.10; + yBounds = { min: -padded, max: padded }; + } + const chart = new Chart(canvas, { type: isHistogram ? 'bar' : 'line', data: { @@ -677,6 +693,7 @@ function renderWaveform(data) { grid: { color: isPrintMode ? '#e0e0e0' : '#21262d', drawTicks: showXAxis }, }, y: { + ...yBounds, ticks: { color: isPrintMode ? '#666' : '#484f58', maxTicksLimit: 5 }, grid: { color: isPrintMode ? '#e0e0e0' : '#21262d' }, title: { display: true, text: unit, diff --git a/sfm/sfm_webapp.html b/sfm/sfm_webapp.html index e072566..2c4a912 100644 --- a/sfm/sfm_webapp.html +++ b/sfm/sfm_webapp.html @@ -2670,6 +2670,24 @@ function _renderScWaveform(data) { return String(v) + xAxisLabel; }; + // Y-axis bounds. Convention: + // - Geophones (Tran/Vert/Long) on waveform-mode events: + // symmetric around zero so the zero line sits in the middle and + // positive/negative excursions are visually balanced. + // - Mic (always positive sound pressure) + histograms (per-interval + // peaks, always positive): default auto-scale, zero at the bottom. + let yBounds = {}; + const isGeoWaveform = !isHistogram && ch !== 'MicL'; + if (isGeoWaveform) { + let absMax = 0; + for (const v of values) { + const a = Math.abs(v); + if (a > absMax) absMax = a; + } + const padded = (absMax || 1) * 1.10; + yBounds = { min: -padded, max: padded }; + } + _scCharts[ch] = new Chart(canvas, { type: isHistogram ? 'bar' : 'line', data: { @@ -2709,6 +2727,7 @@ function _renderScWaveform(data) { grid: { color: '#21262d', drawTicks: showX }, }, y: { + ...yBounds, ticks: { color: '#484f58', maxTicksLimit: 4 }, grid: { color: '#21262d' }, title: { display: true, text: chData.unit || '', color: '#484f58', font: { size: 9 } }, @@ -3072,7 +3091,8 @@ if (currentSection === 'db') {