epezent / implot

Immediate Mode Plotting
MIT License
4.64k stars 516 forks source link

real time data display problem #463

Open kdxq opened 1 year ago

kdxq commented 1 year ago

I used imgui and implot for real-time display of temporal data and found the following problem:

When a series of data values remain constant (the bool variable is most pronounced and often remains in a state), after a few hours, the curve no longer displays. picture as follow

Some of the codes are as follows:

if (ImPlot::BeginPlot("",ImVec2(-1,0),ImPlotFlags_NoMenus) ){ ImPlot::SetupAxisScale(ImAxis_X1, ImPlotScale_Time);

                    if (i == rows - 1)
                    {
                        ImPlot::SetupAxes("", NULL, flags_axis, flags_axis);
                    }
                    else {
                        ImPlot::SetupAxes("", NULL, flags_axis | ImPlotAxisFlags_NoTickLabels, flags_axis);
                    }

                    for (int k = 0; k <= pltManager.pltVec[i].yMax; k++)
                    {
                        ImPlot::SetupAxis(ImAxis_Y1 + k, "", flags_axis);
                    }

                    ImPlot::SetupAxisLimits(ImAxis_X1, t - history, t, paused ? ImGuiCond_Once : ImGuiCond_Always);
                    ImPlot::SetupAxisLimits(ImAxis_Y1, 0, 1);
                    ImPlot::SetNextFillStyle(IMPLOT_AUTO_COL, 0.5f);

                    if (pltManager.pltVec.size() > 0)
                    {
                        for (int n = 0; n < pltManager.pltVec[i].plt.size(); n++)
                        {

                            int k = pltManager.pltVec[i].plt[n].lineIndex;

                            if (vecPltItem[k].isBIT)
                            {
                                ImPlot::SetupAxisLimits(ImAxis_Y1, 0, 1, ImGuiCond_Always);
                            }
                            else {
                                ImPlot::SetupAxisLimits(ImAxis_Y1, 0, 1);
                            }

                            ImPlot::SetAxis(pltManager.pltVec[i].plt[n].yIndex);
                            ImPlot::SetNextLineStyle(vecPltItem[k].Color);

                            if (vecPltItem[k].buffer.Data.size() == 0) continue;

                            if (vecPltItem[k].isBIT)
                            {
                                ImPlot::PlotDigital(
                                    &vecPltItem[k].Label[0],
                                    &vecPltItem[k].buffer.Data[0].x,
                                    &vecPltItem[k].buffer.Data[0].y,
                                    vecPltItem[k].buffer.Data.size(),
                                    0,
                                    vecPltItem[k].buffer.Offset,
                                    2 * sizeof(double));
                            }
                            else {
                                ImPlot::PlotLine(
                                    &vecPltItem[k].Label[0],
                                    &vecPltItem[k].buffer.Data[0].x,
                                    &vecPltItem[k].buffer.Data[0].y,
                                    vecPltItem[k].buffer.Data.size(),
                                    0,
                                    vecPltItem[k].buffer.Offset,
                                    2 * sizeof(double));
                            }

Please help me see how to troubleshoot this problem? image