Py.Cafe

maartenbreddels/

vizro-iris-data-exploration

Vizro Iris Data Exploration (not working yet)

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
import vizro.plotly.express as px
from vizro import Vizro
import vizro.models as vm
from vizro.managers import model_manager;
import vizro._constants
# this doesn't seem to work, we need a modern version of
# vizro and pydantic
import js
vizro._constants.STATIC_URL_PREFIX = "/_app/" + js._pageId + "/vizro"
vizro._vizro.STATIC_URL_PREFIX = vizro._constants.STATIC_URL_PREFIX
model_manager._reset()
print(dir(model_manager))
model_manager._ModelManager__models.clear()
# Vizro._reset()
df = px.data.iris()

import vizro.models as vm

# 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)

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
4
5
dash
# due to py
vizro#==0.1.3
dash-daq