Skip to content

Commit 555ff68

Browse files
authored
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.
1 parent 04ae372 commit 555ff68

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

implot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ bool BeginPlot(const char* title, const char* x_label, const char* y1_label, con
15321532
const bool show_x_label = x_label && !ImHasFlag(plot.XAxis.Flags, ImPlotAxisFlags_NoLabel);
15331533

15341534
const float pad_top = title_size.x > 0.0f ? txt_height + gp.Style.LabelPadding.y : 0;
1535-
const float pad_bot = (plot.XAxis.IsLabeled() ? txt_height + gp.Style.LabelPadding.y + (plot.XAxis.IsTime() ? txt_height + gp.Style.LabelPadding.y : 0) : 0)
1535+
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)
15361536
+ (show_x_label ? txt_height + gp.Style.LabelPadding.y : 0);
15371537

15381538
const float plot_height = plot.CanvasRect.GetHeight() - pad_top - pad_bot;

0 commit comments

Comments
 (0)