Spaces:
Sleeping
Sleeping
Commit
β’
b6f8835
1
Parent(s):
ead70d9
Update app.py
Browse files
app.py
CHANGED
@@ -113,54 +113,6 @@ import altair as alt
|
|
113 |
import pandas as pd
|
114 |
import os
|
115 |
|
116 |
-
def progress_bar_chart() -> alt.Chart:
|
117 |
-
# Load your data
|
118 |
-
source_dataset, _ = obtain_source_target_datasets()
|
119 |
-
total_records = int(os.getenv("TARGET_RECORDS"))
|
120 |
-
annotated_records = len(source_dataset)
|
121 |
-
percentage_complete = annotated_records / total_records * 100
|
122 |
-
|
123 |
-
# Define the data for the bars
|
124 |
-
progress_data = pd.DataFrame({
|
125 |
-
'category': ['Completed', 'Pending'],
|
126 |
-
'value': [annotated_records, total_records - annotated_records]
|
127 |
-
})
|
128 |
-
|
129 |
-
# Base chart for the progress
|
130 |
-
base = alt.Chart(progress_data).encode(
|
131 |
-
alt.X('value:Q', scale=alt.Scale(domain=[0, total_records]), title='Number of Records'),
|
132 |
-
alt.Y('category:N', title='')
|
133 |
-
)
|
134 |
-
|
135 |
-
# Colored bar for completion
|
136 |
-
bar = base.mark_bar(size=50, color='#28a745').transform_filter(
|
137 |
-
alt.datum.category == 'Completed'
|
138 |
-
)
|
139 |
-
|
140 |
-
# Gray bar for pending
|
141 |
-
background = base.mark_bar(size=50, color='#dcdcdc').transform_filter(
|
142 |
-
alt.datum.category == 'Pending'
|
143 |
-
)
|
144 |
-
|
145 |
-
# Text for the completed records
|
146 |
-
text = base.mark_text(align='left', dx=3, dy=0, fontSize=16, fontWeight='bold', color='black').encode(
|
147 |
-
text='value:Q'
|
148 |
-
).transform_filter(
|
149 |
-
alt.datum.category == 'Completed'
|
150 |
-
)
|
151 |
-
|
152 |
-
# Combine the charts
|
153 |
-
chart = alt.layer(background, bar, text).resolve_scale(y='independent').properties(
|
154 |
-
width=700,
|
155 |
-
height=400,
|
156 |
-
title='Progress Towards Goal'
|
157 |
-
).configure_view(
|
158 |
-
strokeWidth=0
|
159 |
-
).configure_axis(
|
160 |
-
grid=False
|
161 |
-
)
|
162 |
-
|
163 |
-
return chart
|
164 |
|
165 |
def donut_chart() -> alt.Chart:
|
166 |
"""
|
@@ -275,7 +227,7 @@ def main() -> None:
|
|
275 |
)
|
276 |
plot = gr.Plot(label="Plot")
|
277 |
demo.load(
|
278 |
-
|
279 |
inputs=[],
|
280 |
outputs=[plot],
|
281 |
)
|
|
|
113 |
import pandas as pd
|
114 |
import os
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
def donut_chart() -> alt.Chart:
|
118 |
"""
|
|
|
227 |
)
|
228 |
plot = gr.Plot(label="Plot")
|
229 |
demo.load(
|
230 |
+
gauge_chart,
|
231 |
inputs=[],
|
232 |
outputs=[plot],
|
233 |
)
|