shamimjony1000 commited on
Commit
197bf20
·
verified ·
1 Parent(s): c728863

Update task_visualization.py

Browse files
Files changed (1) hide show
  1. task_visualization.py +48 -52
task_visualization.py CHANGED
@@ -1,52 +1,48 @@
1
- import matplotlib.pyplot as plt
2
- import pandas as pd
3
- import streamlit as st
4
-
5
- class TaskVisualizer:
6
- def plot_performance(self):
7
- df = pd.DataFrame(st.session_state.tasks)
8
- df['Total Duration'] = df['Task Duration (hours)'] + df['Task Duration (minutes)'] / 60.0
9
-
10
- plt.figure(figsize=(10, 5))
11
- task_times = df.groupby('Task Name')['Total Duration'].sum()
12
- task_times.plot(kind='bar')
13
- plt.xlabel('Task')
14
- plt.ylabel('Hours Spent')
15
- plt.title('Overall Task Performance')
16
- plt.xticks(rotation=45)
17
- plt.tight_layout()
18
- st.pyplot(plt)
19
-
20
- def plot_category_performance(self, timeframe, task_manager):
21
- report = task_manager.generate_report(timeframe)
22
- if not report.empty:
23
- category_times = report.groupby('Category')['Total Duration'].sum()
24
-
25
- plt.figure(figsize=(10, 5))
26
- category_times.plot(kind='bar', color='skyblue')
27
- plt.xlabel('Category')
28
- plt.ylabel('Total Hours Spent')
29
- plt.title(f'Task Performance by Category - {timeframe.capitalize()} Report')
30
- plt.xticks(rotation=45)
31
- plt.tight_layout()
32
- st.pyplot(plt)
33
-
34
- def plot_overall_category_performance(self):
35
- df = pd.DataFrame(st.session_state.tasks)
36
- df['Total Duration'] = df['Task Duration (hours)'] + df['Task Duration (minutes)'] / 60.0
37
-
38
- category_times = df.groupby('Category')['Total Duration'].sum()
39
-
40
- plt.figure(figsize=(10, 5))
41
- category_times.plot(kind='bar', color='lightgreen')
42
- plt.xlabel('Category')
43
- plt.ylabel('Total Hours Spent')
44
- plt.title('Overall Task Performance by Category')
45
- plt.xticks(rotation=45)
46
- plt.tight_layout()
47
- st.pyplot(plt)
48
-
49
- def download_report(self):
50
- df = pd.DataFrame(st.session_state.tasks)
51
- csv = df.to_csv(index=False)
52
- st.download_button("Download CSV", data=csv, file_name="task_report.csv", mime='text/csv')
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+
5
+ class TaskVisualizer:
6
+ def plot_performance(self):
7
+ df = pd.DataFrame(st.session_state.tasks)
8
+ df['Total Duration'] = df['Task Duration (hours)'] + df['Task Duration (minutes)'] / 60.0
9
+
10
+ plt.figure(figsize=(10, 5))
11
+ task_times = df.groupby('Task Name')['Total Duration'].sum()
12
+ task_times.plot(kind='bar')
13
+ plt.xlabel('Task')
14
+ plt.ylabel('Hours Spent')
15
+ plt.title('Overall Task Performance')
16
+ plt.xticks(rotation=45)
17
+ plt.tight_layout()
18
+ st.pyplot(plt)
19
+
20
+ def plot_category_performance(self, timeframe):
21
+ task_manager = TaskManager()
22
+ report = task_manager.generate_report(timeframe)
23
+ if not report.empty:
24
+ category_times = report.groupby('Category')['Total Duration'].sum()
25
+
26
+ plt.figure(figsize=(10, 5))
27
+ category_times.plot(kind='bar', color='skyblue')
28
+ plt.xlabel('Category')
29
+ plt.ylabel('Total Hours Spent')
30
+ plt.title(f'Task Performance by Category - {timeframe.capitalize()} Report')
31
+ plt.xticks(rotation=45)
32
+ plt.tight_layout()
33
+ st.pyplot(plt)
34
+
35
+ def plot_overall_category_performance(self):
36
+ df = pd.DataFrame(st.session_state.tasks)
37
+ df['Total Duration'] = df['Task Duration (hours)'] + df['Task Duration (minutes)'] / 60.0
38
+
39
+ category_times = df.groupby('Category')['Total Duration'].sum()
40
+
41
+ plt.figure(figsize=(10, 5))
42
+ category_times.plot(kind='bar', color='lightgreen')
43
+ plt.xlabel('Category')
44
+ plt.ylabel('Total Hours Spent')
45
+ plt.title('Overall Task Performance by Category')
46
+ plt.xticks(rotation=45)
47
+ plt.tight_layout()
48
+ st.pyplot(plt)