2023-10-12 12:26:41 +04:00
|
|
|
import os
|
|
|
|
import pandas as pd
|
|
|
|
import matplotlib
|
|
|
|
matplotlib.use('Agg')
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
2023-10-12 17:46:05 +04:00
|
|
|
def createGraphics(df: list[pd.DataFrame], nameFile):
|
2023-10-12 12:26:41 +04:00
|
|
|
# для сохранения диаграммы в конкретной папке
|
|
|
|
script_dir = os.path.dirname(__file__)
|
|
|
|
results_dir = os.path.join(script_dir, '../static/')
|
|
|
|
|
|
|
|
if not os.path.isdir(results_dir):
|
|
|
|
os.makedirs(results_dir)
|
|
|
|
|
2023-10-12 17:46:05 +04:00
|
|
|
for i in range(len(df)):
|
|
|
|
dataFrame = df[i]
|
|
|
|
dataFrame.plot.bar()
|
|
|
|
plt.savefig(results_dir + nameFile + str(i) + '.jpg')
|
|
|
|
plt.close()
|
2023-10-12 12:26:41 +04:00
|
|
|
|
|
|
|
return True
|