Visualize.Chart.Builder.Axes (Visualize v0.2.25)

Copy Markdown View Source

Axes ticked where their scale is (spec/14 §18.16, #373): the axes section of a mark's page and of a scale's — one row per position scale, a box per side the scale can stand on, a grid box, and a link to each axis's own page.

rows/2 reads the design; the builder writes what a tick asks for (toggle_axis, toggle_grid) through the ownership rule of §18.15.

This module compiles only when Phoenix.Component is loaded (spec/10 §1.1, D-45, D-85).

Summary

Types

One row: the scale, its sides with the axis standing there, and its grid.

Functions

For each position scale named, the sides an axis of it can stand on — bottom and top for x, left and right for y, one nominal side, shown, for a polar angle (bottom) or r (top) — each with the index of the axis standing there in frame.axes, the first axis of the scale and whether it draws the grid.

Renders the axes section.

Types

row()

@type row() :: %{
  scale: atom(),
  sides: [%{side: atom(), word: String.t(), index: non_neg_integer() | nil}],
  grid: boolean(),
  first: non_neg_integer() | nil
}

One row: the scale, its sides with the axis standing there, and its grid.

Functions

rows(design, scales)

@spec rows(map(), [atom()]) :: [row()]

For each position scale named, the sides an axis of it can stand on — bottom and top for x, left and right for y, one nominal side, shown, for a polar angle (bottom) or r (top) — each with the index of the axis standing there in frame.axes, the first axis of the scale and whether it draws the grid.

iex> design = %{frames: %{main: %{axes: [%{scale: :x, side: :bottom, grid: true}, %{scale: :y, side: :left}]}}}
iex> [x, y] = Visualize.Chart.Builder.Axes.rows(design, [:x, :y])
iex> {x.grid, Enum.map(x.sides, &{&1.side, &1.index}), y.grid, Enum.map(y.sides, &{&1.side, &1.index})}
{true, [bottom: 0, top: nil], false, [left: 1, right: nil]}
iex> [r] = Visualize.Chart.Builder.Axes.rows(design, [:r])
iex> {r.first, r.sides}
{nil, [%{side: :top, word: "shown", index: nil}]}

section(assigns)

Renders the axes section.

Attributes

  • rows (:list) (required) - the rows, as rows/2 gives them.
  • target (:any) - the phx-target of the section's events. Defaults to nil.