gov-uk-dashboards 15.0.2__py3-none-any.whl → 15.1.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/assets/dashboard.css +4 -0
- gov_uk_dashboards/components/dash/home_page_link_button.py +74 -0
- gov_uk_dashboards/components/plotly/enums.py +1 -0
- gov_uk_dashboards/components/plotly/time_series_chart.py +28 -1
- {gov_uk_dashboards-15.0.2.dist-info → gov_uk_dashboards-15.1.0.dist-info}/METADATA +1 -1
- {gov_uk_dashboards-15.0.2.dist-info → gov_uk_dashboards-15.1.0.dist-info}/RECORD +9 -8
- {gov_uk_dashboards-15.0.2.dist-info → gov_uk_dashboards-15.1.0.dist-info}/WHEEL +0 -0
- {gov_uk_dashboards-15.0.2.dist-info → gov_uk_dashboards-15.1.0.dist-info}/licenses/LICENSE +0 -0
- {gov_uk_dashboards-15.0.2.dist-info → gov_uk_dashboards-15.1.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
"""home_page_link_button"""
|
2
|
+
from typing import Optional
|
3
|
+
from dash import html
|
4
|
+
|
5
|
+
|
6
|
+
def home_page_link_button(
|
7
|
+
title: str,
|
8
|
+
pathname_or_url_link: str,
|
9
|
+
pathname_rather_than_url: bool,
|
10
|
+
image_path: str,
|
11
|
+
info: Optional[str] = None,
|
12
|
+
):
|
13
|
+
"""Creates home page link card.
|
14
|
+
|
15
|
+
Args:
|
16
|
+
title (str): Button title.
|
17
|
+
pathname_or_url_link (str): The target link, either a pathname or full URL.
|
18
|
+
pathname_rather_than_url (bool): If True, `pathname_or_url_link` is treated as a pathname
|
19
|
+
(loading content in the same tab). If False, it is treated as a full URL
|
20
|
+
(opening in a new tab).
|
21
|
+
image_path (str): The path to an SVG image used as an icon for the button.
|
22
|
+
info (Optional[str], optional): Additional text for the button. Defaults to None.
|
23
|
+
|
24
|
+
Returns:
|
25
|
+
dash_html_components.A: A Dash HTML `A` element representing the link button.
|
26
|
+
"""
|
27
|
+
|
28
|
+
link_attributes = {
|
29
|
+
"href": pathname_or_url_link,
|
30
|
+
"id": f"link-to-{title.replace(' ', '-')}",
|
31
|
+
"className": "govuk-body homepage-card-grid-item",
|
32
|
+
}
|
33
|
+
|
34
|
+
if pathname_rather_than_url is False:
|
35
|
+
link_attributes["target"] = "_blank"
|
36
|
+
link_attributes["rel"] = "noopener noreferrer"
|
37
|
+
|
38
|
+
return html.A(
|
39
|
+
[
|
40
|
+
html.Div(
|
41
|
+
[
|
42
|
+
html.Div(
|
43
|
+
[
|
44
|
+
html.Div(
|
45
|
+
[title],
|
46
|
+
className="govuk-heading-l"
|
47
|
+
if info is not None
|
48
|
+
else None,
|
49
|
+
),
|
50
|
+
(
|
51
|
+
html.Div(
|
52
|
+
[info], className="font-weight-normal-override"
|
53
|
+
)
|
54
|
+
if info is not None
|
55
|
+
else None
|
56
|
+
),
|
57
|
+
],
|
58
|
+
style={
|
59
|
+
"text-align": "left",
|
60
|
+
"text-decoration": "none",
|
61
|
+
"padding-left": "5%",
|
62
|
+
},
|
63
|
+
),
|
64
|
+
html.Img(src=image_path, style={"width": "100%"}),
|
65
|
+
],
|
66
|
+
style={
|
67
|
+
"display": "grid",
|
68
|
+
"grid-template-columns": "5fr 1fr",
|
69
|
+
"align-items": "center",
|
70
|
+
},
|
71
|
+
)
|
72
|
+
],
|
73
|
+
**link_attributes,
|
74
|
+
)
|
@@ -397,7 +397,6 @@ class TimeSeriesChart:
|
|
397
397
|
tick_text_length = len(tick_text)
|
398
398
|
total_tick_points = int((tick_text_length / 5) * 7)
|
399
399
|
additional_tick_points = total_tick_points - tick_text_length
|
400
|
-
|
401
400
|
last_current_tick_text = datetime.strptime(tick_text[-1], "%b %Y")
|
402
401
|
|
403
402
|
for x in range(additional_tick_points):
|
@@ -417,6 +416,34 @@ class TimeSeriesChart:
|
|
417
416
|
tick_values[-1] + relativedelta(months=1),
|
418
417
|
]
|
419
418
|
tick_text = replace_jun_jul_month_abbreviations(tick_text)
|
419
|
+
|
420
|
+
elif self.xaxis_tick_text_format == XAxisFormat.MONTH_YEAR_MONTHLY_DATA.value:
|
421
|
+
df = self.filtered_df.with_columns(
|
422
|
+
pl.col(self.x_axis_column)
|
423
|
+
.str.strptime(pl.Date, "%Y-%m-%d")
|
424
|
+
.alias(self.x_axis_column)
|
425
|
+
).sort(self.x_axis_column)
|
426
|
+
|
427
|
+
start_datetime = datetime(2024, 7, 1).date()
|
428
|
+
latest_datetime = df[self.x_axis_column].max()
|
429
|
+
extra_datetime = latest_datetime + relativedelta(months=1)
|
430
|
+
|
431
|
+
tick_text = []
|
432
|
+
current = start_datetime
|
433
|
+
while current <= extra_datetime:
|
434
|
+
tick_text.append(current.strftime("%b %Y"))
|
435
|
+
current += relativedelta(months=1)
|
436
|
+
|
437
|
+
tick_values = [
|
438
|
+
datetime.strptime(month_year, "%b %Y").replace(day=1)
|
439
|
+
for month_year in tick_text
|
440
|
+
]
|
441
|
+
|
442
|
+
range_x = [
|
443
|
+
tick_values[0],
|
444
|
+
tick_values[-1],
|
445
|
+
]
|
446
|
+
tick_text = replace_jun_jul_month_abbreviations(tick_text)
|
420
447
|
elif self.xaxis_tick_text_format == XAxisFormat.FINANCIAL_QUARTER.value:
|
421
448
|
tick_values = [1, 2, 3, 4]
|
422
449
|
tick_text = [
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: gov_uk_dashboards
|
3
|
-
Version: 15.0
|
3
|
+
Version: 15.1.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
|
@@ -7,7 +7,7 @@ gov_uk_dashboards/template.html,sha256=uFAki9bEpcei5dP_NZYP8dsxpxXpNIDQPn7ezsE7V
|
|
7
7
|
gov_uk_dashboards/template.py,sha256=WNVkAW3LCNoUHcxQ1kiUPkGCKIan5DgZQaAA_ZbE5WA,534
|
8
8
|
gov_uk_dashboards/assets/__init__.py,sha256=SwV4sjjMQmuZXloVcvf2H86XFiAd8xhPLJvaSMC2MQE,101
|
9
9
|
gov_uk_dashboards/assets/attach-event-to-dash.js,sha256=mbea5TaxEnjMN-MebR3J0hVjOb1B27-zXwWw9ZYqBBw,562
|
10
|
-
gov_uk_dashboards/assets/dashboard.css,sha256=
|
10
|
+
gov_uk_dashboards/assets/dashboard.css,sha256=exnujRlse2xHOeuE_TAs84gITv5YMRzKJKEeSjoXO6U,202134
|
11
11
|
gov_uk_dashboards/assets/get_assets_folder.py,sha256=ozYOmuO2r36vaTdWMU5cBuskl47RHBp8z9KIO06BXBM,171
|
12
12
|
gov_uk_dashboards/assets/govuk-frontend-3.14.0.min.js,sha256=kKi_r2hAqumi2pKM43W8NKpR2UtksUww9lSQOjkOmMI,34806
|
13
13
|
gov_uk_dashboards/assets/mobile-nav.js,sha256=wsmOQtunN6HiA4EimNWPsr-qXomp9UruS2zr09Tsbeg,1772
|
@@ -52,6 +52,7 @@ gov_uk_dashboards/components/dash/footer.py,sha256=RnJKN1YTP88GuJ4e7ci2T-jDqIe0-
|
|
52
52
|
gov_uk_dashboards/components/dash/graph.py,sha256=bd49W5sVyhtWd4lNBfQST1RyLNlTLA0KRxS7jTgVMwE,886
|
53
53
|
gov_uk_dashboards/components/dash/header.py,sha256=ncwPcrGLLSpEL2E1NzSh6qtVW92B5JgAmA-qcTnNBhE,2886
|
54
54
|
gov_uk_dashboards/components/dash/heading.py,sha256=VjyBng591B_366vnan96PukpCDBTTj-2iJWuq0s0CLw,766
|
55
|
+
gov_uk_dashboards/components/dash/home_page_link_button.py,sha256=kmdNNMM7QaxPizUbwLR7XIDgCTZ3u-pVhb3DrpmPuHs,2536
|
55
56
|
gov_uk_dashboards/components/dash/html_list.py,sha256=P3xkxxDp8oT81SSbK594IyX8l2PClufUG3cUTtlARrI,674
|
56
57
|
gov_uk_dashboards/components/dash/key_value_pair.py,sha256=L8mjdCfqpBxOdbcEqZWDC36ou4xISNQSTsmXIWteUxI,690
|
57
58
|
gov_uk_dashboards/components/dash/main_content.py,sha256=GBqVlNx_ambSiW1lsKpwB6-mFVZAvcTZq5oBYzHRza0,545
|
@@ -76,9 +77,9 @@ gov_uk_dashboards/components/helpers/update_layout_bgcolor_margin.py,sha256=i7Nw
|
|
76
77
|
gov_uk_dashboards/components/plotly/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
77
78
|
gov_uk_dashboards/components/plotly/captioned_figure.py,sha256=T0sbtGTiJ79FXxVdPb__hqISuyTc3Dl11cKhgcuW-5U,2804
|
78
79
|
gov_uk_dashboards/components/plotly/choropleth_map.py,sha256=U9RmS3MZGloQAt9HoSYh3Xad205DDfZOjz91ZD_ydbI,9849
|
79
|
-
gov_uk_dashboards/components/plotly/enums.py,sha256=
|
80
|
+
gov_uk_dashboards/components/plotly/enums.py,sha256=ebHiFQljA7O4HJxKoslqlNXcAjUZi1askpTSwxKEcYQ,850
|
80
81
|
gov_uk_dashboards/components/plotly/stacked_barchart.py,sha256=y2XOf96tMfy5ythPb5RzqW5qGc2sKU3W508UbWO2iC0,12175
|
81
|
-
gov_uk_dashboards/components/plotly/time_series_chart.py,sha256=
|
82
|
+
gov_uk_dashboards/components/plotly/time_series_chart.py,sha256=whdOe4xPfpmWazPrOZDF38dfkhGWpZ7dqO3RQPIun3o,19228
|
82
83
|
gov_uk_dashboards/figures/__init__.py,sha256=_snQeNlM81nNKERl4gg9ScH2HYbtwaBjl8yQonccx34,712
|
83
84
|
gov_uk_dashboards/figures/chart_data.py,sha256=fEsNkQFzXKIQ0h7aLBWq3J1qAxHbxvJeKU23JrVodVc,757
|
84
85
|
gov_uk_dashboards/figures/line_chart.py,sha256=rEB51_z9cPl7BcT94iA6ZsZXzecnVCnGpQWW_9SNGUY,2813
|
@@ -99,8 +100,8 @@ gov_uk_dashboards/lib/dap/dap_deployment.py,sha256=ZXixeOAtRNjMsPdGKLwwLNamlo0mi
|
|
99
100
|
gov_uk_dashboards/lib/dap/get_dataframe_from_cds.py,sha256=OiusRCgYnkBjK_GZgYLGzNrxOGizYt8CgThiWRCVKK0,3921
|
100
101
|
gov_uk_dashboards/lib/datetime_functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
101
102
|
gov_uk_dashboards/lib/datetime_functions/datetime_functions.py,sha256=BQgr8I_vFNYwLi-fE4YC6jZ5PpbPea2rnD_2a_lw0YE,12209
|
102
|
-
gov_uk_dashboards-15.0.
|
103
|
-
gov_uk_dashboards-15.0.
|
104
|
-
gov_uk_dashboards-15.0.
|
105
|
-
gov_uk_dashboards-15.0.
|
106
|
-
gov_uk_dashboards-15.0.
|
103
|
+
gov_uk_dashboards-15.1.0.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
|
104
|
+
gov_uk_dashboards-15.1.0.dist-info/METADATA,sha256=AF-hcenFhQ7jtSw02N_Kb44fcGdrnPXP_G2x-l1VDgs,5917
|
105
|
+
gov_uk_dashboards-15.1.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
106
|
+
gov_uk_dashboards-15.1.0.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
|
107
|
+
gov_uk_dashboards-15.1.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|