Safe Haskell | None |
---|---|
Language | Haskell2010 |
Hud (Heads up display) is a collective noun for axes, titles & legends
- data HudOptions = HudOptions {
- outerPad :: Double
- axes :: [AxisOptions]
- grids :: [GridOptions]
- titles :: [(TitleOptions, Text)]
- legends :: [LegendOptions]
- canvas :: RectOptions
- hud :: HudOptions -> Rect Double -> Rect Double -> Chart b
- withHud :: HudOptions -> Rect Double -> Rect Double -> (Rect Double -> Rect Double -> [f (Pair Double)] -> Chart b) -> [f (Pair Double)] -> Chart b
- withHud_ :: Foldable f => HudOptions -> Rect Double -> (Rect Double -> Rect Double -> [f (Pair Double)] -> Chart b) -> [f (Pair Double)] -> Chart b
- placeOutside :: Num n => Place -> V2 n
- placeGap :: (Monoid m, Semigroup m, Ord n, Floating n) => Place -> n -> QDiagram b V2 n m -> QDiagram b V2 n m
- data TickStyle
- = TickNone
- | TickLabels [Text]
- | TickRound Int
- | TickExact Int
- | TickPlaced [(Double, Text)]
- precision :: Int -> [Double] -> [Text]
- data AxisOptions = AxisOptions {
- outerPad :: Double
- orientation :: Orientation
- place :: Place
- rect :: RectOptions
- rectHeight :: Double
- mark :: GlyphOptions
- markStart :: Double
- gap :: Double
- label :: LabelOptions
- tickStyle :: TickStyle
- defXAxis :: AxisOptions
- defYAxis :: AxisOptions
- axis :: AxisOptions -> Range Double -> Range Double -> Chart b
- data AutoOptions = AutoOptions {
- maxXRatio :: Double
- maxYRatio :: Double
- angledRatio :: Double
- allowDiagonal :: Bool
- adjustAxis :: AutoOptions -> Range Double -> Range Double -> AxisOptions -> AxisOptions
- axisSane :: AutoOptions -> AxisOptions -> Range Double -> Range Double -> Chart b
- computeTicks :: AxisOptions -> Range Double -> Range Double -> ([Double], [Text])
- data TitleOptions = TitleOptions {}
- title :: Rect Double -> TitleOptions -> Text -> Chart b
- data LegendType
- data LegendOptions = LegendOptions {}
- legend :: LegendOptions -> Chart b
- data GridStyle
- data GridOptions = GridOptions {}
- data GridPos
- gridPos :: GridPos -> Pos
- defXGrid :: GridOptions
- defYGrid :: GridOptions
- gridl :: GridOptions -> Rect Double -> Rect Double -> Chart b
Documentation
data HudOptions Source #
Various options for a hud.
Defaults to the classical x- and y-axis, no titles and no legends
HudOptions | |
|
hud :: HudOptions -> Rect Double -> Rect Double -> Chart b Source #
Create a hud.
hud def sixbyfour one
withHud :: HudOptions -> Rect Double -> Rect Double -> (Rect Double -> Rect Double -> [f (Pair Double)] -> Chart b) -> [f (Pair Double)] -> Chart b Source #
attach a hud to a chart with a specific range
withHud_ :: Foldable f => HudOptions -> Rect Double -> (Rect Double -> Rect Double -> [f (Pair Double)] -> Chart b) -> [f (Pair Double)] -> Chart b Source #
attach a hud to a chart using the data range
withHudExample :: Chart b withHudExample = withHud_ hopts sixbyfour (lineChart lopts) ls where hopts = #titles .~ [(def, "withHud Example")] $ #legends .~ [ #chartType .~ zipWith (\x y -> (LegendLine x 0.05, y)) lopts ["line1", "line2", "line3"] $ def ] $ def
placeOutside :: Num n => Place -> V2 n Source #
Direction to place stuff on the outside of the built-up hud
placeGap :: (Monoid m, Semigroup m, Ord n, Floating n) => Place -> n -> QDiagram b V2 n m -> QDiagram b V2 n m Source #
A gap to add when placing elements.
Style of tick marks on an axis.
TickNone | no ticks on axis |
TickLabels [Text] | specific labels |
TickRound Int | sensibly rounded ticks and a guide to how many |
TickExact Int | exactly n equally spaced ticks |
TickPlaced [(Double, Text)] | specific labels and placement |
precision :: Int -> [Double] -> [Text] Source #
Provide formatted text for a list of numbers so that they are just distinguished. 'precision 2 ticks' means give the tick labels as much precision as is needed for them to be distinguished, but with at least 2 significant figues.
data AxisOptions Source #
Axes are somewhat complicated. For instance, they contain a range within which tick marks need to be supplied or computed.
AxisOptions | |
|
defXAxis :: AxisOptions Source #
default X axis
defYAxis :: AxisOptions Source #
default Y axis
axis :: AxisOptions -> Range Double -> Range Double -> Chart b Source #
create an axis, based on AxisOptions, a physical aspect, and a range
Under-the-hood, the axis function has gone through many a refactor, and still has a ways to go. A high degree of technical debt tends to acrue here.
axisExample :: Chart b axisExample = axis aopts one (Range 0 100000) where aopts :: AxisOptions aopts = #label . #text %~ ((#rotation .~ -45) . (#size .~ 0.06) . (#alignH .~ AlignLeft)) $ #gap .~ 0.0001 $ def
data AutoOptions Source #
options for prettifying axis decorations
AutoOptions | |
|
adjustAxis :: AutoOptions -> Range Double -> Range Double -> AxisOptions -> AxisOptions Source #
adjust an axis for sane font sizes etc
axisSane :: AutoOptions -> AxisOptions -> Range Double -> Range Double -> Chart b Source #
create an axis, with adjustment to axis options if needed
computeTicks :: AxisOptions -> Range Double -> Range Double -> ([Double], [Text]) Source #
compute tick values and labels given options and ranges
data TitleOptions Source #
Options for titles. Defaults to center aligned, and placed at Top of the hud
title :: Rect Double -> TitleOptions -> Text -> Chart b Source #
Create a title for a chart. The logic used to work out placement is flawed due to being able to freely specify text rotation. It works for specific rotations (Top, Bottom at 0, Left at 90, Right @ 270)
data LegendType Source #
LegendType reuses all the various chart option types to help formulate a legend
legend :: LegendOptions -> Chart b Source #
Create a legend based on a LegendOptions
legends' :: [(LegendType, Text)] legends' = [(LegendText def, "legend")] <> [(LegendPixel (blob ublue) 0.05, "pixel")] <> -- [ (LegendArrow (def & #minStaffWidth .~ 0.01 & #minHeadLength .~ 0.03) 0.05, "arrow")] <> [(LegendRect def 0.05, "rect")] <> [(LegendGLine def def 0.10, "glyph+line")] <> [(LegendGlyph def, "just a glyph")] <> zipWith (\x y -> (LegendLine x 0.05, y)) lopts ["short", "much longer name", "line 3"] legendExample :: Chart b legendExample = legend $ #chartType .~ legends' $ def
Style of grid lines
data GridOptions Source #
Options for gridlines.
The positioning of boundaries for a grid over a space
defXGrid :: GridOptions Source #
default horizontal grid
defYGrid :: GridOptions Source #
default vertical grid