Spaces:
Sleeping
Sleeping
nataliaElv
commited on
Commit
•
8d9fbc8
1
Parent(s):
3036563
Improve user contributions chart
Browse files
app.py
CHANGED
@@ -5,7 +5,6 @@ from typing import List
|
|
5 |
import argilla as rg
|
6 |
import gradio as gr
|
7 |
import pandas as pd
|
8 |
-
import plotly.colors as colors
|
9 |
import plotly.graph_objects as go
|
10 |
|
11 |
client = rg.Argilla(
|
@@ -33,10 +32,7 @@ def get_progress(dataset: rg.Dataset) -> dict:
|
|
33 |
def create_progress_bar(progress):
|
34 |
top_labels = ['Completed', 'Pending']
|
35 |
|
36 |
-
colors = ['rgba(38, 24, 74, 0.8)',
|
37 |
-
# 'rgba(71, 58, 131, 0.8)',
|
38 |
-
# 'rgba(122, 120, 168, 0.8)', 'rgba(164, 163, 204, 0.85)',
|
39 |
-
'rgba(190, 192, 213, 1)']
|
40 |
|
41 |
x_data = [[progress["annotated"], progress["total"] - progress["annotated"]]]
|
42 |
|
@@ -118,28 +114,27 @@ def create_progress_bar(progress):
|
|
118 |
|
119 |
def create_piechart(user_annotations):
|
120 |
sorted_users = sorted(user_annotations.items(), key=lambda x: x[1], reverse=True)
|
121 |
-
color_scale = colors.qualitative.Pastel + colors.qualitative.Set3
|
122 |
|
123 |
-
labels, values
|
124 |
|
125 |
-
for
|
126 |
labels.append(user)
|
127 |
values.append(contribution)
|
128 |
-
user_colors.append(color_scale[i % len(color_scale)])
|
129 |
|
130 |
fig = go.Figure(
|
131 |
go.Pie(
|
132 |
labels=labels,
|
133 |
-
values=values
|
134 |
)
|
135 |
)
|
136 |
|
137 |
fig.update_layout(
|
138 |
-
title_text="User contributions
|
139 |
height=500,
|
140 |
margin=dict(l=10, r=10, t=50, b=10),
|
141 |
-
template="ggplot2"
|
142 |
)
|
|
|
143 |
|
144 |
return fig
|
145 |
|
|
|
5 |
import argilla as rg
|
6 |
import gradio as gr
|
7 |
import pandas as pd
|
|
|
8 |
import plotly.graph_objects as go
|
9 |
|
10 |
client = rg.Argilla(
|
|
|
32 |
def create_progress_bar(progress):
|
33 |
top_labels = ['Completed', 'Pending']
|
34 |
|
35 |
+
colors = ['rgba(38, 24, 74, 0.8)', 'rgba(190, 192, 213, 1)']
|
|
|
|
|
|
|
36 |
|
37 |
x_data = [[progress["annotated"], progress["total"] - progress["annotated"]]]
|
38 |
|
|
|
114 |
|
115 |
def create_piechart(user_annotations):
|
116 |
sorted_users = sorted(user_annotations.items(), key=lambda x: x[1], reverse=True)
|
|
|
117 |
|
118 |
+
labels, values = [], []
|
119 |
|
120 |
+
for user, contribution in sorted_users:
|
121 |
labels.append(user)
|
122 |
values.append(contribution)
|
|
|
123 |
|
124 |
fig = go.Figure(
|
125 |
go.Pie(
|
126 |
labels=labels,
|
127 |
+
values=values
|
128 |
)
|
129 |
)
|
130 |
|
131 |
fig.update_layout(
|
132 |
+
title_text="User contributions",
|
133 |
height=500,
|
134 |
margin=dict(l=10, r=10, t=50, b=10),
|
135 |
+
template="ggplot2"
|
136 |
)
|
137 |
+
fig.update_traces(textposition='inside', textinfo='percent+label')
|
138 |
|
139 |
return fig
|
140 |
|