diff --git a/plotters/src/coord/ranged1d/types/numeric.rs b/plotters/src/coord/ranged1d/types/numeric.rs index 8a9ab2d6..e648aa04 100644 --- a/plotters/src/coord/ranged1d/types/numeric.rs +++ b/plotters/src/coord/ranged1d/types/numeric.rs @@ -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) => { @@ -268,6 +268,17 @@ impl ValueFormatter for RangedCoordf32 { .print(*value as f64) } } +impl ValueFormatter for WithKeyPoints { + 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, @@ -286,6 +297,16 @@ impl ValueFormatter for RangedCoordf64 { .print(*value) } } +impl ValueFormatter for WithKeyPoints { + 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,