Expand description
A high-performance plotting library for Iced applications.
iced_aksel provides interactive charts and plots for the Iced GUI framework,
built on top of the aksel plotting core. It offers flexible axis configuration,
multiple shape primitives, and robust interaction handling.
§Quick Start
To create a simple chart, you need to:
- Define your
State(which stores axes configuration). - Implement
PlotDatafor your data type. - Instantiate the
Chartwidget in your view logic.
use iced_aksel::{
Chart, State, Axis, Plot, PlotPoint, axis, scale::Linear,
plot::PlotData, shape::Ellipse, Measure
};
use iced::{Element, Theme};
struct App {
chart_state: State<&'static str, f64>,
data: ScatterData,
}
#[derive(Debug, Clone)]
enum Message {}
impl App {
fn new() -> Self {
let mut chart_state = State::new();
// Register axes with unique IDs
chart_state.set_axis("x", Axis::new(Linear::new(0.0, 100.0), axis::Position::Bottom));
chart_state.set_axis("y", Axis::new(Linear::new(0.0, 100.0), axis::Position::Left));
Self {
chart_state,
data: ScatterData {
points: vec![
PlotPoint::new(10.0, 20.0),
PlotPoint::new(50.0, 80.0),
],
},
}
}
fn view(&self) -> Element<Message> {
// Render the chart using the persistent state
Chart::new(&self.chart_state)
.plot_data(&self.data, "x", "y")
.into()
}
}
// Your data struct
struct ScatterData {
points: Vec<PlotPoint<f64>>,
}
// Implement PlotData to define how your data is drawn
impl PlotData<f64> for ScatterData {
fn draw(&self, plot: &mut Plot<f64>, theme: &Theme) {
for point in &self.points {
plot.add_shape(
Ellipse::new(*point, Measure::Screen(5.0), Measure::Screen(5.0))
.fill(theme.palette().primary)
);
}
}
}§Core Concepts
Chart: The main widget that renders axes and data. It handles layout and user events.State: A persistent struct that manages axis configuration. You should store this in your application’s state.Axis: Configures scales (Linear, Log), ticks, grid lines, and labels.PlotData: A trait you implement for your own data types to define how they should be rendered.Shape: Visual primitives (lines, circles, rectangles) used withinPlotData::draw.
Re-exports§
pub use axis::Axis;pub use interaction::Interaction;pub use plot::Plot;pub use plot::PlotData;pub use radii::Radii;pub use radii::Radius;pub use shape::Shape;pub use stroke::Stroke;pub use style::Catalog;
Modules§
- axis
- Axis configuration, layout, and rendering logic.
- interaction
- Interaction module
- plot
- Plot rendering and data traits.
- radii
- Radii type implementation
- scale
- Scale types for mapping data values to normalized ranges.
- shape
- Shape primitives for rendering on plots.
- stroke
- Types for describing Stroke around a rendered object
- style
- Styling configuration and theming for Charts.
- transform
- Coordinate transformations between screen space and plot space.
Structs§
- Cached
- A versioned wrapper that caches
PlotDataacross frames. - Chart
- The main charting widget that renders axes and plot data.
- Delta
- Normalized drag delta for panning operations.
- Direct
Marker - Direct marker for messages
- Drag
Event - An event omitted for
on_draghandlers - Enter
Event - An event omitted for
on_enterhandlers - Exit
Event - An event omitted for
on_exithandlers - FnMarker
- Fn marker for closures
- LayerId
- An ID for a layer
- Move
Event - An event omitted for
on_movehandlers - Plot
Point - A point in plot/chart coordinates.
- Press
Event - An event omitted for
on_pressevents - Release
Event - An event omitted for
on_releasehandlers - Scroll
Event - An event omitted for
on_scrollhandlers - State
- Manages the configuration and runtime state of chart axes.
- Transform
- Transforms coordinates between screen space and plot/chart space.
Enums§
- Error
- Errors that can occur during chart construction or rendering.
- Handler
- A handler that can either be a direct
Messageor a closure with arguments - Measure
- Defines how a dimension should be interpreted by the chart.
- Quality
- The rendering quality of a buffer.
Traits§
- Float
- Generic trait for floating point numbers
- Into
Handler - Converts direct messages or closures into a
Handler - Renderer
- Renderer requirements for plotting.
- Scale
- Trait for mapping between a data domain and a normalized [0, 1] range.