flat

Crates.ioflat
lib.rsflat
version0.1.6
sourcesrc
created_at2024-07-03 01:47:05.187172
updated_at2024-10-19 18:17:54.634348
descriptionProject multi-dimensional data onto the **flat** textual plane.
homepage
repositoryhttps://github.com/sawatzkylindsey/flat
max_upload_size
id1290099
size399,604
Lindsey Sawatzky (sawatzkylindsey)

documentation

README

flat

Project multi-dimensional data onto the flat textual plane.

use flat::*;

let schema = Schemas::three("animal", "length", "stable");
let dataset = Dataset::builder(schema)
    .add(("whale".to_string(), 4u32, true))
    .add(("shark".to_string(), 4u32, false))
    .add(("shark".to_string(), 1u32, false))
    .add(("shark".to_string(), 1u32, true))
    .add(("shark".to_string(), 1u32, true))
    .add(("shark".to_string(), 1u32, true))
    .add(("tiger".to_string(), 4u32, false))
    .add(("tiger".to_string(), 4u32, false))
    .add(("tiger".to_string(), 5u32, true))
    .add(("tiger".to_string(), 5u32, true))
    .add(("tiger".to_string(), 5u32, true))
    .add(("tiger".to_string(), 5u32, true))
    .add(("tiger".to_string(), 5u32, true))
    .add(("tiger".to_string(), 5u32, true))
    .add(("tiger".to_string(), 1u32, false))
    .add(("tiger".to_string(), 1u32, false))
    .add(("tiger".to_string(), 1u32, false))
    .build();
let view = dataset.breakdown_3rd();
let flat = BarChart::new(&view).render(Render::default());
assert_eq!(
    format!("\n{}", flat.to_string()),
    r#"
                   Sum(Breakdown(stable))
length    animal  |false   true |
1       - shark   |  **    ***  |
4       ┘
1       ┐
4       - tiger   |*****  ******|
5       ┘
4       - whale   |         *   |"#
);
Commit count: 55

cargo fmt