hledger-lib
Safe HaskellNone
LanguageGHC2021

Hledger.Write.Chart

Description

A renderer-independent description of a chart, made from a report.

This is to charts what Hledger.Write.Spreadsheet is to tables: each chart-capable report has an adapter that turns its report data into a Chart, choosing a useful default chart for that report (see doc/SPEC-charts.md, "Smart defaults"), and renderers turn a Chart into text, SVG, CSV or JSON.

The model carries the report's own display information (period headings, account display names, commodity display styles, the report title) so that every renderer labels things exactly as the report's table would. Signs are already as the report shows them (eg normal-balance flipping done by bsiscf).

Values are kept exact here (Quantity); renderers convert them to Double only for drawing.

Synopsis

Documentation

data Chart Source #

A chart: a title, an x axis, and one or more panels drawn against that x axis. Typically there is one panel per commodity. A chart with no panels, or whose panels have no series, has no data; renderers should say so, not fail.

Constructors

Chart 

Fields

  • chTitle :: Text

    the report's title, as its table would show it (may be empty)

  • chXAxis :: XAxis

    the x positions, shared by all panels

  • chPanels :: [Panel]

    the panels, in display order (eg largest commodity first)

  • chNotes :: [Text]

    notes to show below the chart, eg about what its values leave out

Instances

Instances details
ToJSON Chart Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

toJSON :: Chart -> Value

toEncoding :: Chart -> Encoding

toJSONList :: [Chart] -> Value

toEncodingList :: [Chart] -> Encoding

omitField :: Chart -> Bool

Eq Chart Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

(==) :: Chart -> Chart -> Bool

(/=) :: Chart -> Chart -> Bool

Generic Chart Source # 
Instance details

Defined in Hledger.Write.Chart

Associated Types

type Rep Chart 
Instance details

Defined in Hledger.Write.Chart

