Module

Hylograph.Components.Legend

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

Legend — standalone, not a chart decorator.

A Legend is a Foldable-free preset: it takes an explicit Array LegendItem rather than a dataset, because it's purely presentation. Build items directly, or use the convenience helpers fromSeries / fromLineSeries which derive { label, color, shape } from a chart's series projection in exactly the same way the charts themselves do — so labels + colours are guaranteed to match.

Layout, Theme, Frame are the same shared pieces every chart uses.

Coordinated hover between legend entries and chart marks is not wired in v1 — legends render as static indices. See FUTURE-SESSIONS.md (C1).

#SwatchShape Source

data SwatchShape

Swatch drawn next to a label. SwatchMark delegates to Hylograph.Components.Mark — so any ScatterPlot mark shape is a valid swatch, keeping legend and chart visually consistent. SwatchLine is the distinct case for line-style differentiation (solid / dashed / dotted / custom), which has no direct mark analogue.

Constructors

#LegendOrientation Source

#LegendItem Source

type LegendItem = { color :: String, label :: String, shape :: SwatchShape }

#Config Source

type Config = { itemSpacing :: Number, layout :: Layout, orientation :: LegendOrientation, strokeWidth :: Number, swatchLabelGap :: Number, swatchSize :: Number }

Layout, orientation, swatch sizing. itemSpacing is the gap between successive items — pixels on the cross-axis for Vertical, pixels between item-end and next-item-start for Horizontal.

#Input Source

type Input = { config :: Config, items :: Array LegendItem, theme :: Theme }

#legend Source

#fromSeries Source

fromSeries :: forall t r. Foldable t => (Record r -> String) -> t (Record r) -> Theme -> Array LegendItem

Items are coloured from theme.categoricalPalette using the same index logic as the charts' multi-series rendering — so plugging the result into a legend adjacent to a chart yields the same colour per series.

#fromLineSeries Source

fromLineSeries :: forall t r. Foldable t => (Record r -> String) -> t (Record r) -> Theme -> Array LegendItem

#frame Source

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

Re-exports from Hylograph.Components.LineStyle

#LineStyle Source

data LineStyle

SVG stroke-dasharray patterns as an ADT. CustomDash takes the raw string so unusual patterns remain expressible without combinatorial ADT growth.

Constructors

#dashArray Source

dashArray :: LineStyle -> Maybe String

Produce the stroke-dasharray attribute value for non-solid styles. Solid returns Nothing so the caller can skip emitting the attribute.