Skip to main content

prepare_chart_data

Function prepare_chart_data 

Source
pub fn prepare_chart_data(
    lf: &LazyFrame,
    schema: &Schema,
    x_column: &str,
    y_columns: &[String],
    sampling: &ChartSampling,
    envelope: bool,
) -> Result<ChartDataResult>
Expand description

Prepares XY series from the current LazyFrame. X is cast to f64 (temporal types as ordinal). Nulls are dropped per series: a null X drops the row, a null Y drops that series’ point and breaks its line. Points come in X order, so a line runs left to right whatever order the rows are in; ties keep table order.

With envelope, a view of more rows than the sample size is not sampled: X is cut into half that many steps and each step draws its lowest and highest Y. A random sample of a waveform or any long series joins points far apart and misses its peaks; the envelope keeps every peak, as many steps as a plot has columns. It reads the view twice, so only where ChartSampling::full_passes allows; both passes stop when ChartSampling::cancel is set.