The plotting module provides a bunch of plotting widgets to imgui. We use the implot library to handle this functionality.
Enabling the module
To enable the plotting module, you can either hard-code the USE_PLOTTING_MODULE
option in your CMakeLists.txt
file by finding the following line:
option(USE_PLOTTING_MODULE "Use the plotting module" OFF)
and modifying the line to look like this:
option(USE_PLOTTING_MODULE "Use the plotting module" ON)
Alternatively, you can also generate your project files using CMake options by running the following CMake command:
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DUSE_PLOTTING_MODULE=ON
Finally, update your uvproj.yaml
so that the plotting
key under enabled-modules
is set to true like this:
name: "MyProject"
version: "1.0.0.0"
engine-version: "1.0.0.0"
enabled-modules:
plotting: true
Next, in your source file, include the Modules.hpp
header in your components like this:
#include <Modules/Modules.hpp>
Event safety
The entire module is flagged as event safe at All ready
Testing out the module
In one of your widgets, add the following code to your tick function
250);
ImGui::SetNextItemWidth(if (ImPlot::BeginPlot("##Pie1", ImVec2(350, 350), ImPlotFlags_Equal | ImPlotFlags_NoMouseText))
{static const char* labels[] = { "Data 1", "Data 2" };
double dt[] = { 10.0f, 12.0f };
nullptr, ImPlotAxisFlags_NoDecorations);
ImPlot::SetupAxis(ImAxis_X1, nullptr, ImPlotAxisFlags_NoDecorations);
ImPlot::SetupAxis(ImAxis_Y1, 0, 1, 0, 1, ImPlotCond_Always);
ImPlot::SetupAxesLimits(
ImPlot::SetupLegend(ImPlotLocation_North | ImPlotLocation_West, ImPlotLegendFlags_Horizontal);2, 0.5, 0.5, 0.4, "%.3f", 90.0f, ImPlotPieChartFlags_Normalize);
ImPlot::PlotPieChart(labels, dt,
ImPlot::EndPlot(); }
and if you run your application, you will get some type of output like this:
Learning the module
To learn more about using implot, check out the implot GitHub repository.
Checking for the module
To check for the module at compile time, use the UIMGUI_PLOTTING_MODULE_ENABLED
macro.
Runtime checking can be done using the plotting
member of the ModuleSettings
struct. More info can be found here.
- Home
- Beginner content
- Install guide
- Creating and using the UI components
- The Instance
- The Init Info struct
- Additional features
- Custom type definitions
- C API development
- Config files and Folders
- Interfaces
- Internal Event safety
- Modules system
- I18N
- Plotting
- Knobs
- Spinners
- Toggles
- Text Utils
- Undo/Redo
- CLI Parser
- Theming
- OS
- Opening URLs and using file pickers
- Exec integration
- Fonts
- Unix
- DBus utilities
- XDG integration
- Collaborating with others
- Advanced content
- Loading dynamic libraries at runtime
- Understanding the library layout
- Compilation mode modifiers
- Adding plugin support to your application
- Production export and deployment
- Developer and contributor resources
- Misc