Py.Cafe

antonymilne/

vizro-tips-analysis

Interactive Tips Analysis with Vizro

DocsPricing
  • assets/
  • yaml_version/
  • app.py
  • charts.py
  • data.yaml
  • 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
import vizro.actions as va
import vizro.models as vm
import vizro.plotly.express as px
from vizro import Vizro
from vizro.tables import dash_ag_grid

tips = px.data.tips().reset_index()
columnDefs = [{"field": col, "hide": col == "index"} for col in tips]

page = vm.Page(
    title="Multi-select on a table",
    components=[
        vm.AgGrid(
            title="Select a row to add it to the graph",
            figure=dash_ag_grid(tips, columnDefs=columnDefs, dashGridOptions={"rowSelection": {"checkboxes": True}}),
            actions=va.set_control(control="index_filter", value="index"),
        ),
        vm.Graph(id="tips_graph", figure=px.histogram(tips, x="tip")),  
    ],
    controls=[vm.Filter(id="index_filter", column="index", targets=["tips_graph"], selector=vm.Dropdown(value=[]))],  
)

dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()