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 documentation and examples for Figure #524

Merged
merged 123 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
fb37101
Add KPI Card based on Plotly indicator
huong-li-nguyen May 21, 2024
9428969
Add KPI Card based on custom component
huong-li-nguyen May 21, 2024
c2c3710
Refine and leave some comments
huong-li-nguyen May 21, 2024
dbba0dd
Get dynamic Card working quickly
huong-li-nguyen May 21, 2024
a3ca6f6
Add logic to enable `text_card` and `nav_card`
huong-li-nguyen May 22, 2024
521954a
Tidy
huong-li-nguyen May 22, 2024
1081cd2
Lint
huong-li-nguyen May 22, 2024
4ceeed8
Add partially styled KPI
huong-li-nguyen May 22, 2024
1ca2be2
Simplify dynamic styled card
huong-li-nguyen May 22, 2024
bba9e01
Tidy
huong-li-nguyen May 22, 2024
e1a2858
Add styling to mkd card
huong-li-nguyen May 22, 2024
8309d9f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 22, 2024
7edfec2
Add another KPI style
huong-li-nguyen May 22, 2024
c65678e
Merge branch 'feat/create_kpi_cards' of https://github.com/mckinsey/v…
huong-li-nguyen May 22, 2024
798d8ef
Lint
huong-li-nguyen May 22, 2024
c01a3db
Add comments
huong-li-nguyen May 23, 2024
6062063
Tidy CSS
huong-li-nguyen May 23, 2024
67d41aa
Make sample page with 3 pre-selected designs
huong-li-nguyen May 23, 2024
6eedfe7
Move `dbc.Card` to `build` and remove id provision
huong-li-nguyen May 30, 2024
f3b1d6a
Refactor classNames for `kpi_card_icon`
huong-li-nguyen May 30, 2024
feaf493
Refactor simple and icon KPI card to one
huong-li-nguyen May 30, 2024
466b252
Refactor classNames for `kpi_card_ref`
huong-li-nguyen May 30, 2024
35f64aa
Refactor and tidy some more
huong-li-nguyen May 30, 2024
284f2ba
Add formatting arguments to function for discussion
huong-li-nguyen May 30, 2024
eb2c9c6
Enable coloring of higher-level card
huong-li-nguyen May 30, 2024
456eb29
Improve naming
huong-li-nguyen May 30, 2024
3f87ac9
Remove remaining `kpi-card-icon` reference
huong-li-nguyen May 30, 2024
67321aa
Tidy app
huong-li-nguyen May 30, 2024
3aab16b
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen May 30, 2024
289ada3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 30, 2024
9f37512
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen Jun 4, 2024
1c7eb6e
Update docstrings
huong-li-nguyen Jun 4, 2024
1554541
Return `dbc.Card` inside `CapturedCallable`
huong-li-nguyen Jun 5, 2024
98b8c1e
Replace `kpi_card` with suggested improvement
huong-li-nguyen Jun 5, 2024
26ce1be
Replace `kpi_card_ref` with suggested
huong-li-nguyen Jun 5, 2024
3ef65f2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 5, 2024
a1b1228
Remove redundant code from previous iterations
huong-li-nguyen Jun 5, 2024
4309315
Lint
huong-li-nguyen Jun 5, 2024
90dfcb3
Merge branch 'feat/create_kpi_cards' of https://github.com/mckinsey/v…
huong-li-nguyen Jun 5, 2024
faabc46
Commit this
huong-li-nguyen Jun 5, 2024
6bf46d5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 5, 2024
b005f51
Revert changes in card
huong-li-nguyen Jun 5, 2024
e964bb6
Create higher-level `Figure` model
huong-li-nguyen Jun 5, 2024
5c31faf
Merge branch 'feat/create_kpi_cards' of https://github.com/mckinsey/v…
huong-li-nguyen Jun 5, 2024
7161d15
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 5, 2024
2a92af6
Revert unwanted changes
huong-li-nguyen Jun 5, 2024
ae3e57b
Tidy
huong-li-nguyen Jun 5, 2024
d0bce82
Fix renaming
huong-li-nguyen Jun 5, 2024
ac56dba
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen Jun 5, 2024
b6515ff
Tidy CSS
huong-li-nguyen Jun 5, 2024
bed23b4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 5, 2024
4c6969f
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen Jun 6, 2024
acccea1
Add docstrings to kpi card functions
huong-li-nguyen Jun 6, 2024
a344db5
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen Jun 6, 2024
72343be
Implement reverse-color coding via CSS
huong-li-nguyen Jun 7, 2024
c5c7368
Update schema
huong-li-nguyen Jun 7, 2024
8062991
Add changelog
huong-li-nguyen Jun 7, 2024
fda4a5e
Add ignore for custom format warning
huong-li-nguyen Jun 7, 2024
de649ee
Tidy redundant TODOs
huong-li-nguyen Jun 7, 2024
ec4a45b
Add unit tests for `Figure`
huong-li-nguyen Jun 7, 2024
95ebf91
Add empty doc file for now
huong-li-nguyen Jun 7, 2024
6f5b33d
Revert changes in `vizro-ai`
huong-li-nguyen Jun 7, 2024
4c71bdc
Add relevant updates in docs
huong-li-nguyen Jun 7, 2024
104b99c
Fix doc warning for now
huong-li-nguyen Jun 7, 2024
9d53cbb
Update schema
huong-li-nguyen Jun 7, 2024
f0d0304
Update components.md
stichbury Jun 7, 2024
8883285
Change icon and apply lowercase
huong-li-nguyen Jun 7, 2024
0e5fa7d
Merge branch 'feat/create_kpi_cards' of https://github.com/mckinsey/v…
huong-li-nguyen Jun 7, 2024
f07e7d1
Incorporate PR comments
huong-li-nguyen Jun 11, 2024
7be53bb
Update docs
huong-li-nguyen Jun 11, 2024
09ceea1
Fix height due to added container
huong-li-nguyen Jun 11, 2024
1f0a730
Merge branch 'feat/create_kpi_cards' into docs/add-figure-kpi-card
huong-li-nguyen Jun 11, 2024
5fbfe84
Replace output with function call
huong-li-nguyen Jun 12, 2024
db8ac58
Add constants for defaults and tidy html divs
huong-li-nguyen Jun 12, 2024
41c4ca5
Handle ZeroDivisonError
huong-li-nguyen Jun 12, 2024
782127c
Simplify docstrings for `getitem` and remove TODO
huong-li-nguyen Jun 12, 2024
cea7a61
Add more context to docstrings of kpi card functions
huong-li-nguyen Jun 12, 2024
8363adc
Update API reference
huong-li-nguyen Jun 13, 2024
1006868
Tidy example
huong-li-nguyen Jun 13, 2024
be6e433
Update yaml example
huong-li-nguyen Jun 13, 2024
0e125e1
Tidy df name
huong-li-nguyen Jun 13, 2024
c35947c
Extend features demo dashboard
huong-li-nguyen Jun 13, 2024
3540e9c
Lint
huong-li-nguyen Jun 13, 2024
e2b6d66
Merge branch 'feat/create_kpi_cards' into docs/add-figure
huong-li-nguyen Jun 13, 2024
36c6a4f
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen Jun 17, 2024
ebad116
Merge branch 'feat/create_kpi_cards' into docs/add-figure
huong-li-nguyen Jun 17, 2024
68cf51e
Change container className
huong-li-nguyen Jun 17, 2024
6dc5e92
Add initial code for custom Figure
huong-li-nguyen Jun 17, 2024
37f128b
Merge branch 'feat/create_kpi_cards' into docs/add-figure
huong-li-nguyen Jun 17, 2024
a9088b8
Update docs for custom figure
huong-li-nguyen Jun 17, 2024
9ccf546
Update feature examples dashboard
huong-li-nguyen Jun 17, 2024
03d7c56
Fix CSS
huong-li-nguyen Jun 17, 2024
72eb082
Update changelog for docs
huong-li-nguyen Jun 17, 2024
23831a2
Remove link for now so CI can pass
huong-li-nguyen Jun 17, 2024
cbdbf68
Add link back
huong-li-nguyen Jun 17, 2024
769a314
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen Jun 18, 2024
ee606f8
Incorporate last PR comments
huong-li-nguyen Jun 18, 2024
e89ef26
Merge branch 'feat/create_kpi_cards' into docs/add-figure
huong-li-nguyen Jun 18, 2024
0525dd0
Incorporate PR comments J.
huong-li-nguyen Jun 18, 2024
d7b8051
Update figure.md
huong-li-nguyen Jun 18, 2024
ea5cf95
Ignore links to our built docs
antonymilne Jun 18, 2024
9b181e7
Merge branch 'main' into docs/add-figure
huong-li-nguyen Jun 18, 2024
54bc3fe
Lint
huong-li-nguyen Jun 18, 2024
2e25be6
Merge branch 'main' into docs/add-figure
huong-li-nguyen Jun 19, 2024
08437cc
Incorporate PR comments
huong-li-nguyen Jun 19, 2024
00c56cd
Merge branch 'main' into docs/add-figure
huong-li-nguyen Jun 19, 2024
0dfe6a7
Update vizro-core/docs/pages/user-guides/figure.md
huong-li-nguyen Jun 19, 2024
b670923
Update vizro-core/docs/pages/user-guides/figure.md
huong-li-nguyen Jun 19, 2024
1f9f753
Fix typing in multiple-cards example
huong-li-nguyen Jun 19, 2024
11c96f3
Merge branch 'docs/add-figure' of https://github.com/mckinsey/vizro i…
huong-li-nguyen Jun 19, 2024
86da3da
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 19, 2024
8f2371a
Merge branch 'main' into docs/add-figure
huong-li-nguyen Jun 20, 2024
e59ff43
Update `multiple_cards` example
huong-li-nguyen Jun 20, 2024
db28498
Update examples
huong-li-nguyen Jun 20, 2024
659da68
Consolidate instructions across custom components
huong-li-nguyen Jun 20, 2024
ee38bd3
Update images
huong-li-nguyen Jun 20, 2024
20eaf72
Lint
huong-li-nguyen Jun 20, 2024
1fc39ff
Tidy and consolidate
huong-li-nguyen Jun 20, 2024
eaeb2a8
Add example for dynamic html div
huong-li-nguyen Jun 20, 2024
416edce
Delete 20240618_130047_huong_li_nguyen_add_figure.md
huong-li-nguyen Jun 20, 2024
1a47fd4
Last PR comments
huong-li-nguyen Jun 20, 2024
024b276
Fix non-working link
huong-li-nguyen Jun 20, 2024
4d1065a
Fix link
huong-li-nguyen Jun 20, 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
48 changes: 0 additions & 48 deletions vizro-ai/changelog.d/20240618_130047_huong_li_nguyen_add_figure.md

