Commit
·
800c1ec
1
Parent(s):
72246a1
Fix chart
Browse files
app.py
CHANGED
@@ -28,92 +28,116 @@ def build_dataframes(covered_language_codes):
|
|
28 |
languages_without_lead = clean_languages[~clean_languages['Code'].isin(covered_language_codes)]
|
29 |
return languages_with_lead, languages_without_lead
|
30 |
|
31 |
-
def create_progress_bar(
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
colors = ['rgba(38, 24, 74, 0.8)', 'rgba(190, 192, 213, 1)']
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
for i in range(0, len(x_data[0])):
|
43 |
-
for xd, yd in zip(x_data, y_data):
|
44 |
-
fig.add_trace(go.Bar(
|
45 |
-
x=[xd[i]], y=[yd],
|
46 |
-
orientation='h',
|
47 |
-
marker=dict(
|
48 |
-
color=colors[i],
|
49 |
-
line=dict(color='rgb(248, 248, 249)', width=1)
|
50 |
-
),
|
51 |
-
hoverinfo='text',
|
52 |
-
hovertext=f"{top_labels[i]} records: {xd[i]}"
|
53 |
-
))
|
54 |
|
55 |
fig.update_layout(
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
zeroline=False,
|
61 |
-
domain=[0.15, 1]
|
62 |
-
|
63 |
-
),
|
64 |
-
yaxis=dict(
|
65 |
-
showgrid=False,
|
66 |
-
showline=False,
|
67 |
-
showticklabels=False,
|
68 |
-
zeroline=False,
|
69 |
-
domain=[0.15, 0.5]
|
70 |
-
),
|
71 |
-
barmode='stack',
|
72 |
-
paper_bgcolor='rgb(248, 248, 255)',
|
73 |
-
plot_bgcolor='rgb(248, 248, 255)',
|
74 |
-
margin=dict(l=120, r=10, t=140, b=80),
|
75 |
-
showlegend=False
|
76 |
)
|
|
|
77 |
|
78 |
-
annotations = []
|
79 |
-
|
80 |
-
for yd, xd in zip(y_data, x_data):
|
81 |
-
# labeling the y-axis
|
82 |
-
annotations.append(dict(xref='paper', yref='y',
|
83 |
-
x=0.14, y=yd,
|
84 |
-
xanchor='right',
|
85 |
-
text=str(yd),
|
86 |
-
font=dict(family='Arial', size=14,
|
87 |
-
color='rgb(67, 67, 67)'),
|
88 |
-
showarrow=False, align='right'))
|
89 |
-
# labeling the first percentage of each bar (x_axis)
|
90 |
-
if xd[0] > 0:
|
91 |
-
annotations.append(dict(xref='x', yref='y',
|
92 |
-
x=xd[0] / 2, y=yd,
|
93 |
-
text=str(xd[0]),
|
94 |
-
font=dict(family='Arial', size=14,
|
95 |
-
color='rgb(248, 248, 255)'),
|
96 |
-
showarrow=False))
|
97 |
-
space = xd[0]
|
98 |
-
for i in range(1, len(xd)):
|
99 |
-
if xd[i] > 0:
|
100 |
-
# labeling the rest of percentages for each bar (x_axis)
|
101 |
-
annotations.append(dict(xref='x', yref='y',
|
102 |
-
x=space + (xd[i]/2), y=yd,
|
103 |
-
text=str(xd[i]),
|
104 |
-
font=dict(family='Arial', size=14,
|
105 |
-
color='rgb(248, 248, 255)'),
|
106 |
-
showarrow=False))
|
107 |
-
space += xd[i]
|
108 |
-
|
109 |
-
fig.update_layout(annotations=annotations, height=80)
|
110 |
return fig
|
111 |
|
|
|
112 |
with gr.Blocks() as demo:
|
113 |
gr.Markdown("## Language Leads Dashboard")
|
114 |
languages_with_lead, languages_without_lead = build_dataframes(get_covered_languages())
|
115 |
with gr.Row():
|
116 |
-
|
|
|
117 |
with gr.Tab("Looking for leads!"):
|
118 |
gr.Markdown("These languages don't have a lead yet! Would you like to lead one of them? Sign up using [this form](https://forms.gle/mFCMXNRjxvyFvW5q9).")
|
119 |
gr.DataFrame(languages_without_lead)
|
|
|
28 |
languages_without_lead = clean_languages[~clean_languages['Code'].isin(covered_language_codes)]
|
29 |
return languages_with_lead, languages_without_lead
|
30 |
|
31 |
+
# def create_progress_bar(languages_with_lead, languages_without_lead):
|
32 |
+
# top_labels = ['With lead', 'Without lead']
|
33 |
+
|
34 |
+
# colors = ['rgba(38, 24, 74, 0.8)', 'rgba(190, 192, 213, 1)']
|
35 |
+
|
36 |
+
# x_data = [len(languages_with_lead), len(languages_without_lead)]
|
37 |
+
|
38 |
+
# y_data = ['Progress']
|
39 |
+
|
40 |
+
# fig = go.Figure()
|
41 |
+
|
42 |
+
# for i in range(0, len(x_data[0])):
|
43 |
+
# for xd, yd in zip(x_data, y_data):
|
44 |
+
# fig.add_trace(go.Bar(
|
45 |
+
# x=[xd[i]], y=[yd],
|
46 |
+
# orientation='h',
|
47 |
+
# marker=dict(
|
48 |
+
# color=colors[i],
|
49 |
+
# line=dict(color='rgb(248, 248, 249)', width=1)
|
50 |
+
# ),
|
51 |
+
# hoverinfo='text',
|
52 |
+
# hovertext=f"{top_labels[i]} records: {xd[i]}"
|
53 |
+
# ))
|
54 |
+
|
55 |
+
# fig.update_layout(
|
56 |
+
# xaxis=dict(
|
57 |
+
# showgrid=False,
|
58 |
+
# showline=False,
|
59 |
+
# showticklabels=False,
|
60 |
+
# zeroline=False,
|
61 |
+
# domain=[0.15, 1]
|
62 |
+
|
63 |
+
# ),
|
64 |
+
# yaxis=dict(
|
65 |
+
# showgrid=False,
|
66 |
+
# showline=False,
|
67 |
+
# showticklabels=False,
|
68 |
+
# zeroline=False,
|
69 |
+
# domain=[0.15, 0.5]
|
70 |
+
# ),
|
71 |
+
# barmode='stack',
|
72 |
+
# paper_bgcolor='rgb(248, 248, 255)',
|
73 |
+
# plot_bgcolor='rgb(248, 248, 255)',
|
74 |
+
# margin=dict(l=120, r=10, t=140, b=80),
|
75 |
+
# showlegend=False
|
76 |
+
# )
|
77 |
+
|
78 |
+
# annotations = []
|
79 |
+
|
80 |
+
# for yd, xd in zip(y_data, x_data):
|
81 |
+
# # labeling the y-axis
|
82 |
+
# annotations.append(dict(xref='paper', yref='y',
|
83 |
+
# x=0.14, y=yd,
|
84 |
+
# xanchor='right',
|
85 |
+
# text=str(yd),
|
86 |
+
# font=dict(family='Arial', size=14,
|
87 |
+
# color='rgb(67, 67, 67)'),
|
88 |
+
# showarrow=False, align='right'))
|
89 |
+
# # labeling the first percentage of each bar (x_axis)
|
90 |
+
# if xd[0] > 0:
|
91 |
+
# annotations.append(dict(xref='x', yref='y',
|
92 |
+
# x=xd[0] / 2, y=yd,
|
93 |
+
# text=str(xd[0]),
|
94 |
+
# font=dict(family='Arial', size=14,
|
95 |
+
# color='rgb(248, 248, 255)'),
|
96 |
+
# showarrow=False))
|
97 |
+
# space = xd[0]
|
98 |
+
# for i in range(1, len(xd)):
|
99 |
+
# if xd[i] > 0:
|
100 |
+
# # labeling the rest of percentages for each bar (x_axis)
|
101 |
+
# annotations.append(dict(xref='x', yref='y',
|
102 |
+
# x=space + (xd[i]/2), y=yd,
|
103 |
+
# text=str(xd[i]),
|
104 |
+
# font=dict(family='Arial', size=14,
|
105 |
+
# color='rgb(248, 248, 255)'),
|
106 |
+
# showarrow=False))
|
107 |
+
# space += xd[i]
|
108 |
+
|
109 |
+
# fig.update_layout(annotations=annotations, height=80)
|
110 |
+
# return fig
|
111 |
+
|
112 |
+
|
113 |
+
def create_piechart():
|
114 |
|
115 |
colors = ['rgba(38, 24, 74, 0.8)', 'rgba(190, 192, 213, 1)']
|
116 |
+
fig = go.Figure(
|
117 |
+
go.Pie(
|
118 |
+
labels=["With lead", "Without lead"],
|
119 |
+
values=[len(languages_with_lead), len(languages_without_lead)],
|
120 |
+
marker=dict(colors=colors)
|
121 |
+
)
|
122 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
fig.update_layout(
|
125 |
+
|
126 |
+
title_text="Language Leads",
|
127 |
+
height=500,
|
128 |
+
margin=dict(l=10, r=10, t=50, b=10)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
)
|
130 |
+
fig.update_traces(textposition='inside', textinfo='label+value')
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
return fig
|
133 |
|
134 |
+
|
135 |
with gr.Blocks() as demo:
|
136 |
gr.Markdown("## Language Leads Dashboard")
|
137 |
languages_with_lead, languages_without_lead = build_dataframes(get_covered_languages())
|
138 |
with gr.Row():
|
139 |
+
piechart = create_piechart()
|
140 |
+
gr.Plot(value=piechart, label="Language Leads")
|
141 |
with gr.Tab("Looking for leads!"):
|
142 |
gr.Markdown("These languages don't have a lead yet! Would you like to lead one of them? Sign up using [this form](https://forms.gle/mFCMXNRjxvyFvW5q9).")
|
143 |
gr.DataFrame(languages_without_lead)
|