Shape

Shape :: # (opaque)

A reference line or shaded band drawn across the plotting area, such as an incident on a timeline or a target value. Add shapes to a chart with Layout.Props's shapes.

is_eq : _

Compare the encoded shape, including all style settings.

new : Props -> Shape

Construct a shape from already validated coordinates and styles. This function is infallible.

expect {
    incident = Shape.new({ placement: VerticalLine("2026-11-11 12:05"), label: "Deploy" })
    incident.to_json().contains("Deploy")
}
to_json_value : Shape -> InternalJson

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

to_json : Shape -> Str

Serialize the shape as JSON.

Placement : [
    VerticalLine(Coordinate),
    HorizontalLine(Coordinate),
    VerticalBand({ start : Coordinate, end : Coordinate }),
    HorizontalBand({ start : Coordinate, end : Coordinate }),
]

Where the shape lies, in the coordinates of the x or y axis. VerticalLine(x) crosses the full height of the plotting area at x, and HorizontalLine(y) crosses its full width at y. VerticalBand({ start, end }) shades the full height between two x positions, and HorizontalBand({ start, end }) the full width between two y positions. Use Coordinate.from_time for instants.

Layer : [Above, Below]

Choose whether the shape is drawn over or under the traces.

Props

:= {
    placement : Placement,
    line : Line ?? Line.default,
    fill : Color ?? Color.rgba({ red: 128, green: 128, blue: 128, alpha: 51 }),
    label : Str ?? "",
    layer : Layer ?? Above,
}

Configure one shape.

  • placement is required.
  • line styles a line placement and defaults to Line.default. A line's shape setting does not apply to a straight reference line. Bands are drawn without an outline.
  • fill colors a band and defaults to translucent gray.
  • label is text written beside the shape, and defaults to none: to the right of a vertical line's top, above a horizontal line's right end and inside a band's top-left corner. Plotly interprets its supported text markup.
  • layer defaults to Above for lines and is usually Below for bands, so that the shading does not cover the data.