fn calc_layout_columns(
        width: usize,
        height: usize,
        som_rows: usize,
        som_cols: usize,
        data_columns: usize,
        heading: i32,
        legend: i32,
    ) -> (usize, i32) {
        if data_columns == 1 {
            let panel_width = width as f64 - legend as f64;
            let panel_height = height as f64 - heading as f64;

            let x_scale = panel_width / som_cols as f64;
            let y_scale = panel_height / som_rows as f64;
            let scale = (if x_scale < y_scale { x_scale } else { y_scale }) as i32;

            (1, scale)
        } else {
            (1..data_columns)
                .map(|cols| {
                    let layout_rows = (data_columns as f64 / cols as f64).ceil() as usize;
                    let panel_width = (width as f64 / cols as f64) - legend as f64;
                    let panel_height = (height as f64 / layout_rows as f64) - heading as f64;

                    let x_scale = panel_width / som_cols as f64;
                    let y_scale = panel_height / som_rows as f64;
                    let scale = (if x_scale < y_scale { x_scale } else { y_scale }) as i32;

                    (cols, scale)
                })
                .max_by(|(_col1, scale1), (_col2, scale2)| scale1.cmp(scale2))
                .unwrap()
        }
    }
/// Calculates the optimum number of layout columns.
Calculates the optimum number of layout columns.
Calculates the optimum number of layout columns .
fn calc_layout_columns(
        width: usize,
        height: usize,
        som_rows: usize,
        som_cols: usize,
        data_columns: usize,
        heading: i32,
        legend: i32,
    ) -> (usize, i32) {
        if data_columns == 1 {
            let panel_width = width as f64 - legend as f64;
            let panel_height = height as f64 - heading as f64;
            let x_scale = panel_width / som_cols as f64;
            let y_scale = panel_height / som_rows as f64;
            let scale = (if x_scale < y_scale { x_scale } else { y_scale }) as i32;
            (1, scale)
        } else {
            (1..data_columns)
                .map(|cols| {
                    let layout_rows = (data_columns as f64 / cols as f64).ceil() as usize;
                    let panel_width = (width as f64 / cols as f64) - legend as f64;
                    let panel_height = (height as f64 / layout_rows as f64) - heading as f64;
                    let x_scale = panel_width / som_cols as f64;
                    let y_scale = panel_height / som_rows as f64;
                    let scale = (if x_scale < y_scale { x_scale } else { y_scale }) as i32;
                    (cols, scale)
                })
                .max_by(|(_col1, scale1), (_col2, scale2)| scale1.cmp(scale2))
                .unwrap()
        }
    }
fn calc_layout_columns ( width : usize , height : usize , som_rows : usize , som_cols : usize , data_columns : usize , heading : i32 , legend : i32 , ) -> ( usize , i32 ) { if data_columns == 1 { let panel_width = width as f64 - legend as f64 ; let panel_height = height as f64 - heading as f64 ; let x_scale = panel_width / som_cols as f64 ; let y_scale = panel_height / som_rows as f64 ; let scale = ( if x_scale < y_scale { x_scale } else { y_scale } ) as i32 ; ( 1 , scale ) } else { ( 1 .. data_columns ) . map ( | cols | { let layout_rows = ( data_columns as f64 / cols as f64 ) . ceil ( ) as usize ; let panel_width = ( width as f64 / cols as f64 ) - legend as f64 ; let panel_height = ( height as f64 / layout_rows as f64 ) - heading as f64 ; let x_scale = panel_width / som_cols as f64 ; let y_scale = panel_height / som_rows as f64 ; let scale = ( if x_scale < y_scale { x_scale } else { y_scale } ) as i32 ; ( cols , scale ) } ) . max_by ( | ( _col1 , scale1 ) , ( _col2 , scale2 ) | scale1 . cmp ( scale2 ) ) . unwrap ( ) } }
Calculates the optimum number of layout columns.
Calculates the optimum number of layout columns .
width
usize
height
usize
som_rows
usize
som_cols
usize
data_columns
usize
heading
i32
legend
i32
width
usize
height
usize
som_rows
usize
som_cols
usize
data_columns
usize
heading
i32
legend
i32