Spaces:
Sleeping
Sleeping
shamimjony1000
commited on
Update task_visualization.py
Browse files- task_visualization.py +48 -52
task_visualization.py
CHANGED
@@ -1,52 +1,48 @@
|
|
1 |
-
import
|
2 |
-
import pandas as pd
|
3 |
-
import
|
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 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
plt.
|
29 |
-
plt.
|
30 |
-
plt.
|
31 |
-
plt.
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
df
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
plt.
|
44 |
-
plt.
|
45 |
-
plt.
|
46 |
-
plt.
|
47 |
-
|
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)
|
|
|
|
|
|
|
|