Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion implot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ bool ShowLegendEntries(ImPlotItemGroup& items, const ImRect& legend_bb, bool hov
}
// render
for (int i = 0; i < num_items; ++i) {
const int idx = indices[i];
const int idx = ImHasFlag(items.Legend.Flags, ImPlotLegendFlags_Reverse) ? indices[num_items - 1 - i] : indices[i];
ImPlotItem* item = items.GetLegendItem(idx);
const char* label = items.GetLegendLabel(idx);
const float label_width = ImGui::CalcTextSize(label, nullptr, true).x;
Expand Down
1 change: 1 addition & 0 deletions implot.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ enum ImPlotLegendFlags_ {
ImPlotLegendFlags_Outside = 1 << 4, // legend will be rendered outside of the plot area
ImPlotLegendFlags_Horizontal = 1 << 5, // legend entries will be displayed horizontally
ImPlotLegendFlags_Sort = 1 << 6, // legend entries will be displayed in alphabetical order
ImPlotLegendFlags_Reverse = 1 << 7, // legend entries will be displayed in reverse order
};

// Options for mouse hover text (see SetupMouseText)
Expand Down
1 change: 1 addition & 0 deletions implot_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ void Demo_ShadedPlots() {
ImGui::DragFloat("Alpha",&alpha,0.01f,0,1);

if (ImPlot::BeginPlot("Shaded Plots")) {
ImPlot::SetupLegend(ImPlotLocation_NorthWest, ImPlotLegendFlags_Reverse); // reverse legend to match vertical order on plot
ImPlot::PushStyleVar(ImPlotStyleVar_FillAlpha, alpha);
ImPlot::PlotShaded("Uncertain Data",xs,ys1,ys2,1001);
ImPlot::PlotLine("Uncertain Data", xs, ys, 1001);
Expand Down