This file was deleted.

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.
19 changes: 10 additions & 9 deletions vizro-core/docs/pages/user-guides/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,40 @@ listed below to fill your dashboard with visuals.

<div class="grid cards" markdown>

- :octicons-graph-16:{ .lg .middle } __Graph__
- :octicons-graph-16:{ .lg .middle } __Graphs__

---

Use graphs to visualize your data with any Plotly chart.

[:octicons-arrow-right-24: View user guide](graph.md)

- :material-table-large:{ .lg .middle } __Table__
- :material-table-large:{ .lg .middle } __Tables__

---

Use tables to visualize your tabular data.

[:octicons-arrow-right-24: View user guide](table.md)

- :material-cards-outline:{ .lg .middle } __Card & button__
- :material-graph:{ .lg .middle } __Figures__

---

Use cards and buttons to visualize text, navigate to different URLs or attach any [action](actions.md).
Use figures to make any [Dash component](https://dash.plotly.com/#open-source-component-libraries) reactive.

[:octicons-arrow-right-24: View user guide](card-button.md)
[:octicons-arrow-right-24: View user guide](figure.md)

- :material-graph:{ .lg .middle } __Figure__
- :material-cards-outline:{ .lg .middle } __Cards & buttons__

---

Use figure to visualize your make any Dash component reactive.
Use cards and buttons to visualize text, navigate to different URLs or attach any [action](actions.md).

[:octicons-arrow-right-24: View user guide](card-button.md)

[:octicons-arrow-right-24: View user guide](figure.md)

- :octicons-table-16:{ .lg .middle } __Container__
- :octicons-table-16:{ .lg .middle } __Containers__

---

Expand Down
24 changes: 12 additions & 12 deletions vizro-core/docs/pages/user-guides/custom-charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
This guide shows you how to create custom charts and how to add them to your dashboard.
The [`Graph`][vizro.models.Graph] model accepts the `figure` argument, where you can enter _any_ [`plotly.express`](https://plotly.com/python/plotly-express/) chart as explained in the [user guide on graphs](graph.md).

## Overview of custom charts

In general, the usage of the custom chart decorator `@capture("graph")` is required if your plotly chart requires any post-update calls or customization.

### When to use a custom chart
In general, the usage of the custom chart decorator `@capture("graph")` is required if your plotly chart requires any post-update calls or customization e.g:
huong-li-nguyen marked this conversation as resolved.
Show resolved Hide resolved

- If you want to use any of the post figure update calls by `plotly` such as `update_layout`, `update_xaxes`, `update_traces` (for more details, see the docs on [plotly's update calls](https://plotly.com/python/creating-and-updating-figures/#other-update-methods))
- If you want to use a custom-created [`plotly.graph_objects.Figure()`](https://plotly.com/python/graph-objects/) object (in short, `go.Figure()`) and add traces yourself via [`add_trace`](https://plotly.com/python/creating-and-updating-figures/#adding-traces)
- You want to use any of the post figure update calls by `plotly` such as `update_layout`, `update_xaxes`, `update_traces` (for more details, see the docs on [plotly's update calls](https://plotly.com/python/creating-and-updating-figures/#other-update-methods))
- You want to use a custom-created [`plotly.graph_objects.Figure()`](https://plotly.com/python/graph-objects/) object (in short, `go.Figure()`) and add traces yourself via [`add_trace`](https://plotly.com/python/creating-and-updating-figures/#adding-traces)

### Requirements of a custom chart function
### Steps to create a custom chart

- a `go.Figure()` object is returned by the function
- the function must be decorated with the `@capture("graph")` decorator
- the function accepts a `data_frame` argument (of type `pandas.DataFrame`)
- the visualization is derived from and requires only one `pandas.DataFrame` (for example, any further dataframes added through other arguments will not react to dashboard components such as `Filter`)
1. Define a function that returns a `go.Figure()`.
2. Decorate it with `@capture("graph")`.
3. The function must accept a `data_frame` argument (of type `pandas.DataFrame`).
4. The visualization should be derived from and require only one `pandas.DataFrame`. Dataframes from other arguments
will not react to dashboard controls such as [`Filter`](filters.md).

The below minimal example can be used as a base to build more sophisticated charts.
The below minimal example can be used as a base to build more sophisticated charts._
huong-li-nguyen marked this conversation as resolved.
Show resolved Hide resolved

```py title="Minimal example of a custom chart"
from vizro.models.types import capture
import pandas as pd
import plotly.graph_objects as go

@capture("graph")
def minimal_example(data_frame:pd.DataFrame=None):
Expand Down
2 changes: 1 addition & 1 deletion vizro-core/docs/pages/user-guides/custom-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In general, you can create a custom component based on any dash-compatible compo


All our components are based on `Dash`, and they are shipped with a set of sensible defaults that can be modified. If you would like to overwrite one of those defaults,
or if you would like to use extra `args` or `kwargs` of those components, then this is the correct way to include those. You can use any existing attribute of any underlying Dash component with this method.
or if you would like to use extra `args` or `kwargs` of those components, then this is the correct way to include those. You can use any existing attribute of any underlying [Dash component](https://dash.plotly.com/#open-source-component-libraries) with this method.

!!!note

Expand Down
Loading
Loading