22 lines
711 B
C++
22 lines
711 B
C++
#include "Frequency_Axis.h"
|
|
|
|
#include "Axis_Format.h"
|
|
|
|
#include <cmath>
|
|
|
|
namespace renderive::detail {
|
|
|
|
Frequency_Axis_Control::Frequency_Axis_Control(Plot_Core& plot, const Axis_Properties& properties)
|
|
: Axis(plot, properties) {}
|
|
|
|
std::string Frequency_Axis_Control::tick_label(double tick) const {
|
|
const double absolute = std::abs(tick);
|
|
if (absolute >= 1'000'000.0)
|
|
return localized_axis_number(tick / 1'000'000.0, label_precision(), locale()) + " MHz";
|
|
if (absolute >= 1'000.0)
|
|
return localized_axis_number(tick / 1'000.0, label_precision(), locale()) + " kHz";
|
|
return localized_axis_number(tick, label_precision(), locale()) + " Hz";
|
|
}
|
|
|
|
} // namespace renderive::detail
|