ZennyKenny commited on
Commit
ccb8c8d
·
verified ·
1 Parent(s): d04177d

make arrays

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -108,9 +108,12 @@ def donut_chart_total() -> alt.Chart:
108
  {
109
  "values": [annotated_records, pending_records],
110
  "category": [ANNOTATED, PENDING],
111
- "colors": ["#27AE60", "#F1C40F"], # Green for Completed, yellow for Remaining
112
  }
113
  )
 
 
 
114
 
115
  base = alt.Chart(source).encode(
116
  theta=alt.Theta("values:Q", stack=True),
@@ -118,11 +121,8 @@ def donut_chart_total() -> alt.Chart:
118
  "values", scale=alt.Scale(type="sqrt", zero=True, rangeMin=20)
119
  ),
120
 
121
- color=alt.Color(
122
- "category:N",
123
- scale=alt.Scale(domain=source['category'], range=source['colors']), # Map colors to categories
124
- legend=alt.Legend(title=CATEGORY)
125
- ),
126
  )
127
 
128
  c1 = base.mark_arc(innerRadius=20, stroke="#fff")
 
108
  {
109
  "values": [annotated_records, pending_records],
110
  "category": [ANNOTATED, PENDING],
111
+ "colors": ["#27AE60", "#F1C40F"], # Green for Completed, Yellow for Remaining
112
  }
113
  )
114
+
115
+ domain = source['category'].tolist()
116
+ range_ = source['colors'].tolist()
117
 
118
  base = alt.Chart(source).encode(
119
  theta=alt.Theta("values:Q", stack=True),
 
121
  "values", scale=alt.Scale(type="sqrt", zero=True, rangeMin=20)
122
  ),
123
 
124
+
125
+ color=alt.Color(field="category", type="nominal", scale=alt.Scale(domain=domain, range=range_), legend=alt.Legend(title=CATEGORY)),
 
 
 
126
  )
127
 
128
  c1 = base.mark_arc(innerRadius=20, stroke="#fff")