pub fn plot(&self, axis_positions: &[f64], bar_values: &[f64]) {
        let number_of_points = axis_positions.len().min(bar_values.len());
        // If there is no data to plot, we stop here
        if number_of_points == 0 {
            return;
        }
        unsafe {
            // C++ implot has separate functions for the two variants, but the interfaces
            // are the same, so they are unified here. The x and y values have different
            // meanings though, hence the swapping around before they are passed to the
            // plotting function.
            let (plot_function, x, y);
            if self.horizontal_bars {
                plot_function = sys::ImPlot_PlotBarsHdoublePtrdoublePtr
                    as unsafe extern "C" fn(
                        *const c_char,
                        *const f64,
                        *const f64,
                        i32,
                        f64,
                        i32,
                        i32,
                    );
                x = bar_values;
                y = axis_positions;
            } else {
                plot_function = sys::ImPlot_PlotBarsdoublePtrdoublePtr
                    as unsafe extern "C" fn(
                        *const c_char,
                        *const f64,
                        *const f64,
                        i32,
                        f64,
                        i32,
                        i32,
                    );
                x = axis_positions;
                y = bar_values;
            };

            plot_function(
                self.label.as_ptr() as *const c_char,
                x.as_ptr(),
                y.as_ptr(),
                number_of_points as i32, // "as" casts saturate as of Rust 1.45. This is safe here.
                self.bar_width,
                0,                                 // No offset
                std::mem::size_of::<f64>() as i32, // Stride, set to one f64 for the standard use case
            );
        }
    }
/// Draw a previously-created bar plot. Use this in closures passed to
/// [`Plot::build()`](struct.Plot.html#method.build). The `axis_positions`
/// specify where on the corresponding axis (X for vertical mode, Y for horizontal mode) the
/// bar is drawn, and the `bar_values` specify what values the bars have.
Draw a previously-created bar plot.
Draw a previously - created bar plot .
pub fn plot(&self, axis_positions: &[f64], bar_values: &[f64]) {
        let number_of_points = axis_positions.len().min(bar_values.len());
        // If there is no data to plot, we stop here
        if number_of_points == 0 {
            return;
        }
        unsafe {
            // C++ implot has separate functions for the two variants, but the interfaces
            // are the same, so they are unified here. The x and y values have different
            // meanings though, hence the swapping around before they are passed to the
            // plotting function.
            let (plot_function, x, y);
            if self.horizontal_bars {
                plot_function = sys::ImPlot_PlotBarsHdoublePtrdoublePtr
                    as unsafe extern "C" fn(
                        *const c_char,
                        *const f64,
                        *const f64,
                        i32,
                        f64,
                        i32,
                        i32,
                    );
                x = bar_values;
                y = axis_positions;
            } else {
                plot_function = sys::ImPlot_PlotBarsdoublePtrdoublePtr
                    as unsafe extern "C" fn(
                        *const c_char,
                        *const f64,
                        *const f64,
                        i32,
                        f64,
                        i32,
                        i32,
                    );
                x = axis_positions;
                y = bar_values;
            };
            plot_function(
                self.label.as_ptr() as *const c_char,
                x.as_ptr(),
                y.as_ptr(),
                number_of_points as i32, // "as" casts saturate as of Rust 1.45. This is safe here.
                self.bar_width,
                0,                                 // No offset
                std::mem::size_of::<f64>() as i32, // Stride, set to one f64 for the standard use case
            );
        }
    }
pub fn plot ( & self , axis_positions : & [ f64 ] , bar_values : & [ f64 ] ) { let number_of_points = axis_positions . len ( ) . min ( bar_values . len ( ) ) ; // If there is no data to plot, we stop here if number_of_points == 0 { return ; } unsafe { // C++ implot has separate functions for the two variants, but the interfaces // are the same, so they are unified here. The x and y values have different // meanings though, hence the swapping around before they are passed to the // plotting function. let ( plot_function , x , y ) ; if self . horizontal_bars { plot_function = sys :: ImPlot_PlotBarsHdoublePtrdoublePtr as unsafe extern " " fn ( * const c_char , * const f64 , * const f64 , i32 , f64 , i32 , i32 , ) ; x = bar_values ; y = axis_positions ; } else { plot_function = sys :: ImPlot_PlotBarsdoublePtrdoublePtr as unsafe extern " " fn ( * const c_char , * const f64 , * const f64 , i32 , f64 , i32 , i32 , ) ; x = axis_positions ; y = bar_values ; } ; plot_function ( self . label . as_ptr ( ) as * const c_char , x . as_ptr ( ) , y . as_ptr ( ) , number_of_points as i32 , // "as" casts saturate as of Rust 1.45. This is safe here. self . bar_width , 0 , // No offset std :: mem :: size_of :: < f64 > ( ) as i32 , // Stride, set to one f64 for the standard use case ) ; } }
Draw a previously-created bar plot.
Draw a previously - created bar plot .
&self
axis_positions
&[f64]
bar_values
&[f64]
&self
axis_positions
&[f64]
bar_values
&[f64]