CurveChart

Struct CurveChart 

Source
pub struct CurveChart<C: PixelColor> { /* private fields */ }
Expand description

A smooth curve chart that uses interpolation to create fluid curves from discrete data points.

This chart type builds upon the LineChart foundation but adds sophisticated curve interpolation capabilities including cubic splines, Catmull-Rom curves, and Bezier curves. It automatically generates additional points between input data to create smooth, visually appealing curves.

§Features

  • Multiple interpolation algorithms (cubic spline, Catmull-Rom, Bezier, linear)
  • Configurable curve smoothness and tension
  • Memory-efficient implementation suitable for embedded systems
  • Integration with existing chart styling and theming
  • Support for markers, area fills, and grid systems

§Examples

Basic smooth curve:

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

let chart = CurveChart::builder()
    .line_color(Rgb565::BLUE)
    .interpolation_type(InterpolationType::CubicSpline)
    .subdivisions(12)
    .build()?;

Artistic Bezier curves:

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

let chart = CurveChart::builder()
    .line_color(Rgb565::GREEN)
    .interpolation_type(InterpolationType::Bezier)
    .tension(0.8)
    .subdivisions(16)
    .with_markers(MarkerStyle::default())
    .build()?;

Implementations§

Source§

impl<C> CurveChart<C>
where C: From<Rgb565> + PixelColor + 'static,

Source

pub fn new() -> Self

Create a new curve chart with default settings.

Creates a curve chart with:

  • Cubic spline interpolation
  • 8 subdivisions per segment
  • Medium tension (0.5)
  • Default line chart styling
Source

pub fn builder() -> CurveChartBuilder<C>

Create a builder for configuring the curve chart.

Source

pub fn set_interpolation_config(&mut self, config: InterpolationConfig)

Set the interpolation configuration.

§Arguments
  • config - The interpolation configuration to use
Source

pub fn interpolation_config(&self) -> &InterpolationConfig

Get the current interpolation configuration.

Source

pub fn set_style(&mut self, style: LineChartStyle<C>)

Set the line style configuration.

Source

pub fn style(&self) -> &LineChartStyle<C>

Get the current line style configuration.

Source

pub fn set_config(&mut self, config: ChartConfig<C>)

Set the chart configuration.

Source

pub fn config(&self) -> &ChartConfig<C>

Get the current chart configuration.

Source

pub fn set_grid(&mut self, grid: Option<GridSystem<C>>)

Set the grid system for the chart.

Source

pub fn grid(&self) -> Option<&GridSystem<C>>

Get the current grid system configuration.

Source

pub fn base_chart(&self) -> &LineChart<C>

Get access to the underlying line chart for advanced configuration.

Source

pub fn base_chart_mut(&mut self) -> &mut LineChart<C>

Get mutable access to the underlying line chart.

Trait Implementations§

Source§

impl<C> Chart<C> for CurveChart<C>
where C: From<Rgb565> + PixelColor + 'static,

Source§

type Data = StaticDataSeries<Point2D, 256>

The type of data this chart can render
Source§

type Config = ChartConfig<C>

Configuration type for this chart
Source§

fn draw<D>( &self, data: &Self::Data, config: &Self::Config, viewport: Rectangle, target: &mut D, ) -> ChartResult<()>
where D: DrawTarget<Color = C>, Self::Data: DataSeries, <Self::Data as DataSeries>::Item: DataPoint, <<Self::Data as DataSeries>::Item as DataPoint>::X: Into<f32> + Copy + PartialOrd, <<Self::Data as DataSeries>::Item as DataPoint>::Y: Into<f32> + Copy + PartialOrd,

Draw the chart to the target display Read more
Source§

fn data_bounds(&self, _data: &Self::Data) -> ChartResult<()>

Get the data bounds for this chart
Source§

impl<C: Debug + PixelColor> Debug for CurveChart<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C> Default for CurveChart<C>
where C: From<Rgb565> + PixelColor + 'static,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<C> Freeze for CurveChart<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for CurveChart<C>
where C: RefUnwindSafe,

§

impl<C> Send for CurveChart<C>
where C: Send,

§

impl<C> Sync for CurveChart<C>
where C: Sync,

§

impl<C> Unpin for CurveChart<C>
where C: Unpin,

§

impl<C> UnwindSafe for CurveChart<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.