Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Bar charts
Synopsis
- data BarOptions = BarOptions {}
- defaultBarOptions :: BarOptions
- data BarData = BarData {
- barData :: [[Double]]
- barRowLabels :: [Text]
- barColumnLabels :: [Text]
- barDataLowerUpper :: Stacked -> [[Double]] -> [[(Double, Double)]]
- barRange :: [[Double]] -> Rect Double
- bars :: BarOptions -> BarData -> [Chart]
- barChart :: BarOptions -> BarData -> ChartSvg
- barRects :: BarOptions -> [[Double]] -> [[Rect Double]]
Documentation
data BarOptions Source #
Typical bar chart options.
>>>
let barDataExample = BarData [[1, 2, 3, 5, 8, 0, -2, 11, 2, 1], [1 .. 10]] (("row " <>) . pack . show <$> [1 .. 11]) (("column " <>) . pack . show <$> [1 .. 2])
>>>
let barExample = barChart defaultBarOptions barDataExample
writeChartSvg "other/bar.svg" barExample
BarOptions | |
|
Instances
defaultBarOptions :: BarOptions Source #
The official bar options.
Two dimensional data, maybe with row and column labels.
BarData | |
|
Instances
Generic BarData Source # | |
Show BarData Source # | |
Eq BarData Source # | |
type Rep BarData Source # | |
Defined in Chart.Bar type Rep BarData = D1 ('MetaData "BarData" "Chart.Bar" "chart-svg-0.3.2-J6tMUM4NDxB6yjJ77Hgor" 'False) (C1 ('MetaCons "BarData" 'PrefixI 'True) (S1 ('MetaSel ('Just "barData") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [[Double]]) :*: (S1 ('MetaSel ('Just "barRowLabels") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [Text]) :*: S1 ('MetaSel ('Just "barColumnLabels") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [Text])))) |
barDataLowerUpper :: Stacked -> [[Double]] -> [[(Double, Double)]] Source #
Convert data to a range assuming a zero bound (a very common but implicit assumption in a lot of bar charts)
>>>
barDataLowerUpper NonStacked [[1,2],[2,3]]
[[(0.0,1.0),(0.0,2.0)],[(0.0,2.0),(0.0,3.0)]]
barRange :: [[Double]] -> Rect Double Source #
Calculate the Rect range of a bar data set.
>>>
barRange [[1,2],[2,3]]
Rect 0.0 2.0 0.0 3.0
>>>
barRange [[]]
Rect -0.5 0.5 -0.5 0.5
bars :: BarOptions -> BarData -> [Chart] Source #
A bar chart without hud trimmings.
>>>
bars defaultBarOptions (BarData [[1,2],[2,3]] [] [])
[RectChart (RectStyle {borderSize = 5.0e-3, borderColor = Colour 0.02 0.29 0.48 1.00, color = Colour 0.02 0.29 0.48 0.70}) [Rect 5.0e-2 0.5 0.0 1.0,Rect 1.05 1.5 0.0 2.0],RectChart (RectStyle {borderSize = 5.0e-3, borderColor = Colour 0.66 0.07 0.55 1.00, color = Colour 0.66 0.07 0.55 0.70}) [Rect 0.5 0.95 0.0 2.0,Rect 1.5 1.95 0.0 3.0],BlankChart [Rect -5.0e-2 2.05 0.0 3.0]]
>>>
bars defaultBarOptions (BarData [[]] [] [])
[]