mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 12:43:12 +03:00
fix(chart): Fixed currency rate and date indexes and other minor fixes
This commit is contained in:
parent
ef2c126d68
commit
e1fdda4b54
1 changed files with 7 additions and 6 deletions
|
@ -60,21 +60,20 @@ async def create_chart(
|
||||||
date, rate = [], []
|
date, rate = [], []
|
||||||
|
|
||||||
for row in data:
|
for row in data:
|
||||||
parsed_date = datetime.strptime(row['data'], '%Y-%m-%d%H:%M:%S.%fZ').date()
|
date.append(row[0])
|
||||||
date.append(parsed_date)
|
rate.append(row[1])
|
||||||
rate.append(row['rate'])
|
|
||||||
|
|
||||||
spline = make_interp_spline(range(len(date)), rate, k=2)
|
spline = make_interp_spline(range(len(date)), rate, k=2)
|
||||||
x = np.arange(len(date))
|
x = np.arange(len(date))
|
||||||
|
|
||||||
newx_2 = np.linspace(0, len(date) - 1, 200)
|
newx_2 = np.linspace(0, len(date) - 1, 200)
|
||||||
newy_2 = spline_2(newx_2)
|
newy_2 = spline(newx_2)
|
||||||
fig, ax = plt.subplot(figsize=(15, 6))
|
fig, ax = plt.subplots(figsize=(15, 6))
|
||||||
|
|
||||||
for label in (ax.get_xticklabels() + ax.get_yticklabels()):
|
for label in (ax.get_xticklabels() + ax.get_yticklabels()):
|
||||||
label.set_fontsize(10)
|
label.set_fontsize(10)
|
||||||
|
|
||||||
ax.set_xtick(np.linspace(0, len(date) - 1, 10))
|
ax.set_xticks(np.linspace(0, len(date) - 1, 10))
|
||||||
ax.set_xticklabels(
|
ax.set_xticklabels(
|
||||||
[
|
[
|
||||||
date[int(i)].strftime('%Y-%m-%d')
|
date[int(i)].strftime('%Y-%m-%d')
|
||||||
|
@ -87,6 +86,8 @@ async def create_chart(
|
||||||
datetime.now()
|
datetime.now()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
plt.plot(newx_2, newy_2)
|
||||||
plt.savefig(f'../charts/{name}.png')
|
plt.savefig(f'../charts/{name}.png')
|
||||||
fig.clear()
|
fig.clear()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue