Skip to main content

Custom Dashboards for Beancount in Fava

Project description

Fava Dashboards

Continuous Integration PyPI

fava-dashboards allows creating custom dashboards in Fava.

Example dashboards with random data: Overview Assets Income and Expenses Travelling Sankey Projection

Installation

pip install fava-dashboards

Enable this plugin in Fava by adding the following lines to your ledger:

2010-01-01 custom "fava-extension" "fava_dashboards"

Configuration

The plugin looks by default for a dashboards.yaml file in the directory of the Beancount ledger (e.g. if you run fava personal.beancount, the dashboards.yaml file should be in the same directory as personal.beancount). The location of the dashboards.yaml configuration file can be customized:

2010-01-01 custom "fava-extension" "fava_dashboards" "{
    'config': '/path/to/dashboards.yaml'
}"

Please take a look at the example dashboards configuration dashboards.yaml, which uses most of the functionality described below.

The configuration file can contain multiple dashboards, and a dashboard contains one or more panels. A panel has a relative width (e.g. 50% for 2 columns, or 33.3% for 3 column layouts) and a absolute height.

The queries field contains one or multiple queries. The Beancount query must be stored in the bql field of the respective query. It can contain Jinja template syntax to access the panel and ledger variables described below (example: use {{ledger.ccy}} to access the first configured operating currency). Note that Jinja will replace some protected HTML characters with escapes. For example, a > inside a Jinja variable will be turned into &gt. This can cause problems because > is a valid Beancount query operator, but &gt is not. To skip replacing protected HTML characters, pass the Jinja safe filter to your variable invokation (for example, {{ panel.foo|safe }}.

The query results can be accessed via panel.queries[i].result, where i is the index of the query in the queries field. Note: Additionally to the Beancount query, Fava's filter bar further filters the available entries of the ledger.

Common code for utility functions can be defined in the dashboards configuration file, either inline in utils.inline or in an external file defined in utils.path.

HTML, echarts and d3-sankey panels: The script field must contain valid JavaScript code. It must return a valid configuration depending on the panel type. The following variables and functions are available:

  • ext: the Fava ExtensionContext
  • ext.api.get("query", {bql: "SELECT ..."}: executes the specified BQL query
  • panel: the current (augmented) panel definition. The results of the BQL queries can be accessed with panel.queries[i].result.
  • ledger.dateFirst: start date of the current date filter, or first transaction date of the ledger
  • ledger.dateLast: end date of the current date filter, or last transaction date of the ledger
  • ledger.filterFirst: start date of the current date filter, or null if no date filter is set
  • ledger.filterLast: end date of the current date filter, or null if no date filter is set
  • ledger.operatingCurrencies: configured operating currencies of the ledger
  • ledger.ccy: shortcut for the first configured operating currency of the ledger
  • ledger.accounts: declared accounts of the ledger
  • ledger.commodities: declared commodities of the ledger
  • helpers.urlFor(url): add current Fava filter parameters to url
  • utils: the return value of the utils code of the dashboard configuration

Jinja2 panels: The template field must contain valid Jinja2 template code. The following variables are available:

  • panel: see above
  • ledger: see above
  • favaledger: a reference to the FavaLedger object

Common Panel Properties

  • title: title of the panel. Default: unset
  • width: width of the panel. Default: 100%
  • height: height of the panel. Default: 400px
  • link: optional link target of the panel header.
  • queries: a list of dicts with a bql attribute.
  • type: panel type. Must be one of html, echarts, d3_sankey or jinja2.

HTML panel

The script code of HTML panels must return valid HTML. The HTML code will be rendered in the panel.

ECharts panel

The script code of Apache ECharts panels must return valid Apache ECharts chart options. Please take a look at the ECharts examples to get familiar with the available chart types and options.

d3-sankey panel

The script code of d3-sankey panels must return valid d3-sankey chart options. Please take a look at the example dashboard configuration dashboards.yaml.

Jinja2 panel

The template field of Jinja2 panels must contain valid Jinja2 template code. The rendered template will be shown in the panel.

View Example Ledger

cd example; fava example.beancount

Contributing

This plugin consists of a Python backend and a TypeScript frontend.

Install uv and Node.js 22, run make deps to install the dependencies, and make dev to run the Fava dev server with auto-rebuild.

Before submitting a PR, please run make build to build the frontend in production mode, and add the compiled frontend to the PR.

Why no React/Svelte/X?

The main reason is simplicity. This project is small enough to use plain HTML/CSS/JS and Jinja2 templates only, and doesn't warrant using a modern and ever-changing web development toolchain. Currently it requires only two external dependencies: pyyaml and echarts.

Articles

Related Projects

Acknowledgements

Thanks to Martin Blais and all contributors of Beancount, Jakob Schnitzer, Dominik Aumayr and all contributors of Fava, and to all contributors of Apache ECharts, D3.js and d3-sankey.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fava_dashboards-1.2.3.tar.gz (3.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fava_dashboards-1.2.3-py3-none-any.whl (483.8 kB view details)

Uploaded Python 3

File details

Details for the file fava_dashboards-1.2.3.tar.gz.

File metadata

  • Download URL: fava_dashboards-1.2.3.tar.gz
  • Upload date:
  • Size: 3.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fava_dashboards-1.2.3.tar.gz
Algorithm Hash digest
SHA256 bd3a578cac945d399cb9c1133ee2b24020d1741aa98fea41e8e5331de8a8024e
MD5 8bead9eb9581042f0edb235071e19fcc
BLAKE2b-256 1074453f549167c8ff0128f3379e6a007be04fd3d8df8ba4ee2f33a133895259

See more details on using hashes here.

Provenance

The following attestation bundles were made for fava_dashboards-1.2.3.tar.gz:

Publisher: release.yml on andreasgerstmayr/fava-dashboards

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fava_dashboards-1.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for fava_dashboards-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9ca2fb1341e09255b6ad441caa5967255bd0a503d25b4e1a4c6351777c971d4d
MD5 3e71628d53e367d4905e63a0f1529b4d
BLAKE2b-256 4deb54da32e6d48656faf1d6aeeedf2185bf4269305e3ed4789d3dd73b60b2d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for fava_dashboards-1.2.3-py3-none-any.whl:

Publisher: release.yml on andreasgerstmayr/fava-dashboards

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page