chart-svg-0.4.0: Charting library targetting SVGs.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Chart.Bar

Description

Bar charts

Synopsis

Documentation

data BarOptions Source #

Typical bar chart options.

The internal model for a bar chart (across the x-axis for a vertical bar chart) is:

  • half the outerGap at the start and the end.
  • each row collection of bars, including the outerGap and innerGaps has a value of 1.
  • the entire x range of the chart isequal to the number of rows in the bar data.
  • The value of inner and outer gaps are relative to this model.
>>> 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
writeChartOptions "other/bar.svg" barExample

Constructors

BarOptions 

Fields

Instances

Instances details
Generic BarOptions Source # 
Instance details

Defined in Chart.Bar

Associated Types

type Rep BarOptions :: Type -> Type #

Show BarOptions Source # 
Instance details

Defined in Chart.Bar

Eq BarOptions Source # 
Instance details

Defined in Chart.Bar

type Rep BarOptions Source # 
Instance details

Defined in Chart.Bar

defaultBarOptions :: BarOptions Source #

The official bar options.

data BarData Source #

Two dimensional data, maybe with row and column labels.

Constructors

BarData 

Fields

Instances

Instances details
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 #

Show BarData Source # 
Instance details

Defined in Chart.Bar

Eq BarData Source # 
Instance details

Defined in Chart.Bar

Methods

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

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

type Rep BarData Source # 
Instance details

Defined in Chart.Bar

type Rep BarData = D1 ('MetaData "BarData" "Chart.Bar" "chart-svg-0.4.0-IvsDYjPAAoJCAgDXwgibUh" '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]))))

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 0.0 2.0 0.0 3.0]]
>>> bars defaultBarOptions (BarData [[]] [] [])
[]

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

A bar chart.

>>> emptyBar = barChart defaultBarOptions (BarData [] [] [])
>>> foldOf (#charts % charts') emptyBar
[]

barRects :: BarOptions -> [[Double]] -> [[Rect Double]] Source #

Make bars from the double list values.

>>> barRects defaultBarOptions [[1,2],[2,3]]
[[Rect 5.0e-2 0.5 0.0 1.0,Rect 1.05 1.5 0.0 2.0],[Rect 0.5 0.95 0.0 2.0,Rect 1.5 1.95 0.0 3.0]]
>>> barRects defaultBarOptions [[]]
[]