Skip to content

StackBaseline

Mojo struct 🡭

StackBaseline

@memory_only
struct StackBaseline

Which baseline Mark.STREAMGRAPH stacks its series from, set via Plot.mark_streamgraph(baseline=...).

The stacking itself is the same either way – each series is laid on the running total of the ones below it. Only where that total starts differs, and the two answers are two different charts.

Aliases

  • WIGGLE = StackBaseline(Int(0)): Each category’s stack is centered on zero, starting at -total / 2, so the silhouette is symmetric about the middle. The streamgraph proper, and the default – what this mark drew before this setting existed. Reading a value off it means comparing two wavy edges, which is why it is an editorial form: it shows composition changing over time when the totals themselves are not the point.
  • ZERO = StackBaseline(Int(1)): Every category’s stack starts at a flat zero, giving the ordinary stacked area chart (what stacked_area() selects). The bottom series then sits on a straight axis and can actually be read against it, and the top edge is the running total. That is the one to reach for when the totals matter – which is most of the time.

Implemented traits

AnyType, Copyable, Deinitable, ImplicitlyCopyable, Movable

Methods

__init__

fn def __init__(out self, value: Int)

Prefer the WIGGLE/ZERO comptime constants over constructing one directly.

Args:

  • value (Int): 0 for WIGGLE, 1 for ZERO.
  • self (Self)

Returns:

Self

__eq__

fn def __eq__(self, other: Self) -> Bool

Whether both name the same baseline.

Args:

  • self (Self)
  • other (Self): The baseline to compare against.

Returns:

Bool: True when they match.

__ne__

fn def __ne__(self, other: Self) -> Bool

Whether the two name different baselines.

Args:

  • self (Self)
  • other (Self): The baseline to compare against.

Returns:

Bool: True when they differ.