Changed is it gonna end graph to ignore start and end date for better results

This commit is contained in:
Patrick Müller 2020-04-04 17:05:31 +02:00
parent 80927f470d
commit 374c44af3d
3 changed files with 635 additions and 25 deletions

View File

@ -256,8 +256,13 @@ class Analyser:
countryTimeData = countryData.loc[mask]
return (countryTimeData['deaths'].sum() / countryTimeData['cases'].sum() * 100)
def getIsItOverGraph(self, country, start_date='2019-12-31', end_date=datetime.now().strftime('%Y-%m-%d'),
showPlot=False) -> str:
def getIsItOverGraph(self, country, showPlot=False) -> str:
"""
Get a logarhytmic graph that shows easily if the exponential growth has stopped.
:param country: The country to be compared. TODO: Change to a list of countries
:param showPlot: If a plot is to be shown in the console
:return: The file path for the plot
"""
countryString = country
fig = plt.figure()
fig.dpi = 200.0
@ -266,9 +271,7 @@ class Analyser:
ax.set_ylabel('Case Increase')
ax.set_xlabel('Total Cases')
for index, country in enumerate([country, 'China', 'South_Korea'], start=1):
countryData = self.df[self.df['countriesAndTerritories'].isin([country])]
mask = (countryData['dateRep'] >= start_date) & (countryData['dateRep'] <= end_date)
countryTimeData = countryData.loc[mask]
countryTimeData = self.df[self.df['countriesAndTerritories'].isin([country])]
countryTimeData = countryTimeData.sort_values('dateRep')
countryTimeData['totalCases'] = countryTimeData['cases'].cumsum()
countryTimeData[country] = countryTimeData['cases'].rolling(7).mean()

View File

@ -8,11 +8,11 @@ import sys
from datetime import datetime
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import QDate
from PyQt5.QtCore import *
import Analyser as ana
class UserInterface(QWidget):
class UserInterface(QMainWindow):
def __init__(self, app):
super().__init__()
# Get Analyser instance and required stuff from it
@ -26,6 +26,7 @@ class UserInterface(QWidget):
screen_width, screen_height = app.desktop().screenGeometry().width(), app.desktop().screenGeometry().height()
self.setGeometry(((screen_width / 2) - 750), ((screen_height / 2) - 375), 1500, 750)
self.setMinimumWidth(1500)
self.setMinimumHeight(500)
# Layout boxes
self.header_box = QHBoxLayout()
@ -107,7 +108,11 @@ class UserInterface(QWidget):
layout.addLayout(self.graphBox)
layout.addStretch(1)
self.setLayout(layout)
self.scrollArea = QScrollArea()
self.scrollArea.setLayout(layout)
self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.setCentralWidget(self.scrollArea)
self.show()
def btnstate(self):
@ -135,7 +140,7 @@ class UserInterface(QWidget):
deathGraphPath = self.analyser.getDeathGraph(country, startDate, endDate)
deathIncreaseGraphPath = self.analyser.getDeathIncreaseGraph(country, startDate, endDate)
deathRateGraphPath = self.analyser.getDailyDeathRateGraph(country, startDate, endDate)
isItOverGraph = self.analyser.getIsItOverGraph(country, startDate, endDate)
isItOverGraph = self.analyser.getIsItOverGraph(country)
self.graphPlaceHolder = QLabel(self)
self.clearLayout(self.graphBox)
self.graphBox.addWidget(self.graphPlaceHolder)

File diff suppressed because it is too large Load Diff