MCPcopy Create free account
hub / github.com/elftausend/graplot / draw_bars

Function draw_bars

src/render/bar.rs:41–57  ·  view source on GitHub ↗
(x_level: f32, ys: &[f64], bar: &Bar)

Source from the content-addressed store, hash-verified

39}
40
41pub async fn draw_bars(x_level: f32, ys: &[f64], bar: &Bar) {
42 let mut line_x = DISTANCE;
43 let mut bar_x = DISTANCE + 20.;
44 for (bar_entity, y) in bar.bars.iter().zip(ys) {
45 let y = *y as f32;
46 draw_rectangle(bar_x, x_level-bar.desc.spacing_y * y, bar_entity.width, bar.desc.spacing_y * y, bar_entity.color);
47
48 line_x += bar_entity.width / 2. + 20.;
49 draw_line(line_x, x_level-6., line_x, x_level+6., COORD_THICKNESS, BLACK);
50
51 let text_pos = line_x - bar_entity.label.len() as f32 * (10. / 2.) + COORD_THICKNESS;
52
53 draw_text(&bar_entity.label, text_pos, x_level + 20. / 2. + 8., 20., BLACK);
54 line_x += bar_entity.width / 2.;
55 bar_x += bar_entity.width + 20.;
56 }
57}
58
59pub async fn negative_only(bar: Bar, step_y: f64, y_half_font: f32, y_font_size: f32, max_y: f64, ys: Vec<f64>) {
60 loop {

Callers 3

negative_onlyFunction · 0.85
positive_negativeFunction · 0.85
positive_onlyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected