Visualize.Shape.XBand (Visualize v0.2.25)

Copy Markdown View Source

X-band generator: a shaded region between two domain x values, with an optional label (spec/04 §13, D-27).

The edge accessors yield domain values that scale/2 maps; without a scale they are pixels. Each datum is one annotation; by default a {start, stop} tuple.

Examples

band =
  Visualize.Shape.XBand.new()
  |> Visualize.Shape.XBand.scale(x_scale)
  |> Visualize.Shape.XBand.y1(height)
  |> Visualize.Shape.XBand.label("incident")

[group] = Visualize.Shape.XBand.generate(band, [{t0, t1}])

Summary

Types

t()

An accessor whose value is text or a fill: a 1-arity function, an atom field, or a string.

Functions

Sets the fill accessor: function, atom field, or string constant

Returns one :group element per datum: the rectangle, then the label when there is one.

Sets the label accessor: function, atom field, or string constant; nil clears it

Creates an x-band generator reading tuple elements 0 and 1 as its edges

Sets the x scale the edges map through; nil means the values are pixels

Sets the first-edge domain-value accessor

Sets the second-edge domain-value accessor

Sets the first vertical-extent accessor, in pixels

Sets the second vertical-extent accessor, in pixels

Types

t()

@type t() :: %Visualize.Shape.XBand{
  fill: (any() -> String.t() | nil) | nil,
  label: (any() -> String.t() | nil) | nil,
  scale: struct() | nil,
  x0: Visualize.Shape.Line.accessor() | nil,
  x1: Visualize.Shape.Line.accessor() | nil,
  y0: Visualize.Shape.Line.accessor(),
  y1: Visualize.Shape.Line.accessor()
}

text_accessor()

@type text_accessor() :: (any() -> String.t() | nil) | atom() | String.t()

An accessor whose value is text or a fill: a 1-arity function, an atom field, or a string.

Functions

fill(band, accessor)

@spec fill(t(), text_accessor() | nil) :: t()

Sets the fill accessor: function, atom field, or string constant

generate(band, data)

Returns one :group element per datum: the rectangle, then the label when there is one.

label(band, accessor)

@spec label(t(), text_accessor() | nil) :: t()

Sets the label accessor: function, atom field, or string constant; nil clears it

new()

@spec new() :: t()

Creates an x-band generator reading tuple elements 0 and 1 as its edges

scale(band, scale)

@spec scale(t(), struct() | nil) :: t()

Sets the x scale the edges map through; nil means the values are pixels

x0(band, accessor)

@spec x0(t(), Visualize.Shape.Line.accessor()) :: t()

Sets the first-edge domain-value accessor

x1(band, accessor)

@spec x1(t(), Visualize.Shape.Line.accessor()) :: t()

Sets the second-edge domain-value accessor

y0(band, accessor)

@spec y0(t(), Visualize.Shape.Line.accessor()) :: t()

Sets the first vertical-extent accessor, in pixels

y1(band, accessor)

@spec y1(t(), Visualize.Shape.Line.accessor()) :: t()

Sets the second vertical-extent accessor, in pixels