Skip to content

Commit ba374c6

Browse files
committed
Add Data Plotting features to the GUI
New Features are in the "Data" Menu Bar
1 parent 7f21beb commit ba374c6

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

app.py

+18
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from widgets.py_files.widget_options_menu import Ui_widget_options_menu
1313
from widgets.dialog_create_data_file import DialogCreateDataFile
1414
from utils import open_dialog, get_data_path, set_data_path, is_valid_file
15+
from reportingtools import reportutils
1516

1617

1718
class App(QtWidgets.QMainWindow):
@@ -32,6 +33,8 @@ def setups(self):
3233
self.ui.action_open.triggered.connect(self.open_existing_file)
3334
self.ui.action_close.triggered.connect(self.close_current_file)
3435
self.ui.action_exit.triggered.connect(self.close_app)
36+
self.ui.actionProjects_Chart.triggered.connect(self.make_projects_chart)
37+
self.ui.actionTime_Series_Chart.triggered.connect(self.make_timeseries_chart)
3538
if self.data_path == "" or not os.path.exists(self.data_path):
3639
self.setup_options_menu()
3740
self.ui.action_close.setEnabled(False)
@@ -107,6 +110,21 @@ def close_current_file(self):
107110
set_data_path(self.data_path)
108111
#self.update_data_path()
109112

113+
def make_projects_chart(self):
114+
"""Creates a chart displaying the work done on each project. Automatically opens a browser window containing the chart."""
115+
df, _ = reportutils.dataframe_from_json(self.data_path)
116+
reportutils.plot_project_bar(df)
117+
118+
def make_timeseries_chart(self):
119+
"""
120+
Creates a chart displaying the work done over time. Automatically opens a browser window containing the chart.
121+
122+
Default time frequency used is daily.
123+
Future plan: Provide a selector to daily/weekly/monthly/quarterly views.
124+
"""
125+
_, projects = reportutils.dataframe_from_json(self.data_path)
126+
reportutils.plot_timeseries_bar(projects, 'D')
127+
110128
def close_app(self):
111129
sys.exit()
112130

requirements.txt

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1+
numpy==1.21.1
2+
pandas==1.3.0
3+
plotly==5.1.0
14
PyQt5==5.15.4
25
PyQt5-Qt5==5.15.2
36
PyQt5-sip==12.8.1
7+
python-dateutil==2.8.2
8+
pytz==2021.1
9+
six==1.16.0
10+
tenacity==8.0.1
411
time-tracker-cli==0.0.1
12+
toml==0.9.6

widgets/py_files/main.py

+12
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def setupUi(self, MainWindow):
3939
self.menuFile.setObjectName("menuFile")
4040
self.menuHelp = QtWidgets.QMenu(self.menubar)
4141
self.menuHelp.setObjectName("menuHelp")
42+
self.menuReport = QtWidgets.QMenu(self.menubar)
43+
self.menuReport.setObjectName("menuReport")
4244
MainWindow.setMenuBar(self.menubar)
4345
self.action_about = QtWidgets.QAction(MainWindow)
4446
icon = QtGui.QIcon.fromTheme("help")
@@ -61,13 +63,20 @@ def setupUi(self, MainWindow):
6163
icon = QtGui.QIcon.fromTheme("application-exit")
6264
self.action_exit.setIcon(icon)
6365
self.action_exit.setObjectName("action_exit")
66+
self.actionProjects_Chart = QtWidgets.QAction(MainWindow)
67+
self.actionProjects_Chart.setObjectName("actionProjects_Chart")
68+
self.actionTime_Series_Chart = QtWidgets.QAction(MainWindow)
69+
self.actionTime_Series_Chart.setObjectName("actionTime_Series_Chart")
6470
self.menuFile.addAction(self.action_new)
6571
self.menuFile.addAction(self.action_open)
6672
self.menuFile.addAction(self.action_close)
6773
self.menuFile.addAction(self.action_exit)
6874
self.menuHelp.addAction(self.action_about)
75+
self.menuReport.addAction(self.actionProjects_Chart)
76+
self.menuReport.addAction(self.actionTime_Series_Chart)
6977
self.menubar.addAction(self.menuFile.menuAction())
7078
self.menubar.addAction(self.menuHelp.menuAction())
79+
self.menubar.addAction(self.menuReport.menuAction())
7180

7281
self.retranslateUi(MainWindow)
7382
QtCore.QMetaObject.connectSlotsByName(MainWindow)
@@ -77,6 +86,7 @@ def retranslateUi(self, MainWindow):
7786
MainWindow.setWindowTitle(_translate("MainWindow", "Time Tracker"))
7887
self.menuFile.setTitle(_translate("MainWindow", "File"))
7988
self.menuHelp.setTitle(_translate("MainWindow", "Help"))
89+
self.menuReport.setTitle(_translate("MainWindow", "Report"))
8090
self.action_about.setText(_translate("MainWindow", "About"))
8191
self.action_new.setText(_translate("MainWindow", "New"))
8292
self.action_new.setShortcut(_translate("MainWindow", "Ctrl+N"))
@@ -86,6 +96,8 @@ def retranslateUi(self, MainWindow):
8696
self.action_close.setShortcut(_translate("MainWindow", "Ctrl+W"))
8797
self.action_exit.setText(_translate("MainWindow", "Exit"))
8898
self.action_exit.setShortcut(_translate("MainWindow", "Ctrl+Q"))
99+
self.actionProjects_Chart.setText(_translate("MainWindow", "Projects Chart"))
100+
self.actionTime_Series_Chart.setText(_translate("MainWindow", "Time-Series Chart"))
89101
import resources_rc
90102

91103

widgets/ui/main.ui

+18
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,16 @@
6666
</property>
6767
<addaction name="action_about"/>
6868
</widget>
69+
<widget class="QMenu" name="menuReport">
70+
<property name="title">
71+
<string>Report</string>
72+
</property>
73+
<addaction name="actionProjects_Chart"/>
74+
<addaction name="actionTime_Series_Chart"/>
75+
</widget>
6976
<addaction name="menuFile"/>
7077
<addaction name="menuHelp"/>
78+
<addaction name="menuReport"/>
7179
</widget>
7280
<action name="action_about">
7381
<property name="icon">
@@ -124,6 +132,16 @@
124132
<string>Ctrl+Q</string>
125133
</property>
126134
</action>
135+
<action name="actionProjects_Chart">
136+
<property name="text">
137+
<string>Projects Chart</string>
138+
</property>
139+
</action>
140+
<action name="actionTime_Series_Chart">
141+
<property name="text">
142+
<string>Time-Series Chart</string>
143+
</property>
144+
</action>
127145
</widget>
128146
<resources>
129147
<include location="resources.qrc"/>

0 commit comments

Comments
 (0)