gov-uk-dashboards 21.0.1__py3-none-any.whl → 21.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.
@@ -209,7 +209,7 @@ def table_from_polars_dataframe(
209
209
  dcc.Markdown(header)
210
210
  if format_column_headers_as_markdown
211
211
  else header,
212
- id={"type": "header-button", "index": idx},
212
+ id={"type": f"{table_id}-header-button", "index": idx},
213
213
  n_clicks=0,
214
214
  )
215
215
  if header not in non_sortable_columns
@@ -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
- if decimal_places is not None:
49
- value = round(value, decimal_places)
50
- if value < 0:
48
+ # Handle negative numbers
49
+ is_negative = value < 0
50
+ if is_negative:
51
51
  prefix = f"-{prefix}"
52
52
  value = abs(value)
53
- return f"{prefix}{value:g}{value_suffix}{suffix}"
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.0.1
3
+ Version: 21.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
@@ -62,7 +62,7 @@ gov_uk_dashboards/components/dash/paragraph.py,sha256=yoWa_B6RLiebBX2QaszY3lyZEx
62
62
  gov_uk_dashboards/components/dash/phase_banner.py,sha256=7XIk_y-kStSaptXnk9yHVu8S0n-ypwWehDqOwjb5l-c,1787
63
63
  gov_uk_dashboards/components/dash/row_component.py,sha256=SdmJqyFJA1Kngyzxy0ooZUegIOiN6Bz1wRq6jGigfII,687
64
64
  gov_uk_dashboards/components/dash/side_navbar.py,sha256=pupA0FdjSbPbzdX9up6wEoIKWIuk3zGRun4opnBieCU,1332
65
- gov_uk_dashboards/components/dash/table.py,sha256=uK-J8FALpuQP7dQc8k37WS-tgg48STMlk9GyS7N_Sr4,13749
65
+ gov_uk_dashboards/components/dash/table.py,sha256=Bd_JaUOnjnaO2fzZZ_HR4QiIr7WGuaiGKrM-w-bPMog,13761
66
66
  gov_uk_dashboards/components/dash/tooltip.py,sha256=qTkRWQanhG535Yi4NiaLlEMJqqzjubgRdKJDIhxXzd4,978
67
67
  gov_uk_dashboards/components/dash/tooltip_title.py,sha256=2exMYItzR17yOu3gTL77DyUU4Hi3CIB-ZPS8ftetqZg,874
68
68
  gov_uk_dashboards/components/dash/visualisation_commentary.py,sha256=jBy8qy2DWYqodqDZ8QdDmgOO_USDSwn2Sj5CnL58VMM,648
@@ -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=61VgvGJhFX7C4QAk-A8ZF6DTNjDvZ7uU3vof54H5km4,14187
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=e-ROPS7oFLHCV58MXBIhLsZQut-F-bAYz0TOz33gX2M,1844
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.0.1.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
110
- gov_uk_dashboards-21.0.1.dist-info/METADATA,sha256=KgSOBIpsLWIQ8AcNayDEyu-TvWxUndDrD4oHoRscFyA,5917
111
- gov_uk_dashboards-21.0.1.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
112
- gov_uk_dashboards-21.0.1.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
113
- gov_uk_dashboards-21.0.1.dist-info/RECORD,,
109
+ gov_uk_dashboards-21.2.0.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
110
+ gov_uk_dashboards-21.2.0.dist-info/METADATA,sha256=NnaEZQcyBiLLbjF9jEeaH_n6e9OnPD2ZsIWBXwTwtNE,5917
111
+ gov_uk_dashboards-21.2.0.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
112
+ gov_uk_dashboards-21.2.0.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
113
+ gov_uk_dashboards-21.2.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.4.0)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5