Hylograph.Components.Annotation
- Package
- purescript-hylograph-components
- Repository
- afcondon/purescript-hylograph-components
Chart annotations — reference lines, shaded regions, text callouts.
Annotations are not a chart: they live as an Array Annotation on
the Config of any chart that has continuous x+y axes (ScatterPlot,
LinePlot for now — BarChart's categorical x needs a different model).
The chart threads its scales through renderAnnotations and splices
the result into its own Tree alongside marks.
Every Annotation constructor wraps a record spec. Smart-constructor
helpers (hline, vline, hband, vband, callout) produce those
records with sensible defaults; callers use record-update syntax to
override:
annotations =
[ HLine ((hline 50.0) { label = Just "target", style = Dashed })
, HBand (hband 40.0 60.0) { color = Just "#2563eb" }
, Callout (callout 15.0 45.0 "Q1 spike")
]
Layer order inside a chart: annotations render after axes and
before marks, so marks draw on top of bands/lines — with one
exception: annotation text labels come last so they stay readable
over everything else. That's handled inside renderAnnotations.
#ChartContext Source
type ChartContext = { innerHeight :: Number, innerWidth :: Number, theme :: Theme, xScale :: Scale Number Number Continuous, yScale :: Scale Number Number Continuous }Everything an annotation renderer needs from its host chart.
#renderAnnotations Source
renderAnnotations :: ChartContext -> Array Annotation -> TreeDraw all annotations into a single Group. Bands and lines render first (so marks drawn after in the host chart end up on top); labels render last within this group so they remain legible.
- 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