Skip to main content

dear_implot/
lib.rs

1//! # Dear ImPlot - Rust Bindings with Dear ImGui Compatibility
2//!
3//! High-level Rust bindings for ImPlot, the immediate mode plotting library.
4//! This crate provides safe, idiomatic Rust bindings designed to work seamlessly
5//! with dear-imgui (C++ bindgen) rather than imgui-rs (cimgui).
6//!
7//! ## Features
8//!
9//! - Safe, idiomatic Rust API
10//! - Full compatibility with dear-imgui
11//! - Builder pattern for plots and plot elements
12//! - Memory-safe string handling
13//! - Support for all major plot types
14//!
15//! ## Quick Start
16//!
17//! ```no_run
18//! use dear_imgui_rs::*;
19//! use dear_implot::*;
20//!
21//! let mut ctx = Context::create();
22//! let mut plot_ctx = PlotContext::create(&ctx);
23//!
24//! let ui = ctx.frame();
25//! let plot_ui = plot_ctx.get_plot_ui(&ui);
26//!
27//! if let Some(token) = plot_ui.begin_plot("My Plot") {
28//!     plot_ui.plot_line("Line", &[1.0, 2.0, 3.0, 4.0], &[1.0, 4.0, 2.0, 3.0]);
29//!     token.end();
30//! }
31//! ```
32//!
33//! ## Integration with Dear ImGui
34//!
35//! This crate is designed to work with the `dear-imgui-rs` ecosystem:
36//! - Uses the same context management patterns
37//! - Compatible with dear-imgui's UI tokens and lifetime management
38//! - Shares the same underlying Dear ImGui context
39
40use dear_implot_sys as sys;
41
42// Re-export essential types
43pub use dear_imgui_rs::{Context, Ui};
44pub use sys::{ImPlotPoint, ImPlotRange, ImPlotRect};
45pub use sys::{ImTextureID, ImVec2, ImVec4};
46
47mod advanced;
48mod axis_types;
49mod colormap;
50mod colors;
51mod context;
52mod flags;
53mod histogram_bins;
54mod markers;
55mod numeric_format;
56mod plot_types;
57mod style;
58mod ui_ext;
59mod utils;
60
61// New modular plot types
62pub mod plots;
63
64pub use axis_types::{Axis, XAxis, YAxis, YAxisChoice};
65pub(crate) use axis_types::{IMPLOT_AUTO, y_axis_choice_option_to_i32};
66pub use colormap::Colormap;
67pub use colors::PlotColorElement;
68pub use context::*;
69pub use flags::*;
70pub use histogram_bins::{BinMethod, HistogramBins};
71pub use markers::Marker;
72pub use numeric_format::{AxisFormat, AxisFormatError, FloatFormat, FloatFormatError};
73pub use plot_types::{PlotCond, PlotLocation, PlotOrientation};
74pub use style::*;
75pub use ui_ext::ImPlotExt;
76pub use utils::*;
77
78// Re-export new modular plot types for convenience
79pub use plots::{
80    Plot, PlotData, PlotDataLayout, PlotDataOffset, PlotDataStride, PlotError,
81    bar::{BarPlot, PositionalBarPlot},
82    error_bars::{AsymmetricErrorBarsPlot, ErrorBarsPlot, SimpleErrorBarsPlot},
83    heatmap::{HeatmapPlot, HeatmapPlotF32},
84    histogram::{Histogram2DPlot, HistogramPlot},
85    line::{LinePlot, SimpleLinePlot},
86    pie::{PieChartPlot, PieChartPlotF32},
87    polygon::PolygonPlot,
88    scatter::{ScatterPlot, SimpleScatterPlot},
89    shaded::{ShadedBetweenPlot, ShadedPlot, SimpleShadedPlot},
90    stems::{SimpleStemPlot, StemPlot},
91};
92
93// Re-export all plot types for convenience
94pub use plots::*;
95
96// Re-export advanced features (explicit to avoid AxisFlags name clash)
97pub use advanced::{
98    LegendFlags, LegendLocation, LegendManager, LegendToken, MultiAxisPlot, MultiAxisToken,
99    SubplotFlags, SubplotGrid, SubplotToken, YAxisConfig,
100};