"""This example is a Streamlit implementation of an interactive Country Indicators app. The purpose of this example is to test what we can do and cannot (yet) do in Streamlit compared to [Voila](https://github.com/voila-dashboards/voila) and list how the development experience and the end result compares The benchmark example from Voila is [https://github.com/voila-gallery/voila-gallery-country-indicators] (https://github.com/voila-gallery/voila-gallery-country-indicators) Author: Marc Skov Madsen https://github.com/marcskovmadsen """ import pathlib from typing import Tuple import pandas as pd import plotly.express as px import streamlit as st DATA_LOCAL = pathlib.Path(__file__).parent / "country_indicators.csv" DATA_URL = ( "https://raw.githubusercontent.com/MarcSkovMadsen/awesome-streamlit/master/package/" "awesome_streamlit/app/pages/contributions/country_indicators/country_indicators.csv" ) DATA_ORIGINAL = ( "https://gist.githubusercontent.com/chriddyp/cb5392c35661370d95f300086accea51/" "raw/8e0768211f6b747c0db42a9ce9a0937dafcbd8b2/indicators.csv" ) EXPLANATION = """ ## Compare different development indicators. Select what indicators to plot in the dropdowns, and use the slider to sub-select a fraction of years to include in the plot. Data and idea copied from the [Plotly Dash documentation](https://dash.plot.ly/getting-started-part-2) This example demonstrates combining Plotly with Streamlit widgets. """ def main(): """This is the main component. Run this to start the app.""" intro_section() streamlit_section() voila_section() findings_section() def intro_section(): """This section introduces the app""" st.markdown( """ # Country Indicators ## Introduction This example is a Streamlit implementation of an interactive Country Indicator plot. The purpose of this example is to test what we can do and cannot (yet) do in Streamlit compared to the combination of [Jupyter Notebook](https://jupyter.org/) and [Voila](https://github.com/voila-dashboards/voila). As of today (2019-10-20) both Voila and Streamlit are released for Beta Testing only. """ ) def streamlit_section(): """This section controls the Streamlit Country Indicators App""" st.markdown( """ ## Country Indicators - Streamlit version """ ) App.create_from_url(DATA_URL, DATA_LOCAL) def voila_section(): """This section controls the Voila Reference Country Indicators App""" st.markdown( """ ## Country Indicators - Voila Version We compare to the Country Indicator app in the Voila Gallery. **Click the image** to see the **source**. [![Voila country indicators](https://github.com/MarcSkovMadsen/awesome-streamlit/blob/master/gallery/country_indicators/voila_country_indicators.png?raw=true)](https://github.com/voila-gallery/voila-gallery-country-indicators) Voila also shows a nice spinner by it self while running some of the cells ![Executing 3 of 6 spinner](https://github.com/MarcSkovMadsen/awesome-streamlit/blob/master/gallery/country_indicators/voila_executing_3_of_6.png?raw=true) """ ) def findings_section(): st.markdown( """ ## Findings ### Pros of Voila - The **image updates very, very fast** when changing a selection - The **label and widget are independent**. I.e. you don't have to have a label if you need a more compact layout. - How to get a **range slider is very explicit**, i.e. IntRangeSlider. - You can have columnar and row layout with **HBox and VBox** - It's ok to **style** via HTML and