gov-uk-dashboards 17.2.0__tar.gz → 18.1.0__tar.gz

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.
Files changed (119) hide show
  1. {gov_uk_dashboards-17.2.0/gov_uk_dashboards.egg-info → gov_uk_dashboards-18.1.0}/PKG-INFO +1 -1
  2. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/custom_map_style_functions.js +29 -0
  3. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/dashboard.css +4 -0
  4. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/leaflet/leaflet_choropleth_map.py +60 -17
  5. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0/gov_uk_dashboards.egg-info}/PKG-INFO +1 -1
  6. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/setup.py +1 -1
  7. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/LICENSE +0 -0
  8. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/MANIFEST.in +0 -0
  9. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/README.md +0 -0
  10. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/__init__.py +0 -0
  11. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/__init__.py +0 -0
  12. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/attach-event-to-dash.js +0 -0
  13. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/fonts/bold-affa96571d-v2.woff +0 -0
  14. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/fonts/bold-b542beb274-v2.woff2 +0 -0
  15. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/fonts/light-94a07e06a1-v2.woff2 +0 -0
  16. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/fonts/light-f591b13f7d-v2.woff +0 -0
  17. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/get_assets_folder.py +0 -0
  18. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/govuk-frontend-3.14.0.min.js +0 -0
  19. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/DLUHC_WHITE_Master_AW_sm.png +0 -0
  20. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/MHCLG-favicon.png +0 -0
  21. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/MHCLG_favicon.png +0 -0
  22. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/dcms_coatofarms.png +0 -0
  23. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/dluhc_favicon.ico +0 -0
  24. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/gov_favicon.ico +0 -0
  25. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/govuk-crest.svg +0 -0
  26. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/hm-government-logo.png +0 -0
  27. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/mhclg_coat_of_arms.png +0 -0
  28. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/mhclg_white_no_background.png +0 -0
  29. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/oflog/MedianAbsolute.png +0 -0
  30. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/oflog/how_to_1_selecting_data.png +0 -0
  31. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/oflog/how_to_2_viewing_tabs.png +0 -0
  32. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/oflog/how_to_3_viewing_charts.png +0 -0
  33. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/oflog/how_to_4_viewing_trends.png +0 -0
  34. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/images/oflog/how_to_5_viewing_tables.png +0 -0
  35. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/mobile-nav.js +0 -0
  36. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/topojson/usa_110m.json +0 -0
  37. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/assets/topojson/world_110m.json +0 -0
  38. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/axes.py +0 -0
  39. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/colours.py +0 -0
  40. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/__init__.py +0 -0
  41. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/__init__.py +0 -0
  42. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/apply_and_reset_filters_buttons.py +0 -0
  43. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/banners.py +0 -0
  44. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/card.py +0 -0
  45. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/card_full_width.py +0 -0
  46. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/collapsible_panel.py +0 -0
  47. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/comparison_la_filter_button.py +0 -0
  48. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/context_banner.py +0 -0
  49. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/dashboard_container.py +0 -0
  50. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/details.py +0 -0
  51. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/download_button.py +0 -0
  52. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/filter_panel.py +0 -0
  53. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/footer.py +0 -0
  54. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/graph.py +0 -0
  55. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/header.py +0 -0
  56. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/heading.py +0 -0
  57. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/home_page_link_button.py +0 -0
  58. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/html_list.py +0 -0
  59. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/key_value_pair.py +0 -0
  60. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/main_content.py +0 -0
  61. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/navbar.py +0 -0
  62. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/no_data_message.py +0 -0
  63. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/notification_banner.py +0 -0
  64. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/paragraph.py +0 -0
  65. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/phase_banner.py +0 -0
  66. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/row_component.py +0 -0
  67. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/side_navbar.py +0 -0
  68. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/table.py +0 -0
  69. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/tooltip.py +0 -0
  70. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/tooltip_title.py +0 -0
  71. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/visualisation_commentary.py +0 -0
  72. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/visualisation_title.py +0 -0
  73. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/dash/warning_text.py +0 -0
  74. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/helpers/__init__.py +0 -0
  75. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/helpers/display_chart_or_table_with_header.py +0 -0
  76. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/helpers/generate_dash_graph_from_figure.py +0 -0
  77. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/helpers/get_chart_for_download.py +0 -0
  78. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/helpers/plotting_helper_functions.py +0 -0
  79. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/helpers/update_layout_bgcolor_margin.py +0 -0
  80. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/leaflet/__init__.py +0 -0
  81. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/plotly/__init__.py +0 -0
  82. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/plotly/captioned_figure.py +0 -0
  83. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/plotly/choropleth_map.py +0 -0
  84. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/plotly/enums.py +0 -0
  85. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/plotly/stacked_barchart.py +0 -0
  86. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/components/plotly/time_series_chart.py +0 -0
  87. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/constants.py +0 -0
  88. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/figures/__init__.py +0 -0
  89. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/figures/chart_data.py +0 -0
  90. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/figures/enums/__init__.py +0 -0
  91. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/figures/enums/dash_patterns.py +0 -0
  92. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/figures/line_chart.py +0 -0
  93. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/figures/styles/__init__.py +0 -0
  94. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/figures/styles/line_style.py +0 -0
  95. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/formatting/__init__.py +0 -0
  96. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/formatting/human_readable.py +0 -0
  97. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/formatting/number_formatting.py +0 -0
  98. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/formatting/round_and_add_prefix_and_suffix.py +0 -0
  99. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/formatting/rounding.py +0 -0
  100. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/lib/__init__.py +0 -0
  101. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/lib/dap/__init__.py +0 -0
  102. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/lib/dap/dap_deployment.py +0 -0
  103. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/lib/dap/get_dataframe_from_cds.py +0 -0
  104. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/lib/datetime_functions/__init__.py +0 -0
  105. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/lib/datetime_functions/datetime_functions.py +0 -0
  106. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/lib/download_functions/__init__.py +0 -0
  107. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/lib/download_functions/convert_fig_to_image_and_download.py +0 -0
  108. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/lib/download_functions/download_csv_with_headers.py +0 -0
  109. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/lib/enable_basic_auth.py +0 -0
  110. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/lib/http_headers.py +0 -0
  111. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/lib/logging.py +0 -0
  112. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/symbols.py +0 -0
  113. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/template.html +0 -0
  114. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards/template.py +0 -0
  115. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards.egg-info/SOURCES.txt +0 -0
  116. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards.egg-info/dependency_links.txt +0 -0
  117. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards.egg-info/requires.txt +0 -0
  118. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/gov_uk_dashboards.egg-info/top_level.txt +0 -0
  119. {gov_uk_dashboards-17.2.0 → gov_uk_dashboards-18.1.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gov_uk_dashboards
3
- Version: 17.2.0
3
+ Version: 18.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
@@ -35,6 +35,35 @@ window.myNamespace = Object.assign({}, window.myNamespace, {
35
35
  const local_t = (t * n) - idx;
36
36
  const fillColor = interpolateColor(colors[idx], colors[idx + 1], local_t);
37
37
 
38
+ return {
39
+ ...style,
40
+ fillColor: fillColor
41
+ };
42
+ },
43
+ discreteColorScale: function(feature, context) {
44
+ const {
45
+ colorscale, // e.g., ["#d7191c", "#fdae61", "#abdda4", "#2b83ba"]
46
+ colorProp, // e.g., "category"
47
+ style,
48
+ min // e.g., 1
49
+ } = context.hideout;
50
+
51
+ const value = feature.properties[colorProp];
52
+ const colors = Array.from(colorscale); // ensure no mutation
53
+
54
+ if (value === null || value === undefined) {
55
+ return {
56
+ ...style,
57
+ fillColor: "#b1b4b6" // default gray
58
+ };
59
+ }
60
+
61
+ // Convert value to zero-based index
62
+ const idx = value - min;
63
+
64
+ // Defensive check
65
+ const fillColor = colors[idx] || "#b1b4b6";
66
+
38
67
  return {
39
68
  ...style,
40
69
  fillColor: fillColor
@@ -9347,4 +9347,8 @@ mark.expenditure {
9347
9347
 
9348
9348
  .font-weight-normal-override {
9349
9349
  font-weight: normal !important;
9350
+ }
9351
+
9352
+ .leaflet-interactive:focus {
9353
+ outline: none !important;
9350
9354
  }
@@ -3,6 +3,7 @@
3
3
  from typing import Optional
4
4
  from dash_extensions.javascript import arrow_function, Namespace
5
5
  import dash_leaflet as dl
6
+ import dash_leaflet.express as dlx
6
7
  from dash import html
7
8
  import polars as pl
8
9
 
@@ -31,8 +32,12 @@ class LeafletChoroplethMap:
31
32
  geojson: dict,
32
33
  df: pl.DataFrame,
33
34
  hover_text_columns: list[str],
35
+ column_to_plot: str,
36
+ legend_column: str,
37
+ area_column: str,
34
38
  title: str,
35
39
  subtitle: Optional[str] = None,
40
+ enable_zoom: bool = True,
36
41
  download_chart_button_id: Optional[str] = None,
37
42
  download_data_button_id: Optional[str] = None,
38
43
  color_scale_is_discrete: bool = True,
@@ -41,8 +46,12 @@ class LeafletChoroplethMap:
41
46
  self.geojson_data = geojson
42
47
  self.df = df
43
48
  self.hover_text_columns = hover_text_columns
49
+ self.column_to_plot = column_to_plot
50
+ self.legend_column = legend_column
51
+ self.area_column = area_column
44
52
  self.title = title
45
53
  self.subtitle = subtitle
54
+ self.enable_zoom = enable_zoom
46
55
  self.download_chart_button_id = download_chart_button_id
47
56
  self.download_data_button_id = download_data_button_id
48
57
  self.color_scale_is_discrete = color_scale_is_discrete
@@ -55,6 +64,14 @@ class LeafletChoroplethMap:
55
64
  Returns:
56
65
  dl.Map: A dash leaflet map chart.
57
66
  """
67
+ disabled_zoom_controls = {
68
+ "scrollWheelZoom": False,
69
+ "dragging": False,
70
+ "zoomControl": False,
71
+ "doubleClickZoom": False,
72
+ "touchZoom": False,
73
+ }
74
+ zoom_controls = {} if self.enable_zoom else disabled_zoom_controls
58
75
  choropleth_map = dl.Map(
59
76
  children=[
60
77
  dl.TileLayer() if self.show_tile_layer else None,
@@ -65,13 +82,9 @@ class LeafletChoroplethMap:
65
82
  center=[54.5, -2.5], # Centered on the UK
66
83
  zoom=6.5,
67
84
  minZoom=6.5,
68
- maxZoom=6.5,
85
+ maxZoom=10 if self.enable_zoom else 6.5,
69
86
  maxBounds=[[49.8, -10], [55.9, 1.8]],
70
- scrollWheelZoom=False, # Disable zooming via mouse scroll
71
- dragging=False, # Optional: prevent dragging too if you want
72
- zoomControl=False, # Hide the zoom buttons (+/-)
73
- doubleClickZoom=False, # Prevent double click zoom
74
- touchZoom=False, # Prevent pinch zoom
87
+ **zoom_controls,
75
88
  attributionControl=False,
76
89
  style={"width": "100%", "height": "800px", "background": "white"},
77
90
  )
@@ -86,8 +99,8 @@ class LeafletChoroplethMap:
86
99
  def _add_data_to_geojson(self):
87
100
  info_map = {
88
101
  row["Area_Code"]: {
89
- "value": row["Value"],
90
- "region": row["Region"],
102
+ "value": row[self.column_to_plot],
103
+ "area": row[self.area_column],
91
104
  **{col: row[col] for col in self.hover_text_columns},
92
105
  }
93
106
  for row in self.df.iter_rows(named=True)
@@ -99,9 +112,9 @@ class LeafletChoroplethMap:
99
112
  if info:
100
113
 
101
114
  feature["properties"]["density"] = info["value"]
102
- feature["properties"]["region"] = info["region"]
115
+ feature["properties"]["area"] = info["area"]
103
116
 
104
- tooltip_parts = [f"<b>{info['region']}</b>"]
117
+ tooltip_parts = [f"<b>{info['area']}</b>"]
105
118
  if info["value"] is None:
106
119
  tooltip_parts.append("<br>No data available")
107
120
  else:
@@ -111,7 +124,7 @@ class LeafletChoroplethMap:
111
124
  feature["properties"]["tooltip"] = "".join(tooltip_parts)
112
125
  else:
113
126
  feature["properties"]["density"] = None
114
- feature["properties"]["region"] = "Unknown"
127
+ feature["properties"]["area"] = "Unknown"
115
128
  feature["properties"]["tooltip"] = "No data available"
116
129
 
117
130
  def _get_dl_geojson(self):
@@ -135,26 +148,54 @@ class LeafletChoroplethMap:
135
148
  "colorscale": colorscale, # Use hex strings
136
149
  "style": style,
137
150
  "colorProp": "density",
138
- "min": self.df["Value"].min(),
139
- "max": self.df["Value"].max(),
151
+ "min": self.df[self.column_to_plot].min(),
152
+ "max": self.df[self.column_to_plot].max(),
140
153
  },
141
154
  )
142
155
 
143
156
  def _get_style_handle(self):
144
157
  ns = Namespace("myNamespace", "mapColorScaleFunctions")
145
158
  if self.color_scale_is_discrete:
146
- return ""
159
+ return ns("discreteColorScale")
147
160
  return ns("continuousColorScale")
148
161
 
149
162
  def _get_colorscale(self):
150
163
  if self.color_scale_is_discrete:
151
- return ""
164
+ discrete_colours = ["#217847", "#23BBBE", "#8CCE69", "#FFEA80"]
165
+ if len(self.df[self.column_to_plot].unique()) == 3:
166
+ discrete_colours.pop(1)
167
+ return discrete_colours
152
168
  return ["#B0F2BC", "#257D98"]
153
169
 
170
+ def _get_color_bar_categories(self):
171
+ return (
172
+ self.df.select([self.legend_column, self.column_to_plot])
173
+ .unique()
174
+ .sort(self.column_to_plot, descending=True)
175
+ .select(self.legend_column)
176
+ .to_series()
177
+ .to_list()
178
+ )
179
+
154
180
  def _get_colorbar(self):
155
- min_value = self.df.select(pl.min("Value")).item()
181
+ if self.color_scale_is_discrete:
182
+ self._get_color_bar_categories()
183
+ return dlx.categorical_colorbar(
184
+ categories=self._get_color_bar_categories(), # reversed order
185
+ colorscale=self._get_colorscale()[::-1],
186
+ width=30,
187
+ height=200,
188
+ position="topleft",
189
+ style={
190
+ "padding": "6px",
191
+ "backgroundColor": "white",
192
+ "borderRadius": "4px",
193
+ "fontSize": "16px",
194
+ },
195
+ )
196
+ min_value = self.df.select(pl.min(self.column_to_plot)).item()
156
197
  colorbar_min = min(min_value, 0)
157
- max_value = self.df.select(pl.max("Value")).item()
198
+ max_value = self.df.select(pl.max(self.column_to_plot)).item()
158
199
  mid_value = (colorbar_min + max_value) / 2
159
200
  quarter_value = (colorbar_min + max_value) / 4
160
201
  three_quarter_value = 3 * (colorbar_min + max_value) / 4
@@ -187,6 +228,8 @@ class LeafletChoroplethMap:
187
228
  )
188
229
 
189
230
  def _get_colorbar_title(self):
231
+ if self.color_scale_is_discrete:
232
+ return None
190
233
  return html.Div(
191
234
  self.hover_text_columns[0],
192
235
  style={
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gov_uk_dashboards
3
- Version: 17.2.0
3
+ Version: 18.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
@@ -10,7 +10,7 @@ setup(
10
10
  author="Department for Levelling Up, Housing and Communities",
11
11
  description="Provides access to functionality common to creating a data dashboard.",
12
12
  name="gov_uk_dashboards",
13
- version="17.2.0",
13
+ version="18.1.0",
14
14
  long_description=long_description,
15
15
  long_description_content_type="text/markdown",
16
16
  packages=find_packages(),