Skip to content

Commit

Permalink
Filter grid marks in visible range
Browse files Browse the repository at this point in the history
  • Loading branch information
YgorSouza committed May 29, 2024
1 parent 780c7c8 commit 6233339
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions examples/plot_log_scale/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,21 @@ fn log_axis_spacer(input: GridInput) -> Vec<GridMark> {
let (min, max) = input.bounds;
let mut marks = vec![];
for i in min.floor() as i32..=max.ceil() as i32 {
marks.extend((10..100).map(|j| {
let value = i as f64 + (j as f64).log10() - 1.0;
let step_size = if j == 10 {
1.0
} else if j % 10 == 0 {
0.1
} else {
0.01
};
GridMark { value, step_size }
}));
marks.extend(
(10..100)
.map(|j| {
let value = i as f64 + (j as f64).log10() - 1.0;
let step_size = if j == 10 {
1.0
} else if j % 10 == 0 {
0.1
} else {
0.01
};
GridMark { value, step_size }
})
.filter(|gm| (min..=max).contains(&gm.value)),
);
}
marks
}
Expand Down

0 comments on commit 6233339

Please sign in to comment.