Histogram

Histogram :: # (opaque)

A validated Plotly histogram, which counts raw values into bins in the browser. For values already counted elsewhere, draw the counts with Bar instead, which sends one number per bin rather than every value.

is_eq : _

Compare the encoded trace, including input order and all style settings.

new : Props -> Try(Histogram, [InvalidBinCount(U16), InvalidBins({ start : F64, end : F64, size : F64 }), Infinity, NaN, NegativeInfinity])

Validate the bins and construct a histogram trace. Returns InvalidBinCount(count) for AtMost(0), and InvalidBins({ start, end, size }) for fixed bins whose numbers are nonfinite, whose size is not positive or whose end is not after the start.

expect {
    spread = Histogram.new({ values: [1, 2, 2, 3], bins: AtMost(10) })?
    spread.to_json().contains("nbinsx")
}
to_json_value : Histogram -> InternalJson

Internal composition hook used by Plume's renderers. Applications normally use Histogram.to_json for complete JSON text; this returns the package's safe internal value without accepting raw JSON.

to_json : Histogram -> Str

Serialize the trace as JSON.

Bins : [Auto, AtMost(U16), Fixed({ start : F64, end : F64, size : F64 })]

Choose the bins. Auto lets Plotly choose. AtMost(count) asks for at most count bins, with Plotly choosing round boundaries. Fixed({ start, end, size }) places bins of size from start to end on a numeric axis.

Normalization : [Counts, Percent, Probability, Density, ProbabilityDensity]

Choose what a bar's length measures. Counts is the number of values in the bin, Percent and Probability its share of all values, Density the count divided by the bin's width, and ProbabilityDensity the share divided by it.

Props

:= {
    values : List(Coordinate),
    name : Str ?? "",
    orientation : [Vertical, Horizontal] ?? Vertical,
    bins : Bins ?? Auto,
    normalization : Normalization ?? Counts,
    color : Color ?? Color.rgb({ red: 31, green: 119, blue: 180 }),
}

Configure a histogram. values are the raw observations, which may be empty; text values are counted as categories. orientation defaults to Vertical, with bins along x; Horizontal places them along y. bins defaults to Auto, normalization to Counts, and color to Plotly blue. name is the legend/hover label, and may be empty.