-- 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.7.0.0 -- | 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: -- --
--   scaleExample :: IO ()
--   scaleExample =
--       fileSvg "other/scaleExample.svg" (#size .~ Pair 300 120 $ def) $
--       withHud
--         def
--         widescreen
--         (Rect 0 12 0 0.2)
--         (lineChart (repeat def))
--         (vlineOneD ((0.01*) <$> [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, Renderable (Text Double) b) => QDiagram b V2 Double Any -- | 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)) -- | the aspect of a chart expressed as a ratio of x-plane : y-plane. aspect :: (BoundedField a, Ord a, Multiplicative a, FromInteger a) => a -> Rect a -- | a 1:1 aspect asquare :: Rect Double -- | a 1.5:1 aspect sixbyfour :: Rect Double -- | golden ratio golden :: Rect Double -- | a 3:1 aspect widescreen :: Rect Double -- | a skinny 5:1 aspect skinny :: Rect Double -- | 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 -- | svg text is lower by default alignVTU :: AlignV -> Double -- | Orientation for an element. Watch this space for curvature! data Orientation Hori :: Orientation Vert :: Orientation -- | Placement of elements around (what is implicity but maybe shouldn't -- just be) a rectangular canvas data Place PlaceLeft :: Place PlaceRight :: Place PlaceTop :: Place PlaceBottom :: Place -- | 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 data UColor a UColor :: a -> a -> a -> a -> UColor a [ucred] :: UColor a -> a [ucgreen] :: UColor a -> a [ucblue] :: UColor a -> a [ucopacity] :: UColor a -> a -- | convert a UColor to an AlphaColour acolor :: (Floating a, Num a, Ord a) => UColor a -> AlphaColour a -- | convert an AlphaColour to a UColor ucolor :: (Floating a, Num a, Ord a) => AlphaColour a -> UColor a -- | convert a Colour to a UColor ccolor :: (Floating a, Num a, Ord a) => Colour a -> UColor a -- | the official chart-unit blue ublue :: UColor Double -- | the official chart-unit grey ugrey :: UColor Double -- | transparent utrans :: UColor Double -- | black ublack :: UColor Double -- | white uwhite :: UColor 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 GHC.Generics.Generic (Chart.Core.UColor a) instance GHC.Show.Show a => GHC.Show.Show (Chart.Core.UColor a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Chart.Core.UColor a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Chart.Core.UColor a) instance GHC.Generics.Generic Chart.Core.Place instance GHC.Show.Show Chart.Core.Place instance GHC.Classes.Eq Chart.Core.Place instance GHC.Generics.Generic Chart.Core.Orientation instance GHC.Show.Show Chart.Core.Orientation instance GHC.Classes.Eq Chart.Core.Orientation instance GHC.Generics.Generic Chart.Core.AlignV instance GHC.Show.Show Chart.Core.AlignV instance GHC.Classes.Eq Chart.Core.AlignV instance GHC.Generics.Generic Chart.Core.AlignH instance GHC.Show.Show Chart.Core.AlignH instance GHC.Classes.Eq Chart.Core.AlignH instance Linear.V1.R1 NumHask.Pair.Pair instance Linear.V2.R2 NumHask.Pair.Pair -- | 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 -- | ArrowStyles based on diagrams data ArrowHTStyle a Tri :: ArrowHTStyle a Dart :: ArrowHTStyle a HalfDart :: ArrowHTStyle a Spike :: ArrowHTStyle a Thorn :: ArrowHTStyle a LineHead :: ArrowHTStyle a NoHead :: ArrowHTStyle a Tri2 :: a -> ArrowHTStyle a Dart2 :: a -> ArrowHTStyle a HalfDart2 :: a -> ArrowHTStyle a Spike2 :: a -> ArrowHTStyle a Thorn2 :: a -> ArrowHTStyle a Tri' :: ArrowHTStyle a Dart' :: ArrowHTStyle a HalfDart' :: ArrowHTStyle a Spike' :: ArrowHTStyle a Thorn' :: ArrowHTStyle a LineTail :: ArrowHTStyle a NoTail :: ArrowHTStyle a Quill :: ArrowHTStyle a Block :: ArrowHTStyle a Quill2 :: a -> ArrowHTStyle a Block2 :: a -> ArrowHTStyle a -- | todo: quite a clunky specification of what an arrow is (or could be) data ArrowOptions ArrowOptions :: Double -> Double -> Double -> Double -> Double -> Double -> UColor Double -> ArrowHTStyle Double -> ArrowOptions [minLength] :: ArrowOptions -> Double [maxLength] :: ArrowOptions -> Double [minHeadLength] :: ArrowOptions -> Double [maxHeadLength] :: ArrowOptions -> Double [minStaffWidth] :: ArrowOptions -> Double [maxStaffWidth] :: ArrowOptions -> Double [color] :: ArrowOptions -> UColor Double [hStyle] :: ArrowOptions -> ArrowHTStyle Double -- | 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 -- --
--   arrowsExample :: Chart b
--   arrowsExample =
--     arrows
--       ( #maxLength .~ 0.5 $
--         #maxHeadLength .~ 0.2 $
--         #maxStaffWidth .~ 0.01 $ def)
--       [ Arrow (Pair x (sin (5 * x))) (Pair x (cos x))
--       | x <- grid MidPos (one :: Range Double) 100
--       ]
--   
-- arrows :: (Traversable f) => ArrowOptions -> f Arrow -> Chart b -- | A chart of arrows arrowChart :: (Traversable f) => [ArrowOptions] -> Rect Double -> Rect Double -> [f Arrow] -> Chart b -- | An arrow chart scaled to its own range -- --
--   arrowChart_Example :: Chart b
--   arrowChart_Example = arrowChart_ [def] asquare [as]
--     where
--       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_ :: (Traversable f) => [ArrowOptions] -> Rect Double -> [f Arrow] -> Chart b instance GHC.Generics.Generic Chart.Arrow.Arrow instance GHC.Show.Show Chart.Arrow.Arrow instance GHC.Classes.Eq Chart.Arrow.Arrow instance GHC.Generics.Generic Chart.Arrow.ArrowOptions instance GHC.Show.Show Chart.Arrow.ArrowOptions instance GHC.Generics.Generic (Chart.Arrow.ArrowHTStyle a) instance GHC.Show.Show a => GHC.Show.Show (Chart.Arrow.ArrowHTStyle a) instance Data.Default.Class.Default Chart.Arrow.ArrowOptions -- | 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 rectangular bars with a gap -- between rectBars :: (Enum a, FromInteger a, Ord a, BoundedField a) => 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)] -- | transpose the dimensions of a Rect rectTrans :: Rect a -> Rect a -- | data algorithms related to time module Chart.Data.Time -- | parse text as per iso8601 -- --
--   >>> :set -XOverloadedStrings
--   
--   >>> let t0 = parseUTCTime ("2017-12-05" :: Text)
--   
--   >>> t0
--   Just 2017-12-05 00:00:00 UTC
--   
parseUTCTime :: Text -> Maybe UTCTime -- | a step in time data TimeGrain Years :: Integer -> TimeGrain Months :: Int -> TimeGrain Days :: Int -> TimeGrain Hours :: Int -> TimeGrain Minutes :: Int -> TimeGrain Seconds :: Double -> TimeGrain -- | compute the floor UTCTime based on the timegrain -- --
--   >>> floorGrain (Years 5) (UTCTime (fromGregorian 1999 1 1) 0)
--   1995-12-31 00:00:00 UTC
--   
-- --
--   >>> floorGrain (Months 3) (UTCTime (fromGregorian 2016 12 30) 0)
--   2016-09-30 00:00:00 UTC
--   
-- --
--   >>> floorGrain (Days 5) (UTCTime (fromGregorian 2016 12 30) 1)
--   2016-12-30 00:00:00 UTC
--   
-- --
--   >>> floorGrain (Minutes 15) (UTCTime (fromGregorian 2016 12 30) (fromDouble' $ 15*60+1))
--   2016-12-30 00:15:00 UTC
--   
-- --
--   >>> floorGrain (Seconds 0.1) (UTCTime (fromGregorian 2016 12 30) 0.12)
--   2016-12-30 00:00:00.1 UTC
--   
floorGrain :: TimeGrain -> UTCTime -> UTCTime -- | compute the ceiling UTCTime based on the timegrain -- --
--   >>> ceilingGrain (Years 5) (UTCTime (fromGregorian 1999 1 1) 0)
--   2000-12-31 00:00:00 UTC
--   
-- --
--   >>> ceilingGrain (Months 3) (UTCTime (fromGregorian 2016 12 30) 0)
--   2016-12-31 00:00:00 UTC
--   
-- --
--   >>> ceilingGrain (Days 5) (UTCTime (fromGregorian 2016 12 30) 1)
--   2016-12-31 00:00:00 UTC
--   
-- --
--   >>> ceilingGrain (Minutes 15) (UTCTime (fromGregorian 2016 12 30) (fromDouble' $ 15*60+1))
--   2016-12-30 00:30:00 UTC
--   
-- --
--   >>> ceilingGrain (Seconds 0.1) (UTCTime (fromGregorian 2016 12 30) 0.12)
--   2016-12-30 00:00:00.2 UTC
--   
ceilingGrain :: TimeGrain -> UTCTime -> UTCTime -- | compute a sensible TimeGrain and list of UTCTimes -- --
--   >>> sensibleTimeGrid InnerPos 2 (UTCTime (fromGregorian 2016 12 31) 0, UTCTime (fromGregorian 2017 12 31) 0)
--   (Months 6,[2016-12-31 00:00:00 UTC,2017-06-30 00:00:00 UTC,2017-12-31 00:00:00 UTC])
--   
-- --
--   >>> sensibleTimeGrid InnerPos 2 (UTCTime (fromGregorian 2017 1 1) 0, UTCTime (fromGregorian 2017 12 30) 0)
--   (Months 6,[2017-06-30 00:00:00 UTC])
--   
-- --
--   >>> sensibleTimeGrid UpperPos 2 (UTCTime (fromGregorian 2017 1 1) 0, UTCTime (fromGregorian 2017 12 30) 0)
--   (Months 6,[2017-06-30 00:00:00 UTC,2017-12-31 00:00:00 UTC])
--   
-- --
--   >>> sensibleTimeGrid LowerPos 2 (UTCTime (fromGregorian 2017 1 1) 0, UTCTime (fromGregorian 2017 12 30) 0)
--   (Months 6,[2016-12-31 00:00:00 UTC,2017-06-30 00:00:00 UTC])
--   
sensibleTimeGrid :: Pos -> Int -> (UTCTime, UTCTime) -> (TimeGrain, [UTCTime]) -- | whether to include lower and upper times data PosDiscontinuous PosInnerOnly :: PosDiscontinuous PosIncludeBoundaries :: PosDiscontinuous -- | dates attached to charts are often discontinuous, but we want to -- smooth that reality over and show a continuous range on the axis The -- assumption with getSensibleTimeGrid is that there is a list of -- discountinuous UTCTimes rather than a continuous range. Output is a -- list of index points for the original [UTCTime] and label tuples, and -- a list of unused list elements. -- --
--   >>> placedTimeLabelDiscontinuous PosIncludeBoundaries (Just "%d %b") 2 [UTCTime (fromGregorian 2017 12 6) 0, UTCTime (fromGregorian 2017 12 29) 0, UTCTime (fromGregorian 2018 1 31) 0, UTCTime (fromGregorian 2018 3 3) 0]
--   ([(0,"06 Dec"),(1,"31 Dec"),(2,"28 Feb"),(3,"03 Mar")],[])
--   
placedTimeLabelDiscontinuous :: PosDiscontinuous -> Maybe Text -> Int -> [UTCTime] -> ([(Int, Text)], [UTCTime]) instance GHC.Generics.Generic Chart.Data.Time.TimeGrain instance GHC.Show.Show Chart.Data.Time.TimeGrain -- | rectangular chart elements module Chart.Rect -- | Just about everything on a chart is a rectangle. data RectOptions RectOptions :: Double -> UColor Double -> UColor Double -> RectOptions [borderSize] :: RectOptions -> Double [borderColor] :: RectOptions -> UColor Double [color] :: RectOptions -> UColor Double -- | solid rectangle, no border blob :: UColor Double -> RectOptions -- | clear rect, with border box :: UColor Double -> RectOptions -- | clear and utrans 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 -- --
--   rect_Example :: Double -> Chart b
--   rect_Example n =
--     labelled (opts (Pair n 1)) "z,w" $
--     labelled (opts (Pair n -1)) "z,y" $
--     labelled (opts (Pair (-n) 1)) "x,w" $
--     labelled (opts (Pair (-n) -1)) "x,y" $
--     rect_ def (Ranges (n *. one) one)
--     where
--       opts :: Pair Double -> LabelOptions
--       opts o =
--         #text %~
--           ( (#color .~ black `withOpacity` 0.8) .
--             (#size .~ 0.3)) $
--         #orientation .~ o $
--         def
--   
-- 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 (rectBars 0 [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] -> Rect Double -> Rect Double -> [f (Rect Double)] -> Chart b -- | A chart of rectangles scaled to its own range -- --
--   ropts :: [RectOptions]
--   ropts =
--     [ #borderSize .~ 0 $ def
--     , #borderSize .~ 0 $ #color .~ ucolor 0.3 0.3 0.3 0.2 $ def
--     ]
--   
--   rss :: [[Rect Double]]
--   rss =
--     [ rectXY (\x -> exp (-(x ** 2) / 2)) (Range -5 5) 50
--     , rectXY (\x -> 0.5 * exp (-(x ** 2) / 8)) (Range -5 5) 50
--     ]
--   
--   rectChart_Example :: Chart b
--   rectChart_Example = rectChart_ ropts widescreen rss
--   
-- rectChart_ :: (Traversable f) => [RectOptions] -> Rect Double -> [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 -> UColor Double -> Pixel [pixelRect] :: Pixel -> Rect Double [pixelColor] :: Pixel -> UColor Double -- | A pixel is a rectangle with a color. -- --
--   pixel_Example :: Chart b
--   pixel_Example = text_ opt "I'm a pixel!" <> pixel_ (Pixel one ublue)
--     where
--       opt =
--         #color .~ withOpacity black 0.8 $
--         #size .~ 0.2 $
--         def
--   
-- pixel_ :: Pixel -> Chart b -- | Render multiple pixels -- --
--   pixelsExample :: Chart b
--   pixelsExample =
--     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) => Rect Double -> 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
--          (ucolor 0.47 0.73 0.86 1)
--          (ucolor 0.01 0.06 0.22 1)
--         )) <$>
--      rectF (\(Pair x y) -> (x+y)*(x+y))
--      one (Pair 40 40)]
--   
-- pixelChart_ :: (Traversable f) => Rect Double -> [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 -> Rect Double -> Rect Double -> (Pair Double -> Double) -> Chart b instance GHC.Generics.Generic Chart.Rect.Pixel instance GHC.Show.Show Chart.Rect.Pixel instance GHC.Generics.Generic Chart.Rect.RectOptions instance GHC.Show.Show Chart.Rect.RectOptions instance Data.Default.Class.Default Chart.Rect.PixelationOptions instance Data.Default.Class.Default Chart.Rect.RectOptions -- | Svg rendering module Chart.Svg -- | ToDo: Mathjax capability would be awesome but the html that mathjax -- generates is not valid svg unless it is wrapped in -- foreignObject instead of text. foreignObject also -- cant be a sub-element of a text element. This means extensive digging -- into Diagrams innards etc -- -- https://stackoverflow.com/questions/15962325/mathjax-inside-svg -- -- Svg options data SvgOptions SvgOptions :: Pair Double -> Text -> [Attribute] -> Bool -> SvgOptions [$sel:size:SvgOptions] :: SvgOptions -> Pair Double [$sel:svgId:SvgOptions] :: SvgOptions -> Text [$sel:attributes:SvgOptions] :: SvgOptions -> [Attribute] [$sel:includeDocType:SvgOptions] :: SvgOptions -> Bool renderSvg :: SvgOptions -> Chart SVG -> Element -- | render svg to text toText :: SvgOptions -> Chart SVG -> Text -- | write an svg to file toFile :: FilePath -> Element -> IO () -- | write a chart to an svg file fileSvg :: FilePath -> SvgOptions -> Chart SVG -> IO () -- | a scratch pad scratch :: Chart SVG -> IO () instance GHC.Generics.Generic Chart.Svg.SvgOptions instance GHC.Show.Show Chart.Svg.SvgOptions instance Data.Default.Class.Default Chart.Svg.SvgOptions -- | textual chart elements module Chart.Text -- | text options data TextOptions TextOptions :: Double -> AlignH -> AlignV -> UColor Double -> UFillRule -> Double -> TextType -> TextOptions -- | size as ratio to overall chart size (default: 0.08) [size] :: TextOptions -> Double -- | horizontal alignment (default: AlignCenter) [alignH] :: TextOptions -> AlignH -- | vertical alignment (default: AlignMid) [alignV] :: TextOptions -> AlignV -- | default: greyish [color] :: TextOptions -> UColor Double -- | default: EvenOdd [textFillRule] :: TextOptions -> UFillRule -- | in degrees from the horozontal (default: 0 degrees) [rotation] :: TextOptions -> Double -- | default: TextPath def [textType] :: TextOptions -> TextType -- | options specific to text as an SVG path newtype TextPathOptions TextPathOptions :: TextFont -> TextPathOptions [font] :: TextPathOptions -> TextFont -- | options specific to text as SVG text data TextSvgOptions TextSvgOptions :: Double -> Double -> Double -> Double -> Maybe Text -> Double -> Double -> RectOptions -> TextSvgOptions [nudgeSize] :: TextSvgOptions -> Double [nudgeBottom] :: TextSvgOptions -> Double [nudgeMid] :: TextSvgOptions -> Double [nudgeTop] :: TextSvgOptions -> Double [svgFont] :: TextSvgOptions -> Maybe Text -- | approximate divisor of vertical size [sizeVert] :: TextSvgOptions -> Double -- | approximate divisor of horizontal size per character [sizeHori] :: TextSvgOptions -> Double -- | bounding box [textBox] :: TextSvgOptions -> RectOptions -- | text as a path or as svg text data TextType TextPath :: TextPathOptions -> TextType TextSvg :: TextSvgOptions -> TextType -- | ADT of fonts data TextFont Lin2 :: TextFont FromFontFile :: Text -> TextFont data UFillRule UWinding :: UFillRule UEvenOdd :: UFillRule -- | transform from chart-unit to SVGFonts rep of font textFont :: TextFont -> PreparedFont Double -- | Create a textual chart element -- --
--   text_ def "Welcome to chart-unit!"
--   
-- -- -- Text can be either SVG text or text rendered as an SVG path. Text as -- SVG can be overridden by an opinionated browser. SVG Text not have a -- size, according to diagrams, and according to the svg standards for -- all I know. textSvg corrects for this by adding an approximately -- bounding rectangle so that size is forced. -- --
--   text_SvgExample :: Chart b
--   text_SvgExample = text_
--     (#textType .~ TextSvg (#textBox .~ def $ #svgFont .~ Just "Comic Sans MS" $ def) $
--     #size .~ 0.2 $
--     def)
--     "abc & 0123 & POW!"
--   
-- -- -- Text as an SVG path can use the fonts supplied in SVGFonts, -- follow the instructions there to make your own, or use the -- Hasklig font supplied in chart-unit. -- --
--   text_PathExample :: Chart b
--   text_PathExample = text_
--     (#textType .~ TextPath (#font .~ FromFontFile "other/Hasklig-Regular.svg" $ def) $
--      #size .~ 0.2 $
--      def)
--      "0123 <*> <$> <| |> <> <- -> => ::"
--   
-- text_ :: TextOptions -> Text -> Chart b -- | Create positioned text from a list texts :: (R2 r) => TextOptions -> [(Text, r Double)] -> Chart b -- | A chart of text textChart :: (Traversable f) => [TextOptions] -> Rect Double -> Rect Double -> [f (Text, Pair Double)] -> Chart b -- | A chart of text scaled to its own range -- --
--   ts :: [(Text, Pair Double)]
--   ts = zip
--     (map Text.singleton ['a' .. 'z'])
--     [Pair (sin (x * 0.1)) x | x <- [0 .. 25]]
--   
--   textChart_Example :: Chart b
--   textChart_Example =
--     textChart_ [#size .~ 0.33 $ def] widescreen [ts]
--   
-- textChart_ :: [TextOptions] -> Rect Double -> [[(Text, Pair Double)]] -> Chart b -- | A label is a text element attached to a chart element data LabelOptions LabelOptions :: TextOptions -> Pair Double -> Double -> LabelOptions [text] :: LabelOptions -> TextOptions -- | direction of label [orientation] :: LabelOptions -> Pair Double -- | distance to label [gap] :: LabelOptions -> Double -- | Label a chart element with some text -- --
--   labelledExample :: Chart b
--   labelledExample = D.pad 1.1 $
--     labelled (LabelOptions
--       (#alignH .~ AlignLeft $ #rotation .~ 45 $ def) (Pair 1 1) 0.02)
--     "a label"
--     (glyph_ def)
--   
-- labelled :: LabelOptions -> Text -> Chart b -> Chart b instance GHC.Generics.Generic Chart.Text.LabelOptions instance GHC.Show.Show Chart.Text.LabelOptions instance GHC.Generics.Generic Chart.Text.TextOptions instance GHC.Show.Show Chart.Text.TextOptions instance GHC.Generics.Generic Chart.Text.UFillRule instance GHC.Classes.Eq Chart.Text.UFillRule instance GHC.Show.Show Chart.Text.UFillRule instance GHC.Generics.Generic Chart.Text.TextType instance GHC.Show.Show Chart.Text.TextType instance GHC.Generics.Generic Chart.Text.TextSvgOptions instance GHC.Show.Show Chart.Text.TextSvgOptions instance GHC.Generics.Generic Chart.Text.TextPathOptions instance GHC.Show.Show Chart.Text.TextPathOptions instance GHC.Generics.Generic Chart.Text.TextFont instance GHC.Show.Show Chart.Text.TextFont instance Data.Default.Class.Default Chart.Text.LabelOptions instance Data.Default.Class.Default Chart.Text.TextOptions instance Data.Default.Class.Default Chart.Text.TextSvgOptions instance Data.Default.Class.Default Chart.Text.TextPathOptions -- | 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 GlyphOptions :: Double -> UColor Double -> UColor Double -> Double -> GlyphShape -> GlyphOptions -- | glyph radius [size] :: GlyphOptions -> Double [color] :: GlyphOptions -> UColor Double [borderColor] :: GlyphOptions -> UColor Double -- | normalized [borderSize] :: GlyphOptions -> Double [shape] :: GlyphOptions -> GlyphShape -- | shape of the glyph expressed in diagrams terms data GlyphShape Circle :: GlyphShape Square :: GlyphShape Ellipse :: Double -> GlyphShape Triangle :: GlyphShape Pentagon :: GlyphShape Hexagon :: GlyphShape Septagon :: GlyphShape Octagaon :: GlyphShape RectSharp :: Double -> GlyphShape RectRounded :: Double -> Double -> GlyphShape VLine :: Double -> GlyphShape HLine :: Double -> GlyphShape -- | convert from chart-unit to diagrams shapes glyphShape :: GlyphShape -> (Double -> Chart b) -- | Create a glyph. -- --
--   glyph_ def
--   
-- glyph_ :: GlyphOptions -> Chart b -- | Create positioned glyphs. -- --
--   glyphs def (dataXY sin (Range 0 (2*pi)) 30)
--   
-- glyphs :: (R2 r, Traversable f) => GlyphOptions -> f (r Double) -> Chart b -- | Create labelled, positioned glyphs. -- --
--   lglyphsExample :: Chart b
--   lglyphsExample =
--     lglyphs def def $
--     zip (show <$> [0 ..]) [Pair (x / 10) (sin x / 10) | x <- [0 .. 10]]
--   
-- lglyphs :: (R2 r, Traversable f) => LabelOptions -> GlyphOptions -> f (Text, r Double) -> Chart b -- | A chart of glyphs glyphChart :: (Traversable f) => [GlyphOptions] -> Rect Double -> Rect Double -> [f (Pair Double)] -> Chart b -- | A chart of glyphs scaled to its own range -- --
--   gopts :: [GlyphOptions]
--   gopts =
--     [ #borderSize .~ 0.001 $ def
--     , #borderSize .~ 0.001 $
--       #size .~ 0.1 $
--       #color .~ rybColor 7 `withOpacity` 0.4 $
--       #shape .~ Triangle $ def
--     ]
--   
--   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] -> Rect Double -> [f (Pair Double)] -> Chart b -- | A chart of labelled glyphs lglyphChart :: (Traversable f) => [LabelOptions] -> [GlyphOptions] -> Rect Double -> Rect Double -> [f (Text, Pair Double)] -> Chart b -- | A chart of labelled glyphs scaled to its own range -- --
--   lgdata :: [(Text, Pair Double)]
--   lgdata =
--     [(\(p@(Pair x y)) -> (show x <> "," <> show y, fromIntegral <$> p)) <$>
--       (Pair <$> [0 .. 5] <*> [0 .. 5] :: [Pair Int])
--     ]
--   
--   lglyphChart_Example :: Rect Double -> Chart b
--   lglyphChart_Example a =
--     lglyphChart_
--     [#gap .~ 0.015 $ #text . #size .~ 0.12 $ def]
--     [#color .~ black `withOpacity` 1 $
--      #borderSize .~ 0 $
--      #size .~ 0.01 $
--      def]
--     a
--     [lgdata]
--   
-- lglyphChart_ :: (Traversable f) => [LabelOptions] -> [GlyphOptions] -> Rect Double -> [f (Text, Pair Double)] -> Chart b instance GHC.Generics.Generic Chart.Glyph.GlyphOptions instance GHC.Show.Show Chart.Glyph.GlyphOptions instance GHC.Generics.Generic Chart.Glyph.GlyphShape instance GHC.Show.Show Chart.Glyph.GlyphShape instance Data.Default.Class.Default Chart.Glyph.GlyphOptions -- | 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 -> UColor Double -> LineOptions -- | normalized [size] :: LineOptions -> Double [color] :: LineOptions -> UColor Double -- | A single line connecting 2 points oneline :: (R2 r) => LineOptions -> Pair (r Double) -> Chart b -- | A line connecting a series of points -- --
--   linesExample :: Int -> Chart b
--   linesExample n =
--     lines
--     (#color .~ red `withOpacity` 0.5 $ 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 -> f (r Double) -> Chart b -- | A chart of lines lineChart :: (Traversable f) => [LineOptions] -> Rect Double -> Rect Double -> [f (Pair Double)] -> Chart b -- | A chart of lines scaled to its own range -- --
--   ls :: [[Pair Double]]
--   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 :: [LineOptions]
--   lopts =
--     zipWith
--     (\x y -> LineOptions x (withOpacity (d3Colors1 y) 0.6))
--     [0.01, 0.02, 0.005]
--     [0,1,2]
--   
--   lineChart_Example :: Chart b
--   lineChart_Example = lineChart_ lopts sixbyfour ls
--   
-- lineChart_ :: (Traversable f) => [LineOptions] -> Rect Double -> [f (Pair Double)] -> Chart b -- | A chart of glines glineChart :: (Traversable f) => [LineOptions] -> [GlyphOptions] -> Rect Double -> Rect Double -> [f (Pair Double)] -> Chart b -- | A chart of glyphs_lines scaled to its own range -- --
--   gopts3 :: [GlyphOptions]
--   gopts3 =
--     zipWith
--     (\x y ->
--        #color .~ withOpacity (d3Colors1 x) 0.2 $
--        #borderColor .~ withOpacity (d3Colors1 x) 1 $
--        #borderSize .~ 0.005 $
--        #shape .~ y $
--        #size .~ 0.08 $
--        def)
--     [6,8,2]
--     [Triangle, Square, Circle]
--   
--   glineChart_Example :: Chart b
--   glineChart_Example = glineChart_ lopts gopts3 sixbyfour ls
--   
-- glineChart_ :: (Traversable f) => [LineOptions] -> [GlyphOptions] -> Rect Double -> [f (Pair Double)] -> Chart b instance GHC.Generics.Generic Chart.Line.LineOptions instance GHC.Show.Show Chart.Line.LineOptions instance Data.Default.Class.Default Chart.Line.LineOptions -- | Hud (Heads up display) is a collective noun for axes, titles & -- legends module Chart.Hud -- | Various options for a hud. -- -- Defaults to the classical x- and y-axis, no titles and no legends data HudOptions HudOptions :: Double -> [AxisOptions] -> [GridOptions] -> [(TitleOptions, Text)] -> [LegendOptions] -> RectOptions -> HudOptions [$sel:outerPad:HudOptions] :: HudOptions -> Double [$sel:axes:HudOptions] :: HudOptions -> [AxisOptions] [$sel:grids:HudOptions] :: HudOptions -> [GridOptions] [$sel:titles:HudOptions] :: HudOptions -> [(TitleOptions, Text)] [$sel:legends:HudOptions] :: HudOptions -> [LegendOptions] [$sel:canvas:HudOptions] :: HudOptions -> RectOptions -- | Create a hud. -- --
--   hud def sixbyfour one
--   
-- hud :: () => HudOptions -> Rect Double -> Rect Double -> Chart b -- | attach a hud to a chart with a specific range withHud :: HudOptions -> Rect Double -> Rect Double -> (Rect Double -> Rect Double -> [f (Pair Double)] -> Chart b) -> [f (Pair Double)] -> Chart b -- | 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
--   
-- withHud_ :: (Foldable f) => HudOptions -> Rect Double -> (Rect Double -> Rect Double -> [f (Pair Double)] -> Chart b) -> [f (Pair Double)] -> Chart b -- | 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 AxisOptions :: Double -> Orientation -> Place -> RectOptions -> Double -> GlyphOptions -> Double -> Double -> LabelOptions -> TickStyle -> AxisOptions [$sel:outerPad:AxisOptions] :: AxisOptions -> Double [$sel:orientation:AxisOptions] :: AxisOptions -> Orientation [$sel:place:AxisOptions] :: AxisOptions -> Place [$sel:rect:AxisOptions] :: AxisOptions -> RectOptions [$sel:rectHeight:AxisOptions] :: AxisOptions -> Double [$sel:mark:AxisOptions] :: AxisOptions -> GlyphOptions [$sel:markStart:AxisOptions] :: AxisOptions -> Double [$sel:gap:AxisOptions] :: AxisOptions -> Double [$sel:label:AxisOptions] :: AxisOptions -> LabelOptions [$sel:tickStyle:AxisOptions] :: AxisOptions -> TickStyle -- | default X axis defXAxis :: AxisOptions -- | default Y axis defYAxis :: AxisOptions -- | 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
--   
-- axis :: () => AxisOptions -> Range Double -> Range Double -> Chart b -- | options for prettifying axis decorations data AutoOptions AutoOptions :: Double -> Double -> Double -> Bool -> AutoOptions [$sel:maxXRatio:AutoOptions] :: AutoOptions -> Double [$sel:maxYRatio:AutoOptions] :: AutoOptions -> Double [$sel:angledRatio:AutoOptions] :: AutoOptions -> Double [$sel:allowDiagonal:AutoOptions] :: AutoOptions -> Bool -- | adjust an axis for sane font sizes etc adjustAxis :: AutoOptions -> Range Double -> Range Double -> AxisOptions -> AxisOptions -- | create an axis, with adjustment to axis options if needed axisSane :: () => AutoOptions -> AxisOptions -> Range Double -> Range Double -> Chart b -- | compute tick values and labels given options and ranges computeTicks :: AxisOptions -> Range Double -> Range Double -> ([Double], [Text]) -- | Options for titles. Defaults to center aligned, and placed at Top of -- the hud data TitleOptions TitleOptions :: TextOptions -> AlignH -> Place -> Double -> TitleOptions [$sel:text:TitleOptions] :: TitleOptions -> TextOptions [$sel:align:TitleOptions] :: TitleOptions -> AlignH [$sel:place:TitleOptions] :: TitleOptions -> Place [$sel:gap:TitleOptions] :: 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 :: Rect Double -> TitleOptions -> Text -> Chart b -- | LegendType reuses all the various chart option types to help formulate -- a legend data LegendType LegendText :: TextOptions -> LegendType LegendGlyph :: GlyphOptions -> LegendType LegendLine :: LineOptions -> Double -> LegendType LegendGLine :: GlyphOptions -> LineOptions -> Double -> LegendType LegendRect :: RectOptions -> Double -> LegendType LegendArrow :: ArrowOptions -> Double -> LegendType LegendPixel :: RectOptions -> Double -> LegendType -- | Legend options. todo: allow for horizontal concatenation. data LegendOptions LegendOptions :: [(LegendType, Text)] -> Double -> Double -> Double -> Double -> Place -> AlignH -> Double -> RectOptions -> TextOptions -> LegendOptions [$sel:chartType:LegendOptions] :: LegendOptions -> [(LegendType, Text)] [$sel:innerPad:LegendOptions] :: LegendOptions -> Double [$sel:innerSep:LegendOptions] :: LegendOptions -> Double [$sel:gap:LegendOptions] :: LegendOptions -> Double [$sel:rowPad:LegendOptions] :: LegendOptions -> Double [$sel:place:LegendOptions] :: LegendOptions -> Place [$sel:align:LegendOptions] :: LegendOptions -> AlignH [$sel:sep:LegendOptions] :: LegendOptions -> Double [$sel:canvasRect:LegendOptions] :: LegendOptions -> RectOptions [$sel:text:LegendOptions] :: LegendOptions -> TextOptions -- | 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
--   
-- legend :: LegendOptions -> 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 :: GridPos -> Int -> GridStyle -- | exactly n lines using Pos GridExact :: GridPos -> Int -> GridStyle -- | specific line placement GridPlaced :: [Double] -> GridStyle -- | Options for gridlines. data GridOptions GridOptions :: Orientation -> GridStyle -> LineOptions -> GridOptions [$sel:gridOrientation:GridOptions] :: GridOptions -> Orientation [$sel:gridStyle:GridOptions] :: GridOptions -> GridStyle [$sel:gridLine:GridOptions] :: GridOptions -> LineOptions -- | The positioning of boundaries for a grid over a space data GridPos GridOuterPos :: GridPos GridInnerPos :: GridPos GridLowerPos :: GridPos GridUpperPos :: GridPos GridMidPos :: GridPos -- | conversion from a chart-unit GridPos to a numhask-range Pos gridPos :: GridPos -> Pos -- | default horizontal grid defXGrid :: GridOptions -- | default vertical grid defYGrid :: GridOptions -- | Create a grid line for a chart. gridl :: GridOptions -> Rect Double -> Rect Double -> Chart b instance GHC.Generics.Generic Chart.Hud.HudOptions instance GHC.Show.Show Chart.Hud.HudOptions instance GHC.Generics.Generic Chart.Hud.GridOptions instance GHC.Show.Show Chart.Hud.GridOptions instance GHC.Generics.Generic Chart.Hud.GridStyle instance GHC.Show.Show Chart.Hud.GridStyle instance GHC.Classes.Eq Chart.Hud.GridPos instance GHC.Generics.Generic Chart.Hud.GridPos instance GHC.Show.Show Chart.Hud.GridPos instance GHC.Generics.Generic Chart.Hud.LegendOptions instance GHC.Show.Show Chart.Hud.LegendOptions instance GHC.Generics.Generic Chart.Hud.LegendType instance GHC.Show.Show Chart.Hud.LegendType instance GHC.Generics.Generic Chart.Hud.TitleOptions instance GHC.Show.Show Chart.Hud.TitleOptions instance GHC.Generics.Generic Chart.Hud.AxisOptions instance GHC.Show.Show Chart.Hud.AxisOptions instance GHC.Generics.Generic Chart.Hud.TickStyle instance GHC.Show.Show Chart.Hud.TickStyle instance GHC.Generics.Generic Chart.Hud.AutoOptions instance GHC.Show.Show Chart.Hud.AutoOptions instance Data.Default.Class.Default Chart.Hud.HudOptions instance Data.Default.Class.Default Chart.Hud.GridOptions instance Data.Default.Class.Default Chart.Hud.LegendOptions instance Data.Default.Class.Default Chart.Hud.TitleOptions instance Data.Default.Class.Default Chart.Hud.AxisOptions instance Data.Default.Class.Default Chart.Hud.AutoOptions -- | bar charts module Chart.Bar -- | the usual bar chart eye-candy data BarOptions BarOptions :: [RectOptions] -> Double -> Double -> Bool -> BarValueAcc -> Orientation -> HudOptions -> BarOptions [rectOptions] :: BarOptions -> [RectOptions] [outerGap] :: BarOptions -> Double [innerGap] :: BarOptions -> Double [displayValues] :: BarOptions -> Bool [accumulateValues] :: BarOptions -> BarValueAcc [orientation] :: BarOptions -> Orientation [hudOptions] :: BarOptions -> HudOptions -- | whether to separate each Rect grouping or accumulate them data BarValueAcc BarValueSeparate :: BarValueAcc BarValueAccumulate :: BarValueAcc -- | imagine a data frame ... data BarData BarData :: [[Double]] -> Maybe [Text] -> Maybe [Text] -> BarData [barData] :: BarData -> [[Double]] [barRowLabels] :: BarData -> Maybe [Text] [barColumnLabels] :: BarData -> Maybe [Text] -- | convert data to a range assuming a zero bound a very common but -- implicit assumption in a lot of bar charts barDataLowerUpper :: BarValueAcc -> [[Double]] -> [[(Double, Double)]] -- | calculate the Rect range of a bar data set (imagine a data frame ...) barRange :: [[Double]] -> Rect Double -- | A bar chart -- --
--   barExample :: Chart b
--   barExample  =
--     barChart def (BarData [ys] Nothing Nothing) <>
--     hud
--     ( #titles .~ [(def,"Bar Chart")] $
--       #axes .~
--       [ #tickStyle .~
--         TickLabels labels' $
--         def
--       ] $
--       #range .~ Just (fold (abs <$> rs)) $
--       def)
--     where
--       labels' = fmap Text.pack <$> take 10 $ (:[]) <$> ['a'..]
--       rs = rectBars 0.1 ys
--       ys = [1,2,3,5,8,0,-2,11,2,1]
--   
-- barChart :: BarOptions -> BarData -> Chart b instance GHC.Generics.Generic Chart.Bar.BarData instance GHC.Show.Show Chart.Bar.BarData instance GHC.Generics.Generic Chart.Bar.BarOptions instance GHC.Show.Show Chart.Bar.BarOptions instance GHC.Generics.Generic Chart.Bar.BarValueAcc instance GHC.Show.Show Chart.Bar.BarValueAcc instance Data.Default.Class.Default Chart.Bar.BarOptions -- | Experimental Chart ADT module Chart.ADT -- | (compound) Chart options data ChartOptions ChartOptions :: Maybe (Rect Double) -> Rect Double -> [ChartSpec] -> ChartOptions [$sel:chartRange:ChartOptions] :: ChartOptions -> Maybe (Rect Double) [$sel:chartAspect:ChartOptions] :: ChartOptions -> Rect Double [$sel:charts:ChartOptions] :: ChartOptions -> [ChartSpec] -- | A single Chart specification data ChartSpec GlyphChart :: [(GlyphOptions, [Pair Double])] -> ChartSpec LGlyphChart :: [((LabelOptions, GlyphOptions), [(Text, Pair Double)])] -> ChartSpec LineChart :: [(LineOptions, [Pair Double])] -> ChartSpec GlineChart :: [((LineOptions, GlyphOptions), [Pair Double])] -> ChartSpec TextChart :: [(TextOptions, [(Text, Pair Double)])] -> ChartSpec RectChart :: [(RectOptions, [Rect Double])] -> ChartSpec PixelChart :: [[Pixel]] -> ChartSpec ArrowChart :: [(ArrowOptions, [Arrow])] -> ChartSpec BarChart :: BarOptions -> BarData -> ChartSpec HudChart :: HudOptions -> ChartSpec -- | render a ChartSpec renderSpec :: Rect Double -> Rect Double -> ChartSpec -> Chart b -- | render a Chart specified using ChartOptions renderChart :: ChartOptions -> Chart b -- | extract the range of a single specification rangeSpec :: ChartSpec -> Maybe (Rect Double) -- | calculate the range of a ChartOptions rangeChart :: ChartOptions -> Rect Double instance GHC.Generics.Generic Chart.ADT.ChartOptions instance GHC.Show.Show Chart.ADT.ChartOptions instance GHC.Generics.Generic Chart.ADT.ChartSpec instance GHC.Show.Show Chart.ADT.ChartSpec instance Data.Default.Class.Default Chart.ADT.ChartOptions -- | 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. -- --
--   {-# LANGUAGE FlexibleContexts #-}
--   {-# LANGUAGE NoImplicitPrelude #-}
--   {-# LANGUAGE OverloadedStrings #-}
--   {-# LANGUAGE OverloadedLabels #-}
--   {-# OPTIONS_GHC -Wall #-}
--   
--   import Chart
--   import Control.Lens
--   import Data.Generics.Labels()
--   import qualified Diagrams.Prelude as D
--   import NumHask.Prelude
--   
-- -- Each chart type is built up from a few different elements: -- -- -- -- Chart data is most often one or more traversable series. Also most -- often, the data is 2-dimensional, representing where on the chart to -- place the representation. Some sort of `(Traversable f) => [f -- Pair]` is commonly used in the library api. -- --
--   ls :: [[Pair Double]]
--   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)]
--     ]
--   
-- -- Each data series has representation options dependent on the chart -- type -- --
--   lopts :: [LineOptions]
--   lopts =
--     zipWith
--     (\x y -> LineOptions x (withOpacity (d3Colors1 y) 0.6))
--     [0.01, 0.02, 0.005]
--     [0,1,2]
--   
-- -- The lens library is used extensively for configuration, and -- generic-lens-labels has been adopted to reduce line noise ... -- --
--   as :: [AxisOptions]
--   as = 
--     [ defXAxis
--     , defYAxis
--     , #label . #orientation .~ Pair 0 1 $
--       #place .~ PlaceTop $
--       defXAxis
--     , #label . #orientation .~ Pair 1 0 $
--       #place .~ PlaceRight $
--       defYAxis
--     ] 
--   
-- -- in the examples (but not in core library code), Data.Generic.Labels is -- used which has its detractions in the form of orphan instance fuss and -- bother. For example, using core generic-lens: -- --
--   #label . #orientation .~ Pair 0 1
--   
-- -- translates to: -- --
--   field @"label" . field @"orientation" .~ Pair 0 1
--   
-- -- which is also a pretty fine api. -- -- Using data-default, lens and OverloadedLabels tends to encourage a -- vertical style, which may annoy line counters, but lead to clear code -- and ease of editing. -- --
--   titles' :: [(TitleOptions, Text)]
--   titles' =
--     [ (def, "Example Chart")
--     , ( #align .~ AlignCenter $
--         #text . #rotation .~ 90 $
--         #text . #size .~ 0.12 $
--         #place .~ PlaceLeft $
--         def
--       , "left axis title")
--     , ( #text . #color .~ ublue $
--         #text . #size .~ 0.08 $
--         #align .~ AlignRight $
--         #place .~ PlaceBottom $
--         def
--       , "bottom right, non-essential note")
--     ]
--   
--   legends' :: [(LegendType, Text)]
--   legends' =
--     [(LegendText def, "legend")] <>
--     [(LegendPixel (blob ublue) 0.05, "pixel")] <>
--     [(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"]
--   
-- -- All of which makes chart-unit highly customisable ... -- --
--   mainExample :: Chart b
--   mainExample = withHud_ opts sixbyfour (lineChart lopts) ls
--     where
--       opts =
--         #titles .~ titles' $
--         #axes .~ as $
--         #axes %~ map (#outerPad .~ 1) $
--         #legends .~ [#chartType .~ legends' $ def] $
--         def
--   
--   main :: IO ()
--   main = fileSvg "other/mainExample.svg" def mainExample
--   
-- -- -- There are three different ways of combining charts (and note adding a -- hud to a chart is a subset of combining charts): -- -- -- --
--   hud ho asp r <>
--   lineChart ld sixbyfour r d
--   
-- -- -- --
--   withHud_ ho asp (lineChart ld) d
--   
-- -- -- --
--   renderChart (ChartOptions (Just r) asp [HudChart ho, LineChart (zip ld d)])
--   
-- -- And these three methods are morally equivalent. module Chart -- | A class for types with a default value. class Default a -- | The default value for this type. def :: Default a => a