@@ -328,31 +328,41 @@ void DemoScene::RenderPanel() {
328328 ImPlot::SetupAxisLimits (ImAxis_X1, t - history, t, ImGuiCond_Always);
329329 ImPlot::SetupAxisLimits (ImAxis_Y1, -10000 , 10000 );
330330
331- ImPlot::SetNextFillStyle (IMPLOT_AUTO_COL , 0 .5f );
332- ImPlot::PlotShaded (" Pow drain" , &graph_buffer_.Data [0 ].x ,
333- &graph_buffer_.Data [0 ].y , graph_buffer_.Data .size (),
334- -INFINITY , 0 , graph_buffer_.Offset , 2 * sizeof (float ));
335-
336- ImPlot::PlotLine (" Forecast x1" , &graph_buffer_forecast1_.Data [0 ].x ,
337- &graph_buffer_forecast1_.Data [0 ].y ,
338- graph_buffer_forecast1_.Data .size (), 0 ,
339- graph_buffer_forecast1_.Offset , 2 * sizeof (float ));
340- ImPlot::PlotLine (" x10" , &graph_buffer_forecast2_.Data [0 ].x ,
341- &graph_buffer_forecast2_.Data [0 ].y ,
342- graph_buffer_forecast2_.Data .size (), 0 ,
343- graph_buffer_forecast2_.Offset , 2 * sizeof (float ));
344- ImPlot::PlotLine (" x100" , &graph_buffer_forecast3_.Data [0 ].x ,
345- &graph_buffer_forecast3_.Data [0 ].y ,
346- graph_buffer_forecast3_.Data .size (), 0 ,
347- graph_buffer_forecast3_.Offset , 2 * sizeof (float ));
348- ImPlot::PlotLine (" ADPF" , &graph_buffer_power1_.Data [0 ].x ,
349- &graph_buffer_power1_.Data [0 ].y ,
350- graph_buffer_power1_.Data .size (), 0 ,
351- graph_buffer_power1_.Offset , 2 * sizeof (float ));
352- ImPlot::PlotLine (" NOADPF" , &graph_buffer_power2_.Data [0 ].x ,
353- &graph_buffer_power2_.Data [0 ].y ,
354- graph_buffer_power2_.Data .size (), 0 ,
355- graph_buffer_power2_.Offset , 2 * sizeof (float ));
331+ auto get_x = [](auto & buf) { return buf.Data .empty () ? nullptr : &buf.Data [0 ].x ; };
332+ auto get_y = [](auto & buf) { return buf.Data .empty () ? nullptr : &buf.Data [0 ].y ; };
333+
334+ ImPlot::PlotShaded (" Pow drain" , get_x (graph_buffer_),
335+ get_y (graph_buffer_), graph_buffer_.Data .size (),
336+ -INFINITY ,
337+ ImPlotSpec (ImPlotProp_FillAlpha, 0 .5f ,
338+ ImPlotProp_Offset, graph_buffer_.Offset ,
339+ ImPlotProp_Stride, (int )(2 * sizeof (float ))));
340+
341+ ImPlot::PlotLine (" Forecast x1" , get_x (graph_buffer_forecast1_),
342+ get_y (graph_buffer_forecast1_),
343+ graph_buffer_forecast1_.Data .size (),
344+ ImPlotSpec (ImPlotProp_Offset, graph_buffer_forecast1_.Offset ,
345+ ImPlotProp_Stride, (int )(2 * sizeof (float ))));
346+ ImPlot::PlotLine (" x10" , get_x (graph_buffer_forecast2_),
347+ get_y (graph_buffer_forecast2_),
348+ graph_buffer_forecast2_.Data .size (),
349+ ImPlotSpec (ImPlotProp_Offset, graph_buffer_forecast2_.Offset ,
350+ ImPlotProp_Stride, (int )(2 * sizeof (float ))));
351+ ImPlot::PlotLine (" x100" , get_x (graph_buffer_forecast3_),
352+ get_y (graph_buffer_forecast3_),
353+ graph_buffer_forecast3_.Data .size (),
354+ ImPlotSpec (ImPlotProp_Offset, graph_buffer_forecast3_.Offset ,
355+ ImPlotProp_Stride, (int )(2 * sizeof (float ))));
356+ ImPlot::PlotLine (" ADPF" , get_x (graph_buffer_power1_),
357+ get_y (graph_buffer_power1_),
358+ graph_buffer_power1_.Data .size (),
359+ ImPlotSpec (ImPlotProp_Offset, graph_buffer_power1_.Offset ,
360+ ImPlotProp_Stride, (int )(2 * sizeof (float ))));
361+ ImPlot::PlotLine (" NOADPF" , get_x (graph_buffer_power2_),
362+ get_y (graph_buffer_power2_),
363+ graph_buffer_power2_.Data .size (),
364+ ImPlotSpec (ImPlotProp_Offset, graph_buffer_power2_.Offset ,
365+ ImPlotProp_Stride, (int )(2 * sizeof (float ))));
356366
357367 ImPlot::EndPlot ();
358368 }
0 commit comments