Skip to content

Commit

Permalink
Merge pull request #653 from oldgalileo/master
Browse files Browse the repository at this point in the history
Fix WithKeyPoints for f32 / f64 ranges
  • Loading branch information
AaronErhardt authored Nov 8, 2024
2 parents 1f174c8 + 6268a7f commit 48ed63f
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions plotters/src/coord/ranged1d/types/numeric.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::convert::TryFrom;
use std::ops::Range;

use crate::coord::ranged1d::{
use crate::coord::{combinators::WithKeyPoints, ranged1d::{
AsRangedCoord, DefaultFormatting, DiscreteRanged, KeyPointHint, NoDefaultFormatting, Ranged,
ReversibleRanged, ValueFormatter,
};
}};

macro_rules! impl_discrete_trait {
($name:ident) => {
Expand Down Expand Up @@ -268,6 +268,17 @@ impl ValueFormatter<f32> for RangedCoordf32 {
.print(*value as f64)
}
}
impl ValueFormatter<f32> for WithKeyPoints<RangedCoordf32> {
fn format(value: &f32) -> String {
crate::data::float::FloatPrettyPrinter {
allow_scientific: false,
min_decimal: 1,
max_decimal: 5,
}
.print(*value as f64)
}
}

make_numeric_coord!(
f64,
RangedCoordf64,
Expand All @@ -286,6 +297,16 @@ impl ValueFormatter<f64> for RangedCoordf64 {
.print(*value)
}
}
impl ValueFormatter<f64> for WithKeyPoints<RangedCoordf64> {
fn format(value: &f64) -> String {
crate::data::float::FloatPrettyPrinter {
allow_scientific: false,
min_decimal: 1,
max_decimal: 5,
}
.print(*value)
}
}
make_numeric_coord!(
u32,
RangedCoordu32,
Expand Down

0 comments on commit 48ed63f

Please sign in to comment.