Axis

Axis :: # (opaque)

Plotly axis settings. Numeric and date bounds are explicit closed cases; arbitrary JSON fragments are never accepted as bounds.

default : Axis

Leave the entire axis at Plotly defaults, encoding an empty object. Unlike Axis.new with default props, this adds no range or color overrides.

new : Props -> Try(Axis, [InvalidAxisBounds({ min : F64, max : F64 })])

Validate numeric bounds and construct an axis override. Returns InvalidAxisBounds({ min, max }) if either numeric endpoint is nonfinite. Either endpoint order is accepted. Date bounds remain strings for Plotly to interpret and are not parsed here.

expect {
    axis = Axis.new({ type: Log, range: Bounds({ min: 0, max: 2 }) })?
    axis.to_json().contains("log")
}
to_json_value : Axis -> InternalJson

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

to_json : Axis -> Str

Serialize this validated value as a complete JSON document.

Type : [Auto, Linear, Log, Date, Category]

Choose how Plotly interprets coordinates on one axis. Auto lets Plotly infer the scale. Linear and Log use numeric coordinates; Date interprets date strings. Category uses category labels represented by text coordinates.

RangeSpec : [Auto, Fixed, Reversed, FromZero, Bounds({ min : F64, max : F64 }), DateBounds({ start : Str, end : Str }), TimeBounds({ start : Time, end : Time })]

Choose automatic range behavior or explicit bounds. Auto lets Plotly choose bounds. Fixed disables interactive range changes without selecting bounds. Reversed automatically orders bounds in reverse. Bounds({ min, max }) supplies finite numeric endpoints, whose order may reverse the axis. For a Log axis these are base-10 exponents, so 0 to 2 shows values from 1 to 100. DateBounds({ start, end }) supplies date strings interpreted by Plotly; Plume does not parse or validate their date syntax. TimeBounds({ start, end }) supplies validated Time endpoints for a date axis. FromZero chooses bounds automatically but always includes zero, which suits counts and other nonnegative measures.

Grid : [Auto, Shown, Hidden]

Choose whether grid lines are drawn at the axis ticks. Auto keeps Plotly's choice, which draws them on Cartesian axes.

Props

:= {
    title : Title ?? Title.default,
    type : Type ?? Auto,
    range : RangeSpec ?? Auto,
    color : Color ?? Color.rgb({ red: 68, green: 68, blue: 68 }),
    tick_format : [Auto, Pattern(Str)] ?? Auto,
    tick_suffix : Str ?? "",
    grid : Grid ?? Auto,
}

Override one axis's scale, range, title, color and tick labels. type: Auto omits an explicit scale. range: Auto selects automatic bounds. title defaults to Title.default, and color defaults to dark gray. Use Axis.default to leave the whole axis to Plotly. tick_format: Pattern(pattern) formats tick labels with a d3 number pattern such as ".1%" or "~s", or a d3 time pattern such as "%H:%M" on a date axis; Plotly interprets the pattern and Plume does not validate it. Auto keeps Plotly's labels. tick_suffix is appended to every label, such as " ms", and defaults to none. grid selects grid lines.