mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 20:51:25 +03:00
feat(chart): Add markers on line
This commit is contained in:
parent
3859c34ba4
commit
683e6a40e5
1 changed files with 4 additions and 4 deletions
|
@ -128,7 +128,7 @@ async def get_chart_period(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def create_chart(from_currency: str, conv_currency: str, start_date: str, end_date: str) -> str:
|
async def create_chart(from_currency: str, conv_currency: str, start_date: str, end_date: str) -> (str, None):
|
||||||
cur.execute('SELECT date, rate FROM currency WHERE (date BETWEEN %s AND %s) '
|
cur.execute('SELECT date, rate FROM currency WHERE (date BETWEEN %s AND %s) '
|
||||||
'AND from_currency = %s AND conv_currency = %s ORDER BY date',
|
'AND from_currency = %s AND conv_currency = %s ORDER BY date',
|
||||||
[
|
[
|
||||||
|
@ -140,7 +140,7 @@ async def create_chart(from_currency: str, conv_currency: str, start_date: str,
|
||||||
data = cur.fetchall()
|
data = cur.fetchall()
|
||||||
|
|
||||||
if not data or len(data) <= 1:
|
if not data or len(data) <= 1:
|
||||||
return
|
return None
|
||||||
|
|
||||||
date, rate = [], []
|
date, rate = [], []
|
||||||
|
|
||||||
|
@ -149,9 +149,9 @@ async def create_chart(from_currency: str, conv_currency: str, start_date: str,
|
||||||
rate.append(data[i][1])
|
rate.append(data[i][1])
|
||||||
|
|
||||||
if rate[0] < rate[-1]:
|
if rate[0] < rate[-1]:
|
||||||
plt.plot(date, rate, color='green')
|
plt.plot(date, rate, color='green', marker='o')
|
||||||
elif rate[0] > rate[-1]:
|
elif rate[0] > rate[-1]:
|
||||||
plt.plot(date, rate, color='red')
|
plt.plot(date, rate, color='red', marker='o')
|
||||||
else:
|
else:
|
||||||
plt.plot(date, rate, color='grey')
|
plt.plot(date, rate, color='grey')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue