Module

Hylograph.Components.Heatmap

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

Heatmap component.

A grid of rectangular cells laid out on two categorical axes (x, y), each cell coloured by a continuous value via a Number -> String interpolator (defaulting to interpolateViridis). Canonical use case: day-of-week × hour-of-day activity grids, confusion matrices, calendar heatmaps.

Unlike the cartesian charts in this library, cell colour does not come from series — it comes from value run through interpolator. series still lives on the Encoding (defaulting to \_ -> "") so two heatmaps on the same page can share a highlightGroup and coordinate hover across matching cells.

Value domain is auto-inferred from the dataset; override via valueDomain when you want a fixed scale (e.g. comparing two heatmaps side by side).

#Encoding Source

type Encoding :: Row Type -> Typetype Encoding r = { key :: Record r -> String, series :: Record r -> String, tooltip :: Record r -> String, value :: Record r -> Number, x :: Record r -> String, y :: Record r -> String }

#AxisLabels Source

type AxisLabels = { x :: Maybe String, y :: Maybe String }

#Config Source

type Config :: Row Type -> Typetype Config r = { cellPadding :: Number, encoding :: Encoding r, highlightGroup :: Maybe String, interpolator :: Number -> String, labels :: AxisLabels, layout :: Layout, valueDomain :: Maybe { max :: Number, min :: Number } }

#Input Source

type Input :: (Type -> Type) -> Row Type -> Typetype Input t r = { config :: Config r, dataset :: t (Record r), theme :: Theme }

#config Source

config :: forall r. { value :: Record r -> Number, x :: Record r -> String, y :: Record r -> String } -> Config r

Smart-constructor with reasonable defaults.

Caller provides the three essential projections (x, y, value). key defaults to x + "·" + y, tooltip to "<x>·<y>: <value>", series to the empty string. Interpolator defaults to viridis; valueDomain is auto-derived from the dataset when left as Nothing.

#heatmap Source

heatmap :: forall t r. Foldable t => Input t r -> Tree

Build a HATS Tree for this heatmap.

#frame Source

frame :: forall query output t r m. MonadAff m => Foldable t => Component query (FrameInput (Input t r)) output m