Skip to content

Commit c8586b8

Browse files
Copilotgfauredev
andcommitted
Fix edge case in chart X-axis labels calculation
Co-authored-by: gfauredev <19304085+gfauredev@users.noreply.github.com>
1 parent 3d1374d commit c8586b8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/components/analytics_panel.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,11 @@ fn ChartView(data: Vec<(String, Vec<(f64, f64)>)>, metric: Metric, colors: Vec<&
394394

395395
// X-axis labels
396396
{
397-
let num_labels = 4.min(data.iter().map(|(_, points)| points.len()).max().unwrap_or(0));
397+
let num_labels = 4.min(data.iter().map(|(_, points)| points.len()).max().unwrap_or(0)).max(2);
398398
rsx! {
399399
for i in 0..num_labels {
400400
{
401-
let x_val = min_x + (max_x - min_x) * (i as f64 / (num_labels - 1).max(1) as f64);
401+
let x_val = min_x + (max_x - min_x) * (i as f64 / (num_labels - 1) as f64);
402402
let x_pos = scale_x(x_val);
403403

404404
rsx! {

0 commit comments

Comments
 (0)