Scatter

Scatter :: # (opaque)

A validated Plotly scatter, line, text, or bubble trace.

is_eq : _

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

new : Props -> Scatter

Construct a scatter trace from already validated points and styles. This function is infallible: runtime numbers must first pass through Coordinate.from_number, and marker/line constructors validate sizes. Use Scatter(trace) to include the result in Chart.Props.

expect {
    points = Scatter.new({ data: [{ x: 1, y: 2 }], mode: Markers })
    points.to_json().contains("markers")
}
to_json_value : Scatter -> InternalJson

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

to_json : Scatter -> Str

Serialize the trace as JSON.

Point

:= { x : Coordinate, y : Coordinate, marker : Marker ?? Marker.default, text : Str ?? "", from_previous : [Connected, Gap] ?? Connected }

One point, its marker, and optional display text. x and y are text or finite numeric Coordinate values; use Coordinate.from_time for instants on a date axis. marker defaults to Marker.default. text defaults to an empty label and is drawn when the selected Scatter.Mode includes text. Points are rendered in list order, which also determines connected line order. from_previous: Gap leaves the line unbroken up to the previous point and starts a new segment here, for a missing sample; it has no effect on the first point. The default Connected joins them.

Mode : [Lines, Markers, Text, LinesMarkers, LinesText, MarkersText, LinesMarkersText, Hidden]

Select which parts of each point are drawn. Lines, Markers, and Text select one part. Combined tags such as LinesMarkers or LinesMarkersText select several. Hidden draws none of those parts; it encodes Plotly's none mode and does not remove the trace or its hover information.

Fill : [Unfilled, ToZeroY, ToZeroX, ToNextY, ToNextX, ToSelf, ToNext]

Choose the area to shade beneath or between lines. Unfilled shades nothing. ToZeroY fills down to y = 0 and ToZeroX across to x = 0. ToNextY and ToNextX fill to the previous trace in the chart, for bands and stacked areas, and ToSelf closes the trace's own outline. ToNext fills to the previous trace's outline.

Renderer : [Svg, WebGl]

Choose how the browser draws the trace. Svg draws each point as a vector element and suits up to a few thousand points. WebGl draws with the GPU (Plotly's scattergl) for many points or frequent updates; text and line shapes are supported, but the browser must provide WebGL.

Props

:= {
    data : List(Point),
    name : Str ?? "",
    line : Line ?? Line.default,
    mode : Mode ?? Lines,
    fill : Fill ?? Unfilled,
    fill_color : [Auto, Custom(Color)] ?? Auto,
    renderer : Renderer ?? Svg,
}

The complete scatter, line, bubble, or text series.

  • data preserves point order and may be empty.
  • mode defaults to Lines; use Markers for a scatter/bubble plot.
  • line defaults to Line.default and applies to connected segments.
  • name is the legend/hover label, and may be empty.
  • fill defaults to Unfilled. fill_color: Auto uses Plotly's translucent version of the line color; Custom(color) overrides it.
  • renderer defaults to Svg.

Per-point text, color, size and symbol belong to Scatter.Point. When every point shares a marker field or its text, the output holds that value once instead of repeating it for each point.