Py.Cafe

maartenbreddels/

vizro-example-NaN

Iris Dataset Visualization Demo using Vizro

DocsPricing
  • app.py
  • requirements.txt
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
import vizro.plotly.express as px
from vizro import Vizro
import vizro.models as vm
from vizro.managers import model_manager


### WARNING: These are temporarily to work around some pycafe and/or vizro issues
###          and will not be needed in the future
# NOTE: also choose the pyodide-v0.26.x runtime in settings
import dash._pages
dash._pages.context_value.set({})

Vizro._reset()

# From Maximilian Schulz:
# Hack to stop app crashing when query parameters are specified: allow the layout function to accept **kwargs.
# Something like this will probably be built into vizro in the future so you wouldn't need to do this.
class DashboardWithQueryParameter(vm.Dashboard):
    def _make_page_layout(self, page: vm.Page, **kwargs):
        return super()._make_page_layout(page)
### WARNING: the code above is temporarily
### Here is where the normal vizro code goes:

df = px.data.iris()

page = vm.Page(
    title="My first dashboard",
    components=[
        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="sepal_width", color="species")),
    ],
    controls=[
        vm.Filter(column="species", selector=vm.Dropdown(value=["ALL"])),
    ],
)

dashboard = DashboardWithQueryParameter(pages=[page])

vizro = Vizro()
app = vizro.build(dashboard).dash
requirements.txt
1
2
3
dash
vizro