diff --git a/vizro-core/docs/pages/API-reference/figure-callables.md b/vizro-core/docs/pages/API-reference/figure-callables.md index ada2b5d95..59bcf2651 100644 --- a/vizro-core/docs/pages/API-reference/figure-callables.md +++ b/vizro-core/docs/pages/API-reference/figure-callables.md @@ -3,6 +3,11 @@ API reference for all pre-defined [`CapturedCallable`][vizro.models.types.CapturedCallable] figure functions to be used in the [`Figure`][vizro.models.Figure]. The [how-to guide on figures](../user-guides/figure.md) contains more information. +Identical functions can also be used outside the Vizro framework in a pure Dash app by importing from the `vizro.figures.library` namespace: +```python +from vizro.figures.library import kpi_card, kpi_card_reference +``` + ::: vizro.figures options: show_source: true diff --git a/vizro-core/examples/scratch_dev/app.py b/vizro-core/examples/scratch_dev/app.py index bc783e89a..1547b90ab 100644 --- a/vizro-core/examples/scratch_dev/app.py +++ b/vizro-core/examples/scratch_dev/app.py @@ -3,14 +3,13 @@ import dash_bootstrap_components as dbc import pandas as pd from dash import Dash, html -from vizro.figures.unwrapped import kpi_card, kpi_card_reference +from vizro.figures.library import kpi_card, kpi_card_reference df_kpi = pd.DataFrame({"Actual": [100, 200, 700], "Reference": [100, 300, 500], "Category": ["A", "B", "C"]}) # Add single CSS file figures.css or base = "https://cdn.jsdelivr.net/gh/mckinsey/vizro@tidy/create-module-pure-functions/vizro-core/src/vizro/static/css/" vizro_bootstrap = base + "vizro-bootstrap.min.css" -vizro_css = base + "figures.min.css" # Add entire assets folder from Vizro app = Dash( @@ -58,7 +57,7 @@ ), ], # Note: They need to add vizro_light here - # className="vizro_light", + className="vizro_light", ), ] ) diff --git a/vizro-core/src/vizro/figures/__init__.py b/vizro-core/src/vizro/figures/__init__.py index 4a3c18286..89406f312 100644 --- a/vizro-core/src/vizro/figures/__init__.py +++ b/vizro-core/src/vizro/figures/__init__.py @@ -1,4 +1,4 @@ -from vizro.figures.kpi_cards import kpi_card, kpi_card_reference +from vizro.figures._kpi_cards import kpi_card, kpi_card_reference # Please keep alphabetically ordered __all__ = ["kpi_card", "kpi_card_reference"] diff --git a/vizro-core/src/vizro/figures/kpi_cards.py b/vizro-core/src/vizro/figures/_kpi_cards.py similarity index 100% rename from vizro-core/src/vizro/figures/kpi_cards.py rename to vizro-core/src/vizro/figures/_kpi_cards.py diff --git a/vizro-core/src/vizro/figures/unwrapped/kpi_cards.py b/vizro-core/src/vizro/figures/library.py similarity index 69% rename from vizro-core/src/vizro/figures/unwrapped/kpi_cards.py rename to vizro-core/src/vizro/figures/library.py index 0d64b7815..95e7457f5 100644 --- a/vizro-core/src/vizro/figures/unwrapped/kpi_cards.py +++ b/vizro-core/src/vizro/figures/library.py @@ -4,3 +4,11 @@ kpi_card = kpi_card.__wrapped__ kpi_card_reference = kpi_card_reference.__wrapped__ + + +def f(a): + """Blah blahblah""" + pass + + +__all__ = ["kpi_card", "kpi_card_reference", "f"] diff --git a/vizro-core/src/vizro/figures/unwrapped/__init__.py b/vizro-core/src/vizro/figures/unwrapped/__init__.py deleted file mode 100644 index 5c07a6332..000000000 --- a/vizro-core/src/vizro/figures/unwrapped/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from vizro.figures.unwrapped.kpi_cards import kpi_card, kpi_card_reference - -# Please keep alphabetically ordered -__all__ = ["kpi_card", "kpi_card_reference"]