Bar

Bar :: # (opaque)

A validated Plotly bar trace.

is_eq : _

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

new : Props -> Try(Bar, [InvalidBarWidth(F64), Infinity, NaN, NegativeInfinity])

Validate the width and construct one bar trace. Returns InvalidBarWidth(width) for a negative width, or NaN, Infinity, or NegativeInfinity for a nonfinite width. Coordinates are already checked by their opaque type; values and colors retain input order. Use Bar(trace) to include the result in Chart.Props.

expect {
    bars = Bar.new({ data: [{ x: "Apples", y: 3 }], name: "Sales" })?
    Chart.new({ traces: [Bar(bars)] }).to_json().contains("Sales")
}
to_json_value : Bar -> InternalJson

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

to_json : Bar -> Str

Serialize the trace as JSON.

Point

:= { x : Coordinate, y : Coordinate, color : Color ?? Color.rgb({ red: 31, green: 119, blue: 180 }) }

One bar's axis coordinates and fill color. x and y accept text or finite numeric Coordinate values. For Vertical, x locates the bar and y gives its height; Horizontal uses x for its length and y for its position. color sets this bar's fill and defaults to Plotly blue. Point order is preserved.

Props

:= {
    data : List(Point),
    orientation : [Vertical, Horizontal] ?? Vertical,
    name : Str ?? "",
    width : F64 ?? 0.75,
}

The complete bar series.

  • data contains bars in display order; an empty list is valid.
  • orientation defaults to Vertical; Horizontal swaps axis roles.
  • name is the legend/hover label, and may be empty.
  • width is measured in position-axis units, defaults to 0.75, and may exceed one. It must be finite and nonnegative; zero hides bars.