From 555ff688a8134bc0c602123149abe9c17d577475 Mon Sep 17 00:00:00 2001 From: Jann Date: Sat, 10 Apr 2021 18:31:12 +0200 Subject: [PATCH] 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. --- implot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implot.cpp b/implot.cpp index 96964a6..f97e08c 100644 --- a/implot.cpp +++ b/implot.cpp @@ -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 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); const float plot_height = plot.CanvasRect.GetHeight() - pad_top - pad_bot;