| Copyright | (c) 2025 |
|---|---|
| License | MIT |
| Maintainer | mschavinda@gmail.com |
| Safe Haskell | None |
| Language | GHC2021 |
Granite.Render.Chrome
Description
Backend-agnostic chart chrome: axes, title, legend. Each helper
returns a list of primitive Marks.
Synopsis
- data PlotBox = PlotBox {}
- data Margins = Margins {
- marHasTitle :: !Bool
- marHasRightLegend :: !Bool
- marHasBottomLegend :: !Bool
- marExtraBottom :: !Double
- marLeftWanted :: !Double
- computePlotBox :: Size -> Theme -> Margins -> PlotBox
- data AxisLayout = AxisLayout {
- alMode :: !XLabelMode
- alExtraBottom :: !Double
- alLeftWanted :: !Double
- data XLabelMode
- xModeNoRotate :: XLabelMode
- axisLayout :: Theme -> Size -> Bool -> Bool -> [Text] -> [Text] -> AxisLayout
- domainLabels :: TrainedScale -> [Text]
- axesMarks :: Theme -> PlotBox -> Coord -> XLabelMode -> TrainedScale -> TrainedScale -> [Mark]
- titleMarks :: Theme -> PlotBox -> Maybe Text -> [Mark]
- legendMarks :: Theme -> PlotBox -> [(Text, ColorSpec)] -> [Mark]
Documentation
Pixel rectangle the chart body occupies, plus the overall scene bounds. Margins around the plot area host title, axis labels, legend.
Constructors
| PlotBox | |
Instances
Inputs that grow the plot margins beyond the theme defaults. marExtraBottom
enlarges the bottom margin (for rotated x-labels) and marLeftWanted requests a
left margin (to fit long y-labels / the rotated labels' leftward reach); both
fall back to the defaults when 0/small.
Constructors
| Margins | |
Fields
| |
Instances
data AxisLayout Source #
How the bottom (x) axis labels are laid out, plus the extra margins that
choice needs. Decided exactly once per chart so margin sizing and the actual
label rendering can never disagree (the bug when each recomputed the policy
from a slightly different plot width). XLabelMode is threaded to axesMarks;
alExtraBottom/alLeftWanted feed computePlotBox.
Constructors
| AxisLayout | |
Fields
| |
data XLabelMode Source #
What a panel's x-axis renderer should do. XFixed carries the
chart-global decision verbatim (single panel). XLocalNoRotate lets a faceted
panel pick upright/thin from its own width, but never rotate — rotation needs a
per-cell margin reservation the facet layout doesn't make.
xModeNoRotate :: XLabelMode Source #
The mode for axes that never rotate their labels (polar; also the faceted default).
axisLayout :: Theme -> Size -> Bool -> Bool -> [Text] -> [Text] -> AxisLayout Source #
Decide the bottom-axis label policy and the margins it needs, in one pass.
A wide left label grows the left margin (up to ~42% of the scene); rotated
bottom labels also reach down (bottom margin) and left (left margin) by
sin 45° of their width. Faceted charts never rotate, so they reserve no extra
bottom margin.
domainLabels :: TrainedScale -> [Text] Source #
A trained scale's in-domain tick labels, in break order.
axesMarks :: Theme -> PlotBox -> Coord -> XLabelMode -> TrainedScale -> TrainedScale -> [Mark] Source #