forked from streamlit/demo-self-driving
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
162 lines (149 loc) · 5.48 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import streamlit as st
import streamlit.components.v1 as components
import networkx as nx
import matplotlib.pyplot as plt
from pyvis.network import Network
import numpy as np
import netviz
import color
import complex2
import hist
import scatter4
import treemap2
import stackedbar
import pandas as pd
import urllib
#st.set_page_config(page_title="Writers Dashboard", page_icon="sfdc_cloud_icon_52.png", layout="wide", initial_sidebar_state="auto", menu_items=None)
def main():
# readme_text = st.expander("Not sure how to use the tool?", expanded=False)
# with readme_text:
# st.write("my explanation")
#add two expands, one for help and one for resources
#st.header("Writer's Dashboard")
df = pd.read_csv("https://raw.githubusercontent.com/tyrin/info-topo-dash/master/data/TotalOrganicKeywords-Jan2021vsJan2022.csv")
app_mode = st.sidebar.selectbox("Check your content for:",
['<select>', "Shared Content", "Linked Content", "Customer Search", "Freshness", "Comparison", "Complex Questions", "Beta"])
if app_mode == "<select>":
home()
#readme_text.empty()
elif app_mode == "Shared Content":
#readme_text.empty()
shared_content_page()
elif app_mode == "Linked Content":
#readme_text.empty()
linked_content_page()
elif app_mode == "Customer Search":
#readme_text.empty()
seo_page(df)
elif app_mode == "Freshness":
#readme_text.empty()
freshness_page()
elif app_mode == "Comparison":
#readme_text.empty()
comparison_page()
elif app_mode == "Complex Questions":
#readme_text.empty()
complex_page()
elif app_mode == "Beta":
#readme_text.empty()
test_page()
# THIS IS THE SECTION THAT CONTAINS UTILITY FUNCTIONS
# Download a single file and make its content available as a string.
@st.cache(show_spinner=False)
def get_file_content_as_string(path):
url = 'https://raw.githubusercontent.com/tyrin/info-topo-dash/master/markdown/' + path
response = urllib.request.urlopen(url)
return response.read().decode("utf-8")
# THIS IS THE SECTION THAT RENDERS EACH PAGE
def home():
st.sidebar.success("Select a visualization in the sidebar.")
# Render the readme as markdown using st.markdown.
with st.expander("How Do I Use the Writer's Dashboard?"):
readme_text = st.markdown(get_file_content_as_string("instructions.md"))
with st.expander("Resources"):
resource_text = st.markdown(get_file_content_as_string("resources.md"))
def shared_content_page():
# Render the readme as markdown using st.markdown.
with st.expander("How Do I Use a Network Diagram?"):
video_file = open('NetworkVizHelp.mp4', 'rb')
video_bytes = video_file.read()
st.video(video_bytes)
readme_text = st.markdown(get_file_content_as_string("sharedcontent.md"))
st.subheader("Shared Content")
ref='conref'
# clist = df['country'].unique()
# country = st.selectbox("Select a country:",clist)
netviz.main(ref)
def linked_content_page():
# Render the readme as markdown using st.markdown.
with st.expander("How Do I Use a Network Diagram?"):
video_file = open('NetworkVizHelp.mp4', 'rb')
video_bytes = video_file.read()
st.video(video_bytes)
readme_text = st.markdown(get_file_content_as_string("linkedcontent.md"))
st.subheader("Linked Content")
ref = 'xref'
netviz.main(ref)
def seo_page(df):
# Render the readme as markdown using st.markdown.
with st.expander("How Do I Use the Customer Search SEO Diagram?"):
video_file = open('SEOVizHelp.mp4', 'rb')
video_bytes = video_file.read()
st.video(video_bytes)
readme_text = st.markdown(get_file_content_as_string("customersearch.md"))
st.subheader("Customer Search and SEO")
scattersearch = st.sidebar.radio(
"Keyword search for:",
('term', 'page'))
scatterterm=""
if len(scatterterm) == 0:
scatterterm = 'no'
scatterterm = st.sidebar.text_input('Enter a search term:', value="", max_chars=25)
scattertermlc = scatterterm.lower()
#st.write(scattertermlc)
scatter4.matscatterplot3(scattertermlc, scattersearch)
def freshness_page():
# Render the readme as markdown using st.markdown.
with st.expander("How Do I Use a Freshness Diagram?"):
# video_file = open('NetworkVizHelp.mp4', 'rb')
# video_bytes = video_file.read()
# st.video(video_bytes)
readme_text = st.markdown(get_file_content_as_string("customersearch.md"))
st.subheader("Freshness")
#heat.main()
hist.main()
def comparison_page():
# Render the readme as markdown using st.markdown.
with st.expander("How Do I Use the Comparison Diagrams?"):
video_file = open('ComparisonVizHelp.mp4', 'rb')
video_bytes = video_file.read()
st.video(video_bytes)
readme_text = st.markdown(get_file_content_as_string("comparison.md"))
st.subheader("Comparison")
comparetype = st.sidebar.radio(
"Select a visualization",
('Reference Treemap', 'Portal Freshness'))
if comparetype == "Reference Treemap":
treemap2.main()
elif comparetype == "Portal Freshness":
stackedbar.comparebar()
def complex_page():
# Render the readme as markdown using st.markdown.
with st.expander("How Do I Use the Complex Network Diagram?"):
# video_file = open('NetworkGraphHelpVid.mp4', 'rb')
# video_bytes = video_file.read()
# st.video(video_bytes)
readme_text = st.markdown(get_file_content_as_string("complexquestions.md"))
st.subheader("Complex Questions")
#st.write("This graph is complex and may take longer to load. If you encounter a blank screen, refresh your browser and try again.")
ref = 'choose'
complex2.main()
def test_page():
st.subheader("Beta")
st.write("Testing color scales.")
color.main()
#barplotly.mainbar()
#Unique list of domains...?
#dlist = df['country'].unique()
if __name__ == "__main__":
main()