type Rep Chart = D1 ('MetaData "Chart" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "Chart" 'PrefixI 'True) ((S1 ('MetaSel ('Just "chTitle") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "chXAxis") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 XAxis)) :*: (S1 ('MetaSel ('Just "chPanels") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Panel]) :*: S1 ('MetaSel ('Just "chNotes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text]))))

Methods

from :: Chart -> Rep Chart x

to :: Rep Chart x -> Chart

Show Chart Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

showsPrec :: Int -> Chart -> ShowS

show :: Chart -> String

showList :: [Chart] -> ShowS

type Rep Chart Source # 
Instance details

Defined in Hledger.Write.Chart

type Rep Chart = D1 ('MetaData "Chart" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "Chart" 'PrefixI 'True) ((S1 ('MetaSel ('Just "chTitle") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "chXAxis") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 XAxis)) :*: (S1 ('MetaSel ('Just "chPanels") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Panel]) :*: S1 ('MetaSel ('Just "chNotes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text]))))

data XAxis Source #

The x positions of a chart: what each value in a series corresponds to. Every series in the chart has one value per x position (renderers must not assume this, and should ignore extras).

Renderers choose orientation from this: periods and dates are drawn along a horizontal time axis in SVG, categories as horizontal bars. Text charts always draw one row per x position.

Constructors

XCategories [ChartLabel]

unordered categories, eg the accounts of a single-period balance report

XPeriods [(DateSpan, Text)]

consecutive report periods, each with its heading as the report's table shows it

XDates [Day]

individual dates, possibly irregular and repeated, eg one per transaction in a register

Instances

Instances details
ToJSON XAxis Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

toJSON :: XAxis -> Value

toEncoding :: XAxis -> Encoding

toJSONList :: [XAxis] -> Value

toEncodingList :: [XAxis] -> Encoding

omitField :: XAxis -> Bool

Eq XAxis Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

(==) :: XAxis -> XAxis -> Bool

(/=) :: XAxis -> XAxis -> Bool

Generic XAxis Source # 
Instance details

Defined in Hledger.Write.Chart

Associated Types

type Rep XAxis 
Instance details

Defined in Hledger.Write.Chart

type Rep XAxis = D1 ('MetaData "XAxis" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "XCategories" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ChartLabel])) :+: (C1 ('MetaCons "XPeriods" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(DateSpan, Text)])) :+: C1 ('MetaCons "XDates" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Day]))))

Methods

from :: XAxis -> Rep XAxis x

to :: Rep XAxis x -> XAxis

Show XAxis Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

showsPrec :: Int -> XAxis -> ShowS

show :: XAxis -> String

showList :: [XAxis] -> ShowS

type Rep XAxis Source # 
Instance details

Defined in Hledger.Write.Chart

type Rep XAxis = D1 ('MetaData "XAxis" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "XCategories" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ChartLabel])) :+: (C1 ('MetaCons "XPeriods" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(DateSpan, Text)])) :+: C1 ('MetaCons "XDates" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Day]))))

data ChartLabel Source #

A name for a category or a series. For accounts this comes from the report's display name, so it follows the report's tree/flat mode and depth.

Constructors

ChartLabel 

Fields

  • lbFull :: Text

    the full name, eg a full account name; used in CSV/JSON and tooltips

  • lbShort :: Text

    the name to display, eg a leaf account name in tree mode

  • lbIndent :: Int

    indentation level to display it with (0 for none)

  • lbType :: Maybe AccountType

    the account type, if this names an account (or accounts) of a known type; charts colour accounts by their main type (see seriesColours)

  • lbAccount :: Bool

    does this name an account (or accounts) ? Otherwise it's something else, eg a total.

  • lbTipLines :: [Text]

    more lines for tooltips, eg the accounts that an "other" series combines

Instances

Instances details
ToJSON ChartLabel Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

toJSON :: ChartLabel -> Value

toEncoding :: ChartLabel -> Encoding

toJSONList :: [ChartLabel] -> Value

toEncodingList :: [ChartLabel] -> Encoding

omitField :: ChartLabel -> Bool

Eq ChartLabel Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

(==) :: ChartLabel -> ChartLabel -> Bool

(/=) :: ChartLabel -> ChartLabel -> Bool

Generic ChartLabel Source # 
Instance details

Defined in Hledger.Write.Chart

Associated Types

type Rep ChartLabel 
Instance details

Defined in Hledger.Write.Chart

type Rep ChartLabel = D1 ('MetaData "ChartLabel" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "ChartLabel" 'PrefixI 'True) ((S1 ('MetaSel ('Just "lbFull") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "lbShort") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "lbIndent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))) :*: (S1 ('MetaSel ('Just "lbType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe AccountType)) :*: (S1 ('MetaSel ('Just "lbAccount") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "lbTipLines") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text])))))

Methods

from :: ChartLabel -> Rep ChartLabel x

to :: Rep ChartLabel x -> ChartLabel

Show ChartLabel Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

showsPrec :: Int -> ChartLabel -> ShowS

show :: ChartLabel -> String

showList :: [ChartLabel] -> ShowS

type Rep ChartLabel Source # 
Instance details

Defined in Hledger.Write.Chart

type Rep ChartLabel = D1 ('MetaData "ChartLabel" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "ChartLabel" 'PrefixI 'True) ((S1 ('MetaSel ('Just "lbFull") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "lbShort") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "lbIndent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))) :*: (S1 ('MetaSel ('Just "lbType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe AccountType)) :*: (S1 ('MetaSel ('Just "lbAccount") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "lbTipLines") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text])))))

data Panel Source #

One chart area with its own y axis, holding series of values in a single unit.

Constructors

Panel 

Fields

  • pnUnit :: Amount

    the unit of all values in this panel, as a template amount whose quantity is ignored: its commodity symbol and display style are used to show values and axis ticks. Eg a currency, % (as produced by --percent), or no commodity with precision 0 for counts.

  • pnSeries :: [Series]

    the series, in display order (legend order)

  • pnGroupNames :: [Text]

    names for the groups of series, by group number (see seGroup), if they have names; eg a compound report's section titles. Text charts show them.

  • pnScale :: Maybe Quantity

    a fixed scale, if one was requested: the amount spanned by the chart (see scaleSpans), so that charts with the same scale are drawn at the same size per amount. Otherwise the chart is scaled to fit its values.

  • pnLayout :: BarLayout

    how to draw bars of several groups

  • pnCounts :: Bool

    are the values counts of whole things (eg postings) ? Then text charts draw at most one cell per unit, so that small counts are not magnified (unless a fixed scale is set).

  • pnSummary :: [Summary]

    values summarising the whole chart, shown below it (eg with -T and -A, the total and the average per period)

  • pnValueLabels :: [Maybe Text]

    text to show at each x position (or none there), eg a holding's gain percent: in graphical charts instead of its value (which the axis shows), in a smaller font (over time, only if they all fit); in text charts after it. Text beginning with + is shown in the revenue colour; with -, in the expense colour in graphical charts, the negative style in text charts. If empty, the values are shown as usual

Instances

Instances details
ToJSON Panel Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

toJSON :: Panel -> Value

toEncoding :: Panel -> Encoding

toJSONList :: [Panel] -> Value

toEncodingList :: [Panel] -> Encoding

omitField :: Panel -> Bool

Eq Panel Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

(==) :: Panel -> Panel -> Bool

(/=) :: Panel -> Panel -> Bool

Generic Panel Source # 
Instance details

Defined in Hledger.Write.Chart

Associated Types

type Rep Panel 
Instance details

Defined in Hledger.Write.Chart

type Rep Panel = D1 ('MetaData "Panel" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "Panel" 'PrefixI 'True) (((S1 ('MetaSel ('Just "pnUnit") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Amount) :*: S1 ('MetaSel ('Just "pnSeries") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Series])) :*: (S1 ('MetaSel ('Just "pnGroupNames") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text]) :*: S1 ('MetaSel ('Just "pnScale") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Quantity)))) :*: ((S1 ('MetaSel ('Just "pnLayout") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BarLayout) :*: S1 ('MetaSel ('Just "pnCounts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "pnSummary") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Summary]) :*: S1 ('MetaSel ('Just "pnValueLabels") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Maybe Text])))))

Methods

from :: Panel -> Rep Panel x

to :: Rep Panel x -> Panel

Show Panel Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

showsPrec :: Int -> Panel -> ShowS

show :: Panel -> String

showList :: [Panel] -> ShowS

type Rep Panel Source # 
Instance details

Defined in Hledger.Write.Chart

type Rep Panel = D1 ('MetaData "Panel" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "Panel" 'PrefixI 'True) (((S1 ('MetaSel ('Just "pnUnit") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Amount) :*: S1 ('MetaSel ('Just "pnSeries") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Series])) :*: (S1 ('MetaSel ('Just "pnGroupNames") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text]) :*: S1 ('MetaSel ('Just "pnScale") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Quantity)))) :*: ((S1 ('MetaSel ('Just "pnLayout") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BarLayout) :*: S1 ('MetaSel ('Just "pnCounts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "pnSummary") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Summary]) :*: S1 ('MetaSel ('Just "pnValueLabels") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Maybe Text])))))

data BarLayout Source #

How to draw the bars of a panel whose series are in several groups (eg a compound report's sections).

Constructors

Diverging

all groups stacked in one bar at each x position, positive values above (or right of) zero and negative ones below

Grouped

each group stacked in its own bar, the groups' bars side by side (in text, a row per group), with the total marked separately; values are shown with their usual sign as positive (see setChartLayout)

Instances

Instances details
ToJSON BarLayout Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

toJSON :: BarLayout -> Value

toEncoding :: BarLayout -> Encoding

toJSONList :: [BarLayout] -> Value

toEncodingList :: [BarLayout] -> Encoding

omitField :: BarLayout -> Bool

Eq BarLayout Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

(==) :: BarLayout -> BarLayout -> Bool

(/=) :: BarLayout -> BarLayout -> Bool

Generic BarLayout Source # 
Instance details

Defined in Hledger.Write.Chart

Associated Types

type Rep BarLayout 
Instance details

Defined in Hledger.Write.Chart

type Rep BarLayout = D1 ('MetaData "BarLayout" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "Diverging" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Grouped" 'PrefixI 'False) (U1 :: Type -> Type))

Methods

from :: BarLayout -> Rep BarLayout x

to :: Rep BarLayout x -> BarLayout

Show BarLayout Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

showsPrec :: Int -> BarLayout -> ShowS

show :: BarLayout -> String

showList :: [BarLayout] -> ShowS

type Rep BarLayout Source # 
Instance details

Defined in Hledger.Write.Chart

type Rep BarLayout = D1 ('MetaData "BarLayout" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "Diverging" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Grouped" 'PrefixI 'False) (U1 :: Type -> Type))

data Series Source #

A named sequence of values, one per x position.

Constructors

Series 

Fields

  • seLabel :: ChartLabel
     
  • seRole :: SeriesRole
     
  • seMark :: Mark
     
  • seValues :: [Maybe Quantity]

    one value per x position; Nothing means no value there (a gap, not zero). At each x position, bar series' values are stacked: positive values above zero, negative values below.

  • seGroup :: Int

    which group this series belongs to (eg its section, in a compound report chart; otherwise 0). Groups are stacked together, or drawn side by side, as the panel's pnLayout says.

  • seSign :: Int

    the usual sign of this series' values, if it has one (1 or -1; otherwise 0). Values of the opposite sign are contra amounts, which renderers may show distinctly; eg a refund (negative expense) in a compound report chart.

Instances

Instances details
ToJSON Series Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

toJSON :: Series -> Value

toEncoding :: Series -> Encoding

toJSONList :: [Series] -> Value

toEncodingList :: [Series] -> Encoding

omitField :: Series -> Bool

Eq Series Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

(==) :: Series -> Series -> Bool

(/=) :: Series -> Series -> Bool

Generic Series Source # 
Instance details

Defined in Hledger.Write.Chart

Associated Types

type Rep Series 
Instance details

Defined in Hledger.Write.Chart

type Rep Series = D1 ('MetaData "Series" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "Series" 'PrefixI 'True) ((S1 ('MetaSel ('Just "seLabel") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChartLabel) :*: (S1 ('MetaSel ('Just "seRole") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SeriesRole) :*: S1 ('MetaSel ('Just "seMark") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Mark))) :*: (S1 ('MetaSel ('Just "seValues") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Maybe Quantity]) :*: (S1 ('MetaSel ('Just "seGroup") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "seSign") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))))

Methods

from :: Series -> Rep Series x

to :: Rep Series x -> Series

Show Series Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

showsPrec :: Int -> Series -> ShowS

show :: Series -> String

showList :: [Series] -> ShowS

type Rep Series Source # 
Instance details

Defined in Hledger.Write.Chart

type Rep Series = D1 ('MetaData "Series" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "Series" 'PrefixI 'True) ((S1 ('MetaSel ('Just "seLabel") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChartLabel) :*: (S1 ('MetaSel ('Just "seRole") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SeriesRole) :*: S1 ('MetaSel ('Just "seMark") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Mark))) :*: (S1 ('MetaSel ('Just "seValues") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Maybe Quantity]) :*: (S1 ('MetaSel ('Just "seGroup") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "seSign") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))))

data SeriesRole Source #

What a series represents, which renderers may show differently (eg a muted colour for SeriesOther).

Constructors

SeriesItem

an ordinary series, eg one account

SeriesOther

several items combined, eg "other (5 accounts)", to limit the number of series

SeriesTotal

a total of other series, eg the net total of stacked bars, or net worth

SeriesShortfall

an amount missing from what the bar stands for, eg the part of a holding's cost basis lost (beyond its value): drawn hatched, in its place in the stack

SeriesProvisional

an amount not yet final, eg an unrealised gain or loss: drawn hatched, in its place in the stack

Instances

Instances details
ToJSON SeriesRole Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

toJSON :: SeriesRole -> Value

toEncoding :: SeriesRole -> Encoding

toJSONList :: [SeriesRole] -> Value

toEncodingList :: [SeriesRole] -> Encoding

omitField :: SeriesRole -> Bool

Eq SeriesRole Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

(==) :: SeriesRole -> SeriesRole -> Bool

(/=) :: SeriesRole -> SeriesRole -> Bool

Generic SeriesRole Source # 
Instance details

Defined in Hledger.Write.Chart

Associated Types

type Rep SeriesRole 
Instance details

Defined in Hledger.Write.Chart

type Rep SeriesRole = D1 ('MetaData "SeriesRole" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) ((C1 ('MetaCons "SeriesItem" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SeriesOther" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "SeriesTotal" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "SeriesShortfall" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SeriesProvisional" 'PrefixI 'False) (U1 :: Type -> Type))))

Methods

from :: SeriesRole -> Rep SeriesRole x

to :: Rep SeriesRole x -> SeriesRole

Show SeriesRole Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

showsPrec :: Int -> SeriesRole -> ShowS

show :: SeriesRole -> String

showList :: [SeriesRole] -> ShowS

type Rep SeriesRole Source # 
Instance details

Defined in Hledger.Write.Chart

type Rep SeriesRole = D1 ('MetaData "SeriesRole" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) ((C1 ('MetaCons "SeriesItem" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SeriesOther" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "SeriesTotal" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "SeriesShortfall" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SeriesProvisional" 'PrefixI 'False) (U1 :: Type -> Type))))

data Mark Source #

How a series is drawn.

Constructors

MarkBar

a bar from zero to the value

MarkLine

a line joining the values (in text charts, drawn as bars)

MarkMarker

a marker at the value, not joined, eg a net total over stacked bars, or a budget goal

MarkNone

not drawn: values shown only as text (text charts' value column, tooltips, chart data), eg holdings' values, which their bars' solid parts reach already

Instances

Instances details
ToJSON Mark Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

toJSON :: Mark -> Value

toEncoding :: Mark -> Encoding

toJSONList :: [Mark] -> Value

toEncodingList :: [Mark] -> Encoding

omitField :: Mark -> Bool

Eq Mark Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

(==) :: Mark -> Mark -> Bool

(/=) :: Mark -> Mark -> Bool

Generic Mark Source # 
Instance details

Defined in Hledger.Write.Chart

Associated Types

type Rep Mark 
Instance details

Defined in Hledger.Write.Chart

type Rep Mark = D1 ('MetaData "Mark" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) ((C1 ('MetaCons "MarkBar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MarkLine" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MarkMarker" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MarkNone" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: Mark -> Rep Mark x

to :: Rep Mark x -> Mark

Show Mark Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

showsPrec :: Int -> Mark -> ShowS

show :: Mark -> String

showList :: [Mark] -> ShowS

type Rep Mark Source # 
Instance details

Defined in Hledger.Write.Chart

type Rep Mark = D1 ('MetaData "Mark" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) ((C1 ('MetaCons "MarkBar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MarkLine" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MarkMarker" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MarkNone" 'PrefixI 'False) (U1 :: Type -> Type)))

data Summary Source #

A value summarising a panel's values over the whole x axis, such as their total or their average.

Constructors

Summary 

Fields

Instances

Instances details
ToJSON Summary Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

toJSON :: Summary -> Value

toEncoding :: Summary -> Encoding

toJSONList :: [Summary] -> Value

toEncodingList :: [Summary] -> Encoding

omitField :: Summary -> Bool

Eq Summary Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

(==) :: Summary -> Summary -> Bool

(/=) :: Summary -> Summary -> Bool

Generic Summary Source # 
Instance details

Defined in Hledger.Write.Chart

Associated Types

type Rep Summary 
Instance details

Defined in Hledger.Write.Chart

type Rep Summary = D1 ('MetaData "Summary" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "Summary" 'PrefixI 'True) (S1 ('MetaSel ('Just "suKind") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SummaryKind) :*: (S1 ('MetaSel ('Just "suLabel") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "suValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Amount))))

Methods

from :: Summary -> Rep Summary x

to :: Rep Summary x -> Summary

Show Summary Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

showsPrec :: Int -> Summary -> ShowS

show :: Summary -> String

showList :: [Summary] -> ShowS

type Rep Summary Source # 
Instance details

Defined in Hledger.Write.Chart

type Rep Summary = D1 ('MetaData "Summary" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "Summary" 'PrefixI 'True) (S1 ('MetaSel ('Just "suKind") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SummaryKind) :*: (S1 ('MetaSel ('Just "suLabel") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "suValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Amount))))

data SummaryKind Source #

Constructors

SummaryTotal

the total of all x positions' values

SummaryAverage

the average per x position, which SVG charts also draw as a line across the plot (with a legend entry)

Instances

Instances details
ToJSON SummaryKind Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

toJSON :: SummaryKind -> Value

toEncoding :: SummaryKind -> Encoding

toJSONList :: [SummaryKind] -> Value

toEncodingList :: [SummaryKind] -> Encoding

omitField :: SummaryKind -> Bool

Eq SummaryKind Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

(==) :: SummaryKind -> SummaryKind -> Bool

(/=) :: SummaryKind -> SummaryKind -> Bool

Generic SummaryKind Source # 
Instance details

Defined in Hledger.Write.Chart

Associated Types

type Rep SummaryKind 
Instance details

Defined in Hledger.Write.Chart

type Rep SummaryKind = D1 ('MetaData "SummaryKind" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "SummaryTotal" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SummaryAverage" 'PrefixI 'False) (U1 :: Type -> Type))

Methods

from :: SummaryKind -> Rep SummaryKind x

to :: Rep SummaryKind x -> SummaryKind

Show SummaryKind Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

showsPrec :: Int -> SummaryKind -> ShowS

show :: SummaryKind -> String

showList :: [SummaryKind] -> ShowS

type Rep SummaryKind Source # 
Instance details

Defined in Hledger.Write.Chart

type Rep SummaryKind = D1 ('MetaData "SummaryKind" "Hledger.Write.Chart" "hledger-lib-2.0-5NBavNmBvhzFPKtDMBoaVJ" 'False) (C1 ('MetaCons "SummaryTotal" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SummaryAverage" 'PrefixI 'False) (U1 :: Type -> Type))

data Colour Source #

How a series (or a bar) is coloured, in a renderer-independent way.

Constructors

TypeColour AccountType Int

the conventional hue of this main account type, in its Nth tint (to distinguish several of that type)

IndexColour Int

the Nth categorical colour, for series with no account type

LoneColour

a hue that no account type uses, for a chart's only series when it is not an account, or for an account of unknown type in a chart with one account per panel

NeutralColour

a neutral colour, eg for the contra amounts legend swatch

OtherColour (Maybe AccountType)

a muted colour, for a series combining several items: grey, tinged with their main account type's hue if any

TotalColour

the ink (text) colour, for a total

Instances

Instances details
Eq Colour Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

(==) :: Colour -> Colour -> Bool

(/=) :: Colour -> Colour -> Bool

Show Colour Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

showsPrec :: Int -> Colour -> ShowS

show :: Colour -> String

showList :: [Colour] -> ShowS

seriesColours :: Colouring -> [Series] -> [Colour] Source #

Colours for a panel's series, in order, for the chart's colouring (see chartColouring). Coloured by type, each account of known type gets its main type's hue, in one of several tints (shared when there are more than maxTints of a type). Otherwise, and accounts of unknown type, get categorical colours; except that a lone series which is not an account (eg a total, or "..." for all accounts), or a lone account of unknown type in a chart of single accounts, gets a hue that no account type uses.

The tints and categorical colours are chosen by the series' names, not their positions or number (see stableSlots), so that an account keeps its colour in other charts: eg after removing other accounts (even down to just one), or sorting differently. A series of known type which is not an account (eg a holding's cost or gain) has its type's first tint, so that its colour doesn't depend on its name (which may be translated).

data Colouring Source #

How a chart's accounts are coloured (decided for the whole chart, so that colours mean the same in all of its panels).

Constructors

ByName

in distinct colours chosen by name, to tell them apart: when none has a known type

ByType

by main account type (in tints chosen by name): when any has a known type, even if all are of one type, so that a type's hue means the same in every chart, and an account keeps its colour in other charts

Single

by type, or if unknown in the lone colour: when each panel shows just one account, so there is nothing to tell apart

Instances

Instances details
Eq Colouring Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

(==) :: Colouring -> Colouring -> Bool

(/=) :: Colouring -> Colouring -> Bool

Show Colouring Source # 
Instance details

Defined in Hledger.Write.Chart

Methods

showsPrec :: Int -> Colouring -> ShowS

show :: Colouring -> String

showList :: [Colouring] -> ShowS

chartColouring :: Chart -> Colouring Source #

How this chart's accounts should be coloured: considering all of its panels, so that eg in a balance sheet, a commodity's panel with just one asset account shows it in the assets' hue, like the other panels.

stableSlots :: Ord a => Int -> [(Text, a)] -> [Int] Source #

Give each of these names one of n slots (0 to n-1), chosen by the name rather than its position, so that a name tends to get the same slot in other lists: eg a colour that stays with an account in successive charts. Each name has its own order of preference for the slots (from a hash of it), and gets the first one still free. The names choose in order of their sizes (largest first; then by name), so that adding or removing small items (or removing the largest) disturbs few others; positions don't matter. When there are more names than slots, slots are shared: once all are taken, the names choose among them all again.

stableSlotsFavouringFirst :: Ord a => Double -> Int -> [(Text, a)] -> [Int] Source #

Like stableSlots, but with each name's preferences biased towards the first slots, by this much (0: not at all; 1: fully, so that every name has the same order of preference). Eg with 0.5, the last of 4 slots is never a name's first choice, and the first is its first choice most often.

categoryTints :: [ChartLabel] -> [Maybe Quantity] -> [Int] Source #

A tint for each of these categories (eg a single-period chart's accounts, with their values), chosen by name among the categories of the same main account type, as seriesColours chooses them for series: so that accounts of one type can be told apart, and tend to keep their tints in a multi-period chart.

seriesSize :: Series -> Quantity Source #

A series' size, for ranking: the sum of its absolute values.

maxTints :: Int Source #

How many tints of a type's colour renderers provide, to distinguish several accounts of one type.

mainAccountType :: AccountType -> AccountType Source #

The main account type (asset, liability, equity, revenue or expense) of an account type, which is one of those or a subtype of one.

type SeriesValues = Array Int (Maybe Quantity) Source #

A series' values, indexed by x position, for fast lookup by renderers.

isContra :: Series -> Quantity -> Bool Source #

Is this value of the series a contra amount (of the opposite sign to the series' usual sign) ?

isHatched :: Series -> Quantity -> Bool Source #

Is this value of the series drawn hatched ? Contra amounts are, and the values of hatched series (see hatchedSeries).

hatchedSeries :: Series -> Bool Source #

Is this series drawn hatched throughout, in its colour (and so shown hatched in legends) ? Shortfalls and provisional amounts are (see SeriesShortfall, SeriesProvisional).

legendListsSeries :: Bool -> [Series] -> Bool Source #

Should a legend list these drawn series (on a category axis, or not) ? Yes when there are several, or one is an "other" series (whose muted colour needs explaining), or a lone series names an account on a time axis (where nothing else would name it). A lone series on a category axis is not listed: its bars are labelled on the axis, and coloured by category.

valueAt :: SeriesValues -> Int -> Maybe Quantity Source #

The value at this x position, if there is one.

setChartScales :: [Amount] -> Chart -> Chart Source #

Give each panel a fixed scale (see pnScale): the absolute quantity of the scale amount in the panel's commodity, or else of the one with no commodity symbol. When several are in the same commodity, the last one is used.

chartWithoutTotalMarks :: Chart -> Chart Source #

Don't draw the totals (or nets): give each panel's total series no mark (MarkNone), so that it is still shown as values where those are shown (eg in tooltips), but not drawn.

setChartLayout :: Maybe BarLayout -> Chart -> Chart Source #

Set the bar layout of every panel to this one, if given (otherwise keeping each panel's own), and prepare the panels for it. This should be applied before drawing a chart, or showing its data. The grouped layout is for comparing the groups' sizes, so its series are shown with their usual sign as positive (eg expenses as well as revenues upward, like a compound report's tables), and their contra amounts as negative. (Applying this again does nothing more, since those series' usual sign is then positive.) And since only bars can be side by side, in a panel with several groups, series drawn as lines (eg end balances) become bars. Its series are put in their groups' order.

scaleSpans :: (Ord a, Fractional a) => a -> a -> a -> (a, a) Source #

With a fixed scale (the amount that a chart spans), and the largest positive and (absolute) negative extents of the values, how much of the scale is given to each direction: (above or right of zero, below or left of zero). Negative values get the room they need and positive values the rest (all of it if there are no negative values; if there are only negative values, they get all of it). If the values don't fit, both directions are shrunk in proportion, and the values beyond them will be clipped.

chartAsCsv :: Chart -> CSV Source #

Render a chart's data as CSV (or TSV) records, in long ("tidy") form: one record per value, with a header record. This shows exactly what the chart shows, after any combining of series, and can be charted with other tools.

Values are shown with the panel unit's display precision, without commodity symbol or digit group marks. A gap (no value) is shown as an empty field. Each panel's summary values (see pnSummary) follow its series, with role "rowtotal" or "average", and no mark or x.