1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
//! # Embedded Charts
//!
//! A production-ready, no_std graph framework for embedded systems using embedded-graphics.
//!
//! This library provides comprehensive chart types (line, bar, pie, scatter, gauge), axes, grids,
//! legends, real-time data streaming capabilities, and customizable styling while maintaining
//! memory efficiency and performance suitable for resource-constrained environments.
//!
//! ## Features
//!
//! - **Memory Efficient**: Static allocation with compile-time bounds, no heap usage
//! - **Performance Optimized**: Designed for real-time rendering on embedded systems
//! - **Flexible**: Plugin-like architecture for custom chart types
//! - **Easy to Use**: Fluent builder API with sensible defaults
//! - **std/no_std Compatible**: Full compatibility with both desktop and embedded environments
//! - **Rich Chart Types**: Line, bar, pie, gauge, and scatter charts with professional styling
//! - **Real-time Animation**: Streaming data with smooth transitions and configurable easing
//! - **Professional Styling**: Built-in themes, color palettes, and typography support
//!
//! ## Chart Types
//!
//! ### Line Charts
//! Multi-series line charts with markers, area filling, and smooth curves:
//! ```rust,no_run
//! # #[cfg(feature = "line")]
//! # {
//! # fn test() -> Result<(), embedded_charts::error::ChartError> {
//! use embedded_charts::prelude::*;
//! use embedded_graphics::pixelcolor::Rgb565;
//!
//! let chart = LineChart::builder()
//! .line_color(Rgb565::BLUE)
//! .line_width(2)
//! .with_markers(MarkerStyle {
//! shape: MarkerShape::Circle,
//! size: 6,
//! color: Rgb565::RED,
//! visible: true,
//! })
//! .build()?;
//! # Ok(())
//! # }
//! # }
//! ```
//!
//! ### Bar Charts
//! Vertical and horizontal bar charts with stacking support:
//! ```rust,no_run
//! # #[cfg(feature = "bar")]
//! # fn test() -> Result<(), embedded_charts::error::ChartError> {
//! use embedded_charts::prelude::*;
//! use embedded_graphics::pixelcolor::Rgb565;
//!
//! let chart = BarChart::builder()
//! .orientation(BarOrientation::Vertical)
//! .bar_width(BarWidth::Fixed(20))
//! .colors(&[Rgb565::GREEN])
//! .build()?;
//! Ok(())
//! # }
//! ```
//!
//! ### Pie Charts
//! Full circle pie charts with professional styling:
//! ```rust,no_run
//! # #[cfg(feature = "pie")]
//! # fn test() -> Result<(), embedded_charts::error::ChartError> {
//! use embedded_charts::prelude::*;
//! use embedded_graphics::pixelcolor::Rgb565;
//!
//! let chart = PieChart::builder()
//! .radius(80)
//! .colors(&[Rgb565::BLUE, Rgb565::RED, Rgb565::GREEN])
//! .with_title("Market Share")
//! .build()?;
//! Ok(())
//! # }
//! ```
//!
//! ### Donut Charts
//! Pie charts with hollow centers for improved information density:
//! ```rust,no_run
//! # #[cfg(feature = "pie")]
//! # fn test() -> Result<(), embedded_charts::error::ChartError> {
//! use embedded_charts::prelude::*;
//! use embedded_graphics::pixelcolor::Rgb565;
//!
//! // Balanced donut chart (50% inner radius)
//! let chart = PieChart::builder()
//! .radius(80)
//! .donut(40) // Inner radius of 40 pixels
//! .colors(&[Rgb565::BLUE, Rgb565::RED, Rgb565::GREEN])
//! .with_title("Storage Usage")
//! .build()?;
//! Ok(())
//! # }
//! ```
//!
//! #### Donut Chart Best Practices for Embedded Systems
//!
//! **Optimal Inner Radius Ratios:**
//! - **Thin donut (20-30% inner)**: Emphasizes data segments, good for detailed analysis
//! - **Balanced donut (40-60% inner)**: Best overall readability and visual balance
//! - **Thick donut (70-80% inner)**: Maximizes center space for additional content
//!
//! **Memory Considerations:**
//! - Donut charts use the same memory footprint as regular pie charts
//! - Center area can display totals, units, or status without additional memory cost
//! - Smaller outer radius improves performance on resource-constrained systems
//!
//! **Display Size Guidelines:**
//! - Small displays (≤128px): Use 50% inner radius with 60px outer radius
//! - Medium displays (240px): Use 40-60% inner radius with 80px outer radius
//! - Large displays (≥480px): Use any ratio with 100px+ outer radius for clarity
//!
//! ### Gauge Charts
//! Semicircle gauges with threshold zones and custom indicators:
//! ```rust,no_run
//! # #[cfg(feature = "gauge")]
//! # fn test() -> Result<(), embedded_charts::error::ChartError> {
//! use embedded_charts::prelude::*;
//! use embedded_graphics::pixelcolor::Rgb565;
//!
//! let chart = GaugeChart::builder()
//! .gauge_type(GaugeType::Semicircle)
//! .value_range(0.0, 100.0)
//! .add_threshold_zone(70.0, 100.0, Rgb565::RED)
//! .build()?;
//! Ok(())
//! # }
//! ```
//!
//! ## Data Management
//!
//! ### Static Data Series
//! Fixed-capacity data storage for predictable memory usage:
//! ```rust
//! use embedded_charts::prelude::*;
//!
//! // Create a series with capacity for 256 points
//! let mut series: StaticDataSeries<Point2D, 256> = StaticDataSeries::new();
//! series.push(Point2D::new(0.0, 10.0))?;
//! series.push(Point2D::new(1.0, 20.0))?;
//!
//! // Create from tuples using the macro
//! let data = data_points![(0.0, 10.0), (1.0, 20.0), (2.0, 15.0)];
//! # Ok::<(), embedded_charts::error::DataError>(())
//! ```
//!
//! ### Multi-Series Data
//! Container for multiple data series with automatic color assignment:
//! ```rust
//! use embedded_charts::prelude::*;
//!
//! // Container for 8 series, 256 points each
//! let mut multi_series: MultiSeries<Point2D, 8, 256> = MultiSeries::new();
//!
//! let temp_data = data_points![(0.0, 22.5), (1.0, 23.1), (2.0, 24.2)];
//! let humidity_data = data_points![(0.0, 65.0), (1.0, 68.0), (2.0, 72.0)];
//!
//! multi_series.add_series(temp_data)?;
//! multi_series.add_series(humidity_data)?;
//! # Ok::<(), embedded_charts::error::DataError>(())
//! ```
//!
//! ## Professional Styling
//!
//! ### Themes and Color Palettes
//! Built-in themes optimized for different display types:
//! ```rust,no_run
//! # #[cfg(feature = "color-support")]
//! # {
//! use embedded_charts::prelude::*;
//!
//! // Professional color palettes
//! let colors = quick::professional_colors();
//! let nature_colors = quick::nature_colors();
//! let ocean_colors = quick::ocean_colors();
//!
//! // Complete themes
//! let light_theme = quick::light_theme();
//! let dark_theme = quick::dark_theme();
//! let cyberpunk_theme = quick::cyberpunk_theme();
//! # }
//! ```
//!
//! ### Chart Configuration
//! Fluent configuration with the `chart_config!` macro:
//! ```rust
//! use embedded_charts::prelude::*;
//! use embedded_graphics::pixelcolor::Rgb565;
//!
//! let config = chart_config! {
//! title: "Temperature Monitor",
//! background: Rgb565::WHITE,
//! margins: constants::DEFAULT_MARGINS,
//! grid: true,
//! };
//! ```
//!
//! ## Real-time Animation
//!
//! ### Streaming Data (requires "animations" feature)
//! ```rust,no_run
//! # #[cfg(all(feature = "animations", feature = "line"))]
//! # {
//! use embedded_charts::prelude::*;
//! use embedded_graphics::{prelude::*, pixelcolor::Rgb565};
//!
//! // Sliding window for real-time data
//! let mut streaming_data: SlidingWindowSeries<Point2D, 100> =
//! SlidingWindowSeries::new();
//!
//! // Add data points (automatically removes old ones)
//! let timestamp = 1.0;
//! let value = 25.0;
//! streaming_data.push(Point2D::new(timestamp, value));
//!
//! // Create a chart for rendering
//! let chart: LineChart<Rgb565> = LineChart::builder().build()?;
//! let config: ChartConfig<Rgb565> = ChartConfig::default();
//! let viewport = Rectangle::new(Point::zero(), Size::new(320, 240));
//! // chart.draw(&streaming_data, &config, viewport, &mut display)?;
//! # }
//! # Ok::<(), embedded_charts::error::ChartError>(())
//! ```
//!
//! ## System Optimization
//!
//! ### Feature Configuration
//! Choose the appropriate feature set for your target system's capabilities:
//!
//! ```toml
//! # Minimal configuration - Integer math only
//! [dependencies]
//! embedded-charts = {
//! version = "0.1.0",
//! default-features = false,
//! features = ["integer-math"]
//! }
//!
//! # Balanced configuration - Fixed-point math with color support
//! [dependencies]
//! embedded-charts = {
//! version = "0.1.0",
//! default-features = false,
//! features = ["fixed-point", "color-support"]
//! }
//!
//! # Full-featured configuration - All features enabled
//! [dependencies]
//! embedded-charts = {
//! version = "0.1.0",
//! default-features = false,
//! features = ["floating-point", "animations", "color-support"]
//! }
//! ```
//!
//! ### no_std Usage
//! Complete example for embedded systems:
//! ```rust,ignore
//! #![no_std]
//!
//! use embedded_charts::prelude::*;
//! use embedded_graphics::{pixelcolor::Rgb565, prelude::*};
//!
//! fn render_sensor_chart() -> Result<(), embedded_charts::error::ChartError> {
//! // Create data series with static allocation
//! let mut sensor_data: StaticDataSeries<Point2D, 64> = StaticDataSeries::new();
//! let _ = sensor_data.push(Point2D::new(0.0, 22.5));
//! let _ = sensor_data.push(Point2D::new(1.0, 23.1));
//!
//! // Create minimal chart for small displays
//! let chart = LineChart::builder()
//! .line_color(Rgb565::BLUE)
//! .build()?;
//!
//! // Render to embedded display
//! let viewport = Rectangle::new(Point::zero(), Size::new(128, 64));
//! // chart.draw(&sensor_data, chart.config(), viewport, &mut display)?;
//! Ok(())
//! }
//!
//! fn main() {
//! let _ = render_sensor_chart();
//! }
//! ```
//!
//! ## Complete Example
//!
//! Professional multi-series chart:
//! ```rust,ignore
//! use embedded_charts::prelude::*;
//! use embedded_graphics::{pixelcolor::Rgb565, prelude::*};
//!
//! // Create sample data
//! let temp_data = data_points![(0.0, 22.5), (1.0, 23.1), (2.0, 24.2), (3.0, 23.8)];
//! let humidity_data = data_points![(0.0, 65.0), (1.0, 68.0), (2.0, 72.0), (3.0, 70.0)];
//!
//! // Create multi-series container
//! let mut multi_series: MultiSeries<Point2D, 8, 256> = MultiSeries::new();
//! multi_series.add_series(temp_data)?;
//! multi_series.add_series(humidity_data)?;
//!
//! // Create a simple line chart
//! let chart = LineChart::builder()
//! .line_color(Rgb565::BLUE)
//! .build()?;
//!
//! // Configure the chart
//! let config: ChartConfig<Rgb565> = ChartConfig::default();
//!
//! // Render to display
//! let viewport = Rectangle::new(Point::zero(), Size::new(320, 240));
//! // chart.draw(&multi_series, &config, viewport, &mut display)?;
//! # Ok::<(), embedded_charts::error::ChartError>(())
//! ```
//!
//! ## Module Organization
//!
//! - [`chart`] - Chart implementations (line, bar, pie, gauge, scatter)
//! - [`data`] - Data series and point management
//! - [`fluent`] - Fluent API for easy chart creation
//! - [`style`] - Styling, themes, and color palettes
//! - [`axes`] - Axis configuration and rendering
//! - [`grid`] - Grid system for chart backgrounds
//! - [`legend`] - Legend positioning and styling
//! - [`animation`] - Real-time animations and transitions (feature-gated)
//! - [`render`] - Low-level rendering primitives
//! - [`layout`] - Chart layout and positioning
//! - [`memory`] - Memory management utilities
//! - [`time`] - Time abstraction for animations
//! - [`math`] - Mathematical operations abstraction
//! - [`error`] - Error types and handling
//! - [`prelude`] - Convenient re-exports for common usage
//!
//! For complete API documentation, see the [API Documentation](API_DOCUMENTATION.md).
// Conditional std imports
extern crate std;
extern crate alloc;
// Math abstraction layer - always available
// Core modules
// Grid system
// Optional modules based on features
// Time abstraction layer
// Memory management utilities
// Heapless utilities for enhanced no_std support
// Dashboard layout system
// Convenience re-exports
// Error types
// Re-export commonly used types
pub use embedded_graphics;
pub use heapless;
// Re-export math types for convenience
pub use ;
/// Current version of the library
pub const VERSION: &str = env!;
/// Library configuration and feature detection