Skip to content

Commit

Permalink
added query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
linozen committed Aug 30, 2021
1 parent 21694ad commit 3a385e1
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 15 deletions.
41 changes: 36 additions & 5 deletions explorer/civsoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,10 +1164,29 @@ def get_cs_df():
# Sidebar | Filter logic
###############################################################################

try:
sections = [
"Overview",
"Resources",
"Public Campaigning",
"Policy Advocacy",
"Strategic Litigation",
"Protection",
"Constraints",
"Attitudes",
"Appendix",
]
query_params = st.experimental_get_query_params()
query_section = query_params["section"][0]
section = st.sidebar.radio(
"Choose section",
sections,
index=sections.index(query_section),
key="section_with_param",
)

section = st.sidebar.radio(
"Choose section",
[
except:
sections = [
"Overview",
"Resources",
"Public Campaigning",
Expand All @@ -1177,8 +1196,17 @@ def get_cs_df():
"Constraints",
"Attitudes",
"Appendix",
],
)
]
st.experimental_set_query_params(section=sections[0])
query_params = st.experimental_get_query_params()
query_section = query_params["section"][0]
section = st.sidebar.radio(
"Choose section",
sections,
index=sections.index(query_section),
key="section_no_param",
)


filters = {
"country": st.sidebar.selectbox(
Expand Down Expand Up @@ -3308,3 +3336,6 @@ def get_cs_df():
if show_sig:
fig_sig = get_significance_matrix(df)
st.plotly_chart(fig_sig, use_container_width=True)

if section:
st.experimental_set_query_params(section=section)
39 changes: 34 additions & 5 deletions explorer/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,19 +975,45 @@ def get_ms_df():
# Sidebar | Filter logic
###############################################################################

try:
sections = [
"Overview",
"Resources",
"Media Reporting",
"Protection",
"Constraints",
"Attitudes",
"Appendix",
]
query_params = st.experimental_get_query_params()
query_section = query_params["section"][0]
section = st.sidebar.radio(
"Choose section",
sections,
index=sections.index(query_section),
key="section_with_param",
)

section = st.sidebar.radio(
"Choose section",
[
except:
sections = [
"Overview",
"Resources",
"Media Reporting",
"Protection",
"Constraints",
"Attitudes",
"Appendix",
],
)
]
st.experimental_set_query_params(section=sections[0])
query_params = st.experimental_get_query_params()
query_section = query_params["section"][0]
section = st.sidebar.radio(
"Choose section",
sections,
index=sections.index(query_section),
key="section_no_param",
)


filters = {
"country": st.sidebar.selectbox(
Expand Down Expand Up @@ -3011,3 +3037,6 @@ def get_ms_df():
if show_sig:
fig_sig = get_significance_matrix(df)
st.plotly_chart(fig_sig, use_container_width=True)

if section:
st.experimental_set_query_params(section=section)
41 changes: 36 additions & 5 deletions explorer/merged.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import plotly.graph_objects as go
import plotly.express as px
from pathlib import Path
import time

from lib.figures import (
generate_pie_chart,
Expand Down Expand Up @@ -892,17 +893,43 @@ def get_merged_ms_df():
###############################################################################


section = st.sidebar.radio(
"Choose section",
[
try:
sections = [
"Overview",
"Resources",
"Protection",
"Constraints",
"Attitudes",
"Appendix",
],
)
]
query_params = st.experimental_get_query_params()
query_section = query_params["section"][0]
section = st.sidebar.radio(
"Choose section",
sections,
index=sections.index(query_section),
key="section_with_param",
)

except:
sections = [
"Overview",
"Resources",
"Protection",
"Constraints",
"Attitudes",
"Appendix",
]
st.experimental_set_query_params(section=sections[0])
query_params = st.experimental_get_query_params()
query_section = query_params["section"][0]
section = st.sidebar.radio(
"Choose section",
sections,
index=sections.index(query_section),
key="section_no_param",
)


filters = {
"surveytype": st.sidebar.selectbox(
Expand Down Expand Up @@ -2059,3 +2086,7 @@ def get_merged_ms_df():
if show_sig:
fig_sig = get_significance_matrix(df)
st.plotly_chart(fig_sig, use_container_width=True)


if section:
st.experimental_set_query_params(section=section)

0 comments on commit 3a385e1

Please sign in to comment.