23 lines
827 B
C++
23 lines
827 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::format_tick_label(double tick,
|
|
const Axis_Properties& state) const {
|
|
const double absolute = std::abs(tick);
|
|
if (absolute >= 1'000'000.0)
|
|
return localized_axis_number(tick / 1'000'000.0, state.precision.get(), state.locale) + " MHz";
|
|
if (absolute >= 1'000.0)
|
|
return localized_axis_number(tick / 1'000.0, state.precision.get(), state.locale) + " kHz";
|
|
return localized_axis_number(tick, state.precision.get(), state.locale) + " Hz";
|
|
}
|
|
|
|
} // namespace renderive::detail
|