fn calculate_vertical_scaling(draw_info: &mut DrawInfo) {
    const MIN_PADDING: f32 = HEIGHT / 24.0;
    const MAX_CONTENT_HEIGHT: f32 = HEIGHT - MIN_PADDING * 2.0;
    // The bigger this value, the longer it will take for padding_y to get close
    // to MIN_PADDING.
    const SMOOTHNESS: f32 = 0.2;

    let total_delta = draw_info.max_delta - draw_info.min_delta;
    if total_delta > 0.0 {
        // A hyperbola works well, this looks something like f(x) = 1/(x + 2)
        draw_info.padding_y =
            MAX_CONTENT_HEIGHT * SMOOTHNESS / (total_delta + SMOOTHNESS * 2.0) + MIN_PADDING;

        let content_height = HEIGHT - draw_info.padding_y * 2.0;
        draw_info.scale_factor_y = Some(content_height / total_delta);
    }

    // Else padding_y stays 0 and scale_factor_y stays None, because vertical
    // scaling doesn't matter if all the points are at y=0.
}
/// Calculates the size of the chart's padding and its vertical scale factor.
/// The padding is an area at the top/bottom that stays empty so that the graph
/// doesn't touch the edge of the chart. This value depends on
/// `min_`/`max_delta` because otherwise the scale factor would be huge for
/// small graphs (graphs with only small deltas).
Calculates the size of the chart's padding and its vertical scale factor.
The padding is an area at the top/bottom that stays empty so that the graph
doesn't touch the edge of the chart. This value depends on
`min_`/`max_delta` because otherwise the scale factor would be huge for
small graphs (graphs with only small deltas).
Calculates the size of the chart ' s padding and its vertical scale factor . The padding is an area at the top / bottom that stays empty so that the graph doesn ' t touch the edge of the chart . This value depends on ` min_ ` / ` max_delta ` because otherwise the scale factor would be huge for small graphs ( graphs with only small deltas ) .
fn calculate_vertical_scaling(draw_info: &mut DrawInfo) {
    const MIN_PADDING: f32 = HEIGHT / 24.0;
    const MAX_CONTENT_HEIGHT: f32 = HEIGHT - MIN_PADDING * 2.0;
    // The bigger this value, the longer it will take for padding_y to get close
    // to MIN_PADDING.
    const SMOOTHNESS: f32 = 0.2;
    let total_delta = draw_info.max_delta - draw_info.min_delta;
    if total_delta > 0.0 {
        // A hyperbola works well, this looks something like f(x) = 1/(x + 2)
        draw_info.padding_y =
            MAX_CONTENT_HEIGHT * SMOOTHNESS / (total_delta + SMOOTHNESS * 2.0) + MIN_PADDING;
        let content_height = HEIGHT - draw_info.padding_y * 2.0;
        draw_info.scale_factor_y = Some(content_height / total_delta);
    }
    // Else padding_y stays 0 and scale_factor_y stays None, because vertical
    // scaling doesn't matter if all the points are at y=0.
}
fn calculate_vertical_scaling ( draw_info : & mut DrawInfo ) { const MIN_PADDING : f32 = HEIGHT / 24.0 ; const MAX_CONTENT_HEIGHT : f32 = HEIGHT - MIN_PADDING * 2.0 ; // The bigger this value, the longer it will take for padding_y to get close // to MIN_PADDING. const SMOOTHNESS : f32 = 0.2 ; let total_delta = draw_info . max_delta - draw_info . min_delta ; if total_delta > 0.0 { // A hyperbola works well, this looks something like f(x) = 1/(x + 2) draw_info . padding_y = MAX_CONTENT_HEIGHT * SMOOTHNESS / ( total_delta + SMOOTHNESS * 2.0 ) + MIN_PADDING ; let content_height = HEIGHT - draw_info . padding_y * 2.0 ; draw_info . scale_factor_y = Some ( content_height / total_delta ) ; } // Else padding_y stays 0 and scale_factor_y stays None, because vertical // scaling doesn't matter if all the points are at y=0. }
Calculates the size of the chart's padding and its vertical scale factor.
Calculates the size of the chart ' s padding and its vertical scale factor .
draw_info
&mut DrawInfo
draw_info
&mut DrawInfo