diff --git a/nummi/main/views.py b/nummi/main/views.py index c4b7120..624f40f 100644 --- a/nummi/main/views.py +++ b/nummi/main/views.py @@ -188,8 +188,8 @@ def snapshot_graph(request, uuid): print(_categories_p) print(_categories_m) - fig, ax = plt.subplots() - ax.bar( + 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_p @@ -197,7 +197,7 @@ def snapshot_graph(request, uuid): [_cat["sum"] for _cat in _categories_p], color="#007339", ) - ax.bar( + ax.barh( [ "*" if (c := _cat["category"]) is None else Category.objects.get(id=c).name for _cat in _categories_m @@ -206,7 +206,8 @@ def snapshot_graph(request, uuid): color="#bf1500", ) ax.grid(color="k", alpha=0.2) - ax.set(ylabel="Value (€)") + ax.set(xlabel="Value (€)") + #fig.tight_layout() with tempfile.NamedTemporaryFile(suffix=".svg") as f: fig.savefig(f.name) f.seek(0)