gov-uk-dashboards 17.1.0__py3-none-any.whl → 17.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.
@@ -1,10 +1,14 @@
1
1
  """Leaflet choropleth map class"""
2
2
 
3
+ from typing import Optional
3
4
  from dash_extensions.javascript import arrow_function, Namespace
4
5
  import dash_leaflet as dl
5
6
  from dash import html
6
7
  import polars as pl
7
8
 
9
+ from gov_uk_dashboards.components.helpers.display_chart_or_table_with_header import (
10
+ display_chart_or_table_with_header,
11
+ )
8
12
  from gov_uk_dashboards.formatting.number_formatting import (
9
13
  format_number_into_thousands_or_millions,
10
14
  )
@@ -18,18 +22,31 @@ class LeafletChoroplethMap:
18
22
  discrete"""
19
23
 
20
24
  # pylint: disable=too-few-public-methods
25
+ # pylint: disable=too-many-instance-attributes
26
+ # pylint: disable=too-many-arguments
27
+ # pylint: disable=too-many-positional-arguments
21
28
 
22
29
  def __init__(
23
30
  self,
24
- get_geojson_function,
25
- get_df_function,
26
- hover_text_columns,
27
- color_scale_is_discrete=True,
31
+ geojson: dict,
32
+ df: pl.DataFrame,
33
+ hover_text_columns: list[str],
34
+ title: str,
35
+ subtitle: Optional[str] = None,
36
+ download_chart_button_id: Optional[str] = None,
37
+ download_data_button_id: Optional[str] = None,
38
+ color_scale_is_discrete: bool = True,
39
+ show_tile_layer: bool = False,
28
40
  ):
29
- self.geojson_data = get_geojson_function()
30
- self.df = get_df_function()
41
+ self.geojson_data = geojson
42
+ self.df = df
31
43
  self.hover_text_columns = hover_text_columns
44
+ self.title = title
45
+ self.subtitle = subtitle
46
+ self.download_chart_button_id = download_chart_button_id
47
+ self.download_data_button_id = download_data_button_id
32
48
  self.color_scale_is_discrete = color_scale_is_discrete
49
+ self.show_tile_layer = show_tile_layer
33
50
  self._add_data_to_geojson()
34
51
 
35
52
  def get_leaflet_choropleth_map(self):
@@ -38,9 +55,9 @@ class LeafletChoroplethMap:
38
55
  Returns:
39
56
  dl.Map: A dash leaflet map chart.
40
57
  """
41
- return dl.Map(
58
+ choropleth_map = dl.Map(
42
59
  children=[
43
- dl.TileLayer(),
60
+ dl.TileLayer() if self.show_tile_layer else None,
44
61
  self._get_colorbar(),
45
62
  self._get_colorbar_title(),
46
63
  self._get_dl_geojson(),
@@ -58,6 +75,13 @@ class LeafletChoroplethMap:
58
75
  attributionControl=False,
59
76
  style={"width": "100%", "height": "800px", "background": "white"},
60
77
  )
78
+ return display_chart_or_table_with_header(
79
+ choropleth_map,
80
+ self.title,
81
+ self.subtitle,
82
+ self.download_chart_button_id,
83
+ self.download_data_button_id,
84
+ )
61
85
 
62
86
  def _add_data_to_geojson(self):
63
87
  info_map = {
@@ -93,7 +117,12 @@ class LeafletChoroplethMap:
93
117
  def _get_dl_geojson(self):
94
118
  style_handle = self._get_style_handle()
95
119
  colorscale = self._get_colorscale()
96
- style = {"weight": 2, "opacity": 1, "color": "white", "fillOpacity": 1}
120
+ style = {
121
+ "weight": 2,
122
+ "opacity": 1,
123
+ "color": "white",
124
+ "fillOpacity": 0.7 if self.show_tile_layer else 1,
125
+ }
97
126
  hover_style = arrow_function({"weight": 5, "color": "#666", "dashArray": ""})
98
127
  return dl.GeoJSON(
99
128
  data=self.geojson_data,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gov_uk_dashboards
3
- Version: 17.1.0
3
+ Version: 17.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
@@ -75,7 +75,7 @@ gov_uk_dashboards/components/helpers/get_chart_for_download.py,sha256=RS5SR2tCQP
75
75
  gov_uk_dashboards/components/helpers/plotting_helper_functions.py,sha256=moD2tse2FqTBW2rOHOvZCL9BIlmDbyvU5233yFFu_aI,1635
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
78
- gov_uk_dashboards/components/leaflet/leaflet_choropleth_map.py,sha256=4ysc-FxRKGPSkNuJBDtjlEOGthC7EuIliaillqX2GeI,6221
78
+ gov_uk_dashboards/components/leaflet/leaflet_choropleth_map.py,sha256=UFLRIr2j_GTap3MzL89DUjpdnKf7OI_kaw91VeF0ztI,7310
79
79
  gov_uk_dashboards/components/plotly/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
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
@@ -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=JYDpWObBsiKG5Rtk2ElOTgHwfIR0cRmVocr8RlTfPZQ,534
108
108
  gov_uk_dashboards/lib/download_functions/download_csv_with_headers.py,sha256=h50ejODCjoz9z-yqDt6nsE6jN6XxJN1DWH66CjLJiCk,4155
109
- gov_uk_dashboards-17.1.0.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
110
- gov_uk_dashboards-17.1.0.dist-info/METADATA,sha256=6wQUDbkJ1690nFpTKm5XfCPwIDhvWGgXONm6bI8xoA8,5917
111
- gov_uk_dashboards-17.1.0.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
112
- gov_uk_dashboards-17.1.0.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
113
- gov_uk_dashboards-17.1.0.dist-info/RECORD,,
109
+ gov_uk_dashboards-17.2.0.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
110
+ gov_uk_dashboards-17.2.0.dist-info/METADATA,sha256=XZrUEgGdjxi9hrX_3QcyRXoYCVJmYGxz0ZgtpQOHJ2Y,5917
111
+ gov_uk_dashboards-17.2.0.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
112
+ gov_uk_dashboards-17.2.0.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
113
+ gov_uk_dashboards-17.2.0.dist-info/RECORD,,