Spaces:
Runtime error
Runtime error
Commit
β’
372b939
1
Parent(s):
2f28cd4
Update app.py
Browse files
app.py
CHANGED
@@ -62,6 +62,48 @@ def get_user_annotations_dictionary(
|
|
62 |
|
63 |
return output
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
def donut_chart() -> alt.Chart:
|
67 |
"""
|
@@ -176,7 +218,7 @@ def main() -> None:
|
|
176 |
)
|
177 |
plot = gr.Plot(label="Plot")
|
178 |
demo.load(
|
179 |
-
|
180 |
inputs=[],
|
181 |
outputs=[plot],
|
182 |
)
|
|
|
62 |
|
63 |
return output
|
64 |
|
65 |
+
import altair as alt
|
66 |
+
import pandas as pd
|
67 |
+
import os
|
68 |
+
|
69 |
+
def progress_bar_chart() -> alt.Chart:
|
70 |
+
source_dataset, _ = obtain_source_target_datasets()
|
71 |
+
annotated_records = len(source_dataset)
|
72 |
+
total_records = int(os.getenv("TARGET_RECORDS"))
|
73 |
+
percentage_complete = annotated_records / total_records * 100
|
74 |
+
|
75 |
+
# Data for the progress bar
|
76 |
+
progress_data = pd.DataFrame({
|
77 |
+
'category': ['Progress'],
|
78 |
+
'percentage': [percentage_complete]
|
79 |
+
})
|
80 |
+
|
81 |
+
# Data for the total label
|
82 |
+
total_label = pd.DataFrame({
|
83 |
+
'category': ['Total'],
|
84 |
+
'percentage': [100],
|
85 |
+
'label': [f'{annotated_records} / {total_records}']
|
86 |
+
})
|
87 |
+
|
88 |
+
# Progress bar
|
89 |
+
progress_bar = alt.Chart(progress_data).mark_bar(color='lightgreen', size=50).encode(
|
90 |
+
x=alt.X('percentage:Q', axis=alt.Axis(title='Completion Percentage', format='%'), scale=alt.Scale(domain=(0, 100)))
|
91 |
+
)
|
92 |
+
|
93 |
+
# Total label
|
94 |
+
total_text = alt.Chart(total_label).mark_text(dx=5, dy=-5, align='left', fontSize=15, fontWeight='bold').encode(
|
95 |
+
x=alt.X('percentage:Q'),
|
96 |
+
text=alt.Text('label:N')
|
97 |
+
)
|
98 |
+
|
99 |
+
# Combine the bar and the label
|
100 |
+
chart = progress_bar + total_text
|
101 |
+
|
102 |
+
# Optionally, add a title
|
103 |
+
chart = chart.properties(title='Progress Towards Goal')
|
104 |
+
|
105 |
+
return chart
|
106 |
+
|
107 |
|
108 |
def donut_chart() -> alt.Chart:
|
109 |
"""
|
|
|
218 |
)
|
219 |
plot = gr.Plot(label="Plot")
|
220 |
demo.load(
|
221 |
+
progress_bar_chart,
|
222 |
inputs=[],
|
223 |
outputs=[plot],
|
224 |
)
|