Module prelude

Module prelude 

Source
Expand description

Convenience re-exports for common types and traits.

This module provides a comprehensive prelude that re-exports the most commonly used types, traits, and functions from the embedded-charts library. By importing this prelude, you get access to everything needed for typical chart creation and usage.

§Usage

use embedded_charts::prelude::*;
use embedded_graphics::pixelcolor::Rgb565;

// Now you have access to all common types and functions
let mut data: StaticDataSeries<Point2D, 256> = StaticDataSeries::new();
data.push(Point2D::new(0.0, 10.0))?;

let chart = LineChart::builder()
    .line_color(Rgb565::BLUE)
    .build()?;

§What’s Included

§Core Chart Types

§Data Management

§Styling and Themes

  • Color palettes and themes
  • Line styles, fill patterns, and borders
  • Typography support (feature-gated)

§Layout and Rendering

  • Chart layout and positioning
  • Rendering primitives and utilities
  • Memory management tools

§Utility Modules

  • types - Common type aliases for convenience
  • constants - Predefined constants for margins, spacing, etc.
  • quick - Quick-start functions for common chart configurations

§Utility Macros

§Quick Start Examples

§Simple Line Chart

use embedded_charts::prelude::*;
use embedded_graphics::pixelcolor::Rgb565;

let data = data_points![(0.0, 10.0), (1.0, 20.0), (2.0, 15.0)];
let chart = quick::line_chart().build()?;

§Professional Styled Chart

use embedded_charts::prelude::*;
use embedded_graphics::pixelcolor::Rgb565;

let chart = quick::professional_line_chart()
    .with_markers(MarkerStyle::default())
    .build()?;

let config = chart_config! {
    title: "Temperature Monitor",
    background: Rgb565::WHITE,
    margins: constants::DEFAULT_MARGINS,
    grid: true,
};

§Multi-Series Chart

use embedded_charts::prelude::*;

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)?;

§Feature-Gated Exports

Some exports are only available when specific features are enabled:

  • animations: Animation and streaming chart support
  • color-support: Extended color palette functions
  • std: Standard library time providers and error traits

§Memory Efficiency

All re-exported types are designed for embedded systems:

  • Static allocation with compile-time bounds
  • No heap usage in no_std environments
  • Configurable memory usage through type parameters

Re-exports§

