1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2025-04-22 08:18:50 -04:00

Compare commits

..

No commits in common. "master" and "v0.10" have entirely different histories.

10 changed files with 4861 additions and 7314 deletions

View File

@ -1,95 +0,0 @@
# This build script is not meant for general use, it is for CI use only!
cmake_minimum_required(VERSION 3.0)
project(implot)
#
# Global options
#
# Same as Dear ImGui
set(CMAKE_CXX_STANDARD 11)
# Arch option for linux
if (NOT APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" AND DEFINED GCC_ARCH)
if ("${GCC_ARCH}" MATCHES "Win32|x86|32")
add_compile_options(-m32)
add_link_options(-m32)
elseif ("${GCC_ARCH}" MATCHES "Win64|x64|64")
add_compile_options(-m64)
add_link_options(-m64)
endif ()
endif ()
# Arch option for Mac: arm64 for M1 or x86_64 for intel (32 bits build are deprecated on Mac)
if(APPLE AND DEFINED OSX_ARCH)
if ("${OSX_ARCH}" MATCHES "x86_64")
set(CMAKE_OSX_ARCHITECTURES "x86_64")
elseif ("${OSX_ARCH}" MATCHES "arm64")
set(CMAKE_OSX_ARCHITECTURES "arm64")
else()
message(FATAL_ERROR "Unhandled OSX_ARCH=${OSX_ARCH}")
endif()
endif()
#
# Dear ImGui library with no backend
#
set(imgui_sources
../imgui/imconfig.h
../imgui/imgui.cpp
../imgui/imgui.h
../imgui/imgui_demo.cpp
../imgui/imgui_draw.cpp
../imgui/imgui_internal.h
../imgui/imgui_tables.cpp
../imgui/imgui_widgets.cpp
../imgui/imstb_rectpack.h
../imgui/imstb_textedit.h
../imgui/imstb_truetype.h
)
add_library(imgui ${imgui_sources})
target_include_directories(imgui PUBLIC ../imgui)
#
# ImPlot library
#
file(GLOB SOURCE_CODE ../implot*.*)
add_library(implot STATIC ${SOURCE_CODE})
if(MSVC)
target_compile_options(implot PRIVATE /W4 /WX)
else()
target_compile_options(implot PRIVATE -Wall -Werror -pedantic)
endif()
target_include_directories(implot PUBLIC ${CMAKE_CURRENT_LIST_DIR}/..)
target_link_libraries(implot PUBLIC imgui)
if (UNIX)
target_link_libraries(implot PUBLIC m stdc++)
endif()
# Define supported types via command line:
# - With no choice all types are supported (so that the CI provides support for all known types)
# - with -DIMPLOT_CUSTOM_NUMERIC_TYPES="default" the default set defined in implot_items.cpp is used
# - with -DIMPLOT_CUSTOM_NUMERIC_TYPES="(int)(float)(double)" only int, float and double are supported
if (NOT DEFINED IMPLOT_CUSTOM_NUMERIC_TYPES)
set(IMPLOT_CUSTOM_NUMERIC_TYPES "all")
endif()
if ("${IMPLOT_CUSTOM_NUMERIC_TYPES}" STREQUAL "default")
message("==== Compiling for default types ====")
elseif("${IMPLOT_CUSTOM_NUMERIC_TYPES}" STREQUAL "all")
message("==== Compiling for all types ====")
target_compile_definitions(implot PRIVATE "IMPLOT_CUSTOM_NUMERIC_TYPES=(signed char)(unsigned char)(signed short)(unsigned short)(signed int)(unsigned int)(signed long)(unsigned long)(signed long long)(unsigned long long)(float)(double)(long double)")
else()
message("==== Compiling for custom types: ${IMPLOT_CUSTOM_NUMERIC_TYPES} ====")
target_compile_definitions(implot PRIVATE "IMPLOT_CUSTOM_NUMERIC_TYPES=${IMPLOT_CUSTOM_NUMERIC_TYPES}")
endif()
#
# implot example binary application (with no backend)
#
add_executable(example_implot example_implot.cpp)
target_link_libraries(example_implot PRIVATE implot)

View File

@ -1,55 +0,0 @@
// Sample app built with Dear ImGui and ImPlot
// This app uses implot and imgui, but does not output to any backend! It only serves as a proof that an app can be built, linked, and run.
#include "imgui.h"
#include "implot.h"
#include "stdio.h"
int main(int, char**)
{
printf("sample_implot: start\n");
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImPlot::CreateContext();
// Additional imgui initialization needed when no backend is present
ImGui::GetIO().DisplaySize = ImVec2(400.f, 400.f);
ImGui::GetIO().Fonts->Build();
// Render 500 frames
for(int counter = 0; counter < 500; ++counter)
{
ImGui::NewFrame();
if (ImGui::Begin("Hello, world!"))
{
ImGui::Text("Hello again");
if (ImPlot::BeginPlot("My Plot"))
{
static double values[] = {1., 3., 5.};
ImPlot::PlotLine("Values", values, 3);
ImPlot::EndPlot();
}
#ifdef IMPLOT_INSTANTIATE_ALL_NUMERIC_TYPES
if (ImPlot::BeginPlot("My Plot (long double)"))
{
static long double values[] = {1., 3., 5.};
ImPlot::PlotLine("Values", values, 3);
ImPlot::EndPlot();
}
#endif
ImGui::End();
}
ImGui::Render();
}
ImPlot::DestroyContext();
ImGui::DestroyContext();
printf("sample_implot: end\n");
return 0;
}

View File

@ -1,144 +0,0 @@
name: build
on:
push:
pull_request:
jobs:
Linux:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
build_type:
- debug
- release
compiler:
- gcc
- clang
arch:
- x86
- x64
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: ocornut/imgui
path: imgui
- name: Dependencies
run: sudo apt-get install g++-multilib
- name: Configure
run: cmake -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_C_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DGCC_ARCH=${{ matrix.arch }} -B cmake-build -S .github
- name: Build
run: cmake --build cmake-build --parallel $(nproc)
- name: Run
run: |
file cmake-build/example_implot
cmake-build/example_implot
MacOS:
runs-on: macos-11
strategy:
fail-fast: false
matrix:
build_type:
- debug
- release
arch:
- x86_64
- arm64
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: ocornut/imgui
path: imgui
- name: Configure
shell: bash
run: cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DOSX_ARCH=${{ matrix.arch }} -B cmake-build -S .github
- name: Build
shell: bash
run: cmake --build cmake-build --parallel $(sysctl -n hw.ncpu)
- name: Run
if: matrix.arch == 'x86_64' # github's CI hosts seem to be running intel and can not run ARM
run: |
file cmake-build/example_implot
cmake-build/example_implot
Windows_MSVC:
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
build_type:
- debug
- release
arch:
- Win32
- x64
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: ocornut/imgui
path: imgui
- name: Configure
shell: bash
run: cmake -G 'Visual Studio 17 2022' -A ${{ matrix.arch }} -B cmake-build -S .github
- name: Build
shell: bash
run: cmake --build cmake-build -- -p:Configuration=${{ matrix.build_type }} -maxcpucount:$NUMBER_OF_PROCESSORS
- name: Run
run: .\cmake-build\${{matrix.build_type}}\example_implot.exe
Windows_MingW: # MingW on Github CI does not fully support 32 bits: link fails when it tries to link 64 bits system libraries.
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
build_type:
- debug
- release
arch:
- x64
# - Win32
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: ocornut/imgui
path: imgui
- name: Configure
shell: bash
run: cmake -G 'MinGW Makefiles' -DGCC_ARCH=${{ matrix.arch }} -B cmake-build -S .github
- name: Build
shell: bash
run: cmake --build cmake-build --parallel $NUMBER_OF_PROCESSORS
- name: Run (MingW)
run: .\cmake-build\example_implot.exe

View File

@ -19,7 +19,7 @@ ImPlot is an immediate mode, GPU accelerated plotting library for [Dear ImGui](h
- line plots
- shaded plots
- scatter plots
- vertical/horizontal/stacked bars graphs
- vertical/horizontal bars graphs
- vertical/horizontal error bars
- stem plots
- stair plots
@ -33,7 +33,7 @@ ImPlot is an immediate mode, GPU accelerated plotting library for [Dear ImGui](h
- subplots
- time formatted x-axes (US formatted or ISO 8601)
- reversible and lockable axes
- multiple x-axes and y-axes
- up to three independent y-axes
- controls for zooming, panning, box selection, and auto-fitting data
- controls for creating persistent query ranges (see demo)
- several plot styling options: 10 marker types, adjustable marker sizes, line weights, outline colors, fill colors, etc.
@ -43,7 +43,7 @@ ImPlot is an immediate mode, GPU accelerated plotting library for [Dear ImGui](h
- default styling based on current ImGui theme, or completely custom plot styles
- customizable data getters and data striding (just like ImGui:PlotLine)
- accepts data as float, double, and 8, 16, 32, and 64-bit signed/unsigned integral types
- and more! (see Announcements [2022](https://github.com/epezent/implot/discussions/370)/[2021](https://github.com/epezent/implot/issues/168)/[2020](https://github.com/epezent/implot/issues/48))
- and more! (see Announcements [2020](https://github.com/epezent/implot/issues/48)/[2021](https://github.com/epezent/implot/issues/168))
## Usage
@ -71,7 +71,7 @@ Of course, there's much more you can do with ImPlot...
## Demos
A comprehensive example of ImPlot's features can be found in `implot_demo.cpp`. Add this file to your sources and call `ImPlot::ShowDemoWindow()` somewhere in your update loop. You are encouraged to use this file as a reference when needing to implement various plot types. The demo is always updated to show new plot types and features as they are added, so check back with each release!
A comprehensive example of ImPlot's features can be found in `implot_demo.h`. Add this file to your sources and call `ImPlot::ShowDemoWindow()` somewhere in your update loop. You are encouraged to use this file as a reference when needing to implement various plot types. The demo is always updated to show new plot types and features as they are added, so check back with each release!
An online version of the demo is hosted [here](https://traineq.org/implot_demo/src/implot_demo.html). You can view the plots and the source code that generated them. Note that this demo may not always be up to date and is not as performant as a desktop implementation, but it should give you a general taste of what's possible with ImPlot. Special thanks to [pthom](https://github.com/pthom) for creating and hosting this!
@ -93,19 +93,7 @@ ImGui::DestroyContext();
You should be good to go!
## Installing ImPlot using vcpkg
You can download and install ImPlot using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
```bash
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install implot
```
The ImPlot port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
If you want to test ImPlot quickly, consider trying [mahi-gui](https://github.com/mahilab/mahi-gui), which bundles ImGui, ImPlot, and several other packages for you.
## Extremely Important Note
@ -122,20 +110,20 @@ A: ImGui is an incredibly powerful tool for rapid prototyping and development, b
**Q: Is ImPlot the right plotting library for me?**
A: If you're looking to generate publication quality plots and/or export plots to a file, ImPlot is NOT the library for you! ImPlot is geared toward plotting application data at realtime speeds with high levels of interactivity. ImPlot does its best to create pretty plots (indeed, there are quite a few styling options available), but it will always favor function over form.
A: If you're looking to generate publication quality plots and/or export plots to a file, ImPlot is NOT the library for you. ImPlot is geared toward plotting application data at realtime speeds. ImPlot does its best to create pretty plots (indeed, there are quite a few styling options available), but it will always favor function over form.
**Q: Where is the documentation?**
A: The API is thoroughly commented in `implot.h`, and the demo in `implot_demo.cpp` should be more than enough to get you started. Also take a look at the [implot_demos](https://github.com/epezent/implot_demos) repository.
A: The API is thoroughly commented in `implot.h`, and the demo in `implot_demo.cpp` should be more than enough to get you started.
**Q: Is ImPlot suitable for plotting large datasets?**
A: Yes, within reason. You can plot tens to hundreds of thousands of points without issue, but don't expect millions to be a buttery smooth experience. That said, you can always downsample extremely large datasets by telling ImPlot to stride your data at larger intervals if needed. Also try the experimental `backends` branch which aims to provide GPU acceleration support.
A: Yes, within reason. You can plot tens to hundreds of thousands of points without issue, but don't expect millions to be a buttery smooth experience. That said, you can always downsample extremely large datasets by telling ImPlot to stride your data at larger intervals if needed.
**Q: What data types can I plot?**
A: ImPlot plotting functions accept most scalar types:
`float`, `double`, `int8`, `uint8`, `int16`, `uint16`, `int32`, `uint32`, `int64`, `uint64`. Arrays of custom structs or classes (e.g. `Vector2f` or similar) are easily passed to ImPlot functions using the built-in striding features (see `implot.h` for documentation), and many plotters provide a "getter" overload which accepts data generating callbacks. You can fully customize the list of accepted types by defining `IMPLOT_CUSTOM_NUMERIC_TYPES` at compile time: see doc in `implot_items.cpp`.
`float`, `double`, `int8`, `uint8`, `int16`, `uint16`, `int32`, `uint32`, `int64`, `uint64`. Arrays of custom structs or classes (e.g. `Vector2f` or similar) are easily passed to ImPlot functions using the built in striding features (see `implot.h` for documentation).
**Q: Can plot styles be modified?**
@ -147,7 +135,7 @@ A: Yep! Both logscale and timescale are supported.
**Q: Does ImPlot support multiple y-axes? x-axes?**
A: Yes. Up to three x-axes and three y-axes can be enabled.
A: Yes. Up to three y-axes can be enabled. Multiple x-axes are not supported.
**Q: Does ImPlot support [insert plot type]?**
@ -169,9 +157,9 @@ A: Not exactly, but it does give you the ability to query plot sub-ranges, with
A: Not currently. Use your OS's screen capturing mechanisms if you need to capture a plot. ImPlot is not suitable for rendering publication quality plots; it is only intended to be used as a visualization tool. Post-process your data with MATLAB or matplotlib for these purposes.
**Q: Can I compile ImPlot as a dynamic library?**
**Q: Can a compile ImPlot as a dynamic library?**
A: Like ImGui, it is recommended that you compile and link ImPlot as a *static* library or directly as a part of your sources. However, if you must and are compiling ImPlot and ImGui as separate DLLs, make sure you set the current *ImGui* context with `ImPlot::SetImGuiContext(ImGuiContext* ctx)`. This ensures that global ImGui variables are correctly shared across the DLL boundary.
A: Like ImGui, it is recommended that you compile and link ImPlot as a *static* library or directly as a part of your sources. However, if you are compiling ImPlot and ImGui as separate DLLs, make sure you set the current *ImGui* context with `ImPlot::SetImGuiContext(ImGuiContext* ctx)`. This ensures that global ImGui variables are correctly shared across the DLL boundary.
**Q: Can ImPlot be used with other languages/bindings?**

100
TODO.md
View File

@ -1,100 +0,0 @@
The list below represents a combination of high-priority work, nice-to-have features, and random ideas. We make no guarantees that all of this work will be completed or even started. If you see something that you need or would like to have, let us know, or better yet consider submitting a PR for the feature.
## API
## Axes
- add flag to remove weekends on Time axis
- pixel space scale (`ImPlotTransform_Display`), normalized space scale (`ImPlotTransform_Axes`), data space scale (`ImPlotTransform_Data`)
- make ImPlotFlags_Equal not a flag -> `SetupEqual(ImPlotAxis x, ImPlotAxis y)`
- allow inverted arguments `SetAxes` to transpose data?
- `SetupAxisColors()`
- `SetupAxisHome()`
## Plot Items
- add `PlotBubbles` (see MATLAB bubble chart)
- add non-zero references for `PlotBars` etc.
- add exploding to `PlotPieChart` (on hover-highlight?)
- fix appearance of `PlotBars` spacing
## Styling
- support gradient and/or colormap sampled fills (e.g. ImPlotFillStyle_)
- API for setting different fonts for plot elements
## Colormaps
- gradient editing tool
- `RemoveColormap`
- `enum ImPlotColorRule_ { Solid, Faded, XValue, YValue, ZValue }`
## Legend
- `ImPlotLegendFlags_Scroll`
- improve legend icons (e.g. adopt markers, gradients, etc)
- make legend frame use ButtonBehavior (maybe impossible)
## Tools / Misc.
- add `IsPlotChanging` to detect change in limits
- add ability to extend plot/axis context menus
- add LTTB downsampling for lines
- add box selection to axes
- first frame render delay might fix "fit pop" effect
- move some code to new `implot_tools.cpp`
- ColormapSlider (see metrics)
- FillAlpha should not affect markers?
- fix mouse text for time axes
## Optimizations
- find faster way to buffer data into ImDrawList (very slow)
- reduce number of calls to `PushClipRect`
- explore SIMD operations for high density plot items
## Plotter Pipeline
Ideally every `PlotX` function should use our faster rendering pipeline when it is applicable.
` User Data > Getter > Fitter > Renderer > RenderPrimitives`
|Plotter|Getter|Fitter|Renderer|RenderPrimitives|
|---|:-:|:-:|:-:|:-:|
|PlotLine|Yes|Yes|Yes|Yes|
|PlotScatter|Yes|Yes|Yes|Yes|
|PlotStairs|Yes|Yes|Yes|Yes|
|PlotShaded|Yes|Yes|Yes|Yes|
|PlotBars|Yes|Yes|Yes|Yes|
|PlotBarGroups|:|:|:|:|
|PlotHistogram|:|:|:|:|
|PlotErrorBars|Yes|Yes|No|No|
|PlotStems|Yes|Yes|Yes|Yes|
|PlotInfLines|Yes|Yes|Yes|Yes|
|PlotPieChart|No|No|No|No|
|PlotHeatmap|Yes|No|Yes|Mixed|
|PlotHistogram2D|:|:|:|:|
|PlotDigital|Yes|No|No|No|
|PlotImage|-|-|-|-|
|PlotText|-|-|-|-|
|PlotDummy|-|-|-|-|
## Completed
- make BeginPlot take fewer args:
- make query a tool -> `DragRect`
- rework DragLine/Point to use ButtonBehavior
- add support for multiple x-axes and don't limit count to 3
- make axis side configurable (top/left, right/bottom) via new flag `ImPlotAxisFlags_Opposite`
- add support for setting tick label strings via callback
- give each axis an ID, remove ad-hoc DND solution
- allow axis to be drag to opposite side (ala ImGui Table headers)
- legend items can be hovered even if plot is not
- fix frame delay on DragX tools
- remove tag from drag line/point -> add `Tag` tool
- add shortcut/legacy overloads for BeginPlot
- `SetupAxisConstraints()`
- `SetupAxisScale()`
- add `ImPlotLineFlags`, `ImPlotBarsFlags`, etc. for each plot type
- add `PlotBarGroups` wrapper that makes rendering groups of bars easier, with stacked bar support
- `PlotBars` restore outlines
- add hover/active color for plot axes

4661
implot.cpp

File diff suppressed because it is too large Load Diff

961
implot.h

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff