Spaces:
Running
Running
Last updates
Browse files- README.md +2 -2
- app.py +1 -1
- custom_charts.py +1 -1
- pages/_pages_utils.py +4 -0
- pages/examples/time_column.py +1 -1
README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
#
|
2 |
|
3 |
This dashboard shows a gallery of charts. It includes guidance on when to use each chart type and sample Python code
|
4 |
to create them using [Plotly](https://plotly.com/python/) and [Vizro](https://github.com/mckinsey/vizro).
|
@@ -98,6 +98,6 @@ To contribute a chart, follow the steps below:
|
|
98 |
|
99 |
## How to run the example locally
|
100 |
|
101 |
-
1. If you have `hatch` set up, run the example with the command `hatch run example
|
102 |
Otherwise, with a virtual Python environment activated, run `pip install -r requirements.txt` and then `python app.py`.
|
103 |
2. You should now be able to access the app locally via http://127.0.0.1:8050/.
|
|
|
1 |
+
# Vizro - Visual vocabulary
|
2 |
|
3 |
This dashboard shows a gallery of charts. It includes guidance on when to use each chart type and sample Python code
|
4 |
to create them using [Plotly](https://plotly.com/python/) and [Vizro](https://github.com/mckinsey/vizro).
|
|
|
98 |
|
99 |
## How to run the example locally
|
100 |
|
101 |
+
1. If you have `hatch` set up, run the example with the command `hatch run example _visual-vocabulary`.
|
102 |
Otherwise, with a virtual Python environment activated, run `pip install -r requirements.txt` and then `python app.py`.
|
103 |
2. You should now be able to access the app locally via http://127.0.0.1:8050/.
|
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
"""App configuration for
|
2 |
|
3 |
from typing import List, Union
|
4 |
|
|
|
1 |
+
"""App configuration for dashboard."""
|
2 |
|
3 |
from typing import List, Union
|
4 |
|
custom_charts.py
CHANGED
@@ -136,8 +136,8 @@ def categorical_column(data_frame: pd.DataFrame, x: str, y: str):
|
|
136 |
"""Creates a column chart where the x-axis values are converted to category type."""
|
137 |
fig = px.bar(
|
138 |
data_frame,
|
139 |
-
y=y,
|
140 |
x=x,
|
|
|
141 |
)
|
142 |
# So ticks are aligned with bars when xaxes values are numbers (e.g. years)
|
143 |
fig.update_xaxes(type="category")
|
|
|
136 |
"""Creates a column chart where the x-axis values are converted to category type."""
|
137 |
fig = px.bar(
|
138 |
data_frame,
|
|
|
139 |
x=x,
|
140 |
+
y=y,
|
141 |
)
|
142 |
# So ticks are aligned with bars when xaxes values are numbers (e.g. years)
|
143 |
fig.update_xaxes(type="category")
|
pages/_pages_utils.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
"""Contains reusable data sets and constants."""
|
2 |
|
|
|
3 |
from pathlib import Path
|
4 |
|
5 |
import black
|
@@ -7,6 +8,9 @@ import pandas as pd
|
|
7 |
import vizro.plotly.express as px
|
8 |
from custom_components import CodeClipboard
|
9 |
|
|
|
|
|
|
|
10 |
|
11 |
def make_code_clipboard_from_py_file(filepath: str):
|
12 |
# Black doesn't yet have a Python API, so format_str might not work at some point in the future.
|
|
|
1 |
"""Contains reusable data sets and constants."""
|
2 |
|
3 |
+
import logging
|
4 |
from pathlib import Path
|
5 |
|
6 |
import black
|
|
|
8 |
import vizro.plotly.express as px
|
9 |
from custom_components import CodeClipboard
|
10 |
|
11 |
+
# To disable logging info messages caused by black.format_str: https://github.com/psf/black/issues/2058
|
12 |
+
logging.getLogger("blib2to3").setLevel(logging.ERROR)
|
13 |
+
|
14 |
|
15 |
def make_code_clipboard_from_py_file(filepath: str):
|
16 |
# Black doesn't yet have a Python API, so format_str might not work at some point in the future.
|
pages/examples/time_column.py
CHANGED
@@ -11,8 +11,8 @@ gapminder = px.data.gapminder()
|
|
11 |
def categorical_column(data_frame: pd.DataFrame, x: str, y: str):
|
12 |
fig = px.bar(
|
13 |
data_frame,
|
14 |
-
y=y,
|
15 |
x=x,
|
|
|
16 |
)
|
17 |
# So ticks are aligned with bars when xaxes values are numbers (e.g. years)
|
18 |
fig.update_xaxes(type="category")
|
|
|
11 |
def categorical_column(data_frame: pd.DataFrame, x: str, y: str):
|
12 |
fig = px.bar(
|
13 |
data_frame,
|
|
|
14 |
x=x,
|
15 |
+
y=y,
|
16 |
)
|
17 |
# So ticks are aligned with bars when xaxes values are numbers (e.g. years)
|
18 |
fig.update_xaxes(type="category")
|