Module

Hylograph.Components.Axis

Package
purescript-hylograph-components
Repository
afcondon/purescript-hylograph-components

Axis rendering, factored out of BarChart so every chart preset can share it. Two kinds of axis, two functions:

  • continuousAxis — numeric, with ticks generated by Hylograph.Scale.
  • categoricalAxis — one label per band, centered; no ticks.

Both render in their own local frame with the axis origin at (0,0). The caller wraps in a Group with a transform: translate(...) to place the axis at its final position in the chart.

Only Left (y) and Bottom (x) are honored in v1 — Top and Right fall through to empty. Add them when something needs them.

#AxisSide Source

#ContinuousAxis Source

type ContinuousAxis = { format :: Number -> String, label :: Maybe String, range :: { max :: Number, min :: Number }, scale :: Scale Number Number Continuous, side :: AxisSide, tickCount :: Int }

#CategoricalAxis Source

type CategoricalAxis = { bandWidth :: Number, label :: Maybe String, labels :: Array String, side :: AxisSide }

#categoricalAxis Source

categoricalAxis :: CategoricalAxis -> Theme -> Tree

bandWidth is the pixel length per band along the axis direction: horizontal (Bottom) axes use it as the width per label; vertical (Left) axes use it as the height per label.