@@ -41,15 +41,17 @@ for (let name of wins) {
4141 let db = new Float64Array ( mag . length )
4242 for ( let i = 0 ; i < mag . length ; i ++ ) db [ i ] = 20 * Math . log10 ( Math . max ( mag [ i ] / peak , 1e-15 ) )
4343
44- // Time-domain y-range
45- let tMax = 0
46- for ( let i = 0 ; i < N ; i ++ ) if ( samples [ i ] > tMax ) tMax = samples [ i ]
44+ // Time-domain y-range (handle windows that go negative like flatTop, dolphChebyshev)
45+ let tMax = 0 , tMin = 0
46+ for ( let i = 0 ; i < N ; i ++ ) { if ( samples [ i ] > tMax ) tMax = samples [ i ] ; if ( samples [ i ] < tMin ) tMin = samples [ i ] }
4747 let yTop = tMax <= 1.1 ? 1 : Math . ceil ( tMax )
48- let yTicks = tMax <= 1.1 ? [ 0 , 0.5 , 1 ] : Array . from ( { length : yTop + 1 } , ( _ , i ) => i )
48+ let yBot = tMin >= - 0.01 ? 0 : Math . floor ( tMin * 2 ) / 2 // round down to nearest 0.5
49+ let yTicks = tMax <= 1.1 && tMin >= - 0.01 ? [ 0 , 0.5 , 1 ] : [ ]
50+ if ( ! yTicks . length ) for ( let y = yBot ; y <= yTop ; y += yTop > 2 ? 1 : 0.5 ) yTicks . push ( Math . round ( y * 10 ) / 10 )
4951
5052 let svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${ W } ${ H } " style="font-family:system-ui,-apple-system,sans-serif">\n`
5153
52- svg += panel ( L , samples , 0 , 1 , 0 , yTop , [ 0 , 0.5 , 1 ] , yTicks , true )
54+ svg += panel ( L , samples , 0 , 1 , yBot , yTop , [ 0 , 0.5 , 1 ] , yTicks , true )
5355 svg += panel ( R , db , 0 , 0.5 , - 120 , 0 , [ 0 , 0.1 , 0.2 , 0.3 , 0.4 , 0.5 ] , [ 0 , - 40 , - 80 , - 120 ] , false )
5456
5557 // Axis labels
0 commit comments