gov-uk-dashboards 19.0.0__py3-none-any.whl → 19.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.
@@ -67,6 +67,7 @@ class StackedBarChart:
67
67
  hover_distance: Optional[int] = 1,
68
68
  download_chart_button_id: Optional[str] = None,
69
69
  download_data_button_id: Optional[str] = None,
70
+ total_trace_name: Optional[str] = None,
70
71
  ):
71
72
  """Initializes the StackedBarChart instance.
72
73
  To display the chart, call the `get_stacked_bar_chart()` method.
@@ -90,6 +91,9 @@ class StackedBarChart:
90
91
  if applicable. Defaults to None.
91
92
  download_data_button_id (Optional[str], optional): ID for the data download button, if
92
93
  applicable. Defaults to None.
94
+ total_trace_name (Optional[str], optional): Name for an optional total to be added to
95
+ bottom of hover text, must be in MEASURE column of df, line_trace_name will display
96
+ in legend. Defaults to None.
93
97
  """
94
98
  self.title_data = title_data
95
99
  self.y_axis_column = y_axis_column
@@ -104,6 +108,7 @@ class StackedBarChart:
104
108
  self.hover_distance = hover_distance
105
109
  self.download_chart_button_id = download_chart_button_id
106
110
  self.download_data_button_id = download_data_button_id
111
+ self.total_trace_name = total_trace_name
107
112
  self.fig = self.create_stacked_bar_chart()
108
113
 
109
114
  def get_stacked_bar_chart(self) -> html.Div:
@@ -173,6 +178,23 @@ class StackedBarChart:
173
178
  # pylint: disable=too-many-locals
174
179
 
175
180
  fig = go.Figure()
181
+ if self.total_trace_name is not None:
182
+ df = self.df.filter(pl.col(MEASURE) == self.total_trace_name)
183
+
184
+ fig.add_trace(
185
+ go.Scatter(
186
+ x=df[self.x_axis_column],
187
+ y=df[self.y_axis_column],
188
+ customdata=self._get_custom_data(self.total_trace_name, df),
189
+ mode="markers",
190
+ marker={"color": "white", "opacity": 0},
191
+ name=self.total_trace_name + LEGEND_SPACING,
192
+ hovertemplate="Total income: %{customdata[0]}<extra></extra>",
193
+ showlegend=False,
194
+ hoverinfo="skip",
195
+ legendrank=1,
196
+ )
197
+ )
176
198
  colour_list = (
177
199
  AFAccessibleColours.CATEGORICAL.value
178
200
  if len(self.trace_name_list) != 2
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gov_uk_dashboards
3
- Version: 19.0.0
3
+ Version: 19.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
@@ -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=07egbXxZwWyhlwniQzbr7iBNGJkE2pdw96JaQSwdEGY,13111
83
+ gov_uk_dashboards/components/plotly/stacked_barchart.py,sha256=61VgvGJhFX7C4QAk-A8ZF6DTNjDvZ7uU3vof54H5km4,14187
84
84
  gov_uk_dashboards/components/plotly/time_series_chart.py,sha256=QD9HjXLjNIBA-NBZQUSL3TyIAvRGrBzwnYrRboROECg,23002
85
85
  gov_uk_dashboards/figures/__init__.py,sha256=_snQeNlM81nNKERl4gg9ScH2HYbtwaBjl8yQonccx34,712
86
86
  gov_uk_dashboards/figures/chart_data.py,sha256=fEsNkQFzXKIQ0h7aLBWq3J1qAxHbxvJeKU23JrVodVc,757
@@ -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-19.0.0.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
110
- gov_uk_dashboards-19.0.0.dist-info/METADATA,sha256=sp97E7xIhHGjoadUdtujJEuoKX3plUBKJNPSHTLegV8,5917
111
- gov_uk_dashboards-19.0.0.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
112
- gov_uk_dashboards-19.0.0.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
113
- gov_uk_dashboards-19.0.0.dist-info/RECORD,,
109
+ gov_uk_dashboards-19.1.0.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
110
+ gov_uk_dashboards-19.1.0.dist-info/METADATA,sha256=FwUetPwi9LtIIGAHFPO7nxTh38AMoORL9aABOeb28PQ,5917
111
+ gov_uk_dashboards-19.1.0.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
112
+ gov_uk_dashboards-19.1.0.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
113
+ gov_uk_dashboards-19.1.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.1.0)
2
+ Generator: setuptools (80.3.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5