-
Notifications
You must be signed in to change notification settings - Fork 644
Description
I use my own "ImPlotFormatter formatter" for the X axis.
ImPlot::SetupAxisFormat(ImAxis_X1, Plot::time_axis_formatter, this);In the time_axis_formatter method, the values are displayed in two lines (date \n time):
int time_axis_formatter(double value, char* buff, int size, void* user_data)
{
int64_t ts_ns = static_cast<int64_t>(value);
time_t ts_sec = ts_ns / 1'000'000'000;
int64_t ns_remain = ts_ns % 1'000'000'000;
std::tm tm_utc{};
gmtime_r(&ts_sec, &tm_utc);
// Format: "2025-06-30\n15:01:01.123456789"
std::strftime(buff, size, "%Y-%m-%d\n%H:%M:%S", &tm_utc);
size_t len = strlen(buff);
snprintf(buff + len, size - len, ".%09ld", ns_remain);
return 0;
}It is necessary for ImPlot\Axis to understand that the values are two-line.
It seems to partially understand. Because if you add a name for the ImAxis_X1 axis, it will be displayed correctly below the two-line axis values.
But the problem is that the axis indents apparently do not take this into account.
Therefore, if you use two Plots in a row (Subplots), one overlaps the other.
When you hover over the separator between Plots (blue stripe), it is located either on the Plot axis name ("AxisX_Name") (Fig. 2), or on the values of the axis itself (if there is no Plot name) (Fig. 2)
ps. Volume is the name of the next (second) SubPlot below, not the axis name of the top one.