Skip to main content

egui_charts/drawings/
mod.rs

1//! Drawing tools and annotations anchored to chart coordinates.
2//!
3//! Use [`DrawingManager`] to select tools and manage drawings, undo and redo. With a
4//! [`Chart`](crate::Chart), prefer its drawing APIs for validated timestamp anchors
5//! and save/load operations; [`persistence`] exposes the JSON format for host storage.
6//!
7//! # Interactive drawing
8//!
9//! Select a tool through the chart's drawing manager; the chart collects its points
10//! from pointer input and handles selection and editing:
11//!
12//! ```
13//! use egui_charts::{Chart, drawings::DrawingToolType, model::BarData};
14//!
15//! let mut chart = Chart::new(BarData::default());
16//! chart.drawings_mut().set_active_tool(Some(DrawingToolType::TrendLine));
17//! ```
18//!
19//! [`DrawingToolRegistry`] configures built-in tool availability and lets hosts register
20//! custom renderers. Inspect availability before exposing a tool in a host picker.
21//! For lower-level composition, [`domain`] contains drawing records, [`services`]
22//! provides selection, history, snapping and handle operations, and [`rendering`]
23//! paints drawings against a chart view.
24
25pub mod categories;
26pub mod domain;
27pub(crate) mod glyphs;
28pub mod manager;
29pub mod persistence;
30pub mod registry;
31pub mod rendering;
32pub mod repositories;
33pub mod services;
34pub(crate) mod validation;
35
36// Re-export domain types at module root for convenience
37pub use domain::{
38    ArrowStyle, BarsPatternConfig, BarsPatternMode, ChartPoint, Drawing, DrawingInteractionMode,
39    DrawingOptions, DrawingTemplate, DrawingToolType, ElliottDegree, FibonacciConfig,
40    FibonacciLevel, FontWeight, GannConfig, GannFanDirection, GannLevel, GhostCandle,
41    GhostFeedConfig, HandlePos, ImageConfig, ParseToolTypeError, PitchforkConfig, PitchforkLevel,
42    PositionSize, PositionSizing, RegressionTrendConfig, TimeframeVisibility, VwapBand, VwapConfig,
43};
44
45// Re-export manager types
46pub use manager::{DrawingManager, DrawingManagerOptions, DrawingState};
47pub use registry::{DrawingRenderer, DrawingToolRegistry, RegisteredDrawingTool, ToolAvailability};