chart-unit-0.5.5.0: Native haskell charts.

Safe HaskellNone
LanguageHaskell2010

Chart.Hud

Description

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.

Synopsis

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

Instances

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"]}]}

data Orientation Source #

Orientation for a hud element. Watch this space for curvature!

Constructors

Hori 
Vert 

data Place Source #

Placement of hud elements around (what is implicity but maybe shouldn't just be) a rectangular canvas

Instances

Eq Place Source # 

Methods

(==) :: Place -> Place -> Bool #

(/=) :: Place -> Place -> Bool #

Show Place Source # 

Methods

showsPrec :: Int -> Place -> ShowS #

show :: Place -> String #

showList :: [Place] -> ShowS #

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.

data TickStyle Source #

Style of tick marks on an axis.

Constructors

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.

Instances

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

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 LegendOptions b Source #

Legend options. todo: allow for horizontal concatenation.

Instances

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"])

data GridStyle Source #

Style of grid lines

Constructors

GridNone

no ticks on axis

GridRound Pos Int

sensibly rounded line placement and a guide to how many

GridExact Pos Int

exactly n lines using Pos

GridPlaced [Double]

specific line placement

data GridOptions Source #

Options for gridlines.

Instances

gridl :: GridOptions -> Aspect -> Rect Double -> Chart b Source #

Create a grid line for a chart.