Update plot style
This commit is contained in:
parent
d04fc756d4
commit
b090902648
2 changed files with 22 additions and 6 deletions
|
@ -6,7 +6,7 @@ figure.autolayout: True
|
||||||
figure.figsize: 8, 4
|
figure.figsize: 8, 4
|
||||||
figure.dpi: 300
|
figure.dpi: 300
|
||||||
|
|
||||||
axes.prop_cycle: cycler('color', ["66cc66", "#338033", "#99ff99", "#802653", "#cc6699"])
|
axes.prop_cycle: cycler('color', ["66cc66", "338033", "99ff99", "802653", "cc6699"])
|
||||||
axes.axisbelow: True
|
axes.axisbelow: True
|
||||||
axes.grid: True
|
axes.grid: True
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,17 @@ def categories(request):
|
||||||
@login_required
|
@login_required
|
||||||
def category(request, uuid):
|
def category(request, uuid):
|
||||||
_category = get_object_or_404(Category, id=uuid)
|
_category = get_object_or_404(Category, id=uuid)
|
||||||
_values = (
|
_values_p = (
|
||||||
Transaction.objects.filter(category=_category)
|
Transaction.objects.filter(category=_category)
|
||||||
|
.filter(value__gt=0)
|
||||||
|
.annotate(m=models.functions.TruncMonth("date"))
|
||||||
|
.values("m")
|
||||||
|
.annotate(sum=models.Sum("value"))
|
||||||
|
.order_by("m")
|
||||||
|
)
|
||||||
|
_values_m = (
|
||||||
|
Transaction.objects.filter(category=_category)
|
||||||
|
.filter(value__lt=0)
|
||||||
.annotate(m=models.functions.TruncMonth("date"))
|
.annotate(m=models.functions.TruncMonth("date"))
|
||||||
.values("m")
|
.values("m")
|
||||||
.annotate(sum=models.Sum("value"))
|
.annotate(sum=models.Sum("value"))
|
||||||
|
@ -78,10 +87,17 @@ def category(request, uuid):
|
||||||
)
|
)
|
||||||
|
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
ax.step(
|
ax.bar(
|
||||||
[v["m"] for v in _values],
|
[v["m"] for v in _values_p],
|
||||||
[v["sum"] for v in _values],
|
[v["sum"] for v in _values_p],
|
||||||
where="post",
|
width=12,
|
||||||
|
color="#66cc66",
|
||||||
|
)
|
||||||
|
ax.bar(
|
||||||
|
[v["m"] for v in _values_m],
|
||||||
|
[v["sum"] for v in _values_m],
|
||||||
|
width=12,
|
||||||
|
color="#cc6699",
|
||||||
)
|
)
|
||||||
ax.xaxis.set_major_formatter(
|
ax.xaxis.set_major_formatter(
|
||||||
mdates.ConciseDateFormatter(ax.xaxis.get_major_locator())
|
mdates.ConciseDateFormatter(ax.xaxis.get_major_locator())
|
||||||
|
|
Loading…
Reference in a new issue