pub mod colors;
pub mod day;
pub mod histogram;
pub mod legend;
pub mod pie;
pub mod pie_data;
pub mod tag_percent;
pub use colors::ColorIter;
pub use day::DayHours;
pub use histogram::BarGraph;
pub use legend::Legend;
pub use pie::PieChart;
pub use pie_data::PieData;
pub use tag_percent::Percent;
pub use tag_percent::TagPercent;
pub type Percentages = Vec<TagPercent>;
pub(crate) mod utils {
pub(crate) fn format_coord(coord: f32) -> String {
let s = format!("{coord:.3}");
s.trim_end_matches('0').trim_end_matches('.').to_string()
}
}
#[cfg(test)]
mod tests {
use assert2::assert;
use rstest::rstest;
use super::utils::*;
#[rstest]
#[case(0.0, "0", "zero")]
#[case(1.2345678, "1.235", "three decimal")]
#[case(10.5, "10.5", "half")]
#[case(10.25, "10.25", "quarter")]
fn test_format_coord(#[case]coord: f32, #[case]expected: &str, #[case]msg: &str) {
assert!(format_coord(coord).as_str() == expected, "{msg}");
}
}