Py.Cafe

maxi.schulz/

vizro-on-pycafe

PyCafe on Vizro - create and share beautiful data apps in seconds

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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import vizro.plotly.express as px
from vizro import Vizro
import vizro.models as vm
from vizro.figures import kpi_card, kpi_card_reference

df = px.data.iris()
df["mean_petal_width"] = df.petal_width.mean()
df["mean_sepal_length"] = df.sepal_length.mean()
df["mean_sepal_width"] = df.sepal_width.mean()

page = vm.Page(
    title="Vizro on PyCafe",
    layout = vm.Layout(grid = [
        [0,0,0,0,1,2,3],
        [4,4,8,8,8,8,8],
        [5,5,8,8,8,8,8],
        [6,6,9,9,9,9,9],
        [7,7,9,9,9,9,9]
        ]),
    components=[
        vm.Card(text = """
        ### What is Vizro?

        Vizro is a toolkit for creating modular data visualization applications.

        Rapidly self-serve the assembly of customized dashboards in minutes - without the need for advanced coding or design experience - to create flexible and scalable, Python-enabled data visualization applications.

        """
        ),
        vm.Card(
                text="""
                ### Github

                Checkout Vizro's github page for further information and release notes. Contributions are always welcome!
            """,
            href = "https://github.com/mckinsey/vizro"
            ),
        vm.Card(
                text="""
                ### Docs

                Visit the documentation for codes examples, tutorials and API reference.
            """,
            href = "https://vizro.readthedocs.io/"
            ),
        vm.Card(
                text="""
                ### Gallery

                Head to Vizro's Gallery to see some beautiful dashboards for inspiration.
            """,
            href = "https://huggingface.co/vizro"
            ),
        vm.Figure(
            figure=kpi_card(
                data_frame=df,
                value_column="species",
                agg_func = "count",
                title="Number of samples",
                icon="local_florist",
                ),
            ),
        vm.Figure(
            figure=kpi_card_reference(
                data_frame=df,
                value_column="petal_width",
                reference_column="mean_petal_width",
                agg_func="mean",
                title="Mean petal width",
                icon="grid_goldenratio",
                value_format="{value:.2f} cm",
                reference_format = "{delta:.2f} cm vs. overall ({reference:.2f} cm)"
                ),
            ),
        vm.Figure(
            figure=kpi_card_reference(
                data_frame=df,
                value_column="sepal_length",
                reference_column="mean_sepal_length",
                agg_func="mean",
                title="Mean sepal length",
                icon="grid_goldenratio",
                value_format="{value:.2f} cm",
                reference_format = "{delta:.2f} cm vs. overall ({reference:.2f} cm)"
                ),
            ),
        vm.Figure(
            figure=kpi_card_reference(
                data_frame=df,
                value_column="sepal_width",
                reference_column="mean_sepal_width",
                agg_func="mean",
                title="Mean sepal width",
                icon="grid_goldenratio",
                value_format="{value:.2f} cm",
                reference_format = "{delta:.2f} cm vs. overall ({reference:.2f} cm)"
                ),
            ),
        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"])),
        vm.Filter(column="petal_length"),
        vm.Filter(column="sepal_width")
    ],
)

dashboard = vm.Dashboard(pages=[page])

Vizro().build(dashboard).run()