######################################################################
# Steps to check your YAML configuration from Python dashboard:
# 1. In dashboard.yaml, replace <REPLACE ME> with references to data sources.
# 2. In app.py, make sure data sources are registered in data manager.
# 3. In app.py, define any custom charts/figures/tables/actions.
# 4. Make sure dashboard works as expected.
######################################################################
from pathlib import Path
import vizro.plotly.express as px
import yaml
from vizro import Vizro
from vizro.managers import data_manager
from vizro.models import Dashboard
from vizro.models.types import capture
data_manager["gapminder"] = px.data.gapminder()
data_manager["tips"] = px.data.tips()
data_manager["iris"] = px.data.iris()
@capture("graph")
def scatter_with_line(data_frame, x, y, color=None, size=None, hline=None): # (1)!
fig = px.scatter(data_frame=data_frame, x=x, y=y, color=color, size=size)
fig.add_hline(y=hline, line_color="gray")
return fig
dashboard = yaml.safe_load(Path("dashboard.yaml").read_text(encoding="utf-8"))
dashboard = Dashboard(**dashboard)
Vizro().build(dashboard).run()