beancount / fava

Fava - web interface for Beancount
https://beancount.github.io/fava/
MIT License
1.98k stars 288 forks source link

BQL Query charts - some tweaks #1060

Open ngoonee opened 4 years ago

ngoonee commented 4 years ago

This simple query:-

SELECT year, last(balance)

(where last(balance) can be anything really, sum(cost(position)) etc.) doesn't produce a graph. This is probably because as the description states, the first column needs to be 'a date or a string', and the year isn't any of those.

Similarly months and/or quarters should be handled (my full query actually looks more like the below, but the simple query above is sufficient to show the issue).

SELECT
    QUARTER(date) as quarter, last(balance)
FROM
    date > 2006-12-31
WHERE
    account ~ 'Assets:Banking|Assets:Cash|Liabilities:CreditCards'
GROUP BY quarter
ORDER BY quarter DESC

Currently this doesn't show a line chart as expected, but since what it sees is a string it shows a starburst or treemap (not useful for this particular data set).

Side-note: feature suggestion on this - handling 3-columns IF one of the columns is a date and the other is a string may be possible. For example I think it should be quite common to have the first column being a date or date-like (quarter, month, year), the second column being an account name, and the last being some number (sum of costs, balance etc). Either a multi-line plot or (easier I think) multiple line plots, one for each 2nd column, would be useful here.

ngoonee commented 4 years ago

This is of course related to one of the latest (awesome) features that @yagebu has added in https://github.com/beancount/fava/commit/8a273fa4b92ab6df875209ad8ea83c30984ce0f4