# Vizro is an open-source toolkit for creating modular data visualization applications.
# check out https://github.com/mckinsey/vizro for more info about Vizro
# and checkout https://vizro.readthedocs.io/en/stable/ for documentation.
import vizro.plotly.express as px
from vizro import Vizro
import vizro.models as vm
import pandas as pd
from urllib.request import urlopen
import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
counties = json.load(response)
df = pd.read_csv('data_2024/county_data.csv')
colorscale = [
'rgb(193, 193, 193)',
'rgb(239,239,239)',
'rgb(195, 196, 222)',
'rgb(144,148,194)',
'rgb(101,104,168)',
'rgb(65, 53, 132)'
]
fig = px.choropleth(
df,
geojson=counties,
locations='code',
color='NumInd',
color_continuous_scale="Viridis",
range_color=(0, 12),
scope='usa'
# labels={'unemp':'unemployment rate'}
# legend=dict(
# title=dict(
# text='Population by County'
# )
# ),
# title=dict(
# text='2024 Food Bank Visitors By County'
# )
)
page = vm.Page(
title="Vizro on PyCafe",
layout=vm.Layout(grid=[[0, 1], [2, 2], [2, 2], [3, 3], [3, 3]], row_min_height="140px"),
components=[
vm.Card(
text="""
### What is Vizro?
An open-source toolkit for creating modular data visualization applications.
Rapidly self-serve the assembly of customized dashboards in minutes - without the need for advanced coding or design experience - to create flexible and scalable, Python-enabled data visualization applications."""
),
vm.Card(
text="""
### Github
Checkout Vizro's GitHub page for further information and release notes. Contributions are always welcome!""",
href="https://github.com/mckinsey/vizro",
),
# vm.Graph(id="scatter_chart", figure=px.scatter(df, x="sepal_length", y="petal_width", color="species")),
vm.Graph(id="hist_chart", figure=px.histogram(df, x="county", color="NumInd")),
vm.Graph(id="map", figure=fig)
],
controls=[vm.Filter(column="species"), vm.Filter(column="petal_length"), vm.Filter(column="sepal_width")],
)
dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()