diff --git a/implot.cpp b/implot.cpp index 231dd3c..49d132f 100644 --- a/implot.cpp +++ b/implot.cpp @@ -854,7 +854,9 @@ bool BeginPlot(const char* title, const char* x_label, const char* y_label, cons // BB AND HOVER ----------------------------------------------------------- // frame - const ImVec2 frame_size = ImGui::CalcItemSize(size, 100, 100); + const float default_w = ImGui::CalcItemWidth(); + const float default_h = default_w * 0.75f; + const ImVec2 frame_size = ImGui::CalcItemSize(size, default_w, default_w); gp.BB_Frame = ImRect(Window->DC.CursorPos, Window->DC.CursorPos + frame_size); ImGui::ItemSize(gp.BB_Frame); if (!ImGui::ItemAdd(gp.BB_Frame, 0, &gp.BB_Frame)) { diff --git a/implot_demo.cpp b/implot_demo.cpp index fdf1800..0e15d4c 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -152,7 +152,7 @@ void ShowDemoWindow(bool* p_open) { xs2[i] = i * 0.1f; ys2[i] = xs2[i] * xs2[i]; } - if (ImPlot::BeginPlot("Line Plot", "x", "f(x)", ImVec2(-1,300))) { + if (ImPlot::BeginPlot("Line Plot", "x", "f(x)", ImVec2(0,0))) { ImPlot::PlotLine("sin(50*x)", xs1, ys1, 1001); ImPlot::PushStyleVar(ImPlotStyleVar_Marker, ImPlotMarker_Circle); ImPlot::PlotLine("x^2", xs2, ys2, 11);