gov-uk-dashboards 26.22.0__py3-none-any.whl → 26.24.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gov_uk_dashboards/components/dash/banners.py +20 -0
- gov_uk_dashboards/components/dash/context_card.py +15 -28
- gov_uk_dashboards/constants.py +14 -0
- gov_uk_dashboards/formatting/number_formatting.py +7 -0
- {gov_uk_dashboards-26.22.0.dist-info → gov_uk_dashboards-26.24.0.dist-info}/METADATA +1 -1
- {gov_uk_dashboards-26.22.0.dist-info → gov_uk_dashboards-26.24.0.dist-info}/RECORD +9 -9
- {gov_uk_dashboards-26.22.0.dist-info → gov_uk_dashboards-26.24.0.dist-info}/WHEEL +1 -1
- {gov_uk_dashboards-26.22.0.dist-info → gov_uk_dashboards-26.24.0.dist-info}/licenses/LICENSE +0 -0
- {gov_uk_dashboards-26.22.0.dist-info → gov_uk_dashboards-26.24.0.dist-info}/top_level.txt +0 -0
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from dash import html
|
|
4
4
|
|
|
5
|
+
from gov_uk_dashboards.constants import BANNER_STYLE, ERROR_MESSAGE_BANNER_STYLE
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
def message_banner(category, message, style=None):
|
|
7
9
|
"""
|
|
@@ -30,3 +32,21 @@ def message_banner(category, message, style=None):
|
|
|
30
32
|
className="change-log-banner govuk-!-margin-bottom-2",
|
|
31
33
|
style=style,
|
|
32
34
|
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def get_warning_banner(banner_text: str) -> html.Div:
|
|
38
|
+
"""Returns warning banner with banner_text displayed.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
banner_text (str): Text to display on warning banner.
|
|
42
|
+
"""
|
|
43
|
+
return html.Div(
|
|
44
|
+
[
|
|
45
|
+
message_banner(
|
|
46
|
+
"UPDATE",
|
|
47
|
+
html.Span(banner_text),
|
|
48
|
+
style=ERROR_MESSAGE_BANNER_STYLE,
|
|
49
|
+
)
|
|
50
|
+
],
|
|
51
|
+
style=BANNER_STYLE,
|
|
52
|
+
)
|
|
@@ -10,7 +10,7 @@ from dash.development.base_component import Component
|
|
|
10
10
|
from gov_uk_dashboards.components.dash import (
|
|
11
11
|
heading2,
|
|
12
12
|
)
|
|
13
|
-
from gov_uk_dashboards.formatting.number_formatting import add_commas
|
|
13
|
+
from gov_uk_dashboards.formatting.number_formatting import add_commas, format_percentage
|
|
14
14
|
from gov_uk_dashboards.lib.datetime_functions.datetime_functions import (
|
|
15
15
|
convert_date_string_to_text_string,
|
|
16
16
|
)
|
|
@@ -67,12 +67,12 @@ def get_rolling_period_context_card(
|
|
|
67
67
|
context_card_data = {
|
|
68
68
|
VALUE: latest_year_data[VALUE][0],
|
|
69
69
|
DATE_VALID: latest_year_data[DATE_VALID][0],
|
|
70
|
-
PERCENTAGE_CHANGE_FROM_PREV_YEAR:
|
|
71
|
-
PERCENTAGE_CHANGE_FROM_PREV_YEAR
|
|
72
|
-
|
|
73
|
-
PERCENTAGE_CHANGE_FROM_TWO_PREV_YEAR:
|
|
74
|
-
PERCENTAGE_CHANGE_FROM_TWO_PREV_YEAR
|
|
75
|
-
|
|
70
|
+
PERCENTAGE_CHANGE_FROM_PREV_YEAR: format_percentage(
|
|
71
|
+
latest_year_data[PERCENTAGE_CHANGE_FROM_PREV_YEAR][0]
|
|
72
|
+
),
|
|
73
|
+
PERCENTAGE_CHANGE_FROM_TWO_PREV_YEAR: format_percentage(
|
|
74
|
+
latest_year_data[PERCENTAGE_CHANGE_FROM_TWO_PREV_YEAR][0]
|
|
75
|
+
),
|
|
76
76
|
}
|
|
77
77
|
return html.Div(
|
|
78
78
|
[
|
|
@@ -97,20 +97,6 @@ def _get_rolling_period_data_content_for_x_years(
|
|
|
97
97
|
data[DATE_VALID], abbreviate_month=False, include_year=True
|
|
98
98
|
)
|
|
99
99
|
|
|
100
|
-
current_date = data[DATE_VALID]
|
|
101
|
-
previous_year_datetime = get_a_previous_date(current_date, "previous", False)
|
|
102
|
-
two_years_ago_datetime = get_a_previous_date(current_date, "two_previous", False)
|
|
103
|
-
formatted_year_ago = convert_date_string_to_text_string(
|
|
104
|
-
previous_year_datetime.strftime("%Y-%m-%d"),
|
|
105
|
-
abbreviate_month=False,
|
|
106
|
-
include_year=True,
|
|
107
|
-
)
|
|
108
|
-
formatted_two_years_ago = convert_date_string_to_text_string(
|
|
109
|
-
two_years_ago_datetime.strftime("%Y-%m-%d"),
|
|
110
|
-
abbreviate_month=False,
|
|
111
|
-
include_year=True,
|
|
112
|
-
)
|
|
113
|
-
|
|
114
100
|
return html.Div(
|
|
115
101
|
[
|
|
116
102
|
html.Div(
|
|
@@ -124,21 +110,22 @@ def _get_rolling_period_data_content_for_x_years(
|
|
|
124
110
|
className="govuk-body",
|
|
125
111
|
),
|
|
126
112
|
get_changed_from_content(
|
|
127
|
-
calculated_percentage_change=
|
|
113
|
+
calculated_percentage_change=format_percentage(
|
|
114
|
+
data[PERCENTAGE_CHANGE_FROM_PREV_YEAR]
|
|
115
|
+
),
|
|
128
116
|
use_calculated_percentage_change=True,
|
|
129
117
|
increase_is_positive=True,
|
|
130
|
-
comparison_period_text=
|
|
118
|
+
comparison_period_text="from same period previous year",
|
|
131
119
|
),
|
|
132
120
|
html.Div(
|
|
133
121
|
[
|
|
134
122
|
get_changed_from_content(
|
|
135
|
-
calculated_percentage_change=
|
|
136
|
-
PERCENTAGE_CHANGE_FROM_TWO_PREV_YEAR
|
|
137
|
-
|
|
123
|
+
calculated_percentage_change=format_percentage(
|
|
124
|
+
data[PERCENTAGE_CHANGE_FROM_TWO_PREV_YEAR]
|
|
125
|
+
),
|
|
138
126
|
use_calculated_percentage_change=True,
|
|
139
127
|
increase_is_positive=True,
|
|
140
|
-
comparison_period_text="from same
|
|
141
|
-
f"ending {formatted_two_years_ago}",
|
|
128
|
+
comparison_period_text="from same period a year earlier",
|
|
142
129
|
),
|
|
143
130
|
],
|
|
144
131
|
style=CHANGED_FROM_GAP_STYLE,
|
gov_uk_dashboards/constants.py
CHANGED
|
@@ -44,3 +44,17 @@ NOTIFICATION_STYLE_RED = {"borderColor": "#d4351c", "backgroundColor": "#d4351c"
|
|
|
44
44
|
NOTIFICATION_STYLE_ORANGE = {"borderColor": "#f47738", "backgroundColor": "#f47738"}
|
|
45
45
|
NOTIFICATION_STYLE_YELLOW = {"borderColor": "#ffdd00", "backgroundColor": "#ffdd00"}
|
|
46
46
|
NOTIFICATION_STYLE_GREEN = {"borderColor": "#00703c", "backgroundColor": "#00703c"}
|
|
47
|
+
|
|
48
|
+
BANNER_STYLE = {
|
|
49
|
+
"display": "flex",
|
|
50
|
+
"visibility": "visible",
|
|
51
|
+
"margin": "-10px -15px 0px -15px",
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ERROR_MESSAGE_BANNER_STYLE = {
|
|
55
|
+
"width": "100%",
|
|
56
|
+
"paddingLeft": "30px",
|
|
57
|
+
"paddingRight": "30px",
|
|
58
|
+
"justifyContent": "left",
|
|
59
|
+
"backgroundColor": "#FFDD00",
|
|
60
|
+
}
|
|
@@ -29,3 +29,10 @@ def add_commas(number: int, remove_decimal_places: bool = False) -> str:
|
|
|
29
29
|
if remove_decimal_places:
|
|
30
30
|
return f"{number:,.0f}"
|
|
31
31
|
return f"{number:,}"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def format_percentage(percentage):
|
|
35
|
+
"""Formats percentages to remove decimal place on numbers 10 or more"""
|
|
36
|
+
if abs(percentage) < 10:
|
|
37
|
+
return percentage
|
|
38
|
+
return int(percentage)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gov_uk_dashboards
|
|
3
|
-
Version: 26.
|
|
3
|
+
Version: 26.24.0
|
|
4
4
|
Summary: Provides access to functionality common to creating a data dashboard.
|
|
5
5
|
Author: Department for Levelling Up, Housing and Communities
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
gov_uk_dashboards/__init__.py,sha256=OqwrcJmNWlyzGe8wEy_lkIgRihjvdtSYhcx43TEvpVU,1281
|
|
2
2
|
gov_uk_dashboards/colours.py,sha256=ju_2FIeTARqG4BQo_2jIwo6trD5yOc8ulhaVj7KJ8hw,2858
|
|
3
|
-
gov_uk_dashboards/constants.py,sha256=
|
|
3
|
+
gov_uk_dashboards/constants.py,sha256=xsBbONNbsrmTfj2tD8VScmtlwB0ymQ1AfaxDXSJ7kWs,1807
|
|
4
4
|
gov_uk_dashboards/log_kpi.py,sha256=xDhb-ex16MfQ1RHQF99huv2FNRu5EKM30bIXYqCnd6g,1023
|
|
5
5
|
gov_uk_dashboards/symbols.py,sha256=Ca7kWylg5iLzYyninqsk7FPvefz1qvz8UEKmB1VYcxY,425
|
|
6
6
|
gov_uk_dashboards/template.html,sha256=npP-IeycCFNjOAxf56Yuha4FfpatwPXVYFQRkm84Bnc,1875
|
|
@@ -43,13 +43,13 @@ gov_uk_dashboards/assets/topojson/world_110m.json,sha256=11kV6qMchw32uXLJ5buGkQG
|
|
|
43
43
|
gov_uk_dashboards/components/__init__.py,sha256=2Ks6SdhCpNwXwoTCD-xLBxk3YJ1FJcLACkiSKLP5YN8,188
|
|
44
44
|
gov_uk_dashboards/components/dash/__init__.py,sha256=ItzNnUm3bkqsOUh4I92H4H4gTZVnQJTYftxDreSEYfY,4707
|
|
45
45
|
gov_uk_dashboards/components/dash/apply_and_reset_filters_buttons.py,sha256=qx7cI5cE-600mE-d6cu9CrLGnkpM13CJmReQQnC2UZw,674
|
|
46
|
-
gov_uk_dashboards/components/dash/banners.py,sha256=
|
|
46
|
+
gov_uk_dashboards/components/dash/banners.py,sha256=TPtpNAsYoxalCEQ97Ao8bUERTePHYOA5LOQAWm-f5OY,1470
|
|
47
47
|
gov_uk_dashboards/components/dash/card.py,sha256=8uu2HOX5jBwfbvs3TuicN2rrLtbtJc9CXr6mpskAUUI,421
|
|
48
48
|
gov_uk_dashboards/components/dash/card_full_width.py,sha256=KnpkB3krgLxp1MoqEZazx3xTncj6rDpeM1n2NLC2gB4,413
|
|
49
49
|
gov_uk_dashboards/components/dash/collapsible_panel.py,sha256=6A90xiTLU0b5e4jaWcisTbsf_82nRBvGapbyETd5m70,1192
|
|
50
50
|
gov_uk_dashboards/components/dash/comparison_la_filter_button.py,sha256=u53Vmuz4MJ0J8RSVXGEFvDgzXIp_-JpDDE4o9VijoDw,671
|
|
51
51
|
gov_uk_dashboards/components/dash/context_banner.py,sha256=gy0qKhseiM1oUyRS1X8_HrJuah-WaWN6yeZOHoGzAl4,1009
|
|
52
|
-
gov_uk_dashboards/components/dash/context_card.py,sha256=
|
|
52
|
+
gov_uk_dashboards/components/dash/context_card.py,sha256=6bSGmoFsN3dwYvivm439StF0es4uSh7AF4dFHhFGLSI,21475
|
|
53
53
|
gov_uk_dashboards/components/dash/dashboard_container.py,sha256=KC2isR0NShxUYCl_pzDEAS4WK5pFrLMp4m2We3AqiwM,512
|
|
54
54
|
gov_uk_dashboards/components/dash/data_quality_banner.py,sha256=VLuAndN9xVFuMWFLqoPlolAJt08H9_rQa5x7jqde_RQ,2945
|
|
55
55
|
gov_uk_dashboards/components/dash/details.py,sha256=ENkSBKd6XZTq0X7Jn0-zPaO1qR4F7zPNX-RLAXKVvAI,1107
|
|
@@ -99,7 +99,7 @@ gov_uk_dashboards/figures/styles/__init__.py,sha256=n4FMyPKfc1I0_SyWo3mklMiW7R38
|
|
|
99
99
|
gov_uk_dashboards/figures/styles/line_style.py,sha256=L_1b_lDuU2LStewT47Ge5EhOslOPxSoA87p-SrKgJE0,560
|
|
100
100
|
gov_uk_dashboards/formatting/__init__.py,sha256=bQk9_OEubUhuTRQjXUs4ZItgSY7yyDpwQcLauxf11Tk,460
|
|
101
101
|
gov_uk_dashboards/formatting/human_readable.py,sha256=FYGnNHwE7btWpbi3ZNCkswbSCjhwJi6Ym-H4vMHwOlQ,2438
|
|
102
|
-
gov_uk_dashboards/formatting/number_formatting.py,sha256=
|
|
102
|
+
gov_uk_dashboards/formatting/number_formatting.py,sha256=CakgGq3oevCNnpqciWYvqFKOFmRdXGUaBnP2oatFjcs,1316
|
|
103
103
|
gov_uk_dashboards/formatting/round_and_add_prefix_and_suffix.py,sha256=nxD7HVMjs0_HJA0d-WqJvKu-IwZZla1khyr0YCYUr40,1457
|
|
104
104
|
gov_uk_dashboards/formatting/rounding.py,sha256=Em1yri_j18IYHbZ64d3bhVKX-XEllRSM9FzAUo1o6fU,968
|
|
105
105
|
gov_uk_dashboards/formatting/text_functions.py,sha256=vHstpUo16LnsSk-rzwFDNP1SIAy2npIo-4ims1xNa64,306
|
|
@@ -121,8 +121,8 @@ gov_uk_dashboards/lib/testing_functions/barchart_data_test_assertions.py,sha256=
|
|
|
121
121
|
gov_uk_dashboards/lib/testing_functions/data_test_assertions.py,sha256=1Icy7NZXw6hI_-7QAUaHqjjPKViY0jcFEASlk6Ul2tg,4162
|
|
122
122
|
gov_uk_dashboards/lib/testing_functions/data_test_helper_functions.py,sha256=JoptoXJORuIdrhweVlp9fhX-ew2GtIkctIotpHWBQDQ,9635
|
|
123
123
|
gov_uk_dashboards/lib/testing_functions/timeseries_data_test_assertions.py,sha256=SJa3WLgFqf7Y1W0sxsOew_-4m3689cjynRjoCyBK5WQ,1240
|
|
124
|
-
gov_uk_dashboards-26.
|
|
125
|
-
gov_uk_dashboards-26.
|
|
126
|
-
gov_uk_dashboards-26.
|
|
127
|
-
gov_uk_dashboards-26.
|
|
128
|
-
gov_uk_dashboards-26.
|
|
124
|
+
gov_uk_dashboards-26.24.0.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
|
|
125
|
+
gov_uk_dashboards-26.24.0.dist-info/METADATA,sha256=mEwosVkphxTbDb1G2pAJhT3y5KgZtta6FkANEbl9OcI,5903
|
|
126
|
+
gov_uk_dashboards-26.24.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
127
|
+
gov_uk_dashboards-26.24.0.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
|
|
128
|
+
gov_uk_dashboards-26.24.0.dist-info/RECORD,,
|
{gov_uk_dashboards-26.22.0.dist-info → gov_uk_dashboards-26.24.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|