Show markers on smaller graphs

This commit is contained in:
Lukáš Kucharczyk 2023-01-30 22:01:27 +01:00
parent c1b1cda38e
commit 8918df1dfd
2 changed files with 6 additions and 2 deletions

View File

@ -1,7 +1,7 @@
## Unrelease
* Add React
* Make it possible to edit sessions (https://git.kucharczyk.xyz/lukas/timetracker/issues/46)
* Show markers on smaller graphs to make it clearer which dates the session belong to
## 1.0.0 / 2023-01-20 19:54+01:00

View File

@ -64,7 +64,7 @@ def get_chart(data, title="", xlabel="", ylabel=""):
plt.switch_backend("SVG")
fig, ax = plt.subplots()
fig.set_size_inches(10, 4)
ax.plot(x, y)
lines = ax.plot(x, y, "-o")
first = x[0]
last = x[-1]
difference = last - first
@ -76,7 +76,11 @@ def get_chart(data, title="", xlabel="", ylabel=""):
elif difference.days < 720:
ax.xaxis.set_major_locator(mdates.MonthLocator())
ax.xaxis.set_minor_locator(mdates.WeekdayLocator())
for line in lines:
line.set_marker("")
else:
for line in lines:
line.set_marker("")
ax.xaxis.set_major_locator(mdates.YearLocator())
ax.xaxis.set_minor_locator(mdates.MonthLocator())