Components / Histogram

Histogram

Overlapping channels from ready-made bins, linear or logarithmic, with clip marks.

Example

The component itself, running in WebAssembly, beside its code in a playground. Try it.

Code

use ravenrs::prelude::*;

fn histogram() -> impl View {
    let hill = |center: f32| -> Vec<f32> {
        (0..256).map(|i| 400.0 * (-((i as f32 - center) / 40.0).powi(2)).exp() + 10.0).collect()
    };
    Histogram::new([
        HistogramChannel::new("Red", Color::rgb(0.9, 0.15, 0.15), hill(90.0)),
        HistogramChannel::new("Green", Color::rgb(0.15, 0.8, 0.2), hill(128.0)),
        HistogramChannel::new("Blue", Color::rgb(0.2, 0.3, 0.95), hill(170.0)),
    ])
    .zones(5)
    .height(110.0)
}

Open in the playground, with every example →

Full API of Histogram →