pub use crate::math::Math;
pub use crate::math::Number;
pub use crate::math::NumericConversion;
pub use crate::chart::traits::Chart;
pub use crate::chart::traits::ChartBuilder;
pub use crate::chart::traits::ChartConfig;
pub use crate::chart::traits::IncrementalChart;
pub use crate::chart::traits::Margins;
pub use crate::chart::traits::StylableChart;
pub use crate::chart::traits::AnimatedChart;
pub use crate::chart::traits::StreamingChart;
pub use crate::chart::traits::AxisChart;
pub use crate::chart::traits::LegendChart;
pub use crate::legend::BackgroundStyle;
pub use crate::legend::CompactLegend;
pub use crate::legend::CompactLegendBuilder;
pub use crate::legend::CustomLegend;
pub use crate::legend::CustomLegendBuilder;
pub use crate::legend::DefaultLegend;
pub use crate::legend::DefaultLegendEntry;
pub use crate::legend::DefaultLegendRenderer;
pub use crate::legend::Legend;
pub use crate::legend::LegendAlignment;
pub use crate::legend::LegendBuilder;
pub use crate::legend::LegendEntry;
pub use crate::legend::LegendEntryType;
pub use crate::legend::LegendMargins;
pub use crate::legend::LegendOrientation;
pub use crate::legend::LegendRenderer;
pub use crate::legend::LegendStyle;
pub use crate::legend::PositionCalculator;
pub use crate::legend::SpacingStyle;
pub use crate::legend::StandardLegend;
pub use crate::legend::StandardLegendBuilder;
pub use crate::legend::StandardLegendRenderer;
pub use crate::legend::SymbolStyle;
pub use crate::legend::TextStyle;
pub use crate::legend::types::CompactLegendEntry;
pub use crate::legend::types::CustomLayoutParams;
pub use crate::legend::types::CustomLegendEntry;
pub use crate::legend::types::MarkerShape as LegendMarkerShape;
pub use crate::legend::types::MarkerStyle as LegendMarkerStyle;
pub use crate::legend::types::StandardLegendEntry;
pub use crate::legend::types::SymbolShape;
pub use crate::legend::position::LegendPosition as LegendPos;
pub use crate::axes::AxisConfig;
pub use crate::axes::AxisOrientation;
pub use crate::axes::AxisPosition;
pub use crate::axes::AxisStyle;
pub use crate::axes::AxisValue;
pub use crate::axes::CustomAxisBuilder;
pub use crate::axes::CustomTickGenerator;
pub use crate::axes::LinearAxis;
pub use crate::axes::LinearAxisBuilder;
pub use crate::axes::LinearTickGenerator;
pub use crate::axes::TickStyle;
pub use crate::axes::builder::presets;
pub use crate::axes::traits::Axis;
pub use crate::axes::traits::AxisRenderer;
pub use crate::axes::traits::Tick;
pub use crate::axes::traits::TickGenerator;
pub use crate::axes::range::calculate_nice_range;
pub use crate::axes::range::calculate_nice_ranges_from_bounds;
pub use crate::axes::range::calculate_nice_ranges_separate_config;
pub use crate::axes::range::RangeCalculationConfig;
pub use crate::grid::CustomGrid;
pub use crate::grid::CustomGridBuilder;
pub use crate::grid::GridBuilder;
pub use crate::grid::GridContainer;
pub use crate::grid::GridLineStyle;
pub use crate::grid::GridSpacing;
pub use crate::grid::GridStyle;
pub use crate::grid::GridSystem;
pub use crate::grid::GridType;
pub use crate::grid::GridVisibility;
pub use crate::grid::LinearGrid;
pub use crate::grid::LinearGridBuilder;
pub use crate::grid::MajorGridStyle;
pub use crate::grid::MinorGridStyle;
pub use crate::grid::TickBasedGrid;
pub use crate::grid::TickBasedGridBuilder;
pub use crate::grid::traits::DefaultGridRenderer;
pub use crate::grid::traits::Grid;
pub use crate::grid::traits::GridConfiguration;
pub use crate::grid::traits::GridOrientation;
pub use crate::grid::traits::GridRenderer;
pub use crate::grid::traits::TickAlignedGrid;
pub use crate::chart::LineChart;
pub use crate::chart::LineChartBuilder;
pub use crate::chart::LineChartStyle;
pub use crate::chart::MarkerShape;
pub use crate::chart::MarkerStyle;
pub use crate::chart::CurveChart;
pub use crate::chart::CurveChartBuilder;
pub use crate::math::interpolation::InterpolationConfig;
pub use crate::math::interpolation::InterpolationType;
pub use crate::chart::AnimatedLineChart;
pub use crate::chart::AnimatedLineChartBuilder;
pub use crate::chart::BarChart;
pub use crate::chart::BarChartBuilder;
pub use crate::chart::BarChartStyle;
pub use crate::chart::BarOrientation;
pub use crate::chart::AnimatedBarChart;
pub use crate::chart::AnimatedBarChartBuilder;
pub use crate::chart::bar::BarWidth;
pub use crate::chart::PieChart;
pub use crate::chart::PieChartBuilder;
pub use crate::chart::PieChartStyle;
pub use crate::data::calculate_bounds;
pub use crate::data::calculate_multi_series_bounds;
pub use crate::data::DataBounds;
pub use crate::data::DataPoint;
pub use crate::data::DataSeries;
pub use crate::data::FloatBounds;
pub use crate::data::IntBounds;
pub use crate::data::IntPoint;
pub use crate::data::MultiSeries;
pub use crate::data::Point2D;
pub use crate::data::StaticDataSeries;
pub use crate::data::TimestampedPoint;
pub use crate::data::SlidingWindowSeries;
pub use crate::data::streaming::ChartInstance;
pub use crate::data::streaming::ChartInstanceConfig;
pub use crate::data::streaming::ChartType;
pub use crate::data::streaming::ErrorRecovery;
pub use crate::data::streaming::ManagerConfig;
pub use crate::data::streaming::ManagerMetrics;
pub use crate::data::streaming::MemoryStrategy;
pub use crate::data::streaming::MonitoringLevel;
pub use crate::data::streaming::PipelineConfig;
pub use crate::data::streaming::PipelineMetrics;
pub use crate::data::streaming::SourceConfig;
pub use crate::data::streaming::SourceState;
pub use crate::data::streaming::StreamingChartManager;
pub use crate::data::streaming::StreamingConfig;
pub use crate::data::streaming::StreamingDataPipeline;
pub use crate::data::streaming::StreamingDataSource;
pub use crate::data::streaming::StreamingMetrics;
pub use crate::data::streaming::SyncMode;
pub use crate::data::streaming::SyncState;
pub use crate::data::streaming::UnifiedStreamingBuffer;
pub use crate::style::BorderStyle;
pub use crate::style::ColorInterpolation;
pub use crate::style::ColorPalette;
pub use crate::style::ColorUtils;
pub use crate::style::FillPattern;
pub use crate::style::FillStyle;
pub use crate::style::LineCap;
pub use crate::style::LineJoin;
pub use crate::style::LinePattern;
pub use crate::style::LineStyle;
pub use crate::style::StrokeStyle;
pub use crate::style::themes::Theme;
pub use crate::layout::ChartLayout;
pub use crate::layout::ComponentPositioning;
pub use crate::layout::Viewport;
pub use crate::render::ChartRenderer;
pub use crate::render::ClippingRenderer;
pub use crate::render::EnhancedChartRenderer;
pub use crate::render::PrimitiveRenderer;
pub use crate::render::AnimationFrameRenderer;
pub use crate::render::text::TextRenderer;
pub use crate::memory::ChartMemoryManager;
pub use crate::memory::FixedCapacityCollections;
pub use crate::memory::LabelStorage;
pub use crate::memory::ManagedSlidingWindow;
pub use crate::memory::MemoryStats;
pub use crate::error::ChartError;
pub use crate::error::ChartResult;
pub use crate::error::DataError;
pub use crate::error::DataResult;
pub use crate::error::LayoutError;
pub use crate::error::LayoutResult;
pub use crate::error::RenderError;
pub use crate::error::RenderResult;
pub use crate::error::AnimationError;
pub use crate::error::AnimationResult;
pub use crate::animation::ChartAnimator;
pub use crate::animation::EasingFunction;
pub use crate::animation::Interpolatable;
pub use crate::animation::MultiStateAnimator;
pub use crate::animation::Progress;
pub use crate::animation::StreamingAnimator;
pub use crate::animation::TimeBasedProgress;
pub use crate::time::ManualTimeProvider;
pub use crate::time::Microseconds;
pub use crate::time::Milliseconds;
pub use crate::time::MonotonicTimeProvider;
pub use crate::time::TimeProvider;
pub use crate::time::StdTimeProvider;
pub use crate::fluent::quick as fluent_quick;
pub use crate::fluent::Chart as FluentChart;
pub use crate::fluent::ChartPreset;
pub use crate::heapless_utils::sizes;
pub use crate::heapless_utils::string;
pub use crate::heapless_utils::vec;
pub use crate::heapless_utils::CircularBuffer;
pub use crate::heapless_utils::HeaplessConfig;
pub use crate::heapless_utils::HeaplessPool;

