epezent / implot

Immediate Mode Plotting
MIT License
4.65k stars 517 forks source link

Legend issue with PlotDigital (and PlotDummy) #376

Closed olivier-gerard closed 2 years ago

olivier-gerard commented 2 years ago

Hi I'm using latest commit of ImPlot(fc0fd11), and noted that the legends entries are not any more created for DigitalPlots. You can see this with the demo code : image

I tried using PlotDummy to cheat this, but I have some troubles as it seems to not take into account PushStyleColor. My legend label is changing (according to the line selected in a table), and the color is changing every time the text changes, even if I am using PushStyleColor. With latest release 0.13 my code was fine (the legend entry was added with changing label, and the color for the plot and the legend was constant), but I had to use latest code to fix DragPoints with ImGui 1.88

//Legend entry is added, but its color changes as labelTX is changing
ImPlot::PushStyleColor(ImPlotCol_Line | ImPlotCol_Fill, ImPlot::GetColormapColor(0)); //as label is changing we need fixed color
ImPlot::PlotDummy(labelTX);
ImPlot::PlotDigital("NotDisplayed", &dataX[0], &dataDigitalTX[0], GP->probe.probe.nbElements+1);
ImPlot::PopStyleColor();

//Code OK with rev 0.13, now no legend entry (but plot color is constant)
ImPlot::PushStyleColor(ImPlotCol_Line | ImPlotCol_Fill, ImPlot::GetColormapColor(1));
ImPlot::PlotDigital(labelRX, &dataX[0], &dataDigitalRX[0], GP->probe.probe.nbElements+1);
ImPlot::PopStyleColor();

Is there a trick for this ? Thanks

epezent commented 2 years ago

Fixed by https://github.com/epezent/implot/commit/8c5333348987080e5fab779196ab06e995c4a225