pub struct XyTimeData { /* private fields */ }
Expand description
Animatable 2d line chart.
§Usage
Ensure the timechart
feature is enabled to use this type.
Creating the chart is very simple. You only need to provide 4 parameters, 3 of which are just strings.
points
: A slice of tuples, arranged so that the first float is the x position, the second the y position, and the third is the time the next point is to be shown at(or in the case of the last point, the time the animation ends).x_unit
: String describing the data on the X axis.y_unit
: String describing the data on the Y axis.caption
: String to be shown as the caption of the chart.
This will create a basic line chart with nothing fancy, which you can easily
add to your egui project. You can also animate this chart with .toggle_playback()
and adjust various parameters with the many .set_
functions included.
Implementations§
Source§impl XyTimeData
impl XyTimeData
Sourcepub fn new(
points: &[(f32, f32, f32)],
x_unit: &str,
y_unit: &str,
caption: &str,
) -> Self
pub fn new( points: &[(f32, f32, f32)], x_unit: &str, y_unit: &str, caption: &str, ) -> Self
Create a new XyTimeData chart. See Usage.
Sourcepub fn time(self, time: f32) -> Self
pub fn time(self, time: f32) -> Self
Set the time to resume playback at. Time is in seconds. Consumes self.
Sourcepub fn set_playback_speed(&mut self, speed: f32)
pub fn set_playback_speed(&mut self, speed: f32)
Set the playback speed. 1.0 is normal speed, 2.0 is double, & 0.5 is half.
Sourcepub fn playback_speed(self, speed: f32) -> Self
pub fn playback_speed(self, speed: f32) -> Self
Set the playback speed. 1.0 is normal speed, 2.0 is double, & 0.5 is half. Consumes self.
Sourcepub fn set_line_style(&mut self, line_style: ShapeStyle)
pub fn set_line_style(&mut self, line_style: ShapeStyle)
Set the style of the plotted line.
Sourcepub fn line_style(self, line_style: ShapeStyle) -> Self
pub fn line_style(self, line_style: ShapeStyle) -> Self
Set the style of the plotted line. Consumes self.
Sourcepub fn set_grid_style(&mut self, grid_style: ShapeStyle)
pub fn set_grid_style(&mut self, grid_style: ShapeStyle)
Set the style of the grid.
Sourcepub fn grid_style(self, grid_style: ShapeStyle) -> Self
pub fn grid_style(self, grid_style: ShapeStyle) -> Self
Set the style of the grid. Consumes self.
Sourcepub fn set_subgrid_style(&mut self, subgrid_style: ShapeStyle)
pub fn set_subgrid_style(&mut self, subgrid_style: ShapeStyle)
Set the style of the subgrid.
Sourcepub fn subgrid_style(self, subgrid_style: ShapeStyle) -> Self
pub fn subgrid_style(self, subgrid_style: ShapeStyle) -> Self
Set the style of the subgrid. Consumes self.
Sourcepub fn set_axes_style(&mut self, axes_style: ShapeStyle)
pub fn set_axes_style(&mut self, axes_style: ShapeStyle)
Set the style of the axes.
Sourcepub fn axes_style(self, axes_style: ShapeStyle) -> Self
pub fn axes_style(self, axes_style: ShapeStyle) -> Self
Set the style of the plotted line. Consumes self.
Sourcepub fn set_text_color<T>(&mut self, color: T)
pub fn set_text_color<T>(&mut self, color: T)
Set the text color of the chart.
Sourcepub fn text_color<T>(self, color: T) -> Self
pub fn text_color<T>(self, color: T) -> Self
Set the text color of the chart. Consumes self.
Sourcepub fn set_background_color<T>(&mut self, color: T)
pub fn set_background_color<T>(&mut self, color: T)
Set the background color of the chart.
Sourcepub fn background_color<T>(self, color: T) -> Self
pub fn background_color<T>(self, color: T) -> Self
Set the background color of the chart. Consumes self.
Sourcepub fn set_ratio(&mut self, ratio: f32)
pub fn set_ratio(&mut self, ratio: f32)
Set the ratio between X and Y values, default being 1 x unit to 1 y unit.
Sourcepub fn ratio(self, ratio: f32) -> Self
pub fn ratio(self, ratio: f32) -> Self
Set the ratio between X and Y values, default being 1 x unit to 1 y unit. Consumes self.
Sourcepub fn draw(&mut self, ui: &Ui)
pub fn draw(&mut self, ui: &Ui)
Draw the chart to a Ui. Will also proceed to animate the chart if playback is currently enabled.
Sourcepub fn start_playback(&mut self)
pub fn start_playback(&mut self)
Start/enable playback of the chart.
Sourcepub fn stop_playback(&mut self)
pub fn stop_playback(&mut self)
Stop/disable playback of the chart.
Sourcepub fn toggle_playback(&mut self)
pub fn toggle_playback(&mut self)
Toggle playback of the chart.
Sourcepub fn is_playing(&self) -> bool
pub fn is_playing(&self) -> bool
Return true if playback is currently enabled & underway.
Sourcepub fn start_time(&self) -> f32
pub fn start_time(&self) -> f32
Return the time the chart starts at when playback is enabled.
Sourcepub fn current_time(&mut self) -> f32
pub fn current_time(&mut self) -> f32
Return the current time to be animated when playback is enabled.
Sourcepub fn end_time(&self) -> f32
pub fn end_time(&self) -> f32
Return the time the chart finished animating at when playback is enabled.
Sourcepub fn get_playback_speed(&self) -> f32
pub fn get_playback_speed(&self) -> f32
Return the speed the chart is animated at.