gov-uk-dashboards 26.23.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.
@@ -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: latest_year_data[
71
- PERCENTAGE_CHANGE_FROM_PREV_YEAR
72
- ][0],
73
- PERCENTAGE_CHANGE_FROM_TWO_PREV_YEAR: latest_year_data[
74
- PERCENTAGE_CHANGE_FROM_TWO_PREV_YEAR
75
- ][0],
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=data[PERCENTAGE_CHANGE_FROM_PREV_YEAR],
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=f"from same rolling period ending {formatted_year_ago}",
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=data[
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 rolling period "
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,
@@ -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.23.0
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
@@ -49,7 +49,7 @@ gov_uk_dashboards/components/dash/card_full_width.py,sha256=KnpkB3krgLxp1MoqEZaz
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=3CzgSEYeyXoKvs5kOBPlp9LDaBq7tgfelKkG-aKzwCE,21987
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=YrGpnTF1dQcL_U0IxWWpa8yabye-X6Rsy-eiJoyUILM,1121
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.23.0.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
125
- gov_uk_dashboards-26.23.0.dist-info/METADATA,sha256=WFFsOytCRQkFGsmcgXBepjbYpuBijAPT4KmpYikqQzc,5903
126
- gov_uk_dashboards-26.23.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
127
- gov_uk_dashboards-26.23.0.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
128
- gov_uk_dashboards-26.23.0.dist-info/RECORD,,
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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.10.1)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5