1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-10-09 23:57:26 -04:00

Merge pull request #68 from jpieper/20200622-empty-legend

Only display non-empty legends
This commit is contained in:
Evan Pezent 2020-06-23 21:20:48 -05:00 committed by GitHub
commit 2177ad1982
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;
gp.LegendIndices.push_back(idx); if (ImGui::FindRenderedTextEnd(label_id, NULL) != label_id) {
item->NameOffset = gp.LegendLabels.size(); gp.LegendIndices.push_back(idx);
gp.LegendLabels.append(label_id, label_id + strlen(label_id) + 1); item->NameOffset = gp.LegendLabels.size();
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;