Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Add py.cafe to the docs examples #569

Merged
merged 86 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
868e7d1
First docs proposal
maxschulz-COL Jul 5, 2024
d89c274
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2024
4d70c90
Merge branch 'main' into docs/pycafe_embedding
maxschulz-COL Jul 22, 2024
749e66b
Try out the new mkdocs plugin
maxschulz-COL Jul 30, 2024
9578ebd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 30, 2024
5dee5cc
Merge branch 'main' into docs/pycafe_embedding
maxschulz-COL Aug 1, 2024
1438caf
Update first tutorial
stichbury Aug 6, 2024
4d3bf78
Add py.cafe logo
stichbury Aug 6, 2024
d6429a1
Swap ordering of onboarding pages
stichbury Aug 7, 2024
95a8167
Update first-dashboard.md
stichbury Aug 7, 2024
baacd96
Update install.md
stichbury Aug 7, 2024
bf7c22c
Linting
stichbury Aug 7, 2024
49a00f5
Update explore-components.md
stichbury Aug 7, 2024
238dfc3
Merge branch 'main' into docs/pycafe_embedding
stichbury Aug 7, 2024
5ec800c
Update index.md
stichbury Aug 7, 2024
032e1ec
Merge branch 'docs/pycafe_embedding' of https://github.com/mckinsey/v…
stichbury Aug 7, 2024
4cec06e
Update first-dashboard.md
stichbury Aug 7, 2024
9242846
Vale
stichbury Aug 7, 2024
5427de0
Fundamentals section
stichbury Aug 7, 2024
4d7db62
Vale
stichbury Aug 7, 2024
cd77c4a
Update figure.md
stichbury Aug 7, 2024
4e366c0
Update graph.md
stichbury Aug 7, 2024
d7f15e0
Update table.md
stichbury Aug 7, 2024
cf75356
Update figure.md
stichbury Aug 7, 2024
f39f722
Update card-button.md
stichbury Aug 7, 2024
26cdd61
Update container.md
stichbury Aug 7, 2024
28bd661
Update tabs.md
stichbury Aug 7, 2024
865065c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 7, 2024
77230b3
Update filters.md
stichbury Aug 7, 2024
bec9057
Merge branch 'docs/pycafe_embedding' of https://github.com/mckinsey/v…
stichbury Aug 7, 2024
f485422
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 7, 2024
0307b2a
Update parameters.md
stichbury Aug 7, 2024
ddb3dd2
Update selectors.md
stichbury Aug 7, 2024
2678299
Merge branch 'docs/pycafe_embedding' of https://github.com/mckinsey/v…
stichbury Aug 7, 2024
65b0a23
Update navigation.md
stichbury Aug 7, 2024
d8cd089
Update layouts.md
stichbury Aug 7, 2024
60908e3
Update themes.md
stichbury Aug 7, 2024
7c7f707
Update actions.md
stichbury Aug 7, 2024
a476769
Update custom-charts.md
stichbury Aug 7, 2024
a56f72d
Update custom-tables.md
stichbury Aug 7, 2024
6f74941
Update custom-components.md
stichbury Aug 7, 2024
2966fd6
Update custom-actions.md
stichbury Aug 7, 2024
73c63e6
Update custom-figures.md
stichbury Aug 7, 2024
a9218ab
Update explore-components.md
stichbury Aug 8, 2024
786167c
Add SVGs
stichbury Aug 12, 2024
d24a6f0
Update explore-components.md
stichbury Aug 12, 2024
64833f1
Updates to card button graphics and projects
stichbury Aug 12, 2024
ac90812
Convert links to HTML so open in new tab with image
stichbury Aug 12, 2024
13edb77
Update figure.md
stichbury Aug 12, 2024
f18199e
Add openpyxl as extra requirement
stichbury Aug 12, 2024
a719191
Revise locations of github-hosted graphics for py.cafe
stichbury Aug 12, 2024
ab9d720
Store graphics for carousel
stichbury Aug 12, 2024
5b97a3d
Update carousel example
stichbury Aug 12, 2024
740f855
Update assets.md
stichbury Aug 12, 2024
6b04506
Lint
stichbury Aug 12, 2024
6fdb521
Update data.md
stichbury Aug 12, 2024
5465692
Update data.md
stichbury Aug 12, 2024
5fb5368
Merge branch 'main' into docs/pycafe_embedding
stichbury Aug 12, 2024
935b58c
Update custom-figures.md
stichbury Aug 13, 2024
ff72918
Update page_sunburst.png
stichbury Aug 13, 2024
da1bd68
Update navigation.md
stichbury Aug 13, 2024
0d987c5
Merge branch 'main' into docs/pycafe_embedding
stichbury Aug 13, 2024
498f30f
Update custom-components.md
stichbury Aug 13, 2024
5ce3ecf
Merge branch 'docs/pycafe_embedding' of https://github.com/mckinsey/v…
stichbury Aug 13, 2024
1eee7bb
Delete pycafe_logo.png
stichbury Aug 14, 2024
3dfefe1
Update vizro-core/docs/pages/tutorials/explore-components.md
stichbury Aug 14, 2024
5de548d
Update vizro-core/docs/pages/tutorials/explore-components.md
stichbury Aug 14, 2024
7a69eb2
Example of using code block specifications with py.cafe plugin
maxschulz-COL Aug 14, 2024
e63e383
Update to image placement example
stichbury Aug 14, 2024
0657e6a
Merge branch 'docs/pycafe_embedding' of https://github.com/mckinsey/v…
stichbury Aug 14, 2024
40764c7
Update custom-components.md
stichbury Aug 14, 2024
a749572
Add simple footnotes to code as comments
stichbury Aug 14, 2024
7000a3e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 14, 2024
922455a
Update data.md
stichbury Aug 14, 2024
5ffa875
Update data.md
stichbury Aug 14, 2024
1acab8c
Merge branch 'docs/pycafe_embedding' of https://github.com/mckinsey/v…
stichbury Aug 14, 2024
a8e9bc6
Update vizro-core/docs/pages/user-guides/themes.md
stichbury Aug 14, 2024
e796c7c
Update vizro-core/docs/pages/user-guides/themes.md
stichbury Aug 14, 2024
757b7a7
Update hatch.toml
stichbury Aug 14, 2024
6fb44a8
Pull new change
maxschulz-COL Aug 14, 2024
7a8f05a
Update vizro-core/docs/pages/user-guides/card-button.md
stichbury Aug 14, 2024
a81215a
Update container.md
stichbury Aug 14, 2024
724320a
Merge branch 'docs/pycafe_embedding' of https://github.com/mckinsey/v…
stichbury Aug 14, 2024
f0e4c93
Update explore-components.md
stichbury Aug 14, 2024
3507614
Update vizro-core/hatch.toml
stichbury Aug 14, 2024
3df2956
Update profile for examples
stichbury Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vale/styles/Microsoft/Headings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ exceptions:
- Pandas
- Plotly
- Pydantic
- Py.Cafe
- Python
- QuantumBlack
- QuantumBlack Labs
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨

- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Removed

- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Added

- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Changed

- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Deprecated

- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Fixed

- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Security

- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
3 changes: 3 additions & 0 deletions vizro-core/docs/assets/tutorials/collections.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions vizro-core/docs/assets/tutorials/features.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions vizro-core/docs/assets/user_guides/components/africa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vizro-core/docs/assets/user_guides/pages/page_sunburst.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions vizro-core/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ Vizro is a toolkit for creating modular data visualization applications.

---

[:octicons-arrow-right-24: Install Vizro](pages/user-guides/install.md) </br>
[:octicons-arrow-right-24: Quickstart tutorial](pages/tutorials/first-dashboard.md)
[:octicons-arrow-right-24: Quickstart tutorial](pages/tutorials/first-dashboard.md) </br>
[:octicons-arrow-right-24: Install Vizro](pages/user-guides/install.md)




Expand Down
52 changes: 24 additions & 28 deletions vizro-core/docs/pages/tutorials/explore-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ In this tutorial, we walk through the process of creating a sophisticated dashbo

If you haven't yet done so, you may want to review the [first dashboard tutorial](../tutorials/first-dashboard.md) before starting on this one.

## 1. Install Vizro and get ready to run your code
## 1. (Optional) Install Vizro and get ready to run your code

To get started with this tutorial, make sure you have [installed Vizro](../user-guides/install.md), and can run the dashboard code within a Jupyter Notebook cell or from a Python script.
The code for this tutorial is all available for you to experiment with in [Py.Cafe](https://py.cafe/) so there is no need to install Vizro and run it locally.

However, if you prefer working in a Notebook or Python script, you should [install Vizro](../user-guides/install.md).

## 2. Create a first dashboard page

Expand All @@ -23,9 +25,10 @@ The code below shows the steps necessary to add a box plot to the page:
1. Add a Vizro [`Graph`][vizro.models.Graph] to the `components` list.
2. Add a [`plotly.express.box`](https://plotly.com/python-api-reference/generated/plotly.express.box.html#plotly.express.box) figure to the list of components.


!!! example "First component"
=== "app.py"
```py
```{.python pycafe-link}
from vizro import Vizro
import vizro.models as vm
import vizro.plotly.express as px
Expand All @@ -40,7 +43,6 @@ The code below shows the steps necessary to add a box plot to the page:
title="First Page",
components=[
vm.Graph(
id="box_cont",
figure=px.box(gapminder_data, x="continent", y="lifeExp", color="continent",
labels={"lifeExp": "Life Expectancy", "continent": "Continent"}),
),
Expand All @@ -50,12 +52,11 @@ The code below shows the steps necessary to add a box plot to the page:
dashboard = vm.Dashboard(pages=[first_page])
Vizro().build(dashboard).run()
```
=== "Result"
[![FirstPage1]][FirstPage1]
=== "Screenshot"
![Dashboard](https://py.cafe/preview/maxi.schulz/vizro-tutorial-explore-vizro-1)
huong-li-nguyen marked this conversation as resolved.
Show resolved Hide resolved

[FirstPage1]: ../../assets/tutorials/dashboard/dashboard21.png

!!! note "To see the dashboard in action"
??? note "To run the dashboard in a Notebook or script"

Paste the above code into a Notebook cell, run the Notebook, and evaluate it.

Expand All @@ -69,7 +70,7 @@ The code below shows the steps necessary to add a box plot to the page:

Once the script is running, open your web browser and go to `localhost:8050`. You should see the dashboard page with the gapminder data displayed, as shown in the `Result` tab above.

As you can see from the code, the `first_page` is added to the [`Dashboard`][vizro.models.Dashboard] before building and running it with `Vizro().build(dashboard).run()`. Every [`Page`][vizro.models.Page] that you want to display needs to be added to the [`Dashboard`][vizro.models.Dashboard] object.
As you can see from the code, `first_page` is added to the [`Dashboard`][vizro.models.Dashboard] and the dashboard is displayed by running `Vizro().build(dashboard).run()`.

### 2.2. Add further components

Expand Down Expand Up @@ -107,9 +108,8 @@ The code below adds two components to the page:
"gdpPercap":"GDP Per Cap"}, title=''),
)
```

=== "app.py"
```py
```{.python pycafe-link}
from vizro import Vizro
import vizro.models as vm
import vizro.plotly.express as px
Expand All @@ -131,12 +131,10 @@ The code below adds two components to the page:
""",
),
vm.Graph(
id="box_cont",
figure=px.box(gapminder_data, x="continent", y="lifeExp", color="continent",
labels={"lifeExp": "Life Expectancy", "continent": "Continent"}),
),
vm.Graph(
id="line_gdp",
figure=px.line(gapminder_data, x="year", y="gdpPercap", color="continent",
labels={"year": "Year", "continent": "Continent",
"gdpPercap":"GDP Per Cap"}, title=''),
Expand All @@ -153,15 +151,14 @@ The code below adds two components to the page:

[FirstPage2]: ../../assets/tutorials/dashboard/dashboard22.png

As you explore the dashboard, you may notice that the current layout could be further enhanced. The charts may appear cramped, while the text component has ample unused space. The next section explains how to configure the layout and arrange the components.
As you explore the dashboard, you may notice that the current layout could be further enhanced. The charts appear cramped, while the text component has ample unused space. The next section explains how to configure the layout and arrange the components.

!!! note "An introduction to Vizro-AI"

In the example above, the code to create the line graph was generated using [Vizro-AI](https://vizro.readthedocs.io/en/latest/pages/tutorials/first-dashboard/). Vizro-AI enables you to use English, or other languages, to create interactive charts with [Plotly](https://plotly.com/python/) by simplifying the process through use of a large language model. In essence, Vizro-AI generates code from natural language instructions so that you can add it into a Vizro dashboard, such as in the example above.

Find out more in the [Vizro-AI documentation](https://vizro.readthedocs.io/projects/vizro-ai/)!


### 2.3. Configure the layout

By default, Vizro places each element in the order it was added to `components` list, and spaces them equally.
Expand Down Expand Up @@ -202,9 +199,8 @@ Run the code below to apply the layout to the dashboard page:
```py
layout=vm.Layout(grid=[[0, 0], [1, 2], [1, 2], [1, 2]])
```

=== "app.py"
```py
```{.python pycafe-link}
from vizro import Vizro
import vizro.models as vm
import vizro.plotly.express as px
Expand All @@ -227,12 +223,10 @@ Run the code below to apply the layout to the dashboard page:
""",
),
vm.Graph(
id="box_cont",
figure=px.box(gapminder_data, x="continent", y="lifeExp", color="continent",
labels={"lifeExp": "Life Expectancy", "continent": "Continent"}),
),
vm.Graph(
id="line_gdp",
figure=px.line(gapminder_data, x="year", y="gdpPercap", color="continent",
labels={"year": "Year", "continent": "Continent",
"gdpPercap":"GDP Per Cap"}),
Expand Down Expand Up @@ -262,7 +256,7 @@ There are two types of control:

The guides on [`How to use Filters`](../user-guides/filters.md) and [`How to use Parameters`](../user-guides/parameters.md) offer instructions on their application. For further customization, refer to the guide on [`How to use selectors`](../user-guides/selectors.md).

To link a control to a component, use the id assigned to the component, which is unique across all dashboard pages and serves as a reference to target it.
To link a control to a component, use an `id` assigned to the component, which is unique across all dashboard pages and serves as a reference to target it.

To illustrate, let's add a [`Filter`][vizro.models.Filter] on specific
continents of the underlying gapminder data. The [`Filter`][vizro.models.Filter] requires the `column` argument, that denotes
Expand All @@ -278,7 +272,7 @@ are listed in the `targets` parameter, meaning that the filter is be applied to
]
```
=== "app.py"
```py
```{.python pycafe-link}
from vizro import Vizro
import vizro.models as vm
import vizro.plotly.express as px
Expand Down Expand Up @@ -320,6 +314,7 @@ are listed in the `targets` parameter, meaning that the filter is be applied to
dashboard = vm.Dashboard(pages=[first_page])
Vizro().build(dashboard).run()
```

=== "Result"
[![FirstPage4]][FirstPage4]

Expand All @@ -336,7 +331,7 @@ Fantastic job! You have completed first dashboard page and gained valuable skill

This section adds a second dashboard page and explains how to use controls and selectors. The new page is structured similarly to the page you created, but contains two charts that visualize the [iris data](https://plotly.com/python-api-reference/generated/plotly.express.data.html#plotly.express.data.iris).

The code below illustrates how to add the page, titled `second_page` to the dashboard by calling `vm.Dashboard(pages=[first_page,second_page])`. There are two `Graph` objects added to the list of components. To enable interactivity on those components, we add two [`Parameters`][vizro.models.Parameter] to the list of `controls`.
Every [`Page`][vizro.models.Page] that you want to display needs to be added to the [`Dashboard`][vizro.models.Dashboard] object. The code below illustrates how to add the page, titled `second_page` to the dashboard by calling `vm.Dashboard(pages=[first_page,second_page])`. There are two `Graph` objects added to the list of components. To enable interactivity on those components, we add two [`Parameters`][vizro.models.Parameter] to the list of `controls`.

In creating a [`Parameter`][vizro.models.Parameter] object, you define the `target` it applies to. In the code below:

Expand Down Expand Up @@ -390,7 +385,7 @@ for parameters](../user-guides/parameters.md).
)
```
=== "app.py"
```py
```{.python pycafe-link}
from vizro import Vizro
import vizro.models as vm
import vizro.plotly.express as px
Expand Down Expand Up @@ -518,7 +513,7 @@ of the subpages. Additionally, you can use the navigation panel on the left side
components=[
vm.Card(
text="""
![](assets/images/icons/content/collections.svg#icon-top)
![](https://raw.githubusercontent.com/mckinsey/vizro/786167c822cce65fe85ffad8ed000d8553a5ef44/vizro-core/docs/assets/images/collections.svg#icon-top)
stichbury marked this conversation as resolved.
Show resolved Hide resolved

### First Page

Expand All @@ -528,7 +523,7 @@ of the subpages. Additionally, you can use the navigation panel on the left side
),
vm.Card(
text="""
![](assets/images/icons/content/features.svg#icon-top)
![](https://raw.githubusercontent.com/mckinsey/vizro/786167c822cce65fe85ffad8ed000d8553a5ef44/vizro-core/docs/assets/images/features.svg#icon-top)
stichbury marked this conversation as resolved.
Show resolved Hide resolved

### Second Page

Expand All @@ -543,7 +538,8 @@ of the subpages. Additionally, you can use the navigation panel on the left side
dashboard = vm.Dashboard(pages=[home_page, first_page, second_page])
```
=== "app.py"
```py
```{.python pycafe-link}

from vizro import Vizro
import vizro.models as vm
import vizro.plotly.express as px
Expand All @@ -553,7 +549,7 @@ of the subpages. Additionally, you can use the navigation panel on the left side
components=[
vm.Card(
text="""
![](assets/images/icons/content/collections.svg#icon-top)
![](https://raw.githubusercontent.com/mckinsey/vizro/786167c822cce65fe85ffad8ed000d8553a5ef44/vizro-core/docs/assets/images/collections.svg)

### First Page

Expand All @@ -563,7 +559,7 @@ of the subpages. Additionally, you can use the navigation panel on the left side
),
vm.Card(
text="""
![](assets/images/icons/content/features.svg#icon-top)
![](https://raw.githubusercontent.com/mckinsey/vizro/786167c822cce65fe85ffad8ed000d8553a5ef44/vizro-core/docs/assets/images/features.svg#icon-top)

### Second Page

Expand Down
Loading
Loading