Skip to content

Commit

Permalink
small formatiing changes; some optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
linozen committed Aug 31, 2021
1 parent 955041b commit f472479
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 74 deletions.
91 changes: 55 additions & 36 deletions explorer/civsoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,10 +1200,10 @@ def callback():
sections,
index=sections.index(query_section),
key="section",
on_change=callback
on_change=callback,
)

st.write(selected_section)
st.caption("__" + selected_section + "__ | Civil Society representatives")

filters = {
"country": st.sidebar.selectbox(
Expand Down Expand Up @@ -1241,7 +1241,7 @@ def callback():
window.parent.document.querySelector('section.main').scrollTo(0, 0);
</script>
""",
height=0
height=0,
)

st.markdown(
Expand All @@ -1255,9 +1255,6 @@ def callback():
###############################################################################


st.title("IOI Survey Data Explorer")
st.write("... of the responses given by __civil society organisation__ representatives")

if selected_section == "Overview":
st.write("# Overview")

Expand All @@ -1278,6 +1275,12 @@ def callback():
df[filter],
values=country_counts,
names=country_counts.index,
color=country_counts.index,
color_discrete_map={
"Germany": px.colors.qualitative.Prism[5],
"France": px.colors.qualitative.Prism[1],
"United Kingdom": px.colors.qualitative.Prism[7],
},
)
)

Expand Down Expand Up @@ -1527,7 +1530,7 @@ def callback():
continue

st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Very important",
Expand Down Expand Up @@ -1560,7 +1563,8 @@ def callback():
marker_color="#FFC300",
),
],
)
),
use_container_width=True,
)

st.write("### If you selected ‘other’, please specify `[CSfinance2other]`")
Expand Down Expand Up @@ -1795,7 +1799,7 @@ def callback():
continue

st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Very important",
Expand Down Expand Up @@ -1828,7 +1832,8 @@ def callback():
marker_color="#FFC300",
),
],
)
),
use_container_width=True,
)

campact2other_list = df[filter]["CScampact2other"].dropna().to_list()
Expand Down Expand Up @@ -1927,7 +1932,7 @@ def callback():
else:
continue
st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Agree completely",
Expand Down Expand Up @@ -1960,7 +1965,8 @@ def callback():
marker_color="#FFC300",
),
],
)
),
use_container_width=True,
)

CScampimpact2_list = df[filter]["CScampimpact2"].dropna().to_list()
Expand Down Expand Up @@ -2036,7 +2042,7 @@ def callback():
continue

st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Very important",
Expand Down Expand Up @@ -2069,7 +2075,8 @@ def callback():
marker_color="#FFC300",
),
],
)
),
use_container_width=True,
)

campact2other_list = df[filter]["CSadvocact2other"].dropna().to_list()
Expand Down Expand Up @@ -2168,7 +2175,7 @@ def callback():
else:
continue
st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Agree completely",
Expand Down Expand Up @@ -2201,7 +2208,8 @@ def callback():
marker_color="#FFC300",
),
],
)
),
use_container_width=True,
)

CSadvocimpact2_list = df[filter]["CSadvocimpact2"].dropna().to_list()
Expand Down Expand Up @@ -2277,7 +2285,7 @@ def callback():
continue

st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Very important",
Expand Down Expand Up @@ -2310,7 +2318,8 @@ def callback():
marker_color="#FFC300",
),
],
)
),
use_container_width=True,
)

campact2other_list = df[filter]["CSlitigateact2other"].dropna().to_list()
Expand Down Expand Up @@ -2478,7 +2487,7 @@ def callback():
else:
continue
st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Agree completely",
Expand Down Expand Up @@ -2511,7 +2520,8 @@ def callback():
marker_color="#FFC300",
),
],
)
),
use_container_width=True,
)

CSlitigateimpact2_list = df[filter]["CSlitigateimpact2"].dropna().to_list()
Expand Down Expand Up @@ -2567,7 +2577,7 @@ def callback():
continue

st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Yes",
Expand All @@ -2594,7 +2604,8 @@ def callback():
marker_color=px.colors.qualitative.Prism[10],
),
],
)
),
use_container_width=True,
)

st.write(
Expand Down Expand Up @@ -2662,7 +2673,7 @@ def callback():
continue

st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Very important",
Expand Down Expand Up @@ -2695,7 +2706,8 @@ def callback():
marker_color="#FFC300",
),
],
)
),
use_container_width=True,
)

CSprotectops3other_list = df[filter]["CSprotectops3other"].dropna().to_list()
Expand Down Expand Up @@ -2816,7 +2828,7 @@ def callback():
else:
continue
st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Yes",
Expand Down Expand Up @@ -2845,7 +2857,8 @@ def callback():
opacity=0.8,
),
],
)
),
use_container_width=True,
)

protectleg3other_list = df[filter]["CSprotectleg3other"].dropna().to_list()
Expand Down Expand Up @@ -2940,7 +2953,7 @@ def callback():
else:
continue
st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Yes",
Expand Down Expand Up @@ -2969,7 +2982,8 @@ def callback():
opacity=0.8,
),
],
)
),
use_container_width=True,
)

st.write(
Expand Down Expand Up @@ -3003,7 +3017,7 @@ def callback():
else:
continue
st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Yes",
Expand Down Expand Up @@ -3032,7 +3046,8 @@ def callback():
opacity=0.8,
),
],
)
),
use_container_width=True,
)

constraintinter5other_list = (
Expand Down Expand Up @@ -3087,7 +3102,7 @@ def callback():
else:
continue
st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Yes",
Expand Down Expand Up @@ -3116,7 +3131,8 @@ def callback():
opacity=0.8,
),
],
)
),
use_container_width=True,
)

constraintinter6other_list = (
Expand Down Expand Up @@ -3163,7 +3179,7 @@ def callback():
else:
continue
st.plotly_chart(
generate_stacked_bar_chart(
render_stacked_bar_chart(
data=[
go.Bar(
name="Yes",
Expand Down Expand Up @@ -3192,7 +3208,8 @@ def callback():
opacity=0.8,
),
],
)
),
use_container_width=True,
)

constraintself1other_list = df[filter]["CSconstraintself1other"].dropna().to_list()
Expand Down Expand Up @@ -3267,7 +3284,7 @@ def callback():
CSattitude3_df = CSattitude3_df.drop_duplicates()

st.plotly_chart(
generate_histogram(
render_histogram(
df=CSattitude3_df,
x="option",
y="count",
Expand All @@ -3279,7 +3296,8 @@ def callback():
"United Kingdom": px.colors.qualitative.Prism[7],
},
labels={"count": "people who answered 'Yes'"},
)
),
use_container_width=True,
)

scoring = {1: 6, 2: 5, 3: 4, 4: 3, 5: 2, 6: 1}
Expand Down Expand Up @@ -3308,6 +3326,7 @@ def callback():
st.plotly_chart(render_ranking_plot("CSattitude6"))

if selected_section == "Appendix":

st.write("# Appendix")

st.write("## Raw data")
Expand Down
Loading

0 comments on commit f472479

Please sign in to comment.