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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -64,6 +64,10 @@ def get_user_annotations_dictionary(
64
 
65
 
66
 
 
 
 
 
67
  import altair as alt
68
  import pandas as pd
69
  import os
@@ -83,7 +87,7 @@ def donut_chart() -> alt.Chart:
83
 
84
  # Create the base of the donut chart
85
  base = alt.Chart(source).encode(
86
- theta=alt.Theta(field="values", type="quantitative", stack=True),
87
  color=alt.Color(field="color", type="nominal", legend=None), # Use the colors defined in the DataFrame
88
  tooltip=["category", "values"]
89
  )
@@ -91,10 +95,10 @@ def donut_chart() -> alt.Chart:
91
  # Create the arcs for the donut chart
92
  arcs = base.mark_arc(innerRadius=100, outerRadius=120, stroke="#fff")
93
 
94
- # Add text labels in the middle of the donut chart
95
- text = base.mark_text(radius=140, size=20, align='center').encode(
96
  text=alt.Text("values:Q"),
97
- angle=alt.Angle(field="values", type="quantitative", aggregate='sum', stack=True) # Calculate the mid-angle position for the labels
98
  )
99
 
100
  # Combine the arcs and text
 
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
 
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
  )
 
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