Skip to main content

Gov UK dashboards

This package contains functionality which is common to UK Government plotly dashboards.

Table of Contents

Background

This package is to enable quicker development of government data dashboards, such as the government colour schemes and plotly components.

Install

For installation using pip:

pip install gov-uk-dashboards

or for a specific version:

pip install gov-uk-dashboards~=6.7.0

For installation using conda, paste the following code into the environment configuration file:

 - pip:
     - gov-uk-dashboards~=6.7.0

Usage

Using Government dashboard template with dash:

import dash
from gov_uk_dashboards.template import read_template

app = dash.Dash(__name__, suppress_callback_exceptions=True)
app.index_string = read_template()

For colours:

from gov_uk_dashboards.colours import GovUKColours

GovUKColours.DLUHC_BLUE.value

For components:

from gov_uk_dashboards.components.plotly import banners

banners.message_banner('category','message')

For formatting:

from gov_uk_dashboards.formatting.human_readable import format_as_human_readable

format_as_human_readable(1200,prefix='£')

For figures:

from gov_uk_dashboards import figures

chart_data = figures.ChartData(
    dataframe,
    x_column = "Date",
    y_column = "Value",
    category_column = "Category"
)

line_chart = figures.line_chart(
    data = chart_data,
    title = "Chart title"
    line_style = {
        "Category 1": figures.format.LineFormat(
            color = "#000000",
            dash_pattern = figures.enums.DashPatterns.SOLID,
        ),
    }
)

Updating the CSS

We use SCSS to generate our CSS - NEVER directly alter the dashboard.css file in the assets folder. To update CSS:

  • Add your changes to dashboard.scss in the sccs folder
  • Run npm install if you haven't recently (/ever)
  • Run npm run sass to generate CSS from SCSS
  • Change package version in setup.py
  • Push your changes to a new branch
  • Try new CSS on dashboard repo using pip install git+https://github.com/communitiesuk/pkg_gov_uk_dashboards.git@

Updating govuk-frontend CSS

  • Update govuk-frontend version in package.json
  • Run npm run sass to generate CSS from SCSS
  • Follow steps above to test new CSS on dashboard repo

Updating the package

When making changes to the package, the following should be done:

  • Update version in setup.py accordingly
    • Style: Major.Minor.Patch, e.g. 1.2.3
    • Major - any breaking changes to previous functionality.
    • Minor - additional functionality that doesn't effect backward compatibility. When updated the patch version should be reset to zero. eg. 2.3.1 goes to 2.4.0 for minor update.
    • Patch - bug fixes that don't effect backward compatibility. For more information see here
  • After merging with main, go here to add a new version tag.
    • Click 'Draft a new release'
    • Under 'Choose a tag' dropdown, enter 'v<version number>'. Click 'Create new tag'
    • Give the tag a release title, this should be the same as the tag name.
    • Give a bullet point list of changes in the "Describe this release" section.
    • Make sure 'Target' is set to 'main'.
    • Click 'Publish release'.
    • The release will be uploaded to PyPI.org automatically.
  • Update the package references within projects where the package is used, by following the Installation section.

Trying out changes to the package from other repositories

When you want to make changes to the package to use in another repository, it can be useful to see what changes would look like before commiting to the package repo. You can do this by making changes directly to the package files in the conda environment of the repository you're working in.

  • Open the file you wish to change in the conda environment
  • Do this by clicking into functions from the package in your IDE or by finding the file you wish to change in your file system, e.g. .../anaconda3/envs/*repo*/lib/python3.9/site-packages/gov_uk_dashboards/components/...
  • Make the changes to the package file and you should see the changes in your localhost on refresh
  • If you want to undo your changes: pip install --upgrade --force-reinstall <package_name>~=<package_version>

When you're happy, you can make the changes on a branch in the package repo and install it locally to check it works as expected when imported before merging into main in the package repo:

  • You can update the environment.yml to point at your branch or run pip install with the url: git+https://github.com/communitiesuk/pkg_gov_uk_dashboards.git@<your-branch>

License

MIT Copyright (c) 2022 Crown Copyright (Department for Levelling Up, Housing and Communities)

Metadata

Release files for gov-uk-dashboards 34.32.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gov-uk-dashboards 34.32.0
File Size Uploaded Provenance Actions
gov_uk_dashboards-34.32.0.tar.gz 4.4 MB Without provenance Details for gov_uk_dashboards-34.32.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gov-uk-dashboards 34.32.0
File Interpreter ABI Platform Actions
gov_uk_dashboards-34.32.0-py3-none-any.whl Python 3 none any Details for gov_uk_dashboards-34.32.0-py3-none-any.whl

Total release size: 8.9 MB

Release files / gov_uk_dashboards-34.32.0.tar.gz

Download URL gov_uk_dashboards-34.32.0.tar.gz
Size 4.4 MB
Tags Source
SHA-256 checksum
How to use checksums
6b1408d3801f47804bac1799e9e8ea4bbc8ba41fa345060fb63c04093a79e0f3
BLAKE2b-256 checksum
How to use checksums
e9d404922e74d7fbb4a283e55532085e16021c41f71536ff43f5511a3a6a52cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / gov_uk_dashboards-34.32.0-py3-none-any.whl

Download URL gov_uk_dashboards-34.32.0-py3-none-any.whl
Size 4.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
36a68f6f7225d0bdfc650e305ee0b817e8764b0d605c6d969048ae7897f3e5eb
BLAKE2b-256 checksum
How to use checksums
2193a97985673a67b48543f3b411f72a9b1c41d06fff17183295aacd6c501661
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for gov-uk-dashboards 34.32.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

34.32.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page