Skip to content

Instantly share code, notes, and snippets.

async function callback(selection){
let response = await fetch("/callback?data="+selection);
if (response.ok) {
let result = await response.json();
Plotly.newPlot('chart1', result, {});
} else {
alert(response.status);
}
}
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
</head>
<body>
<div class="jumbotron">
<h1>Weather Data</h1>
<p class="lead">
<body>
<div class="jumbotron">
<h1>Weather Data</h1>
<p class="lead">
Some graphs about the weather in London in 2020
</p>
</div>
<div class="row">
<div class="col-sm-2 p-2 ml-4 mb-1">
<button type="button" class="btn btn-secondary">Select chart from list:</button>
<head>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
<py-env>
- matplotlib
- pandas
- plotly
# Countries
clist = df['country'].unique()
country = st.selectbox("Select a country:", clist)
col1, col2 = st.columns(2)
fig = px.line(df[df['country'] == country],
x="year", y="gdpPercap", title="GDP per Capita")
col1.plotly_chart(fig, use_container_width=True)
# Continents
contlist = df['continent'].unique()
continent = st.selectbox("Select a continent:", contlist)
col1, col2 = st.columns(2)
fig = px.line(df[df['continent'] == continent],
x = "year", y = "gdpPercap",
title = "GDP per Capita",color = 'country')
col1.plotly_chart(fig)
import streamlit as st
import pandas as pd
import plotly.express as px
st.set_page_config(layout="wide")
df = pd.DataFrame(px.data.gapminder())
def countryData():
# Countries code goes here
def run():
import streamlit as st
import pandas as pd
import plotly.express as px
df = pd.DataFrame(px.data.gapminder())
# Continents/Country code goes here
# This code allows you to run the app standalone
message = """
__Select an application from the list below__
"""
import streamlit as st
st.set_page_config(layout = "wide") # optional
from stlib import countryData
from stlib import continentData
@alanjones2
alanjones2 / 02-06-22-stmulitpage-mp4.py
Created June 2, 2022 10:39
02-06-22-stmulitpage-mp4.py
message = """
__Select an application from the list below__
"""
import json
import streamlit as st
import importlib
import stlib # default library name for apps
from stlib import libContents