gov-uk-dashboards 15.0.3__py3-none-any.whl → 15.2.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/time_series_chart.py +15 -0
- {gov_uk_dashboards-15.0.3.dist-info → gov_uk_dashboards-15.2.0.dist-info}/METADATA +1 -1
- {gov_uk_dashboards-15.0.3.dist-info → gov_uk_dashboards-15.2.0.dist-info}/RECORD +8 -7
- {gov_uk_dashboards-15.0.3.dist-info → gov_uk_dashboards-15.2.0.dist-info}/WHEEL +0 -0
- {gov_uk_dashboards-15.0.3.dist-info → gov_uk_dashboards-15.2.0.dist-info}/licenses/LICENSE +0 -0
- {gov_uk_dashboards-15.0.3.dist-info → gov_uk_dashboards-15.2.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
|
+
)
|
@@ -69,6 +69,8 @@ class TimeSeriesChart:
|
|
69
69
|
last_2_traces_filled=False,
|
70
70
|
trace_names_to_prevent_hover_of_first_point_list=None,
|
71
71
|
x_axis_column=DATE_VALID,
|
72
|
+
x_unified_hovermode: Optional[bool] = False,
|
73
|
+
x_hoverformat: Optional[str] = None,
|
72
74
|
x_axis_title: Optional[str] = None,
|
73
75
|
download_chart_button_id: Optional[str] = None,
|
74
76
|
download_data_button_id: Optional[str] = None,
|
@@ -91,6 +93,8 @@ class TimeSeriesChart:
|
|
91
93
|
trace_names_to_prevent_hover_of_first_point_list
|
92
94
|
)
|
93
95
|
self.x_axis_column = x_axis_column
|
96
|
+
self.x_unified_hovermode = x_unified_hovermode
|
97
|
+
self.x_hoverformat = x_hoverformat
|
94
98
|
self.x_axis_title = x_axis_title
|
95
99
|
self.download_chart_button_id = download_chart_button_id
|
96
100
|
self.download_data_button_id = download_data_button_id
|
@@ -125,6 +129,12 @@ class TimeSeriesChart:
|
|
125
129
|
"""generates a time series chart"""
|
126
130
|
# pylint: disable=too-many-locals
|
127
131
|
# pylint: disable=duplicate-code
|
132
|
+
|
133
|
+
if not self.x_unified_hovermode and self.x_hoverformat is not None:
|
134
|
+
raise ValueError(
|
135
|
+
"x_hoverformat can only be specified if x_unified_hovermode is True"
|
136
|
+
)
|
137
|
+
|
128
138
|
fig = go.Figure()
|
129
139
|
for i, (df, trace_name, colour, marker) in enumerate(
|
130
140
|
zip(
|
@@ -232,6 +242,8 @@ class TimeSeriesChart:
|
|
232
242
|
legend=get_legend_configuration(),
|
233
243
|
font={"size": CHART_LABEL_FONT_SIZE},
|
234
244
|
yaxis_tickformat=",",
|
245
|
+
hovermode="x unified" if self.x_unified_hovermode is True else "closest",
|
246
|
+
hoverdistance=1000, # Increase distance to simulate hover 'always on'
|
235
247
|
)
|
236
248
|
return fig
|
237
249
|
|
@@ -244,6 +256,7 @@ class TimeSeriesChart:
|
|
244
256
|
ticktext=tick_text,
|
245
257
|
tickmode="array",
|
246
258
|
range=range_x,
|
259
|
+
hoverformat=self.x_hoverformat,
|
247
260
|
)
|
248
261
|
|
249
262
|
def create_time_series_trace(
|
@@ -301,6 +314,8 @@ class TimeSeriesChart:
|
|
301
314
|
]
|
302
315
|
|
303
316
|
def _get_custom_hover_template(self, i, df, trace_name):
|
317
|
+
if self.x_unified_hovermode is True:
|
318
|
+
return "%{customdata[0]}"
|
304
319
|
hover_text_headers = self.hover_data[trace_name][HOVER_TEXT_HEADERS]
|
305
320
|
if (
|
306
321
|
self.hover_data_for_traces_with_different_hover_for_last_point is not None
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: gov_uk_dashboards
|
3
|
-
Version: 15.0
|
3
|
+
Version: 15.2.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
|
@@ -78,7 +79,7 @@ gov_uk_dashboards/components/plotly/captioned_figure.py,sha256=T0sbtGTiJ79FXxVdP
|
|
78
79
|
gov_uk_dashboards/components/plotly/choropleth_map.py,sha256=U9RmS3MZGloQAt9HoSYh3Xad205DDfZOjz91ZD_ydbI,9849
|
79
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=-hO_yz6CmwylLS8x0qW_Me6PgAUu5Kyl0PQ_UO_zaM8,19927
|
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.2.0.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
|
104
|
+
gov_uk_dashboards-15.2.0.dist-info/METADATA,sha256=EJHevNpKFYF8I9Fgf54MIQVTv9oqnxiVabqn8tnDTF4,5917
|
105
|
+
gov_uk_dashboards-15.2.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
106
|
+
gov_uk_dashboards-15.2.0.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
|
107
|
+
gov_uk_dashboards-15.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|