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>
impl<C> CurveChart<C>
Sourcepub fn new() -> Self
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
Sourcepub fn builder() -> CurveChartBuilder<C>
pub fn builder() -> CurveChartBuilder<C>
Create a builder for configuring the curve chart.
Sourcepub fn set_interpolation_config(&mut self, config: InterpolationConfig)
pub fn set_interpolation_config(&mut self, config: InterpolationConfig)
Sourcepub fn interpolation_config(&self) -> &InterpolationConfig
pub fn interpolation_config(&self) -> &InterpolationConfig
Get the current interpolation configuration.
Sourcepub fn set_style(&mut self, style: LineChartStyle<C>)
pub fn set_style(&mut self, style: LineChartStyle<C>)
Set the line style configuration.
Sourcepub fn style(&self) -> &LineChartStyle<C>
pub fn style(&self) -> &LineChartStyle<C>
Get the current line style configuration.
Sourcepub fn set_config(&mut self, config: ChartConfig<C>)
pub fn set_config(&mut self, config: ChartConfig<C>)
Set the chart configuration.
Sourcepub fn config(&self) -> &ChartConfig<C>
pub fn config(&self) -> &ChartConfig<C>
Get the current chart configuration.
Sourcepub fn set_grid(&mut self, grid: Option<GridSystem<C>>)
pub fn set_grid(&mut self, grid: Option<GridSystem<C>>)
Set the grid system for the chart.
Sourcepub fn grid(&self) -> Option<&GridSystem<C>>
pub fn grid(&self) -> Option<&GridSystem<C>>
Get the current grid system configuration.
Sourcepub fn base_chart(&self) -> &LineChart<C>
pub fn base_chart(&self) -> &LineChart<C>
Get access to the underlying line chart for advanced configuration.
Sourcepub fn base_chart_mut(&mut self) -> &mut LineChart<C>
pub fn base_chart_mut(&mut self) -> &mut LineChart<C>
Get mutable access to the underlying line chart.