Module

Hylograph.Components.PieChart

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

Pie / Donut chart component.

First non-cartesian preset. Two channels: value (Number) drives the slice angle; category (String) is the semantic label (used for keys and tooltips by default). innerRadius > 0 turns a pie into a donut.

Categorical colors come from Hylograph.Scale.ColorSchemes — default palette is schemeCategory10, cycled modulo length. Override via colors in the Config for a themed palette.

No axes. Layout's margin still applies — the slices center inside the inner area. outerRadius: Nothing auto-sizes to the smaller inner dimension.

#Encoding Source

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

#Config Source

type Config :: Row Type -> Typetype Config r = { encoding :: Encoding r, endAngle :: Number, highlightGroup :: Maybe String, innerRadius :: Number, layout :: Layout, outerRadius :: Maybe Number, padAngle :: Number, startAngle :: 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. { category :: Record r -> String, value :: Record r -> Number } -> Config r

Smart-constructor with defaults: full circle, no padding, pie (not donut — innerRadius: 0), auto outerRadius, schemeCategory10 palette. key defaults to category; tooltip defaults to "<category>: <value>".

#pieChart Source

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

#frame Source

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