Currently the chart relies on the following trait bounds for the given data:
Data: IntoIterator<Item = Item> + Clone,
Item: Into<(f32, f32)>
An alternative solution is to provide &dyn Fn(&Item) -> f32 for x and y, like PointSeries does currently.
impl PointSeries {
// ...
pub fn x(mut self, x_fn: &'a dyn Fn(&Item) -> f32) -> Self {
self.x_fn = Some(x_fn);
self
}
pub fn y(mut self, y_fn: &'a dyn Fn(&Item) -> f32) -> Self {
self.y_fn = Some(y_fn);
self
}
}
// usage
point_series(&data)
.x(&|item| item.x_value)
.y(&|item| item.y_value)
Todo: Compare performance.
Currently the chart relies on the following trait bounds for the given data:
An alternative solution is to provide
&dyn Fn(&Item) -> f32forxandy, likePointSeriesdoes currently.Todo: Compare performance.