MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / Demo_AutoFittingData

Function Demo_AutoFittingData

Source/3rdParty/implot/implot_demo.cpp:1713–1741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1711//-----------------------------------------------------------------------------
1712
1713void Demo_AutoFittingData() {
1714 IMGUI_DEMO_MARKER("Axes/Auto-Fitting Data");
1715 ImGui::BulletText("The Y-axis has been configured to auto-fit to only the data visible in X-axis range.");
1716 ImGui::BulletText("Zoom and pan the X-axis. Disable Stems to see a difference in fit.");
1717 ImGui::BulletText("If ImPlotAxisFlags_RangeFit is disabled, the axis will fit ALL data.");
1718
1719 static ImPlotAxisFlags xflags = ImPlotAxisFlags_None;
1720 static ImPlotAxisFlags yflags = ImPlotAxisFlags_AutoFit|ImPlotAxisFlags_RangeFit;
1721
1722 ImGui::TextUnformatted("X: "); ImGui::SameLine();
1723 ImGui::CheckboxFlags("ImPlotAxisFlags_AutoFit##X", (unsigned int*)&xflags, ImPlotAxisFlags_AutoFit); ImGui::SameLine();
1724 ImGui::CheckboxFlags("ImPlotAxisFlags_RangeFit##X", (unsigned int*)&xflags, ImPlotAxisFlags_RangeFit);
1725
1726 ImGui::TextUnformatted("Y: "); ImGui::SameLine();
1727 ImGui::CheckboxFlags("ImPlotAxisFlags_AutoFit##Y", (unsigned int*)&yflags, ImPlotAxisFlags_AutoFit); ImGui::SameLine();
1728 ImGui::CheckboxFlags("ImPlotAxisFlags_RangeFit##Y", (unsigned int*)&yflags, ImPlotAxisFlags_RangeFit);
1729
1730 static double data[101];
1731 srand(0);
1732 for (int i = 0; i < 101; ++i)
1733 data[i] = 1 + sin(i/10.0f);
1734
1735 if (ImPlot::BeginPlot("##DataFitting")) {
1736 ImPlot::SetupAxes("X","Y",xflags,yflags);
1737 ImPlot::PlotLine("Line",data,101);
1738 ImPlot::PlotStems("Stems",data,101);
1739 ImPlot::EndPlot();
1740 };
1741}
1742
1743//-----------------------------------------------------------------------------
1744

Callers

nothing calls this directly

Calls 7

BulletTextFunction · 0.85
BeginPlotFunction · 0.85
SetupAxesFunction · 0.85
PlotLineFunction · 0.85
PlotStemsFunction · 0.85
EndPlotFunction · 0.85
sinFunction · 0.50

Tested by

no test coverage detected