From fee519b3e9626ba2a4bc3c6f6cda44d817e6f3e1 Mon Sep 17 00:00:00 2001 From: Evan Pezent Date: Mon, 27 Apr 2020 17:18:12 -0500 Subject: [PATCH] fix bug in demo --- implot_demo.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/implot_demo.cpp b/implot_demo.cpp index 083e33c..bc7e7b6 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -175,6 +175,7 @@ void ShowImPlotDemoWindow(bool* p_open) { } //------------------------------------------------------------------------- if (ImGui::CollapsingHeader("Realtime Plots")) { + ImGui::BulletText("Move your mouse to change the data!"); static bool paused = false; static ScrollingData sdata1, sdata2; static RollingData rdata1, rdata2; @@ -301,7 +302,8 @@ void ShowImPlotDemoWindow(bool* p_open) { if (ImGui::IsPlotHovered() && ImGui::IsMouseClicked(0)) data.push_back(ImGui::GetPlotMousePos()); ImGui::PushPlotStyleVar(ImPlotStyleVar_Marker, ImMarker_Diamond); - ImGui::Plot("Art", &data[0].x, &data[0].y, data.size(), 0, 2 * sizeof(float)); + if (data.size() > 0) + ImGui::Plot("Art", &data[0].x, &data[0].y, data.size(), 0, 2 * sizeof(float)); ImGui::PopPlotStyleVar(); ImGui::EndPlot(); }