Update plot
This commit is contained in:
parent
0437814725
commit
d9abdf798f
1 changed files with 18 additions and 1 deletions
|
@ -185,10 +185,25 @@ def snapshot_graph(request, uuid):
|
|||
.values("category")
|
||||
.annotate(sum=models.Sum("value"))
|
||||
)
|
||||
_categories = (
|
||||
_snapshot.transactions.values("category")
|
||||
.annotate(sum=models.Sum("value"))
|
||||
.order_by("-sum")
|
||||
)
|
||||
|
||||
print(_categories_p)
|
||||
print(_categories_m)
|
||||
fig, ax = plt.subplots(constrained_layout=True)
|
||||
ax.barh(
|
||||
[
|
||||
"*" if (c := _cat["category"]) is None else Category.objects.get(id=c).name
|
||||
for _cat in _categories
|
||||
],
|
||||
[_cat["sum"] for _cat in _categories],
|
||||
hatch="/",
|
||||
fill=False,
|
||||
zorder=10,
|
||||
)
|
||||
ax.barh(
|
||||
[
|
||||
"*" if (c := _cat["category"]) is None else Category.objects.get(id=c).name
|
||||
|
@ -196,6 +211,7 @@ def snapshot_graph(request, uuid):
|
|||
],
|
||||
[_cat["sum"] for _cat in _categories_p],
|
||||
color="#007339",
|
||||
zorder=9,
|
||||
)
|
||||
ax.barh(
|
||||
[
|
||||
|
@ -204,6 +220,7 @@ def snapshot_graph(request, uuid):
|
|||
],
|
||||
[_cat["sum"] for _cat in _categories_m],
|
||||
color="#bf1500",
|
||||
zorder=9,
|
||||
)
|
||||
ax.grid(color="k", alpha=0.2)
|
||||
ax.set(xlabel="Value (€)")
|
||||
|
|
Loading…
Reference in a new issue