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 SwatchShapeSwatch 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
#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.
#fromSeries Source
fromSeries :: forall t r. Foldable t => (Record r -> String) -> t (Record r) -> Theme -> Array LegendItemItems 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 mRe-exports from Hylograph.Components.LineStyle
- Modules
- Hylograph.
Components. Annotation - Hylograph.
Components. Axis - Hylograph.
Components. BarChart - Hylograph.
Components. Binning - Hylograph.
Components. BoxPlot - Hylograph.
Components. Frame - Hylograph.
Components. Heatmap - Hylograph.
Components. Layout - Hylograph.
Components. Legend - Hylograph.
Components. LinePlot - Hylograph.
Components. LineStyle - Hylograph.
Components. Mark - Hylograph.
Components. PieChart - Hylograph.
Components. ScatterPlot - Hylograph.
Components. Series - Hylograph.
Components. Theme - Hylograph.
Components. Treemap