Skip to content

Commit 2c232a5

Browse files
authored
fix: add assertion for n_ticks minimum when labels provided (#677)
Fix: Add assertion for n_ticks minimum when labels provided
2 parents dae3b22 + d0dd37f commit 2c232a5

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

implot.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,6 +2257,8 @@ void SetupAxisTicks(ImAxis idx, double v_min, double v_max, int n_ticks, const c
22572257
ImPlotContext& gp = *GImPlot;
22582258
IM_ASSERT_USER_ERROR(gp.CurrentPlot != nullptr && !gp.CurrentPlot->SetupLocked,
22592259
"Setup needs to be called after BeginPlot and before any setup locking functions (e.g. PlotX)!");
2260+
IM_ASSERT_USER_ERROR(labels == nullptr || n_ticks >= 2,
2261+
"When providing custom labels, n_ticks must be at least 2!");
22602262
n_ticks = n_ticks < 2 ? 2 : n_ticks;
22612263
FillRange(gp.TempDouble1, n_ticks, v_min, v_max);
22622264
SetupAxisTicks(idx, gp.TempDouble1.Data, n_ticks, labels, show_default);

0 commit comments

Comments
 (0)