viewers: enforce minimum Y-range on histogram channels
Quiet histogram events were filling the chart panel even though the
peak was tiny (0.005 in/s rendered as 90% of chart height because
Chart.js auto-scaled to peak * 1.1). Made everything look uniformly
loud regardless of actual amplitude.
BW's solution: a near-fixed scale per channel ("Geo: 0.002 in/s/div"
from the footer). Quiet events render small, loud events render
proportionally tall.
Match the intent without copying BW's "no Y-axis labels at all"
convention. For histogram channels:
Geo (in/s): min Y range 0.05 in/s
Mic in psi: min Y range 0.001 psi
Mic in dBL: unchanged (the 60 dBL floor + peak+5 top already
gives quiet events a sensible baseline)
So a 0.005 in/s geo event renders as ~10% of chart height; a 0.05
event fills it; a 5.0 event still fills it (max(peak*1.1, 0.05) ==
peak*1.1 for any peak > 0.045).
Waveform charts unchanged — they should zoom for shape detail.
Applied to both the modal in sfm_webapp.html and the standalone
/events page in event_browser.html.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+17
-4
@@ -717,8 +717,9 @@ function renderWaveform(data) {
|
||||
// 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) {
|
||||
const isGeo = ch !== 'MicL';
|
||||
if (isGeo && !isHistogram) {
|
||||
// Waveform geo: symmetric around zero for full shape detail.
|
||||
let absMax = 0;
|
||||
for (const v of values) {
|
||||
const a = Math.abs(v);
|
||||
@@ -726,13 +727,25 @@ function renderWaveform(data) {
|
||||
}
|
||||
const padded = (absMax || 1) * 1.10;
|
||||
yBounds = { min: -padded, max: padded };
|
||||
} else if (isGeo && isHistogram) {
|
||||
// Histogram geo: enforce minimum chart range so quiet events
|
||||
// look quiet (matches BW's near-fixed-scale convention).
|
||||
const HIST_GEO_MIN_INS = 0.05;
|
||||
let p = 0;
|
||||
for (const v of values) { const a = Math.abs(v); if (a > p) p = a; }
|
||||
yBounds = { min: 0, max: Math.max(p * 1.10, HIST_GEO_MIN_INS) };
|
||||
} else if (ch === 'MicL' && micUnit === 'dBL') {
|
||||
// Baseline at noise-floor minimum (matches what we floored
|
||||
// null/quiet samples to), top at peak + 5 dB headroom.
|
||||
// Mic dBL: baseline at noise-floor minimum, top at peak + 5 dB.
|
||||
const peakDbl = (typeof peak === 'number' && isFinite(peak))
|
||||
? peak + 5
|
||||
: 100;
|
||||
yBounds = { min: MIC_DBL_FLOOR, max: Math.max(peakDbl, MIC_DBL_FLOOR + 20) };
|
||||
} else if (ch === 'MicL' && isHistogram && micUnit === 'psi') {
|
||||
// Mic histogram in psi: same minimum-range treatment as geo.
|
||||
const HIST_MIC_MIN_PSI = 0.001;
|
||||
let p = 0;
|
||||
for (const v of values) { const a = Math.abs(v); if (a > p) p = a; }
|
||||
yBounds = { min: 0, max: Math.max(p * 1.10, HIST_MIC_MIN_PSI) };
|
||||
}
|
||||
|
||||
const chart = new Chart(canvas, {
|
||||
|
||||
Reference in New Issue
Block a user