Charts / React science and statistics charts / Time series
Time–frequency power in dB on a canvas raster with harmonic callouts and annotation bands, for spotting tones, sweeps and resonances in a signal.
React component Spectrogram, data through props. One or more measures over a continuous run of time. Tags: spectrogram, frequency, signal, audio, canvas, raster, fft.
npm i klar-charts
import 'klar-charts/styles.css'
import { ThemeScope, Spectrogram } from 'klar-charts'
# or copy the source:
npx shadcn@latest add https://klar.run/r/sci-spectrogram.json<Spectrogram
data={data}
height={400}
logFreq={scale === 'log'}
fMax={scale === 'log' ? 8000 : 7000}
bands={[
{ axis: 'time', from: 0.6, to: 4.2, label: 'Run-up 140 → 1,150 Hz' },
{ axis: 'freq', from: 3000, to: 3400, label: 'Housing resonance' },
]}
labels={[
{ t: 5.55, f: 1150, text: 'f₀' },
{ t: 5.55, f: 2300, text: '2f₀' },
{ t: 5.55, f: 3450 + (scale === 'log' ? 0 : 120), text: '3f₀' },
{ t: 5.55, f: 4600, text: '4f₀' },
{ t: 2.35, f: scale === 'log' ? 5600 : 6300, text: 'Impact' },
{ t: 5.1, f: scale === 'log' ? 5600 : 6300, text: 'Impact' },
...(scale === 'log' ? [{ t: 1.2, f: 62, text: 'Mains hum 50 Hz' }] : []),
]}
/>