Safe Haskell | None |
---|---|
Language | Haskell2010 |
Hud (Heads up display) is a collective noun for axes, titles & legends
todo: refactor me please. A hud for a chart uses beside
to combine elements, and this restricts the hud to the outside of the chart canvas. This tends to make hud elements (such as gridlines) harder to implement than they should be.
- data HudOptions b = HudOptions {
- hudPad :: Double
- hudAxes :: [AxisOptions b]
- hudGrids :: [GridOptions]
- hudTitles :: [(TitleOptions, Text)]
- hudLegends :: [LegendOptions b]
- hudRange :: Maybe (Rect Double)
- hudAspect :: Aspect
- hudCanvas :: RectOptions
- hud :: HudOptions b -> Chart b
- withHud :: Foldable f => HudOptions b -> (Aspect -> Rect Double -> [f (Pair Double)] -> Chart b) -> [f (Pair Double)] -> Chart b
- data Orientation
- data Place
- 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 b = AxisOptions {}
- defXAxis :: AxisOptions b
- defYAxis :: AxisOptions b
- axis :: AxisOptions b -> Range Double -> Range Double -> Chart b
- data TitleOptions = TitleOptions {}
- title :: Aspect -> TitleOptions -> Text -> Chart b
- data LegendType b
- data LegendOptions b = LegendOptions {
- legendChartType :: [(LegendType b, Text)]
- legendInnerPad :: Double
- legendInnerSep :: Double
- legendGap :: Double
- legendRowPad :: Double
- legendPlace :: Place
- legendAlign :: AlignH
- legendSep :: Double
- legendRect :: RectOptions
- legendText :: TextOptions
- legend :: LegendOptions b -> Chart b
- data GridStyle
- data GridOptions = GridOptions {}
- defXGrid :: GridOptions
- defYGrid :: GridOptions
- gridl :: GridOptions -> Aspect -> Rect Double -> Chart b
Documentation
data HudOptions b Source #
Various options for a hud.
Defaults to the classical x- and y-axis, a sixbyfour aspect, no titles and no legends
HudOptions | |
|
Default (HudOptions b) Source # | |
hud :: HudOptions b -> Chart b Source #
Create a hud.
hud def
todo: the example highlights the issues with using beside. The x-axis is placed first,
and then the y-axis. In setting that beside
the combination of the canvas, and the x-axis, it calculates the middle, which has moved slightly from the canvas middle.
withHud :: Foldable f => HudOptions b -> (Aspect -> Rect Double -> [f (Pair Double)] -> Chart b) -> [f (Pair Double)] -> Chart b Source #
create a chart with a hud from data (using the data range)
withHudExample :: Chart b withHudExample = withHud hopts (lineChart lopts) ls where hopts = def {hudTitles=[(def,"withHud Example")], hudLegends=[def {legendChartType=zipWith (\x y -> (LegendLine x 0.05, y)) lopts ["line1", "line2", "line3"]}]}
Placement of hud elements around (what is implicity but maybe shouldn't just be) a rectangular canvas
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 b Source #
Axes are somewhat complicated. For instance, they contain a range within which tick marks need to be supplied or computed.
AxisOptions | |
|
Default (AxisOptions b) Source # | |
defXAxis :: AxisOptions b Source #
default X axis
defYAxis :: AxisOptions b Source #
default Y axis
axis :: AxisOptions b -> 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 = def {axisLabel=(axisLabel def) { labelGap=0.0001, labelText=(labelText (axisLabel def)) { textSize=0.06, textAlignH=AlignLeft, textRotation=(-45)}}}
data TitleOptions Source #
Options for titles. Defaults to center aligned, and placed at Top of the hud
TitleOptions | |
|
title :: Aspect -> 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 b Source #
LegendType reuses all the various chart option types to help formulate a legend
data LegendOptions b Source #
Legend options. todo: allow for horizontal concatenation.
LegendOptions | |
|
Default (LegendOptions b) Source # | |
legend :: LegendOptions b -> Chart b Source #
Create a legend based on a LegendOptions
legendExample :: Chart b legendExample = legend $ def {legendChartType=legends} where legends = [ (LegendText def, "legend")] <> [ (LegendPixel (blob (withOpacity blue 0.4)) 0.05, "pixel")] <> -- [ (LegendArrow (def {arrowMinStaffWidth=0.01, -- arrowMinHeadLength=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"])
Style of grid lines
data GridOptions Source #
Options for gridlines.