1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-23 02:38:53 -05:00

Only display non-empty legends

This commit is contained in:
Josh Pieper 2020-06-22 13:56:38 -04:00
parent 9894df4934
commit 0b3bf9bc9f

View File

@ -628,9 +628,11 @@ ImPlotItem* RegisterItem(const char* label_id) {
item->SeenThisFrame = true; item->SeenThisFrame = true;
int idx = gp.CurrentPlot->Items.GetIndex(item); int idx = gp.CurrentPlot->Items.GetIndex(item);
item->ID = id; item->ID = id;
if (ImGui::FindRenderedTextEnd(label_id, NULL) != label_id) {
gp.LegendIndices.push_back(idx); gp.LegendIndices.push_back(idx);
item->NameOffset = gp.LegendLabels.size(); item->NameOffset = gp.LegendLabels.size();
gp.LegendLabels.append(label_id, label_id + strlen(label_id) + 1); gp.LegendLabels.append(label_id, label_id + strlen(label_id) + 1);
}
if (item->Show) if (item->Show)
gp.VisibleItemCount++; gp.VisibleItemCount++;
return item; return item;