Axis generator for creating reference marks and labels.
Creates element groups containing tick marks, labels, and axis lines. Colours, font and
size come from a Visualize.Theme (theme/2, default Visualize.Theme.default/0),
resolved as CSS references for SVG and as literals for a canvas (spec/05 §1.4, D-55).
Examples
x_scale = Visualize.Scale.linear()
|> Visualize.Scale.domain([0, 100])
|> Visualize.Scale.range([0, 500])
x_axis = Visualize.Axis.bottom(x_scale)
|> Visualize.Axis.ticks(5)
|> Visualize.Axis.tick_format(fn v -> "#{v}%" end)
element = Visualize.Axis.generate(x_axis)
Summary
Functions
Creates a bottom-oriented axis
Generates the axis as an IR Element tree.
Creates a left-oriented axis
Sets the pixel offset for crisp edges
Renders the axis to a string using the specified backend.
Creates a right-oriented axis
Sets the theme the axis's colours, font and size resolve from
Sets the tick format function
Sets the padding between tick and label
Sets both inner and outer tick sizes
Sets the inner tick size (length of tick lines)
Sets the outer tick size (length of domain line extensions)
Sets explicit tick values
Sets the approximate number of ticks
Creates a top-oriented axis
Types
@type orientation() :: :top | :right | :bottom | :left
Functions
Creates a bottom-oriented axis
@spec generate(t(), keyword()) :: Visualize.IR.Element.t()
Generates the axis as an IR Element tree.
Returns a group element containing the domain line and tick groups.
Options
:resolve- how the theme's slots render::css(default) for references a stylesheet can override,:literalfor the plain values a canvas needs
Creates a left-oriented axis
Sets the pixel offset for crisp edges
Renders the axis to a string using the specified backend.
Options
:backend- The backend to use (:svg,:canvas, or a module). Defaults to:svg.:resolve- the theme mode ofgenerate/2; defaults toVisualize.Theme.mode/1of the backend, so an SVG axis carries CSS references and a canvas axis literals
Creates a right-oriented axis
@spec theme(t(), Visualize.Theme.t()) :: t()
Sets the theme the axis's colours, font and size resolve from
Sets the tick format function
Sets the padding between tick and label
Sets both inner and outer tick sizes
Sets the inner tick size (length of tick lines)
Sets the outer tick size (length of domain line extensions)
Sets explicit tick values
Sets the approximate number of ticks
Creates a top-oriented axis