| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Hledger.Write.Chart.Text
Description
Draw a Chart as text, for terminals.
Every chart is drawn as horizontal bars, one row per x position, with an aligned value column before the bars. Several series are drawn as stacked segments, positive values growing right from a zero axis and negative values growing left. Lines are drawn as bars too, since text has no good way to draw lines.
The output is a list of styled lines, so that different frontends can apply the styles in their own way:
styledLinesAsText turns them into plain or ANSI-coloured text.
Synopsis
- data TextChartOpts = TextChartOpts {}
- data Style
- = StylePlain
- | StyleSeries Int
- | StyleType AccountType Int
- | StyleOther (Maybe AccountType)
- | StyleLone
- | StyleNegative
- data ColourMode
- = NoColour
- | BasicColour
- | RgbColour Bool
- type StyledLine = [(Style, Text)]
- chartAsStyledLines :: TextChartOpts -> Chart -> [StyledLine]
- styledLinesAsText :: ColourMode -> [StyledLine] -> Text
- tests_Hledger_Write_Chart_Text :: TestTree
Documentation
How a piece of text should be shown.
Constructors
| StylePlain | |
| StyleSeries Int | the colour of the Nth ordinary series in a panel |
| StyleType AccountType Int | the colour of a main account type, in its Nth variant |
| StyleOther (Maybe AccountType) | the colour of a series combining several items ("other"), of this main account type if any |
| StyleLone | the colour of a chart's only series, when it is not an account |
| StyleNegative | a negative value |
data ColourMode Source #
How to colour a text chart.
Constructors
| NoColour | |
| BasicColour | with the terminal's basic ANSI colours (whose exact shades depend on its colour theme) |
| RgbColour Bool | with exact 24-bit colours, the same as SVG charts'; their variants for a dark background if true |
Instances
| Eq ColourMode Source # | |
Defined in Hledger.Write.Chart.Text | |
| Show ColourMode Source # | |
Defined in Hledger.Write.Chart.Text Methods showsPrec :: Int -> ColourMode -> ShowS show :: ColourMode -> String showList :: [ColourMode] -> ShowS | |
type StyledLine = [(Style, Text)] Source #
A line of text made of styled pieces.
chartAsStyledLines :: TextChartOpts -> Chart -> [StyledLine] Source #
Draw a chart as styled lines of text: the title (if any), then each panel,
with a heading naming its commodity when there are several (and it has a commodity symbol),
and a legend (see legendListsSeries) listing the series that are visible (a series too small to fill a character cell is not).
A chart of dates (eg a register) has a row per date, however many there are.
A chart with no panels (nothing to show, eg in an empty period) says so.
styledLinesAsText :: ColourMode -> [StyledLine] -> Text Source #
Render styled lines as text, with ANSI colours or without.