1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-26 20:28:50 -05:00

add appropriate space for X tick labels with newlines (#214)

When painting a graph with densely labeled ticks on the X axis, it may be
necessary to add newlines in the labels to avoid label text overlap.

Reserve appropriate padding space for that.
This commit is contained in:
Jann 2021-04-10 18:31:12 +02:00 committed by GitHub
parent 04ae3728f8
commit 555ff688a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1532,7 +1532,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y1_label, con
const bool show_x_label = x_label && !ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_NoLabel); const bool show_x_label = x_label && !ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_NoLabel);
const float pad_top = title_size.x > 0.0f ? txt_height + gp.Style.LabelPadding.y : 0; const float pad_top = title_size.x > 0.0f ? txt_height + gp.Style.LabelPadding.y : 0;
const float pad_bot = (plot.XAxis.IsLabeled() ? txt_height + gp.Style.LabelPadding.y + (plot.XAxis.IsTime() ? txt_height + gp.Style.LabelPadding.y : 0) : 0) const float pad_bot = (plot.XAxis.IsLabeled() ? ImMax(txt_height, gp.XTicks.MaxHeight) + gp.Style.LabelPadding.y + (plot.XAxis.IsTime() ? txt_height + gp.Style.LabelPadding.y : 0) : 0)
+ (show_x_label ? txt_height + gp.Style.LabelPadding.y : 0); + (show_x_label ? txt_height + gp.Style.LabelPadding.y : 0);
const float plot_height = plot.CanvasRect.GetHeight() - pad_top - pad_bot; const float plot_height = plot.CanvasRect.GetHeight() - pad_top - pad_bot;