chart-svg-0.2.2: Charting library targetting SVGs.
Safe HaskellNone
LanguageHaskell2010

Chart.Bar

Description

bar charts

Synopsis

Documentation

data BarOptions Source #

Typical bar chart options.

>>> let barDataExample = BarData [[1, 2, 3, 5, 8, 0, -2, 11, 2, 1], [1 .. 10]] (Just (("row " <>) . pack . show <$> [1 .. 11])) (Just (("column " <>) . pack . show <$> [1 .. 2]))
>>> let barExample = barChart defaultBarOptions barDataExample
writeChartSvg "other/bar.svg" barExample

Instances

Instances details
Eq BarOptions Source # 
Instance details

Defined in Chart.Bar

Show BarOptions Source # 
Instance details

Defined in Chart.Bar

Generic BarOptions Source # 
Instance details

Defined in Chart.Bar

Associated Types

type Rep BarOptions :: Type -> Type #

type Rep BarOptions Source # 
Instance details

Defined in Chart.Bar

defaultBarOptions :: BarOptions Source #

The official bar options.

data BarData Source #

imagine a dataframe you get in other languages:

  • definitely some [[Double]]
  • maybe some row names
  • maybe some column names

Constructors

BarData 

Instances

Instances details
Eq BarData Source # 
Instance details

Defined in Chart.Bar

Methods

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

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

Show BarData Source # 
Instance details

Defined in Chart.Bar

Generic BarData Source # 
Instance details

Defined in Chart.Bar

Associated Types

type Rep BarData :: Type -> Type #

Methods

from :: BarData -> Rep BarData x #

to :: Rep BarData x -> BarData #

type Rep BarData Source # 
Instance details

Defined in Chart.Bar

type Rep BarData = D1 ('MetaData "BarData" "Chart.Bar" "chart-svg-0.2.2-AJskDBGhW2w5nFQE5Ah360" 'False) (C1 ('MetaCons "BarData" 'PrefixI 'True) (S1 ('MetaSel ('Just "barData") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 [[Double]]) :*: (S1 ('MetaSel ('Just "barRowLabels") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe [Text])) :*: S1 ('MetaSel ('Just "barColumnLabels") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe [Text])))))

barDataLowerUpper :: Bool -> [[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 False [[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

bars :: BarOptions -> BarData -> [Chart Double] Source #

A bar chart without hud trimmings.

>>> bars defaultBarOptions (BarData [[1,2],[2,3]] Nothing Nothing)
[Chart {annotation = RectA (RectStyle {borderSize = 2.0e-3, borderColor = Colour 0.69 0.35 0.16 1.00, color = Colour 0.69 0.35 0.16 1.00}), xys = [R 5.0e-2 0.45 0.0 1.0,R 1.05 1.4500000000000002 0.0 2.0]},Chart {annotation = RectA (RectStyle {borderSize = 2.0e-3, borderColor = Colour 0.65 0.81 0.89 1.00, color = Colour 0.65 0.81 0.89 1.00}), xys = [R 0.45 0.8500000000000001 0.0 2.0,R 1.4500000000000002 1.85 0.0 3.0]},Chart {annotation = BlankA, xys = [R -5.0e-2 1.9500000000000002 0.0 3.0]}]

barChart :: BarOptions -> BarData -> ChartSvg Source #

A bar chart.

By convention only, the first axis (if any) is the bar axis.