PhiaUi.Components.Data.ChartAxis (phia_ui v0.1.17)

Copy Markdown View Source

Composable SVG axis components for charts.

Each axis renders ticks, labels, and an optional title as SVG <g> groups. They accept scale functions (from ChartScales) and tick values to position elements — working both standalone and inside xy_chart.

Examples

<svg viewBox="0 0 400 300">
  <.x_axis ticks={[0, 25, 50, 75, 100]} scale={scale_fn} y={260} width={340} />
  <.y_axis ticks={[0, 50, 100]} scale={scale_fn} x={44} height={244} />
</svg>

Summary

Functions

Concentric circles axis for polar charts — renders value rings.

Angular axis for polar/radar charts — renders labels around a circle.

Horizontal axis with ticks, labels, and optional title.

Vertical axis with ticks, labels, and optional title.

Functions

angle_axis(assigns)

Concentric circles axis for polar charts — renders value rings.

Attributes

  • ticks (:list) (required) - List of radial tick values.
  • scale (:any) (required) - Scale function fn(value) -> radius_px.
  • cx (:any) (required)
  • cy (:any) (required)
  • label_format (:any) - Defaults to nil.
  • class (:string) - Defaults to nil.

radial_axis(assigns)

Angular axis for polar/radar charts — renders labels around a circle.

Attributes

  • labels (:list) (required) - List of category labels.
  • cx (:any) (required) - Center X.
  • cy (:any) (required) - Center Y.
  • radius (:any) (required) - Radius for label placement.
  • class (:string) - Defaults to nil.

x_axis(assigns)

Horizontal axis with ticks, labels, and optional title.

Renders a baseline, tick marks, and text labels at positions determined by the scale function.

Attributes

  • ticks (:list) (required) - List of tick values.
  • scale (:any) (required) - Scale function fn(value) -> pixel_x.
  • y (:any) (required) - Y position of the axis line.
  • width (:any) (required) - Width of the axis line.
  • x_offset (:any) - X offset for the axis start. Defaults to 0.
  • tick_size (:integer) - Length of tick marks in px. Defaults to 5.
  • label_format (:any) - Optional fn(value) -> string for labels. Defaults to nil.
  • title (:string) - Optional axis title. Defaults to nil.
  • position (:atom) - Defaults to :bottom. Must be one of :top, or :bottom.
  • class (:string) - Defaults to nil.

y_axis(assigns)

Vertical axis with ticks, labels, and optional title.

Attributes

  • ticks (:list) (required)
  • scale (:any) (required) - Scale function fn(value) -> pixel_y.
  • x (:any) (required) - X position of the axis line.
  • height (:any) (required) - Height of the axis line.
  • y_offset (:any) - Y offset for the axis start. Defaults to 0.
  • tick_size (:integer) - Defaults to 5.
  • label_format (:any) - Defaults to nil.
  • title (:string) - Defaults to nil.
  • position (:atom) - Defaults to :left. Must be one of :left, or :right.
  • class (:string) - Defaults to nil.