Przeglądaj źródła

fix(channels): clamp peaks with Math.min, not Math.max - everything pegged at -25 (#1251)

Math.max -> Math.min on the peak/label clamp. #1214
Nacho 2 miesięcy temu
rodzic
commit
762ecee1dc

+ 2 - 2
app/src/components/channels/ChannelSpectrum.tsx

@@ -263,7 +263,7 @@ export function ChannelSpectrum({
         const topHalf = (0.5 * slotW * Math.max(n.widthMhz, 20)) / 20
         const topHalf = (0.5 * slotW * Math.max(n.widthMhz, 20)) / 20
         const sigma = 0.75 * slotW
         const sigma = 0.75 * slotW
         const reach = topHalf + 1.5 * slotW
         const reach = topHalf + 1.5 * slotW
-        const peak = y(Math.max(n.signal, DBM_TOP))
+        const peak = y(Math.min(n.signal, DBM_TOP))
         g.beginPath()
         g.beginPath()
         for (let d = -reach; d <= reach; d += 1) {
         for (let d = -reach; d <= reach; d += 1) {
           const fall = Math.max(Math.abs(d) - topHalf, 0)
           const fall = Math.max(Math.abs(d) - topHalf, 0)
@@ -301,7 +301,7 @@ export function ChannelSpectrum({
         const rows: { px: number; py: number }[][] = [[], []]
         const rows: { px: number; py: number }[][] = [[], []]
         for (const n of labelables) {
         for (const n of labelables) {
           const px = Math.min(Math.max(xch(n.channel), PAD.l + 42), w - PAD.r - 42)
           const px = Math.min(Math.max(xch(n.channel), PAD.l + 42), w - PAD.r - 42)
-          const peakY = y(Math.max(n.signal, DBM_TOP))
+          const peakY = y(Math.min(n.signal, DBM_TOP))
           for (const rowIdx of [0, 1]) {
           for (const rowIdx of [0, 1]) {
             const py = peakY - 8 - rowIdx * 13
             const py = peakY - 8 - rowIdx * 13
             const clash = rows[rowIdx]!.some((q) => Math.abs(q.px - px) < slotW * 1.6)
             const clash = rows[rowIdx]!.some((q) => Math.abs(q.px - px) < slotW * 1.6)