Size

Size :: # (opaque)

The figure's pixel size and the margins around its plotting area. The default leaves all of them to Plotly, which fills the width of its container, uses a height of 450 pixels and reserves room for titles.

default : Size

Leave the size and margins to Plotly, encoding no settings.

new : Props -> Try(Size, [InvalidWidth(U16), InvalidHeight(U16)])

Validate fixed dimensions and construct a size. Returns InvalidWidth(pixels) or InvalidHeight(pixels) for a fixed dimension below ten pixels. Margins accept any pixel count.

expect {
    size = Size.new({ height: Pixels(320), margin: Pixels({ left: 48, right: 16, top: 24, bottom: 40 }) })?
    size.to_json().contains("320")
}
to_json_fields : Size -> List({ name : Str, value : InternalJson })

Internal composition hook used by Plume's renderers. It returns the layout fields this size sets, which Layout merges into its own object; most applications use Size.to_json instead.

to_json : Size -> Str

Serialize the layout fields this size sets as a JSON object.

Margin

:= {
    left : U16 ?? 80,
    right : U16 ?? 80,
    top : U16 ?? 100,
    bottom : U16 ?? 80,
}

Margins between the figure's edge and its plotting area, in pixels. Unnamed sides keep Plotly's defaults: 80 at the left, right and bottom, and 100 at the top. Axis labels, legends and titles still expand a margin when they need more room.

Props

:= {
    width : [Auto, Pixels(U16)] ?? Auto,
    height : [Auto, Pixels(U16)] ?? Auto,
    margin : [Auto, Pixels(Margin)] ?? Auto,
}

Configure the figure's size. width and height default to Auto; Pixels(count) fixes one dimension, and must be at least ten pixels, the smallest size Plotly draws. A dashboard usually fixes only the height and lets the width follow its container. margin defaults to Auto, which keeps Plotly's margins; Pixels(margin) sets them, which tightens a small chart.