Modules§

constants
Commonly used constants
quick
Quick start functions for common chart types
types
Common type aliases for convenience

Macros§

chart_config
Macro for creating chart configurations with a fluent syntax.
data_points
Re-export the macros Utility macros for common operations
heapless_string
Create a heapless string with error handling
heapless_vec
Create a heapless vector from items

Structs§

Angle
Angle.
Circle
Circle primitive
Line
Line primitive
Pixel
A single pixel.
Point
2D point.
Rectangle
Rectangle primitive
Rgb565
Rgb565 color.
Size
2D size.
String
A fixed capacity String
Vec
A fixed capacity Vec

Enums§

BinaryColor
Binary color.

Traits§

AngleUnit
AngleUnit trait.
ContainsPoint
Trait to check if a point is inside a closed shape.
ContiguousIteratorExt
Extension trait for contiguous iterators.
Dimensions
Adds the ability to get the bounding box of an item.
DrawTarget
A target for embedded-graphics drawing operations.
DrawTargetExt
Extension trait for DrawTargets.
Drawable
Marks an object as “drawable”. Must be implemented for all graphics objects
GrayColor
Grayscale color.
ImageDrawable
Image drawable.
ImageDrawableExt
Extension trait for image drawables.
IntoStorage
Convert a PixelColor into its underlying storage type
OffsetOutline
Offset outline trait.
OriginDimensions
Dimensions with top_left of the bounding box at (0, 0).
PixelColor
Pixel color trait.
PixelIteratorExt
Extension trait for pixel iterators.
PointsIter
Create an iterator over all points in the primitive.
Primitive
Primitive trait
RawData
Trait implemented by all RawUx types.
RgbColor
RGB color.
Transform
Transform operations
WebColors
Named colors as defined in the CSS specification.
_
Trait to convert colors into a byte array.