There are plenty threads on the forum, the magnifier icon lets you search for FFT to find e.g. this thread:
TL;DR: the amplitude is linear from 0 to fft.getSize(), so you might want to normalise by:
y = jmap (bin [i], 0.0f, float (fft.getSize()), float (bounds.getBottom()), float (bounds.getY()));
Now the frequency is linear as well (which is annoying, since you get plenty information about higher frequencies, but not much for lower ones).
These are the two mapping functions I use:
inline float indexToX (float index, float minFreq) const
{
const auto freq = (sampleRate * index) / fft.getSize();
return (freq > 0.01f) ? std::log (freq / minFreq) / std::log (2.0f) : 0.0f;
}
inline float binToY (float bin, const Rectangle<float> bounds) const
{
const float infinity = -80.0f;
return jmap (Decibels::gainToDecibels (bin, infinity),
infinity, 0.0f, bounds.getBottom(), bounds.getY());
}
Hope that helps
