Skip to content

Test different data interfaces #3

Description

@kunerd

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions