Py.Cafe

huong-li-nguyen/

btn-style

Analyzing Iris Dataset with Vizro

DocsPricing
  • assets/
  • 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
42
43
# Vizro is an open-source toolkit for creating modular data visualization applications.
# check out https://github.com/mckinsey/vizro for more info about Vizro
# and checkout https://vizro.readthedocs.io/en/stable/ for documentation.

import vizro.models as vm
import vizro.plotly.express as px
from vizro import Vizro

iris = px.data.iris()

page_1 = vm.Page(
    title="Buttons",
    components=[
        vm.Graph(figure=px.scatter(iris, x="sepal_width", y="sepal_length", color="species", size="petal_length")),
    ],
    controls=[
        vm.Filter(column="species", selector=vm.Dropdown(title="Species")),
    ],

)
dashboard = vm.Dashboard(pages=[page_1])
app = Vizro().build(dashboard)

# Add script to modify reset-button className
app.dash.index_string = app.dash.index_string.replace(
    '</body>',
    '''
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            setTimeout(function() {
                var button = document.getElementById('reset-button');
                if (button) {
                    button.className = 'btn btn-secondary';
                }
            }, 200);
        });
    </script>
    </body>
    '''
    )

app.run()