Module

Hylograph.Components.ScatterPlot

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

Scatter plot component.

Second preset in the library. Same contract shape as BarChart: typed Config record, Foldable-polymorphic data, a pure scatterPlot function producing a HATS Tree, and a Halogen Frame wrapper in a sibling module.

Five encoding channels: x, y (Number), key + tooltip (String), and radius (Number, per-row point size — use \_ -> 5.0 for uniform dots, or a projection to encode a third dimension).

Axis domains are inferred from data by default; override via xDomain / yDomain when you want fixed axes or padded ranges.

#Encoding Source

type Encoding :: Row Type -> Typetype Encoding r = { colorBy :: Maybe (ColorBy r), key :: Record r -> String, radius :: Record r -> Number, series :: Record r -> String, shape :: Record r -> MarkShape, tooltip :: Record r -> String, x :: Record r -> Number, y :: Record r -> Number }

#AxisLabels Source

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

#ColorBy Source

type ColorBy :: Row Type -> Typetype ColorBy r = { domain :: Maybe { max :: Number, min :: Number }, interpolator :: Number -> String, value :: Record r -> Number }

Continuous colour encoding. When present in Encoding.colorBy, each point's fill colour is derived by normalising value against domain and looking the result up in the interpolator (e.g. Hylograph.Scale.Sequential.interpolateViridis). Takes precedence over series-based colouring.

domain: Nothing means auto-derive min/max from the dataset.

#Jitter Source

type Jitter = { x :: Number, y :: Number }

Per-axis pixel jitter magnitude. Each point is displaced by a deterministic value in [-jitter, +jitter] on each axis, seeded from encoding.key. Deterministic means jitter stays put across rerenders. Set one axis to 0 for a strip-plot effect.

#Config Source

type Config :: Row Type -> Typetype Config r = { annotations :: Array Annotation, encoding :: Encoding r, highlightGroup :: Maybe String, jitter :: Maybe Jitter, labels :: AxisLabels, layout :: Layout, xDomain :: Maybe { max :: Number, min :: Number }, yDomain :: 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. { x :: Record r -> Number, y :: Record r -> Number } -> Config r

Smart-constructor with reasonable defaults.

Caller provides the two essential projections (x, y). key defaults to show x <> "," <> show y, tooltip to the same, radius to 5.0. Domains auto-computed from data.

#scatterPlot Source

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

Build a HATS Tree for this scatter plot.

#frame Source

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