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