Rule generator: a vertical line at a domain x value, with an optional label (spec/04 §12, D-27).
The x accessor yields a domain value that scale/2 maps, so the rule stays aligned
with the axis whatever the margins. Without a scale the value is a pixel coordinate.
Each datum is one annotation; by default the datum is the value itself.
Examples
rule =
Visualize.Shape.Rule.new()
|> Visualize.Shape.Rule.scale(x_scale)
|> Visualize.Shape.Rule.y1(height)
|> Visualize.Shape.Rule.label("deploy")
[group] = Visualize.Shape.Rule.generate(rule, [~U[2024-01-01 12:00:00Z]])
Summary
Types
An accessor whose value is text: a 1-arity function, an atom field, or a string.
Functions
Returns one :group element per datum: the line, then the label when there is one.
Sets the label accessor: function, atom field, or string constant; nil clears it
Creates a rule generator reading each datum as its x value, with extent 0 to 100
Sets the x scale the values map through; nil means the values are pixels
Sets the domain-value accessor
Sets the first vertical-extent accessor, in pixels
Sets the second vertical-extent accessor, in pixels
Types
@type t() :: %Visualize.Shape.Rule{ label: (any() -> String.t() | nil) | nil, scale: struct() | nil, x: Visualize.Shape.Line.accessor() | nil, y0: Visualize.Shape.Line.accessor(), y1: Visualize.Shape.Line.accessor() }
An accessor whose value is text: a 1-arity function, an atom field, or a string.
Functions
@spec generate(t(), Visualize.Data.Table.source()) :: [Visualize.IR.Element.t()]
Returns one :group element per datum: the line, then the label when there is one.
@spec label(t(), text_accessor() | nil) :: t()
Sets the label accessor: function, atom field, or string constant; nil clears it
@spec new() :: t()
Creates a rule generator reading each datum as its x value, with extent 0 to 100
Sets the x scale the values map through; nil means the values are pixels
@spec x(t(), Visualize.Shape.Line.accessor()) :: t()
Sets the domain-value accessor
@spec y0(t(), Visualize.Shape.Line.accessor()) :: t()
Sets the first vertical-extent accessor, in pixels
@spec y1(t(), Visualize.Shape.Line.accessor()) :: t()
Sets the second vertical-extent accessor, in pixels