dvilasuero HF staff commited on
Commit
fa06f76
1 Parent(s): db78e5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -33
app.py CHANGED
@@ -63,51 +63,33 @@ def get_user_annotations_dictionary(
63
  return output
64
 
65
 
66
-
67
- import altair as alt
68
- import pandas as pd
69
- import os
70
-
71
- import altair as alt
72
- import pandas as pd
73
- import os
74
-
75
  def donut_chart() -> alt.Chart:
76
  # Load your data
77
  source_dataset, results = obtain_source_target_datasets()
78
  pending_records = len(source_dataset)
79
  annotated_records = len(results)
 
 
 
 
 
 
 
80
 
81
- # Prepare data for the donut chart
82
- source = pd.DataFrame({
83
- "values": [annotated_records, pending_records],
84
- "category": ["Submitted", "Pending"],
85
- "color": ["#28a745", "#dcdcdc"] # Green for submitted, grey for pending
86
- })
87
-
88
- # Create the base of the donut chart
89
  base = alt.Chart(source).encode(
90
- theta=alt.Theta(field="values", type="quantitative"),
91
- color=alt.Color(field="color", type="nominal", legend=None), # Use the colors defined in the DataFrame
92
- tooltip=["category", "values"]
 
 
93
  )
94
 
95
- # Create the arcs for the donut chart
96
- arcs = base.mark_arc(innerRadius=100, outerRadius=120, stroke="#fff")
97
 
98
- # Add text labels
99
- text = base.mark_text(radiusOffset=20, size=20).encode(
100
- text=alt.Text("values:Q"),
101
- color=alt.value('black') # Setting text color to black for better readability
102
- )
103
-
104
- # Combine the arcs and text
105
- chart = arcs + text
106
 
107
- # Set the chart background to transparent
108
- chart = chart.configure_view(strokeOpacity=0)
109
 
110
- return chart
111
 
112
 
113
 
 
63
  return output
64
 
65
 
 
 
 
 
 
 
 
 
 
66
  def donut_chart() -> 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
+ source = pd.DataFrame(
73
+ {
74
+ "values": [annotated_records, pending_records],
75
+ "category": ["Annotated", "Pending"], # Add a new column for categories
76
+ }
77
+ )
78
 
 
 
 
 
 
 
 
 
79
  base = alt.Chart(source).encode(
80
+ theta=alt.Theta("values:Q", stack=True),
81
+ radius=alt.Radius(
82
+ "values", scale=alt.Scale(type="sqrt", zero=True, rangeMin=20)
83
+ ),
84
+ color=alt.Color("category:N", legend=alt.Legend(title="Category")),
85
  )
86
 
87
+ c1 = base.mark_arc(innerRadius=20, stroke="#fff")
 
88
 
89
+ c2 = base.mark_text(radiusOffset=10).encode(text="values:Q")
 
 
 
 
 
 
 
90
 
91
+ chart = c1 + c2
 
92
 
 
93
 
94
 
95