gov-uk-dashboards 21.0.0__py3-none-any.whl → 21.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/components/helpers/get_chart_for_download.py +4 -2
- gov_uk_dashboards/components/plotly/stacked_barchart.py +13 -0
- gov_uk_dashboards/formatting/human_readable.py +20 -4
- {gov_uk_dashboards-21.0.0.dist-info → gov_uk_dashboards-21.1.0.dist-info}/METADATA +1 -1
- {gov_uk_dashboards-21.0.0.dist-info → gov_uk_dashboards-21.1.0.dist-info}/RECORD +8 -8
- {gov_uk_dashboards-21.0.0.dist-info → gov_uk_dashboards-21.1.0.dist-info}/WHEEL +0 -0
- {gov_uk_dashboards-21.0.0.dist-info → gov_uk_dashboards-21.1.0.dist-info}/licenses/LICENSE +0 -0
- {gov_uk_dashboards-21.0.0.dist-info → gov_uk_dashboards-21.1.0.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,7 @@ def get_chart_for_download(self, fig):
|
|
6
6
|
"""Returns a fig with title and subtitle for download as png"""
|
7
7
|
main_title = self.title_data[MAIN_TITLE]
|
8
8
|
subtitle = self.title_data[SUBTITLE]
|
9
|
-
footnote = self
|
9
|
+
footnote = getattr(self, "footnote", None)
|
10
10
|
|
11
11
|
fig.update_layout(
|
12
12
|
title={
|
@@ -29,6 +29,8 @@ def get_chart_for_download(self, fig):
|
|
29
29
|
"showarrow": False,
|
30
30
|
"align": "left",
|
31
31
|
}
|
32
|
-
]
|
32
|
+
]
|
33
|
+
if footnote is not None
|
34
|
+
else [],
|
33
35
|
)
|
34
36
|
return fig
|
@@ -60,9 +60,11 @@ class StackedBarChart:
|
|
60
60
|
df: pl.DataFrame,
|
61
61
|
trace_name_list: list[str],
|
62
62
|
trace_name_column: Optional[str] = None,
|
63
|
+
initially_hidden_traces: Optional[list[str]] = None,
|
63
64
|
xaxis_tick_text_format: XAxisFormat = XAxisFormat.YEAR.value,
|
64
65
|
line_trace_name: Optional[str] = None,
|
65
66
|
x_axis_column=DATE_VALID,
|
67
|
+
show_x_axis_title=False,
|
66
68
|
x_unified_hovermode: Optional[bool] = False,
|
67
69
|
hover_distance: Optional[int] = 1,
|
68
70
|
download_chart_button_id: Optional[str] = None,
|
@@ -101,9 +103,11 @@ class StackedBarChart:
|
|
101
103
|
self.df = df
|
102
104
|
self.trace_name_list = trace_name_list
|
103
105
|
self.trace_name_column = trace_name_column
|
106
|
+
self.initially_hidden_traces = initially_hidden_traces
|
104
107
|
self.xaxis_tick_text_format = xaxis_tick_text_format
|
105
108
|
self.line_trace_name = line_trace_name
|
106
109
|
self.x_axis_column = x_axis_column
|
110
|
+
self.show_x_axis_title = show_x_axis_title
|
107
111
|
self.x_unified_hovermode = x_unified_hovermode
|
108
112
|
self.hover_distance = hover_distance
|
109
113
|
self.download_chart_button_id = download_chart_button_id
|
@@ -253,6 +257,7 @@ class StackedBarChart:
|
|
253
257
|
showlegend=True,
|
254
258
|
barmode="relative",
|
255
259
|
xaxis={"categoryorder": "category ascending"},
|
260
|
+
xaxis_title=self.x_axis_column if self.show_x_axis_title else None,
|
256
261
|
## copied from timeseries
|
257
262
|
hovermode="x unified" if self.x_unified_hovermode is True else "closest",
|
258
263
|
hoverdistance=self.hover_distance, # Increase distance to simulate hover 'always on'
|
@@ -275,11 +280,19 @@ class StackedBarChart:
|
|
275
280
|
hover_label (dict[str,str]): Properties for hoverlabel parameter.
|
276
281
|
colour (str): Colour for bar.
|
277
282
|
"""
|
283
|
+
if (
|
284
|
+
self.initially_hidden_traces is not None
|
285
|
+
and trace_name in self.initially_hidden_traces
|
286
|
+
):
|
287
|
+
visible = "legendonly"
|
288
|
+
else:
|
289
|
+
visible = True
|
278
290
|
|
279
291
|
return go.Bar(
|
280
292
|
x=df[self.x_axis_column],
|
281
293
|
y=df[self.y_axis_column],
|
282
294
|
name=trace_name + LEGEND_SPACING,
|
295
|
+
visible=visible,
|
283
296
|
hovertemplate=[
|
284
297
|
self._get_hover_template(trace_name) for i in range(df.shape[0])
|
285
298
|
],
|
@@ -45,9 +45,25 @@ def format_as_human_readable(
|
|
45
45
|
value = value_to_format / 1_000
|
46
46
|
value_suffix = "k"
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
if
|
48
|
+
# Handle negative numbers
|
49
|
+
is_negative = value < 0
|
50
|
+
if is_negative:
|
51
51
|
prefix = f"-{prefix}"
|
52
52
|
value = abs(value)
|
53
|
-
|
53
|
+
|
54
|
+
if decimal_places is not None:
|
55
|
+
if decimal_places < 0:
|
56
|
+
# Round to significant digits when decimal_places is negative
|
57
|
+
magnitude = 10 ** (-decimal_places)
|
58
|
+
value = round(value / magnitude) * magnitude
|
59
|
+
formatted_value = (
|
60
|
+
f"{value:g}" # Use general format to show significant digits
|
61
|
+
)
|
62
|
+
else:
|
63
|
+
# Round to the specified number of decimal places
|
64
|
+
value = round(value, decimal_places)
|
65
|
+
formatted_value = f"{value:.{decimal_places}f}"
|
66
|
+
else:
|
67
|
+
formatted_value = f"{value:g}"
|
68
|
+
|
69
|
+
return f"{prefix}{formatted_value}{value_suffix}{suffix}"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: gov_uk_dashboards
|
3
|
-
Version: 21.
|
3
|
+
Version: 21.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
|
@@ -71,7 +71,7 @@ gov_uk_dashboards/components/dash/warning_text.py,sha256=31XvPUINt2QsWIaaMnqEvn2
|
|
71
71
|
gov_uk_dashboards/components/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
72
72
|
gov_uk_dashboards/components/helpers/display_chart_or_table_with_header.py,sha256=wDK8VUfaK4cfJDwafN_U1tf4R0kxzv9_V98vnXO-sio,3255
|
73
73
|
gov_uk_dashboards/components/helpers/generate_dash_graph_from_figure.py,sha256=sdhC6Mjfw6kqs1MDRDoMuOt8dNS9Bl1WEoJX9S5AssA,1813
|
74
|
-
gov_uk_dashboards/components/helpers/get_chart_for_download.py,sha256=
|
74
|
+
gov_uk_dashboards/components/helpers/get_chart_for_download.py,sha256=I0IH7bE3B8UmdIHTn5tM26iGR6bfnB_fCfgnFQEIF4o,1179
|
75
75
|
gov_uk_dashboards/components/helpers/plotting_helper_functions.py,sha256=WUif1mlSgWPuTZptBqaElWpJTlitmuiJofMTpOe_Bsg,1833
|
76
76
|
gov_uk_dashboards/components/helpers/update_layout_bgcolor_margin.py,sha256=i7Nwp0CxFpkyQeR8KfOBVMBkzctG7hMpWI2OzgxB2jY,740
|
77
77
|
gov_uk_dashboards/components/leaflet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -80,7 +80,7 @@ gov_uk_dashboards/components/plotly/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQ
|
|
80
80
|
gov_uk_dashboards/components/plotly/captioned_figure.py,sha256=T0sbtGTiJ79FXxVdPb__hqISuyTc3Dl11cKhgcuW-5U,2804
|
81
81
|
gov_uk_dashboards/components/plotly/choropleth_map.py,sha256=U9RmS3MZGloQAt9HoSYh3Xad205DDfZOjz91ZD_ydbI,9849
|
82
82
|
gov_uk_dashboards/components/plotly/enums.py,sha256=ebHiFQljA7O4HJxKoslqlNXcAjUZi1askpTSwxKEcYQ,850
|
83
|
-
gov_uk_dashboards/components/plotly/stacked_barchart.py,sha256=
|
83
|
+
gov_uk_dashboards/components/plotly/stacked_barchart.py,sha256=AVX9w6_TlAXOkJVmQL_owd60AW5QXSrL4Jb2bwSMElE,14716
|
84
84
|
gov_uk_dashboards/components/plotly/time_series_chart.py,sha256=6mfNPStKmP9T1OmKZtLg8NIWglLm5svggSDcEApKABU,24737
|
85
85
|
gov_uk_dashboards/figures/__init__.py,sha256=_snQeNlM81nNKERl4gg9ScH2HYbtwaBjl8yQonccx34,712
|
86
86
|
gov_uk_dashboards/figures/chart_data.py,sha256=fEsNkQFzXKIQ0h7aLBWq3J1qAxHbxvJeKU23JrVodVc,757
|
@@ -90,7 +90,7 @@ gov_uk_dashboards/figures/enums/dash_patterns.py,sha256=wEdjOe1UDx2u7tG8p4vN1000
|
|
90
90
|
gov_uk_dashboards/figures/styles/__init__.py,sha256=wVa8BU0TvXnanksOUVWN4utFKW4OTLC5q-7J07rPE6Y,215
|
91
91
|
gov_uk_dashboards/figures/styles/line_style.py,sha256=sXc9pGrAVxFrxqXSTsrw0hEgyhmhMOLhqhwx93J-PtI,559
|
92
92
|
gov_uk_dashboards/formatting/__init__.py,sha256=bQk9_OEubUhuTRQjXUs4ZItgSY7yyDpwQcLauxf11Tk,460
|
93
|
-
gov_uk_dashboards/formatting/human_readable.py,sha256=
|
93
|
+
gov_uk_dashboards/formatting/human_readable.py,sha256=o5-Xlbm7wP_4wU9mIdsG0ztU5aDEL4nZnJ-z5uA9QwI,2437
|
94
94
|
gov_uk_dashboards/formatting/number_formatting.py,sha256=9LVqKqx0mMQyv8XLI_im1pdASZDJxRjzRWtRN-g6kPs,913
|
95
95
|
gov_uk_dashboards/formatting/round_and_add_prefix_and_suffix.py,sha256=_DboRfdvwb9Y62H9LFDFJ0ju4626z-_oFuwagRgyZDY,1456
|
96
96
|
gov_uk_dashboards/formatting/rounding.py,sha256=Em1yri_j18IYHbZ64d3bhVKX-XEllRSM9FzAUo1o6fU,968
|
@@ -106,8 +106,8 @@ gov_uk_dashboards/lib/datetime_functions/datetime_functions.py,sha256=BQgr8I_vFN
|
|
106
106
|
gov_uk_dashboards/lib/download_functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
107
107
|
gov_uk_dashboards/lib/download_functions/convert_fig_to_image_and_download.py,sha256=-dkYbpTL6txftFfAZW-vfW_O9efb6Dse9WJ9MM6mAqw,534
|
108
108
|
gov_uk_dashboards/lib/download_functions/download_csv_with_headers.py,sha256=uKMxKrdhaLj1c0ZWAmc02uu8PICjbn1fWt9YBw8FGnQ,4408
|
109
|
-
gov_uk_dashboards-21.
|
110
|
-
gov_uk_dashboards-21.
|
111
|
-
gov_uk_dashboards-21.
|
112
|
-
gov_uk_dashboards-21.
|
113
|
-
gov_uk_dashboards-21.
|
109
|
+
gov_uk_dashboards-21.1.0.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
|
110
|
+
gov_uk_dashboards-21.1.0.dist-info/METADATA,sha256=9tniS5FEZhzGdIV4dZjeFYL4PjAD9fm3lRHYbb_4yJ0,5917
|
111
|
+
gov_uk_dashboards-21.1.0.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
112
|
+
gov_uk_dashboards-21.1.0.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
|
113
|
+
gov_uk_dashboards-21.1.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|