diff --git a/egui_demo_lib/src/apps/demo/plot_demo.rs b/egui_demo_lib/src/apps/demo/plot_demo.rs index d1c2dc6c..9fbac26b 100644 --- a/egui_demo_lib/src/apps/demo/plot_demo.rs +++ b/egui_demo_lib/src/apps/demo/plot_demo.rs @@ -382,7 +382,7 @@ impl Widget for &mut CustomAxisDemo { x.rem_euclid(MINS_PER_H).floor() } fn get_percent(y: f64) -> f64 { - (100.0 * y).round() + 100.0 * y } let x_fmt = |x, _range: &RangeInclusive| { @@ -401,7 +401,7 @@ impl Widget for &mut CustomAxisDemo { let y_fmt = |y, _range: &RangeInclusive| { // Display only integer percentages if !is_approx_zero(y) && is_approx_integer(100.0 * y) { - format!("{}%", get_percent(y)) + format!("{:.0}%", get_percent(y)) } else { String::new() } @@ -409,7 +409,7 @@ impl Widget for &mut CustomAxisDemo { let label_fmt = |_s: &str, val: &Value| { format!( - "Day {d}, {h}:{m:02}\n{p}%", + "Day {d}, {h}:{m:02}\n{p:.2}%", d = get_day(val.x), h = get_hour(val.x), m = get_minute(val.x), @@ -417,6 +417,8 @@ impl Widget for &mut CustomAxisDemo { ) }; + ui.label("Zoom in on the X-axis to see hours and minutes"); + Plot::new("custom_axes") .data_aspect(2.0 * MINS_PER_DAY as f32) .x_axis_formatter(x_fmt)