Spaces:
Running
Running
Copy over third batch version
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitignore +164 -0
- Dockerfile +18 -0
- LICENSE.txt +21 -0
- README.md +103 -11
- app.py +111 -0
- assets/app.svg +9 -0
- assets/css/custom.css +71 -0
- assets/favicon.ico +0 -0
- assets/images/charts/arc.svg +25 -0
- assets/images/charts/area.svg +1 -0
- assets/images/charts/bar.svg +1 -0
- assets/images/charts/barcode.svg +136 -0
- assets/images/charts/beeswarm.svg +1 -0
- assets/images/charts/boxplot.svg +78 -0
- assets/images/charts/bubble-map.svg +0 -0
- assets/images/charts/bubble-timeline.svg +35 -0
- assets/images/charts/bubble.svg +32 -0
- assets/images/charts/bullet.svg +41 -0
- assets/images/charts/bump.svg +1 -0
- assets/images/charts/butterfly.svg +27 -0
- assets/images/charts/chord.svg +23 -0
- assets/images/charts/choropleth.svg +0 -0
- assets/images/charts/column-and-line.svg +20 -0
- assets/images/charts/column.svg +1 -0
- assets/images/charts/connected-scatter.svg +1 -0
- assets/images/charts/cumulative-curve.svg +18 -0
- assets/images/charts/diverging-bar.svg +21 -0
- assets/images/charts/diverging-stacked-bar.svg +1 -0
- assets/images/charts/donut.svg +25 -0
- assets/images/charts/dot-map.svg +0 -0
- assets/images/charts/dot-plot.svg +30 -0
- assets/images/charts/fan.svg +21 -0
- assets/images/charts/flow-map.svg +0 -0
- assets/images/charts/funnel.svg +19 -0
- assets/images/charts/gantt.svg +20 -0
- assets/images/charts/gridplot.svg +1 -0
- assets/images/charts/heatmap-matrix.svg +179 -0
- assets/images/charts/heatmap.svg +27 -0
- assets/images/charts/histogram.svg +25 -0
- assets/images/charts/line.svg +17 -0
- assets/images/charts/lollipop.svg +26 -0
- assets/images/charts/marimekko.svg +27 -0
- assets/images/charts/network.svg +44 -0
- assets/images/charts/ordered-bar.svg +20 -0
- assets/images/charts/ordered-bubble.svg +20 -0
- assets/images/charts/ordered-column.svg +20 -0
- assets/images/charts/paired-bar.svg +1 -0
- assets/images/charts/paired-column.svg +1 -0
- assets/images/charts/parallel-coordinates.svg +26 -0
- assets/images/charts/pictogram.svg +63 -0
.gitignore
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# npm node_modules
|
| 3 |
+
node_modules/
|
| 4 |
+
|
| 5 |
+
# Ipynb
|
| 6 |
+
ipynb_checkpoints
|
| 7 |
+
*/.ipynb_checkpoints/*
|
| 8 |
+
|
| 9 |
+
# IPython
|
| 10 |
+
profile_default/
|
| 11 |
+
ipython_config.py
|
| 12 |
+
|
| 13 |
+
# Byte-compiled / optimized / DLL files
|
| 14 |
+
__pycache__/
|
| 15 |
+
*.py[cod]
|
| 16 |
+
*$py.class
|
| 17 |
+
|
| 18 |
+
# C extensions
|
| 19 |
+
*.so
|
| 20 |
+
|
| 21 |
+
# Distribution / packaging
|
| 22 |
+
.Python
|
| 23 |
+
build/
|
| 24 |
+
develop-eggs/
|
| 25 |
+
dist/
|
| 26 |
+
downloads/
|
| 27 |
+
eggs/
|
| 28 |
+
.eggs/
|
| 29 |
+
lib/
|
| 30 |
+
lib64/
|
| 31 |
+
parts/
|
| 32 |
+
sdist/
|
| 33 |
+
var/
|
| 34 |
+
wheels/
|
| 35 |
+
share/python-wheels/
|
| 36 |
+
*.egg-info/
|
| 37 |
+
.installed.cfg
|
| 38 |
+
*.egg
|
| 39 |
+
MANIFEST
|
| 40 |
+
|
| 41 |
+
# macOS
|
| 42 |
+
*.DS_Store
|
| 43 |
+
.DS_Store
|
| 44 |
+
.AppleDouble
|
| 45 |
+
.LSOverride
|
| 46 |
+
.Trashes
|
| 47 |
+
|
| 48 |
+
# PyInstaller
|
| 49 |
+
*.manifest
|
| 50 |
+
*.spec
|
| 51 |
+
|
| 52 |
+
# Installer logs
|
| 53 |
+
pip-log.txt
|
| 54 |
+
pip-delete-this-directory.txt
|
| 55 |
+
|
| 56 |
+
# Unit test / coverage reports
|
| 57 |
+
htmlcov/
|
| 58 |
+
.tox/
|
| 59 |
+
.nox/
|
| 60 |
+
.coverage
|
| 61 |
+
.coverage.*
|
| 62 |
+
.cache
|
| 63 |
+
nosetests.xml
|
| 64 |
+
coverage.xml
|
| 65 |
+
*.cover
|
| 66 |
+
*.py,cover
|
| 67 |
+
.hypothesis/
|
| 68 |
+
.pytest_cache/
|
| 69 |
+
cover/
|
| 70 |
+
|
| 71 |
+
# Translations
|
| 72 |
+
*.mo
|
| 73 |
+
*.pot
|
| 74 |
+
|
| 75 |
+
# Django
|
| 76 |
+
*.log
|
| 77 |
+
local_settings.py
|
| 78 |
+
db.sqlite3
|
| 79 |
+
db.sqlite3-journal
|
| 80 |
+
|
| 81 |
+
# Flask
|
| 82 |
+
instance/
|
| 83 |
+
.webassets-cache
|
| 84 |
+
|
| 85 |
+
# Scrapy
|
| 86 |
+
.scrapy
|
| 87 |
+
|
| 88 |
+
# mkdocs
|
| 89 |
+
vizro-core/site
|
| 90 |
+
vizro-ai/site
|
| 91 |
+
|
| 92 |
+
# PyBuilder
|
| 93 |
+
.pybuilder/
|
| 94 |
+
target/
|
| 95 |
+
|
| 96 |
+
# IntelliJ
|
| 97 |
+
.idea/
|
| 98 |
+
*.iml
|
| 99 |
+
out/
|
| 100 |
+
.idea_modules/
|
| 101 |
+
|
| 102 |
+
# Vscode
|
| 103 |
+
.vscode/
|
| 104 |
+
|
| 105 |
+
# PEP 582
|
| 106 |
+
__pypackages__/
|
| 107 |
+
|
| 108 |
+
# Celery
|
| 109 |
+
celerybeat-schedule
|
| 110 |
+
celerybeat.pid
|
| 111 |
+
|
| 112 |
+
# SageMath
|
| 113 |
+
*.sage.py
|
| 114 |
+
|
| 115 |
+
# Environments
|
| 116 |
+
.env
|
| 117 |
+
.venv
|
| 118 |
+
env/
|
| 119 |
+
venv/
|
| 120 |
+
ENV/
|
| 121 |
+
env.bak/
|
| 122 |
+
venv.bak/
|
| 123 |
+
|
| 124 |
+
# Spyder
|
| 125 |
+
.spyderproject
|
| 126 |
+
.spyproject
|
| 127 |
+
|
| 128 |
+
# Rope
|
| 129 |
+
.ropeproject
|
| 130 |
+
|
| 131 |
+
# Mkdocs
|
| 132 |
+
/site
|
| 133 |
+
|
| 134 |
+
# Mypy
|
| 135 |
+
.mypy_cache/
|
| 136 |
+
.dmypy.json
|
| 137 |
+
dmypy.json
|
| 138 |
+
|
| 139 |
+
# Pyre
|
| 140 |
+
.pyre/
|
| 141 |
+
|
| 142 |
+
# Pytype
|
| 143 |
+
.pytype/
|
| 144 |
+
|
| 145 |
+
# Cython
|
| 146 |
+
cython_debug/
|
| 147 |
+
|
| 148 |
+
# Ruff
|
| 149 |
+
.ruff_cache/
|
| 150 |
+
|
| 151 |
+
# Ignore data files except for white-listed folders
|
| 152 |
+
*.csv
|
| 153 |
+
*.xls
|
| 154 |
+
*.xlsx
|
| 155 |
+
*.parquet
|
| 156 |
+
*.tsv
|
| 157 |
+
*.hdf5
|
| 158 |
+
*.h5
|
| 159 |
+
*.pickle
|
| 160 |
+
*.pkl
|
| 161 |
+
*.db
|
| 162 |
+
*.sqlite
|
| 163 |
+
*.sqlite3
|
| 164 |
+
*.orc
|
Dockerfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
+
# you will also find guides on how best to write your Dockerfile
|
| 3 |
+
|
| 4 |
+
FROM python:3.9
|
| 5 |
+
|
| 6 |
+
RUN useradd -m -u 1000 user
|
| 7 |
+
|
| 8 |
+
WORKDIR /app
|
| 9 |
+
|
| 10 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 11 |
+
|
| 12 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 13 |
+
|
| 14 |
+
COPY --chown=user . /app
|
| 15 |
+
|
| 16 |
+
EXPOSE 7860
|
| 17 |
+
|
| 18 |
+
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "app:server"]
|
LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2016 FT Interactive News
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
CHANGED
|
@@ -1,11 +1,103 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Chart gallery dashboard
|
| 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).
|
| 5 |
+
|
| 6 |
+
**Created by:**
|
| 7 |
+
|
| 8 |
+
- [Huong Li Nguyen](https://github.com/huong-li-nguyen) and [Antony Milne](https://github.com/antonymilne)
|
| 9 |
+
|
| 10 |
+
- Images created by QuantumBlack
|
| 11 |
+
|
| 12 |
+
**Inspired by:**
|
| 13 |
+
|
| 14 |
+
- [The FT Visual Vocabulary](https://github.com/Financial-Times/chart-doctor/blob/main/visual-vocabulary/README.md): Alan Smith, Chris Campbell, Ian Bott, Liz Faunce, Graham Parrish, Billy Ehrenberg, Paul McCallum,
|
| 15 |
+
Martin Stabe.
|
| 16 |
+
|
| 17 |
+
- [The Graphic Continuum](https://www.informationisbeautifulawards.com/showcase/611-the-graphic-continuum): Jon Swabish and Severino Ribecca
|
| 18 |
+
|
| 19 |
+
**Credits, tutorials and resources:**
|
| 20 |
+
|
| 21 |
+
- [Plotly](https://plotly.com/python/plotly-express/)
|
| 22 |
+
- [Guide to data chart mastery](https://www.atlassian.com/data/charts)
|
| 23 |
+
|
| 24 |
+
## Chart types
|
| 25 |
+
|
| 26 |
+
The dashboard is still in development. Below is an overview of the chart types for which a completed page is available.
|
| 27 |
+
|
| 28 |
+
| Chart Type | Status | Category |
|
| 29 |
+
| --------------------- | ------ | ------------------------ |
|
| 30 |
+
| Arc | ❌ | Part-to-whole |
|
| 31 |
+
| Area | ✅ | Time |
|
| 32 |
+
| Bar | ✅ | Magnitude |
|
| 33 |
+
| Barcode | ❌ | Distribution |
|
| 34 |
+
| Beeswarm | ❌ | Distribution |
|
| 35 |
+
| Boxplot | ✅ | Distribution |
|
| 36 |
+
| Bubble | ✅ | Correlation |
|
| 37 |
+
| Bubble map | ❌ | Spatial |
|
| 38 |
+
| Bubble timeline | ❌ | Time |
|
| 39 |
+
| Bullet | ❌ | Magnitude |
|
| 40 |
+
| Bump | ❌ | Ranking |
|
| 41 |
+
| Butterfly | ✅ | Deviation, Distribution |
|
| 42 |
+
| Chord | ❌ | Flow |
|
| 43 |
+
| Choropleth | ✅ | Spatial |
|
| 44 |
+
| Column | ✅ | Magnitude, Time |
|
| 45 |
+
| Column and line | ✅ | Correlation, Time |
|
| 46 |
+
| Connected scatter | ✅ | Correlation, Time |
|
| 47 |
+
| Cumulative curve | ❌ | Distribution |
|
| 48 |
+
| Diverging bar | ❌ | Deviation |
|
| 49 |
+
| Diverging stacked bar | ❌ | Deviation |
|
| 50 |
+
| Donut | ✅ | Part-to-whole |
|
| 51 |
+
| Dot map | ❌ | Spatial |
|
| 52 |
+
| Dot plot | ❌ | Distribution |
|
| 53 |
+
| Fan | ❌ | Time |
|
| 54 |
+
| Flow map | ❌ | Spatial |
|
| 55 |
+
| Funnel | ✅ | Part-to-whole |
|
| 56 |
+
| Gantt | ❌ | Time |
|
| 57 |
+
| Gridplot | ❌ | Part-to-whole |
|
| 58 |
+
| Heatmap | ✅ | Time |
|
| 59 |
+
| Heatmap matrix | ❌ | Correlation |
|
| 60 |
+
| Histogram | ✅ | Distribution |
|
| 61 |
+
| Line | ✅ | Time |
|
| 62 |
+
| Lollipop | ❌ | Ranking, Magnitude |
|
| 63 |
+
| Marimekko | ❌ | Magnitude, Part-to-whole |
|
| 64 |
+
| Network | ❌ | Flow |
|
| 65 |
+
| Ordered bar | ✅ | Ranking |
|
| 66 |
+
| Ordered bubble | ❌ | Ranking |
|
| 67 |
+
| Ordered column | ✅ | Ranking |
|
| 68 |
+
| Paired bar | ✅ | Magnitude |
|
| 69 |
+
| Paired column | ✅ | Magnitude |
|
| 70 |
+
| Parallel coordinates | ✅ | Magnitude |
|
| 71 |
+
| Pictogram | ❌ | Magnitude |
|
| 72 |
+
| Pie | ✅ | Part-to-whole |
|
| 73 |
+
| Radar | ❌ | Magnitude |
|
| 74 |
+
| Radial | ❌ | Magnitude |
|
| 75 |
+
| Sankey | ✅ | Flow |
|
| 76 |
+
| Scatter | ✅ | Correlation |
|
| 77 |
+
| Scatter matrix | ✅ | Correlation |
|
| 78 |
+
| Slope | ❌ | Ranking, Time |
|
| 79 |
+
| Sparkline | ❌ | Time |
|
| 80 |
+
| Stacked bar | ✅ | Part-to-whole |
|
| 81 |
+
| Stacked column | ✅ | Part-to-whole |
|
| 82 |
+
| Stepped line | ✅ | Time |
|
| 83 |
+
| Surplus deficit line | ❌ | Deviation |
|
| 84 |
+
| Treemap | ✅ | Part-to-whole |
|
| 85 |
+
| Venn | ❌ | Part-to-whole |
|
| 86 |
+
| Violin | ✅ | Distribution |
|
| 87 |
+
| Waterfall | ❌ | Part-to-whole, Flow |
|
| 88 |
+
|
| 89 |
+
To contribute a chart, follow the steps below:
|
| 90 |
+
|
| 91 |
+
1. Place an `svg` file named after the chart type in the `assets` folder if it doesn't already exist.
|
| 92 |
+
2. Add the data set to `_pages_utils.py` if it doesn't already exist.
|
| 93 |
+
3. Create a new page for the chart type and add it to the relevant category `.py` file such as `correlation.py`,
|
| 94 |
+
`deviation.py`, `distribution.py`, etc.
|
| 95 |
+
4. Add a `.py` file containing a code example of the chart type in the `pages/examples` folder, for instance, `area.py`
|
| 96 |
+
5. Remove the `IncompletePage(..)` entry for that chart type in `chart_groups.py`.
|
| 97 |
+
6. Update this `README.md` with the new chart type.
|
| 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 _chart-gallery`.
|
| 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
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""App configuration for chart gallery dashboard."""
|
| 2 |
+
|
| 3 |
+
from typing import List, Union
|
| 4 |
+
|
| 5 |
+
import vizro.models as vm
|
| 6 |
+
from chart_groups import ALL_CHART_GROUP, CHART_GROUPS, ChartGroup, IncompletePage
|
| 7 |
+
from custom_components import FlexContainer, Markdown
|
| 8 |
+
from vizro import Vizro
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def make_chart_card(page: Union[vm.Page, IncompletePage]) -> vm.Card:
|
| 12 |
+
"""Makes a card with svg icon, linked to the right page if page is complete.
|
| 13 |
+
|
| 14 |
+
Args:
|
| 15 |
+
page: page to make card for
|
| 16 |
+
|
| 17 |
+
Returns: card with svg icon, linked to the right page if page is complete.
|
| 18 |
+
|
| 19 |
+
"""
|
| 20 |
+
# There's one SVG per chart title, so that e.g. pages distribution-butterfly and deviation-butterfly, which both
|
| 21 |
+
# have title "Butterfly", correspond to butterfly.svg.
|
| 22 |
+
# Incomplete pages have page.path = "" so won't be linked to here.
|
| 23 |
+
svg_name = page.title.lower().replace(" ", "-")
|
| 24 |
+
return vm.Card(
|
| 25 |
+
text=f"""
|
| 26 |
+

|
| 27 |
+
|
| 28 |
+
#### {page.title}
|
| 29 |
+
""",
|
| 30 |
+
href=page.path,
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def make_homepage_container(chart_group: ChartGroup) -> vm.Container:
|
| 35 |
+
"""Makes a container with cards for each completed and incomplete chart in chart_group.
|
| 36 |
+
|
| 37 |
+
Args:
|
| 38 |
+
chart_group: group of charts to make container for.
|
| 39 |
+
|
| 40 |
+
Returns: container with cards for each chart in chart_group.
|
| 41 |
+
|
| 42 |
+
"""
|
| 43 |
+
# Pages are sorted in title's alphabetical order and deduplicated so that e.g. pages distribution-butterfly and
|
| 44 |
+
# deviation-butterfly, which both have title "Butterfly", correspond to a single card.
|
| 45 |
+
return vm.Container(
|
| 46 |
+
title=chart_group.name,
|
| 47 |
+
layout=vm.Layout(grid=[[0, 1, 1]], col_gap="40px"),
|
| 48 |
+
components=[
|
| 49 |
+
Markdown(text=chart_group.intro_text, classname="intro-text"),
|
| 50 |
+
FlexContainer(
|
| 51 |
+
components=[
|
| 52 |
+
make_chart_card(page)
|
| 53 |
+
for page in sorted(
|
| 54 |
+
_remove_duplicates(chart_group.pages + chart_group.incomplete_pages),
|
| 55 |
+
key=lambda page: page.title,
|
| 56 |
+
)
|
| 57 |
+
],
|
| 58 |
+
),
|
| 59 |
+
],
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def _remove_duplicates(pages: List[Union[vm.Page, IncompletePage]]) -> List[Union[vm.Page, IncompletePage]]:
|
| 64 |
+
# Deduplicate pages that have the same title. Using reversed means that the page that is kept is the first one
|
| 65 |
+
# in the dashboard. This will be the one that the card on the homepage links to.
|
| 66 |
+
return list({page.title: page for page in reversed(pages)}.values())
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def make_navlink(chart_group: ChartGroup) -> vm.NavLink:
|
| 70 |
+
"""Makes a navlink with icon and links to every complete page within chart_group.
|
| 71 |
+
|
| 72 |
+
Args:
|
| 73 |
+
chart_group: chart_group to make a navlink for.
|
| 74 |
+
|
| 75 |
+
Returns: navlink for chart_group.
|
| 76 |
+
|
| 77 |
+
"""
|
| 78 |
+
# Pages are sorted in alphabetical order within each chart group.
|
| 79 |
+
return vm.NavLink(
|
| 80 |
+
label=chart_group.name,
|
| 81 |
+
pages={chart_group.name: [page.id for page in sorted(chart_group.pages, key=lambda page: page.title)]},
|
| 82 |
+
icon=chart_group.icon,
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
homepage = vm.Page(
|
| 87 |
+
title="Overview",
|
| 88 |
+
components=[
|
| 89 |
+
vm.Tabs(tabs=[make_homepage_container(chart_group) for chart_group in [ALL_CHART_GROUP, *CHART_GROUPS]]),
|
| 90 |
+
],
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
# TODO: consider whether each chart group should have its own individual homepage,
|
| 94 |
+
# e.g. at http://localhost:8050/deviation/. This could just repeat the content of the tab from the homepage and would
|
| 95 |
+
# work nicely with the hierarchical navigation.
|
| 96 |
+
dashboard = vm.Dashboard(
|
| 97 |
+
# ALL_CHART_GROUP.pages has duplicated pages, e.g. both distribution-butterfly and deviation-butterfly.
|
| 98 |
+
title="Vizro - Visual Vocabulary",
|
| 99 |
+
pages=[homepage, *ALL_CHART_GROUP.pages],
|
| 100 |
+
navigation=vm.Navigation(
|
| 101 |
+
nav_selector=vm.NavBar(
|
| 102 |
+
items=[
|
| 103 |
+
vm.NavLink(label="Overview", pages=[homepage.id], icon="Home"),
|
| 104 |
+
]
|
| 105 |
+
+ [make_navlink(chart_group) for chart_group in CHART_GROUPS]
|
| 106 |
+
)
|
| 107 |
+
),
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
if __name__ == "__main__":
|
| 111 |
+
Vizro().build(dashboard).run()
|
assets/app.svg
ADDED
|
|
assets/css/custom.css
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#page-header {
|
| 2 |
+
padding-left: 8px;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
#left-main {
|
| 6 |
+
width: 288px;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
img[src*="#chart-icon"] {
|
| 10 |
+
width: 100%;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
.code-clipboard {
|
| 14 |
+
font-size: 20px;
|
| 15 |
+
position: absolute;
|
| 16 |
+
right: 14px;
|
| 17 |
+
top: 12px;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.code-clipboard-container {
|
| 21 |
+
background: var(--surfaces-bg-card);
|
| 22 |
+
font-family: monospace;
|
| 23 |
+
max-height: 500px;
|
| 24 |
+
overflow: auto;
|
| 25 |
+
padding: 1rem;
|
| 26 |
+
position: relative;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
.code-clipboard-container::-webkit-scrollbar-thumb {
|
| 30 |
+
border-color: var(--surfaces-bg-card);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
.flex-container {
|
| 34 |
+
display: flex;
|
| 35 |
+
flex-wrap: wrap;
|
| 36 |
+
gap: 24px;
|
| 37 |
+
justify-content: flex-start;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
.flex-container h4 {
|
| 41 |
+
color: var(--text-secondary);
|
| 42 |
+
margin: 0;
|
| 43 |
+
padding-top: 12px;
|
| 44 |
+
text-align: center;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
.flex-container .card {
|
| 48 |
+
height: 232px;
|
| 49 |
+
margin: 0 0 auto;
|
| 50 |
+
opacity: 0.3;
|
| 51 |
+
width: 176px;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.flex-container .card-nav {
|
| 55 |
+
opacity: 1;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.flex-container .card img {
|
| 59 |
+
width: 100%;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
.intro-text {
|
| 63 |
+
border-left: 4px solid var(--text-secondary);
|
| 64 |
+
padding: 4px 12px;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
.intro-text p {
|
| 68 |
+
font-size: 16px;
|
| 69 |
+
line-height: 20px;
|
| 70 |
+
margin: 0;
|
| 71 |
+
}
|
assets/favicon.ico
ADDED
|
|
assets/images/charts/arc.svg
ADDED
|
|
assets/images/charts/area.svg
ADDED
|
|
assets/images/charts/bar.svg
ADDED
|
|
assets/images/charts/barcode.svg
ADDED
|
|
assets/images/charts/beeswarm.svg
ADDED
|
|
assets/images/charts/boxplot.svg
ADDED
|
|
assets/images/charts/bubble-map.svg
ADDED
|
|
assets/images/charts/bubble-timeline.svg
ADDED
|
|
assets/images/charts/bubble.svg
ADDED
|
|
assets/images/charts/bullet.svg
ADDED
|
|
assets/images/charts/bump.svg
ADDED
|
|
assets/images/charts/butterfly.svg
ADDED
|
|
assets/images/charts/chord.svg
ADDED
|
|
assets/images/charts/choropleth.svg
ADDED
|
|
assets/images/charts/column-and-line.svg
ADDED
|
|
assets/images/charts/column.svg
ADDED
|
|
assets/images/charts/connected-scatter.svg
ADDED
|
|
assets/images/charts/cumulative-curve.svg
ADDED
|
|
assets/images/charts/diverging-bar.svg
ADDED
|
|
assets/images/charts/diverging-stacked-bar.svg
ADDED
|
|
assets/images/charts/donut.svg
ADDED
|
|
assets/images/charts/dot-map.svg
ADDED
|
|
assets/images/charts/dot-plot.svg
ADDED
|
|
assets/images/charts/fan.svg
ADDED
|
|
assets/images/charts/flow-map.svg
ADDED
|
|
assets/images/charts/funnel.svg
ADDED
|
|
assets/images/charts/gantt.svg
ADDED
|
|
assets/images/charts/gridplot.svg
ADDED
|
|
assets/images/charts/heatmap-matrix.svg
ADDED
|
|
assets/images/charts/heatmap.svg
ADDED
|
|
assets/images/charts/histogram.svg
ADDED
|
|
assets/images/charts/line.svg
ADDED
|
|
assets/images/charts/lollipop.svg
ADDED
|
|
assets/images/charts/marimekko.svg
ADDED
|
|
assets/images/charts/network.svg
ADDED
|
|
assets/images/charts/ordered-bar.svg
ADDED
|
|
assets/images/charts/ordered-bubble.svg
ADDED
|
|
assets/images/charts/ordered-column.svg
ADDED
|
|
assets/images/charts/paired-bar.svg
ADDED
|
|
assets/images/charts/paired-column.svg
ADDED
|
|
assets/images/charts/parallel-coordinates.svg
ADDED
|
|
assets/images/charts/pictogram.svg
ADDED
|
|