Spaces:
Runtime error
Runtime error
Commit
β’
df4792a
1
Parent(s):
1356f44
Update app.py
Browse files
app.py
CHANGED
@@ -63,6 +63,47 @@ def get_user_annotations_dictionary(
|
|
63 |
return output
|
64 |
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
def donut_chart() -> alt.Chart:
|
67 |
"""
|
68 |
This function returns a donut chart with the number of annotated and pending records.
|
@@ -175,7 +216,7 @@ def main() -> None:
|
|
175 |
)
|
176 |
plot = gr.Plot(label="Plot")
|
177 |
demo.load(
|
178 |
-
|
179 |
inputs=[],
|
180 |
outputs=[plot],
|
181 |
)
|
|
|
63 |
return output
|
64 |
|
65 |
|
66 |
+
def donut_chart2() -> alt.Chart:
|
67 |
+
# Load your data
|
68 |
+
source_dataset, results = obtain_source_target_datasets()
|
69 |
+
pending_records = len(source_dataset)
|
70 |
+
annotated_records = len(results)
|
71 |
+
|
72 |
+
# Prepare data for the donut chart
|
73 |
+
source = pd.DataFrame({
|
74 |
+
"values": [annotated_records, pending_records],
|
75 |
+
"category": ["Completed", "Remaining"],
|
76 |
+
"colors": ["#4CAF50", "#757575"] # Green for Completed, Grey for Remaining
|
77 |
+
})
|
78 |
+
|
79 |
+
# Base chart for donut segments
|
80 |
+
base = alt.Chart(source).encode(
|
81 |
+
theta=alt.Theta(field="values", type="quantitative", stack=True), # The angle encoding
|
82 |
+
color=alt.Color(field="colors", type="nominal", legend=alt.Legend(title="Category"), scale=None), # Direct color specification
|
83 |
+
tooltip=['category', 'values'] # Tooltips for interactivity
|
84 |
+
)
|
85 |
+
|
86 |
+
# Arc marks for donut segments
|
87 |
+
arcs = base.mark_arc(innerRadius=100, outerRadius=150, stroke="#fff") # Increased inner radius for a thicker donut
|
88 |
+
|
89 |
+
# Text marks for labels, adjusted to be placed within the donut segments
|
90 |
+
text = base.mark_text(radiusOffset=-70, size=16, color='white').encode(
|
91 |
+
text=alt.Text(field="values", type="quantitative"), # The text to display
|
92 |
+
)
|
93 |
+
|
94 |
+
# Combine the arcs and text
|
95 |
+
chart = arcs + text
|
96 |
+
|
97 |
+
# Configure the view to have a transparent background
|
98 |
+
chart = chart.configure_view(
|
99 |
+
strokeWidth=0, # Remove border around chart
|
100 |
+
fill=None # Ensure background is transparent
|
101 |
+
).configure_axis(
|
102 |
+
grid=False # Turn off the grid
|
103 |
+
)
|
104 |
+
|
105 |
+
return chart
|
106 |
+
|
107 |
def donut_chart() -> alt.Chart:
|
108 |
"""
|
109 |
This function returns a donut chart with the number of annotated and pending records.
|
|
|
216 |
)
|
217 |
plot = gr.Plot(label="Plot")
|
218 |
demo.load(
|
219 |
+
donut_chart2,
|
220 |
inputs=[],
|
221 |
outputs=[plot],
|
222 |
)
|