From 0b3bf9bc9f8be4f14458e402a61bc5cc4a4b00df Mon Sep 17 00:00:00 2001 From: Josh Pieper Date: Mon, 22 Jun 2020 13:56:38 -0400 Subject: [PATCH] Only display non-empty legends --- implot.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/implot.cpp b/implot.cpp index 21bd171..c02f47f 100644 --- a/implot.cpp +++ b/implot.cpp @@ -628,9 +628,11 @@ ImPlotItem* RegisterItem(const char* label_id) { item->SeenThisFrame = true; int idx = gp.CurrentPlot->Items.GetIndex(item); item->ID = id; - gp.LegendIndices.push_back(idx); - item->NameOffset = gp.LegendLabels.size(); - gp.LegendLabels.append(label_id, label_id + strlen(label_id) + 1); + if (ImGui::FindRenderedTextEnd(label_id, NULL) != label_id) { + gp.LegendIndices.push_back(idx); + item->NameOffset = gp.LegendLabels.size(); + gp.LegendLabels.append(label_id, label_id + strlen(label_id) + 1); + } if (item->Show) gp.VisibleItemCount++; return item;