Package: gov-uk-dashboards
Gov UK dashboardsThis package contains functionality which is common to UK Government plotly dashboards.Table of ContentsBackgroundInstallUsageUpdatingTrying out changes to the package from other repositoriesLicenseBackgroundThis package is to enable quicker development of government data dashboards, such as the government colour schemes and plotly components.InstallFor installation using pip:pipinstallgov-uk-dashboardsor for a specific version:pipinstallgov-uk-dashboards~=6.7.0For installation using conda, paste the following code into the environment configuration file:- pip:
     - gov-uk-dashboards~=6.7.0UsageUsing Government dashboard template with dash:importdashfromgov_uk_dashboards.templateimportread_templateapp=dash.Dash(__name__,suppress_callback_exceptions=True)app.index_string=read_template()For colours:fromgov_uk_dashboards.coloursimportGovUKColoursGovUKColours.DLUHC_BLUE.valueFor components:fromgov_uk_dashboards.components.plotlyimportbannersbanners.message_banner('category','message')For formatting:fromgov_uk_dashboards.formatting.human_readableimportformat_as_human_readableformat_as_human_readable(1200,prefix='£')For figures:fromgov_uk_dashboardsimportfigureschart_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 CSSWe use SCSS to generate our CSS - NEVER directly alter thedashboard.cssfile in the assets folder.
To update CSS:Add your changes todashboard.scssin the sccs folderRunnpm installif you haven't recently (/ever)Runnpm run sassto generate CSS from SCSSChange package version in setup.pyPush your changes to a new branchTry new CSS on dashboard repo using pip install git+https://github.com/communitiesuk/pkg_gov_uk_dashboards.git@Updating govuk-frontend CSSUpdate govuk-frontend version in package.jsonRunnpm run sassto generate CSS from SCSSFollow steps above to test new CSS on dashboard repoUpdating the packageWhen making changes to the package, the following should be done:Update version in setup.py accordinglyStyle: Major.Minor.Patch, e.g. 1.2.3Major - 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 seehereAfter merging with main, gohereto 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 beuploaded to PyPI.org automatically.Update the package references within projects where the package is used, by following theInstallationsection.Trying out changes to the package from other repositoriesWhen 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 environmentDo 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 refreshIf 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 theenvironment.ymlto point at your branch or runpip installwith the url:git+https://github.com/communitiesuk/pkg_gov_uk_dashboards.git@<your-branch>LicenseMITCopyright (c) 2022 Crown Copyright (Department for Levelling Up, Housing and Communities)