Skip to content

Commit 48ed63f

Browse files
authored
Merge pull request #653 from oldgalileo/master
Fix WithKeyPoints for f32 / f64 ranges
2 parents 1f174c8 + 6268a7f commit 48ed63f

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

plotters/src/coord/ranged1d/types/numeric.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::convert::TryFrom;
22
use std::ops::Range;
33

4-
use crate::coord::ranged1d::{
4+
use crate::coord::{combinators::WithKeyPoints, ranged1d::{
55
AsRangedCoord, DefaultFormatting, DiscreteRanged, KeyPointHint, NoDefaultFormatting, Ranged,
66
ReversibleRanged, ValueFormatter,
7-
};
7+
}};
88

99
macro_rules! impl_discrete_trait {
1010
($name:ident) => {
@@ -268,6 +268,17 @@ impl ValueFormatter<f32> for RangedCoordf32 {
268268
.print(*value as f64)
269269
}
270270
}
271+
impl ValueFormatter<f32> for WithKeyPoints<RangedCoordf32> {
272+
fn format(value: &f32) -> String {
273+
crate::data::float::FloatPrettyPrinter {
274+
allow_scientific: false,
275+
min_decimal: 1,
276+
max_decimal: 5,
277+
}
278+
.print(*value as f64)
279+
}
280+
}
281+
271282
make_numeric_coord!(
272283
f64,
273284
RangedCoordf64,
@@ -286,6 +297,16 @@ impl ValueFormatter<f64> for RangedCoordf64 {
286297
.print(*value)
287298
}
288299
}
300+
impl ValueFormatter<f64> for WithKeyPoints<RangedCoordf64> {
301+
fn format(value: &f64) -> String {
302+
crate::data::float::FloatPrettyPrinter {
303+
allow_scientific: false,
304+
min_decimal: 1,
305+
max_decimal: 5,
306+
}
307+
.print(*value)
308+
}
309+
}
289310
make_numeric_coord!(
290311
u32,
291312
RangedCoordu32,

0 commit comments

Comments
 (0)