Saturday, February 6, 2010


Since Maria and I moved to Kiev in September 2009 we actively use hledger to track our money.

On average, we record 5 transactions each day — or 35 transactions if you record them at the end of the week. In order for this operation not to consume too much time, transaction entry should be very quick and easy. That's why I made several changes to hledger so that it better fits my workflow.

It took a while before my changes made their way to the main hledger repository. Benefits of some of these patches may be not obvious, so I am going to make a series of blog posts which describe my workflow and show how to efficiently use hledger.

I am going to start with the chart facility. It is useful e.g. when you want to know the structure of your expenses, like: where the most of the money go, where you can save and where saving does not make sense etc.

By the way, I find a lot of criticism of pie charts. But for this purpose I don't see any good alternative.

In order to create ledger charts you have to enable it. E.g. if you use cabal-install, just type "cabal install -fchart" from inside hledger source directory (as of 2010-02-06, hledger with chart facility is not yet released). You will need Chart package installed.

Everything else is trivial. Just type hledger chart ^Expenses to get a fancy pie chart packed in a PNG file. Here's an example:
ledger pie chart

Some tips:

  1. Plotting everything does not make sense since ledger has both positive and negative accounts. Make sure that you plot only accounts with the same sign. «Expenses» accounts are almost always positive.
  2. Usual hledger filtering constructs apply. Some useful examples:
    • hledger chart --depth 2 ^Expenses — plot only top-level subaccounts of Expenses
    • hledger chart -p Dec ^Expenses —make a report for the last December
    • hledger chart ^Expenses not:Rent — ignore Rent account (useful if its balance is too big relative to other expenses)
  3. chart command has some additional options. Use hledger chart -o mychart.png --size 300x500 ^Expenses to specify output file name and dimensions of the image.


Simon Michael said...

Roman, thank you for this great contribution and for blogging about it. Tim Docker, author of the Chart library is also a hledger contributor. I have been having fun polishing it up, eg handling that positive/negative issue you mentioned. Docs are at .

Simon Michael said...

PS, I'm sorry it took a while for me to react to these, which as you know was because I didn't receive them. :)

Roman Cheplyaka said...

Wow, you already wrote the docs -- that's great!