-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Native haskell charts. -- -- -- chart-unit is a native haskell charting library designed: -- -- -- -- See chart-unit for a chart gallery. @package chart-unit @version 0.5.2 -- | chart data combinators module Chart.Data -- | Convert a one-dimensional data set to line data lineOneD :: (Enum a, AdditiveUnital a) => [a] -> [Pair a] -- | Convert a one-dimensional data set to verticle line data vlineOneD :: (Enum a, AdditiveUnital a) => [a] -> [[Pair a]] -- | Convert a one-dimensional data set to horizontal line data hlineOneD :: (Enum a, AdditiveUnital a) => [a] -> [[Pair a]] -- | Convert a one-dimensional data set to bars rectOneD :: (Enum a, FromInteger a, Ord a, BoundedField a, Additive a, MultiplicativeUnital a) => [a] -> [Rect a] -- | Create line data for a formulae y = f(x) dataXY :: (BoundedField a, Ord a, FromInteger a) => (a -> a) -> Range a -> Int -> [Pair a] -- | Create line data for a formulae x = f(y) dataYX :: (BoundedField a, Ord a, FromInteger a) => (a -> a) -> Range a -> Int -> [Pair a] -- | Create rect data for a formulae y = f(x) rectXY :: (BoundedField a, Ord a, FromInteger a) => (a -> a) -> Range a -> Int -> [Rect a] -- | Create rect data for a formulae x = f(y) rectYX :: (BoundedField a, Ord a, FromInteger a) => (a -> a) -> Range a -> Int -> [Rect a] -- | Create rect data for a formulae c = f(x,y) rectF :: (Signed a, BoundedField a, Ord a, FromInteger a) => (Pair a -> b) -> Rect a -> Pair Int -> [(Rect a, b)] -- | In making a chart, there are three main size domains you have to be -- concerned about: -- -- -- -- Jumping ahead a bit, the code snippet below draws vertical lines using -- a data range of "Rect 0 12 0 0.2" (slightly different to the actual -- data range), using a widescreen (3:1) aspect, and renders the chart as -- a 300 by 120 pixel svg: -- --
--   fileSvg "other/scaleExample.svg" (300,120) $
--     withHud (hudAspect_ .~ widescreen $ hudRange_ .~ Just (Rect 0 12 0 0.2) $ def)
--     (lineChart (repeat def)) ((\x -> [Pair x 0, Pair x (x/100)]) <$> [0..10])
--   
-- module Chart.Core -- | A Chart is simply a type synonym for a typical Diagrams object. A -- close relation to this type is Diagram B, but this -- usage tends to force a single backend (B comes from the backend -- libraries), so making Chart b's maintains backend polymorphism. -- -- Just about everything - text, circles, lines, triangles, charts, axes, -- titles, legends etc - are Charts, which means that most things -- are amenable to full use of the combinatorially-inclined diagrams-lib. type Chart b = (Renderable (Path V2 Double) b) => QDiagram b V2 Double Any -- | a UChart provides a late binding of a chart Aspect so multiple charts -- can be rendered using the same range. data UChart a b UChart :: (Aspect -> Rect Double -> a -> Chart b) -> Rect Double -> a -> UChart a b [uchartRenderer] :: UChart a b -> Aspect -> Rect Double -> a -> Chart b [uchartRenderRange] :: UChart a b -> Rect Double [uchartData] :: UChart a b -> a -- | render a list of charts, taking into account each of their ranges combine :: Aspect -> [UChart a b] -> Chart b -- | determine the range of a double-containered set of data range :: (Foldable f, Foldable g) => g (f (Pair Double)) -> Rect Double -- | project a double-containered set of data to a new Rect range projectss :: (Functor f, Functor g) => Rect Double -> Rect Double -> g (f (Pair Double)) -> g (f (Pair Double)) -- | a wrapped Rect specifying the shape od the chart canvas. -- -- The Aspect tends to be: -- -- newtype Aspect Aspect :: (Rect Double) -> Aspect -- | the rendering aspect of a chart expressed as a ratio of x-plane : -- y-plane. aspect :: Double -> Aspect -- | a 1:1 aspect asquare :: Aspect -- | a 1.5:1 aspect sixbyfour :: Aspect -- | golden ratio golden :: Aspect -- | a 3:1 aspect widescreen :: Aspect -- | a skinny 5:1 aspect skinny :: Aspect -- | horizontal alignment data AlignH AlignLeft :: AlignH AlignCenter :: AlignH AlignRight :: AlignH -- | vertical alignment data AlignV AlignTop :: AlignV AlignMid :: AlignV AlignBottom :: AlignV -- | conversion of horizontal alignment to (one :: Range Double) limits alignHU :: AlignH -> Double -- | svg text is forced to be lower left (-0.5) by default alignHTU :: AlignH -> Double -- | conversion of vertical alignment to (one :: Range Double) limits alignVU :: AlignV -> Double -- | position an element at a point positioned :: (R2 r) => r Double -> Chart b -> Chart b -- | convert an R2 to a diagrams Point p_ :: (R2 r) => r Double -> Point V2 Double -- | convert an R2 to a V2 r_ :: R2 r => r a -> V2 a -- | foldMap for beside; stacking chart elements in a direction, with a -- premap stack :: (R2 r, V a ~ V2, Foldable t, Juxtaposable a, Semigroup a, N a ~ Double, Monoid a) => r Double -> (b -> a) -> t b -> a -- | combine elements vertically, with a premap vert :: (V a ~ V2, Foldable t, Juxtaposable a, Semigroup a, N a ~ Double, Monoid a) => (b -> a) -> t b -> a -- | combine elements horizontally, with a premap hori :: (V a ~ V2, Foldable t, Juxtaposable a, Semigroup a, N a ~ Double, Monoid a) => (b -> a) -> t b -> a -- | vertical separator sepVert :: Double -> Chart b -> Chart b -- | horizontal separator sepHori :: Double -> Chart b -> Chart b -- | write an svg to file fileSvg :: FilePath -> (Double, Double) -> Diagram SVG -> IO () -- | convert an rgba spec to an AlphaColour ucolor :: (Floating a, Ord a) => a -> a -> a -> a -> AlphaColour a -- | the official chart-unit blue ublue :: AlphaColour Double -- | the official chart-unit grey ugrey :: AlphaColour Double -- | the diagrams scaleX with a zero divide guard to avoid error throws scaleX :: (N t ~ Double, Transformable t, R2 (V t), Additive (V t)) => Double -> t -> t -- | the diagrams scaleY with a zero divide guard to avoid error throws scaleY :: (N t ~ Double, Transformable t, R2 (V t), Additive (V t)) => Double -> t -> t -- | the diagrams scale with a zero divide guard to avoid error throws scale :: (N t ~ Double, Transformable t, R2 (V t), Additive (V t)) => Double -> t -> t instance Linear.V1.R1 NumHask.Pair.Pair instance Linear.V2.R2 NumHask.Pair.Pair -- | rectangular chart elements module Chart.Rect -- | Just about everything on a chart is a rectangle. data RectOptions RectOptions :: Double -> AlphaColour Double -> AlphaColour Double -> RectOptions [rectBorderSize] :: RectOptions -> Double [rectBorderColor] :: RectOptions -> AlphaColour Double [rectColor] :: RectOptions -> AlphaColour Double -- | solid rectangle, no border blob :: AlphaColour Double -> RectOptions -- | clear rect, with border box :: AlphaColour Double -> RectOptions -- | clear and transparent rect clear :: RectOptions -- | place a rect around an Chart, with a size equal to the chart range bound :: RectOptions -> Double -> Chart b -> Chart b -- | A single rectangle specified using a Rect x z y w where (x,y) is -- location of lower left corner (z,w) is location of upper right corner -- --
--   let opts o = def {labelText = (labelText def) {textColor=withOpacity black 0.8,
--           textSize = 0.3}, labelOrientation=o}
--   labelled (opts (Pair 2 1)) ("z,w") $ labelled (opts (Pair -2 -1)) ("x,y")
--       (rect_ def (Ranges (2*.one) one))
--   
-- rect_ :: (N b ~ Double, V b ~ V2, Transformable b, HasOrigin b, TrailLike b, HasStyle b) => RectOptions -> Rect Double -> b -- | Create rectangles (with the same configuration). -- --
--   rects def (rectOneD [1, 2, 3, 5, 8, 0, -2, 11, 2, 1])
--   
-- rects :: (V a ~ V2, N a ~ Double, Functor t, HasStyle a, TrailLike a, HasOrigin a, Transformable a, Foldable t, Monoid a) => RectOptions -> t (Rect Double) -> a -- | A chart of rects rectChart :: (Traversable f) => [RectOptions] -> Aspect -> Rect Double -> [f (Rect Double)] -> Chart b -- | A chart of rectangles scaled to its own range -- --
--   let ropts = [def {rectBorderSize=0}, def
--           {rectBorderSize=0,rectColor=ucolor 0.3 0.3 0.3 0.2}]
--   let rss = [ rectXY (\x -> exp (-(x ** 2) / 2)) (Range -5 5) 50
--             , rectXY (\x -> 0.5 * exp (-(x ** 2) / 8)) (Range -5 5) 50
--             ]
--   rectChart_ ropts widescreen rss
--   
-- rectChart_ :: (Traversable f) => [RectOptions] -> Aspect -> [f (Rect Double)] -> Chart b -- | At some point, a color of a rect becomes more about data than -- stylistic option, hence the pixel. Echewing rect border leaves a Pixel -- with no stylistic options to choose. data Pixel Pixel :: Rect Double -> AlphaColour Double -> Pixel [pixelRect] :: Pixel -> Rect Double [pixelColor] :: Pixel -> AlphaColour Double -- | A pixel is a rectangle with a color. -- --
--   let opt = def {textColor=withOpacity black 0.8, textSize = 0.2}
--   text_ opt "I'm a pixel!" <> pixel_ (Pixel one ublue)
--   
-- pixel_ :: Pixel -> Chart b -- | Render multiple pixels -- --
--   pixels $ [Pixel (Rect (5*x) (5*x+0.1) (sin (10*x)) (sin (10*x) + 0.1)) (dissolve (2*x) ublue) | x <- grid OuterPos (Range 0 1) 100]
--   
-- pixels :: (Traversable f) => f Pixel -> Chart b -- | A chart of pixels pixelChart :: (Traversable f) => Aspect -> Rect Double -> [f Pixel] -> Chart b -- | A chart of pixels scaled to its own range -- --
--   pixelChart_Example :: Chart b
--   pixelChart_Example =
--       pixelChart_ asquare
--       [ (\(r,c) -> Pixel r
--                   (blend c
--                    (rybColor 14 `withOpacity` 1)
--                    (ucolor 0.8 0.8 0.8 0.3))) <$>
--         rectF (\(Pair x y) -> 4*(x*x+y*y))
--         one (Pair 40 40)
--       ]
--   
-- pixelChart_ :: (Traversable f) => Aspect -> [f Pixel] -> Chart b -- | Options to pixelate a Rect using a function data PixelationOptions PixelationOptions :: Range (AlphaColour Double) -> Pair Int -> PixelationOptions [pixelationGradient] :: PixelationOptions -> Range (AlphaColour Double) [pixelationGrain] :: PixelationOptions -> Pair Int -- | Transform a Rect into Pixels using a function over a Pair pixelate :: PixelationOptions -> Rect Double -> (Pair Double -> Double) -> [Pixel] -- | Chart pixels using a function This is a convenience function, and the -- example below is equivalent to the pixelChart_ example -- --
--   pixelateChart def asquare one (\(Pair x y) -> (x+y)*(x+y))
--   
pixelateChart :: PixelationOptions -> Aspect -> Rect Double -> (Pair Double -> Double) -> Chart b instance Data.Default.Class.Default Chart.Rect.RectOptions instance Data.Default.Class.Default Chart.Rect.PixelationOptions -- | textual chart elements module Chart.Text -- | text options data TextOptions TextOptions :: Double -> AlignH -> AlphaColour Double -> FillRule -> Double -> PreparedFont Double -> TextOptions [textSize] :: TextOptions -> Double [textAlignH] :: TextOptions -> AlignH [textColor] :: TextOptions -> AlphaColour Double [textFillRule] :: TextOptions -> FillRule [textRotation] :: TextOptions -> Double [textFont] :: TextOptions -> PreparedFont Double -- | Create a textual chart element -- --
--   let text_Example = text_ def "Welcome to chart-unit!"
--   
-- text_ :: TextOptions -> Text -> Chart b -- | Creatye positioned text from a list -- --
--   let ts = map (Text.singleton) ['a'..'z']
--   texts def ts [Pair (0.05*x) 0 |x <- [0..5]]
--   
-- texts :: (R2 r) => TextOptions -> [Text] -> [r Double] -> Chart b -- | A chart of text textChart :: (Traversable f) => [TextOptions] -> Aspect -> Rect Double -> [f (Text, Pair Double)] -> Chart b -- | A chart of text scaled to its own range -- --
--   import qualified Data.Text as Text
--   let ps = [Pair (sin (x*0.1)) x | x<-[0..25]]
--   textChart_ (repeat $ def {textSize=0.33}) widescreen [zip ts ps]
--   
-- textChart_ :: [TextOptions] -> Aspect -> [[(Text, Pair Double)]] -> Chart b -- | A label is a text element attached to a chart element data LabelOptions LabelOptions :: TextOptions -> Pair Double -> Double -> LabelOptions [labelText] :: LabelOptions -> TextOptions -- | direction of label [labelOrientation] :: LabelOptions -> Pair Double -- | distance to label [labelGap] :: LabelOptions -> Double -- | Label a chart element with some text -- --
--   let lopts = def {textAlignH = AlignLeft, textRotation=45}
--   labelled (LabelOptions lopts (Pair 1 1) 0.05) "a label" (glyph_ def)
--   
-- labelled :: LabelOptions -> Text -> Chart b -> Chart b instance Data.Default.Class.Default Chart.Text.TextOptions instance Data.Default.Class.Default Chart.Text.LabelOptions -- | Glyphs are (typically) small shapes symbolically representing a data -- point. module Chart.Glyph -- | The actual shape of a glyph can be any Chart element data GlyphOptions b GlyphOptions :: Double -> AlphaColour Double -> AlphaColour Double -> Double -> (Double -> Chart b) -> GlyphOptions b -- | glyph radius [glyphSize] :: GlyphOptions b -> Double [glyphColor] :: GlyphOptions b -> AlphaColour Double [glyphBorderColor] :: GlyphOptions b -> AlphaColour Double -- | normalized [glyphBorderSize] :: GlyphOptions b -> Double [glyphShape] :: GlyphOptions b -> Double -> Chart b -- | Horizontal line glyph shape with a reasonable thickness as "hline_ 1" hline_ :: Double -> Double -> Chart b -- | Vertical line glyph shape with a reasonable thickness at "vline_ 1" vline_ :: Double -> Double -> Chart b -- | Create a glyph. -- --
--   let glyph_Example = glyph_ def
--   
-- glyph_ :: GlyphOptions b -> Chart b -- | Create positioned glyphs. -- --
--   glyphsExample :: Chart b
--   glyphsExample = glyphs def (dataXY sin (Range 0 (2*pi)) 30)
--   
-- glyphs :: (R2 r, Traversable f) => GlyphOptions b -> f (r Double) -> Chart b -- | Create labelled, positioned glyphs. -- --
--   lglyphs def def $ zip (show <$> [0..]) ps
--   
-- lglyphs :: (R2 r, Traversable f) => LabelOptions -> GlyphOptions b -> f (Text, r Double) -> Chart b -- | A chart of glyphs glyphChart :: (Traversable f) => [GlyphOptions b] -> Aspect -> Rect Double -> [f (Pair Double)] -> Chart b -- | A chart of glyphs scaled to its own range -- --
--   gopts :: [GlyphOptions b]
--   gopts = [ glyphBorderSize_ .~ 0.001 $ def
--           , glyphBorderSize_ .~ 0.001 $
--             glyphSize_ .~ 0.1 $
--             glyphColor_ .~ rybColor 7 `withOpacity` 0.4 $
--             def {glyphShape = triangle}
--           ]
--   
--   gdata :: [[Pair Double]]
--   gdata = [ dataXY sin (Range 0 (2*pi)) 30
--           , dataXY cos (Range 0 (2*pi)) 30
--           ]
--   
--   glyphChart_Example :: Chart b
--   glyphChart_Example = glyphChart_ gopts widescreen gdata
--   
-- glyphChart_ :: (Traversable f) => [GlyphOptions b] -> Aspect -> [f (Pair Double)] -> Chart b -- | A chart of labelled glyphs lglyphChart :: (Traversable f) => [LabelOptions] -> [GlyphOptions b] -> Aspect -> Rect Double -> [f (Text, Pair Double)] -> Chart b -- | A chart of labelled glyphs scaled to its own range -- --
--   let g = Pair <$> [0..5] <*> [0..5] :: [Pair Int]
--   let xs = [(\(p@(Pair x y)) -> ((show x <> "," <> show y), fromIntegral <$> p)) <$> g]
--   lglyphChart_ [def {labelGap=0.01}] [def] sixbyfour xs
--   
-- lglyphChart_ :: (Traversable f) => [LabelOptions] -> [GlyphOptions b] -> Aspect -> [f (Text, Pair Double)] -> Chart b -- | A circle of the given radius, centered at the origin. As a path, it -- begins at (r,0). circle :: (TrailLike t, (~) (* -> *) (V t) V2, (~) * (N t) n, Transformable t) => n -> t -- | A square with its center at the origin and sides of the given length, -- oriented parallel to the axes. -- square :: (InSpace V2 n t, TrailLike t) => n -> t -- | An equilateral triangle, with sides of the given length and base -- parallel to the x-axis. -- triangle :: (InSpace V2 n t, TrailLike t) => n -> t instance Data.Default.Class.Default (Chart.Glyph.GlyphOptions b) -- | Points on a chart connected by lines. module Chart.Line -- | The main features of a line (that distinguish it from a glyph say) is -- that: -- -- data LineOptions LineOptions :: Double -> AlphaColour Double -> LineOptions -- | normalized [lineSize] :: LineOptions -> Double [lineColor] :: LineOptions -> AlphaColour Double -- | A single line connecting 2 points oneline :: (R2 r) => LineOptions -> Pair (r Double) -> Chart b -- | A line connecting a series of points -- --
--   lines def (dataXY cos (Range 0 (4*pi)) n)
--   
-- lines :: (Traversable f, R2 r) => LineOptions -> f (r Double) -> Chart b -- | Lines with glyphs atop eack point glines :: (Traversable f, R2 r) => LineOptions -> GlyphOptions b -> f (r Double) -> Chart b -- | A chart of lines lineChart :: (Traversable f) => [LineOptions] -> Aspect -> Rect Double -> [f (Pair Double)] -> Chart b -- | A chart of lines scaled to its own range -- --
--   import Data.Colour.Palette.Harmony (tetrad)
--   ls = map (uncurry Pair) <$> [[(0.0,1.0),(1.0,1.0),(2.0,5.0)],
--                                [(0.0,0.0),(3.0,3.0)], [(0.5,4.0),(0.5,0)]]
--   lopts = zipWith (\x y -> LineOptions x (withOpacity y 0.6)) [0.01,0.02,0.005]
--           (tetrad blue)
--   lineChart_ lopts sixbyfour ls
--   
-- lineChart_ :: (Traversable f) => [LineOptions] -> Aspect -> [f (Pair Double)] -> Chart b -- | A chart of glines glineChart :: (Traversable f) => [LineOptions] -> [GlyphOptions b] -> Aspect -> Rect Double -> [f (Pair Double)] -> Chart b -- | A chart of glyphs_lines scaled to its own range -- --
--   let gopts = zipWith (\x y -> def {glyphColor=transparent,
--           glyphBorderColor=withOpacity x 0.6, glyphShape=y}) (tetrad green)
--           [triangle, square, circle]
--   
--   glineChart_ lopts gopts sixbyfour ls
--   
-- glineChart_ :: (Traversable f) => [LineOptions] -> [GlyphOptions b] -> Aspect -> [f (Pair Double)] -> Chart b instance Data.Default.Class.Default Chart.Line.LineOptions -- | Charts that depict gradients and similar data, using arrows in -- positions module Chart.Arrow -- | An arrow structure contains position, direction and size information data Arrow Arrow :: Pair Double -> Pair Double -> Arrow [arrowPos] :: Arrow -> Pair Double [arrowDir] :: Arrow -> Pair Double -- | todo: quite a clunky specification of what an arrow is (or could be) data ArrowOptions a ArrowOptions :: a -> a -> a -> a -> a -> a -> AlphaColour Double -> ArrowHT a -> ArrowOptions a [arrowMinLength] :: ArrowOptions a -> a [arrowMaxLength] :: ArrowOptions a -> a [arrowMinHeadLength] :: ArrowOptions a -> a [arrowMaxHeadLength] :: ArrowOptions a -> a [arrowMinStaffWidth] :: ArrowOptions a -> a [arrowMaxStaffWidth] :: ArrowOptions a -> a [arrowColor] :: ArrowOptions a -> AlphaColour Double [arrowHeadStyle] :: ArrowOptions a -> ArrowHT a -- | Equalize the arrow space width with the data space one. this creates -- the right arrow sizing in physical chart space normArrows :: [Arrow] -> [Arrow] -- | Rescale data across position, and between position and arrow -- direction. -- -- note that, due to this auto-scaling, there is no such thing as a -- single arrow_ chart -- --
--   arrows (def {arrowMaxLength=0.5,arrowMaxHeadLength=0.2,arrowMaxStaffWidth=0.01})
--       [Arrow (Pair x (sin (5*x))) (Pair x (cos x)) |
--        x<-grid MidPos (one::Range Double) 100]
--   
-- arrows :: (Traversable f) => ArrowOptions Double -> f Arrow -> Chart b -- | A chart of arrows arrowChart :: (Traversable f) => [ArrowOptions Double] -> Aspect -> Rect Double -> [f Arrow] -> Chart b -- | An arrow chart scaled to its own range -- --
--   let as = normArrows [Arrow (Pair x y) (Pair (sin 1/x+0.0001) (cos 1/y+0.0001)) |
--                        x<-grid MidPos (one::Range Double) 20,
--                        y<-grid MidPos (one::Range Double) 20]
--   arrowChart_ [def] asquare [as]
--   
-- arrowChart_ :: (Traversable f) => [ArrowOptions Double] -> Aspect -> [f Arrow] -> Chart b instance GHC.Show.Show Chart.Arrow.Arrow instance GHC.Classes.Eq Chart.Arrow.Arrow instance Data.Default.Class.Default (Chart.Arrow.ArrowOptions GHC.Types.Double) -- | 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. module Chart.Hud -- | Various options for a hud. -- -- Defaults to the classical x- and y-axis, a sixbyfour aspect, no titles -- and no legends data HudOptions b HudOptions :: Double -> [AxisOptions b] -> [GridOptions] -> [(TitleOptions, Text)] -> [LegendOptions b] -> Maybe (Rect Double) -> Aspect -> RectOptions -> HudOptions b [hudPad] :: HudOptions b -> Double [hudAxes] :: HudOptions b -> [AxisOptions b] [hudGrids] :: HudOptions b -> [GridOptions] [hudTitles] :: HudOptions b -> [(TitleOptions, Text)] [hudLegends] :: HudOptions b -> [LegendOptions b] [hudRange] :: HudOptions b -> Maybe (Rect Double) [hudAspect] :: HudOptions b -> Aspect [hudCanvas] :: HudOptions b -> RectOptions -- | 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. hud :: HudOptions b -> Chart b -- | 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"]}]}
--   
-- withHud :: (Foldable f) => HudOptions b -> (Aspect -> Rect Double -> [f (Pair Double)] -> Chart b) -> [f (Pair Double)] -> Chart b -- | Orientation for a hud element. Watch this space for curvature! data Orientation Hori :: Orientation Vert :: Orientation -- | Placement of hud elements around (what is implicity but maybe -- shouldn't just be) a rectangular canvas data Place PlaceLeft :: Place PlaceRight :: Place PlaceTop :: Place PlaceBottom :: Place -- | Direction to place stuff on the outside of the built-up hud placeOutside :: Num n => Place -> V2 n -- | A gap to add when placing elements. placeGap :: (Monoid m, Semigroup m, Ord n, Floating n) => Place -> n -> QDiagram b V2 n m -> QDiagram b V2 n m -- | Style of tick marks on an axis. data TickStyle -- | no ticks on axis TickNone :: TickStyle -- | specific labels TickLabels :: [Text] -> TickStyle -- | sensibly rounded ticks and a guide to how many TickRound :: Int -> TickStyle -- | exactly n equally spaced ticks TickExact :: Int -> TickStyle -- | specific labels and placement TickPlaced :: [(Double, Text)] -> TickStyle -- | 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. precision :: Int -> [Double] -> [Text] -- | Axes are somewhat complicated. For instance, they contain a range -- within which tick marks need to be supplied or computed. data AxisOptions b AxisOptions :: Double -> Orientation -> Place -> RectOptions -> Double -> GlyphOptions b -> Double -> Double -> LabelOptions -> TickStyle -> AxisOptions b [axisPad] :: AxisOptions b -> Double [axisOrientation] :: AxisOptions b -> Orientation [axisPlace] :: AxisOptions b -> Place [axisRect] :: AxisOptions b -> RectOptions [axisRectHeight] :: AxisOptions b -> Double [axisMark] :: AxisOptions b -> GlyphOptions b [axisMarkStart] :: AxisOptions b -> Double [axisGap] :: AxisOptions b -> Double [axisLabel] :: AxisOptions b -> LabelOptions [axisTickStyle] :: AxisOptions b -> TickStyle -- | default X axis defXAxis :: AxisOptions b -- | default Y axis defYAxis :: AxisOptions b -- | 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)}}}
--   
-- axis :: AxisOptions b -> Range Double -> Range Double -> Chart b -- | Options for titles. Defaults to center aligned, and placed at Top of -- the hud data TitleOptions TitleOptions :: TextOptions -> AlignH -> Place -> Double -> TitleOptions [titleText] :: TitleOptions -> TextOptions [titleAlign] :: TitleOptions -> AlignH [titlePlace] :: TitleOptions -> Place [titleGap] :: TitleOptions -> Double -- | 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) title :: Aspect -> TitleOptions -> Text -> Chart b -- | LegendType reuses all the various chart option types to help formulate -- a legend data LegendType b LegendText :: TextOptions -> LegendType b LegendGlyph :: (GlyphOptions b) -> LegendType b LegendLine :: LineOptions -> Double -> LegendType b LegendGLine :: (GlyphOptions b) -> LineOptions -> Double -> LegendType b LegendRect :: RectOptions -> Double -> LegendType b LegendArrow :: (ArrowOptions Double) -> Double -> LegendType b LegendPixel :: RectOptions -> Double -> LegendType b -- | Legend options. todo: allow for horizontal concatenation. data LegendOptions b LegendOptions :: [(LegendType b, Text)] -> Double -> Double -> Double -> Double -> Place -> AlignH -> Double -> RectOptions -> TextOptions -> LegendOptions b [legendChartType] :: LegendOptions b -> [(LegendType b, Text)] [legendInnerPad] :: LegendOptions b -> Double [legendInnerSep] :: LegendOptions b -> Double [legendGap] :: LegendOptions b -> Double [legendRowPad] :: LegendOptions b -> Double [legendPlace] :: LegendOptions b -> Place [legendAlign] :: LegendOptions b -> AlignH [legendSep] :: LegendOptions b -> Double [legendRect] :: LegendOptions b -> RectOptions [legendText] :: LegendOptions b -> TextOptions -- | 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"])
--   
-- legend :: LegendOptions b -> Chart b -- | Style of grid lines data GridStyle -- | no ticks on axis GridNone :: GridStyle -- | sensibly rounded line placement and a guide to how many GridRound :: Pos -> Int -> GridStyle -- | exactly n lines using Pos GridExact :: Pos -> Int -> GridStyle -- | specific line placement GridPlaced :: [Double] -> GridStyle -- | Options for gridlines. data GridOptions GridOptions :: Orientation -> GridStyle -> LineOptions -> GridOptions [gridOrientation] :: GridOptions -> Orientation [gridStyle] :: GridOptions -> GridStyle [gridLine] :: GridOptions -> LineOptions defXGrid :: GridOptions defYGrid :: GridOptions -- | Create a grid line for a chart. gridl :: GridOptions -> Aspect -> Rect Double -> Chart b instance GHC.Show.Show Chart.Hud.Place instance GHC.Classes.Eq Chart.Hud.Place instance Data.Default.Class.Default (Chart.Hud.HudOptions b) instance Data.Default.Class.Default (Chart.Hud.AxisOptions b) instance Data.Default.Class.Default Chart.Hud.TitleOptions instance Data.Default.Class.Default (Chart.Hud.LegendOptions b) instance Data.Default.Class.Default Chart.Hud.GridOptions -- | Lenses for all the options. Note the trailing underscore_ naming -- convention, rather than the more obnoxious prefixed _underscore -- convention. module Chart.Lenses arrowMinLength_ :: forall a_aDYD. Lens' (ArrowOptions a_aDYD) a_aDYD arrowMaxLength_ :: forall a_aDYD. Lens' (ArrowOptions a_aDYD) a_aDYD arrowMinHeadLength_ :: forall a_aDYD. Lens' (ArrowOptions a_aDYD) a_aDYD arrowMaxHeadLength_ :: forall a_aDYD. Lens' (ArrowOptions a_aDYD) a_aDYD arrowMinStaffWidth_ :: forall a_aDYD. Lens' (ArrowOptions a_aDYD) a_aDYD arrowMaxStaffWidth_ :: forall a_aDYD. Lens' (ArrowOptions a_aDYD) a_aDYD arrowColor_ :: forall a_aDYD. Lens' (ArrowOptions a_aDYD) (AlphaColour Double) arrowHeadStyle_ :: forall a_aDYD. Lens' (ArrowOptions a_aDYD) (ArrowHT a_aDYD) glyphSize_ :: forall b_aBQI. Lens' (GlyphOptions b_aBQI) Double glyphColor_ :: forall b_aBQI. Lens' (GlyphOptions b_aBQI) (AlphaColour Double) glyphBorderColor_ :: forall b_aBQI. Lens' (GlyphOptions b_aBQI) (AlphaColour Double) glyphBorderSize_ :: forall b_aBQI. Lens' (GlyphOptions b_aBQI) Double hudPad_ :: forall b_aG59. Lens' (HudOptions b_aG59) Double hudAxes_ :: forall b_aG59. Lens' (HudOptions b_aG59) [AxisOptions b_aG59] hudGrids_ :: forall b_aG59. Lens' (HudOptions b_aG59) [GridOptions] hudTitles_ :: forall b_aG59. Lens' (HudOptions b_aG59) [(TitleOptions, Text)] hudLegends_ :: forall b_aG59. Lens' (HudOptions b_aG59) [LegendOptions b_aG59] hudRange_ :: forall b_aG59. Lens' (HudOptions b_aG59) (Maybe (Rect Double)) hudAspect_ :: forall b_aG59. Lens' (HudOptions b_aG59) Aspect hudCanvas_ :: forall b_aG59. Lens' (HudOptions b_aG59) RectOptions axisPad_ :: forall b_aG58. Lens' (AxisOptions b_aG58) Double axisOrientation_ :: forall b_aG58. Lens' (AxisOptions b_aG58) Orientation axisPlace_ :: forall b_aG58. Lens' (AxisOptions b_aG58) Place axisRect_ :: forall b_aG58. Lens' (AxisOptions b_aG58) RectOptions axisRectHeight_ :: forall b_aG58. Lens' (AxisOptions b_aG58) Double axisMark_ :: forall b_aG58 b_aOnD. Lens (AxisOptions b_aG58) (AxisOptions b_aOnD) (GlyphOptions b_aG58) (GlyphOptions b_aOnD) axisMarkStart_ :: forall b_aG58. Lens' (AxisOptions b_aG58) Double axisGap_ :: forall b_aG58. Lens' (AxisOptions b_aG58) Double axisLabel_ :: forall b_aG58. Lens' (AxisOptions b_aG58) LabelOptions axisTickStyle_ :: forall b_aG58. Lens' (AxisOptions b_aG58) TickStyle titleText_ :: Lens' TitleOptions TextOptions titleAlign_ :: Lens' TitleOptions AlignH titlePlace_ :: Lens' TitleOptions Place titleGap_ :: Lens' TitleOptions Double legendChartType_ :: forall b_aG56 b_aOw2. Lens (LegendOptions b_aG56) (LegendOptions b_aOw2) [(LegendType b_aG56, Text)] [(LegendType b_aOw2, Text)] legendInnerPad_ :: forall b_aG56. Lens' (LegendOptions b_aG56) Double legendInnerSep_ :: forall b_aG56. Lens' (LegendOptions b_aG56) Double legendGap_ :: forall b_aG56. Lens' (LegendOptions b_aG56) Double legendRowPad_ :: forall b_aG56. Lens' (LegendOptions b_aG56) Double legendPlace_ :: forall b_aG56. Lens' (LegendOptions b_aG56) Place legendAlign_ :: forall b_aG56. Lens' (LegendOptions b_aG56) AlignH legendSep_ :: forall b_aG56. Lens' (LegendOptions b_aG56) Double legendRect_ :: forall b_aG56. Lens' (LegendOptions b_aG56) RectOptions legendText_ :: forall b_aG56. Lens' (LegendOptions b_aG56) TextOptions lineSize_ :: Lens' LineOptions Double lineColor_ :: Lens' LineOptions (AlphaColour Double) rectBorderSize_ :: Lens' RectOptions Double rectBorderColor_ :: Lens' RectOptions (AlphaColour Double) rectColor_ :: Lens' RectOptions (AlphaColour Double) textSize_ :: Lens' TextOptions Double textAlignH_ :: Lens' TextOptions AlignH textColor_ :: Lens' TextOptions (AlphaColour Double) textFillRule_ :: Lens' TextOptions FillRule textRotation_ :: Lens' TextOptions Double textFont_ :: Lens' TextOptions (PreparedFont Double) labelText_ :: Lens' LabelOptions TextOptions labelOrientation_ :: Lens' LabelOptions (Pair Double) labelGap_ :: Lens' LabelOptions Double gridOrientation_ :: Lens' GridOptions Orientation gridStyle_ :: Lens' GridOptions GridStyle gridLine_ :: Lens' GridOptions LineOptions -- | The Chart module exports all of the chart-unit functionality, and most -- of what you need from outside libraries. -- -- Chart is designed to be used in conjunction with both the numhask and -- diagrams preludes. Diagrams.Prelude conatins much of the lens library -- and many re-exports that clash with NumHask, so best to import -- qualified. -- --
--   {-# NoImplicitPrelude #-}
--   {-# OverloadedString #-}
--   import NumHask.Prelude
--   import qualified Diagrams.Prelude as D
--   import Chart
--   
module Chart -- | A class for types with a default value. class Default a -- | The default value for this type. def :: Default a => a -- | A space efficient, packed, unboxed Unicode text type. data Text :: * -- | a scratch pad scratch :: Diagram SVG -> IO ()