newsworthycharts 1.74.0__py3-none-any.whl → 1.74.2__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,4 +1,4 @@
1
- __version__ = "1.74.0"
1
+ __version__ = "1.74.2"
2
2
 
3
3
  from .chart import Chart
4
4
  from .choroplethmap import ChoroplethMap
newsworthycharts/chart.py CHANGED
@@ -2,6 +2,7 @@
2
2
  For use with Newsworthy's robot writer and other similar projects.
3
3
  """
4
4
  import types
5
+ import math
5
6
  from .lib import color_fn
6
7
  from .lib.mimetypes import MIME_TYPES
7
8
  from .lib.utils import loadstyle, outline, to_date
@@ -107,15 +108,6 @@ class Chart(object):
107
108
  if height:
108
109
  self._h = int(height)
109
110
 
110
- # Dynamic typography
111
- self._title_font = FontProperties()
112
- # scale up slightly < 600px, scale down slightly > 600px
113
- import math
114
- adjusted_fontsize = math.log(self._h, 600)
115
- self._title_font.set_family(self._nwc_style["title_font"])
116
- self._title_font.set_size(int(adjusted_fontsize * self._style["figure.titlesize"]))
117
- self._title_font.set_weight(self._style["figure.titleweight"])
118
-
119
111
  # Chart elements. Made available for fitting.
120
112
  self._title_elem = None
121
113
  self._subtitle_elem = None
@@ -496,6 +488,14 @@ class Chart(object):
496
488
  self._h = h # This was tentatively set in init. Overwritten here!
497
489
  self._set_size(self._w, h)
498
490
 
491
+ # Dynamic typography
492
+ self._title_font = FontProperties()
493
+ # scale up slightly < 600px, scale down slightly > 600px
494
+ adjusted_fontsize = math.log(self._h, 600)
495
+ self._title_font.set_family(self._nwc_style["title_font"])
496
+ self._title_font.set_size(int(adjusted_fontsize * self._style["figure.titlesize"]))
497
+ self._title_font.set_weight(self._style["figure.titleweight"])
498
+
499
499
  # Legend / data labels
500
500
  if self.legend_title:
501
501
  # Legend can contain data labels (.labels[]),
@@ -241,3 +241,4 @@ class ChoroplethMap(Map):
241
241
  **label_kwargs,
242
242
  )
243
243
  # self.ax.get_figure().savefig("TST.png", bbox_inches="tight")
244
+ self.df = df
@@ -539,7 +539,10 @@ class SerialChart(Chart):
539
539
  (x0, x1) = self.highlighted_x_ranges[idx]
540
540
  x0 = to_date(x0)
541
541
  x1 = to_date(x1)
542
+ # Put label betwen top value and axis limit
542
543
  _y = self.ymax or self.data.max_val + self.baseline
544
+ _y_top = self.ax.get_ylim()[1]
545
+ _y = _y_top - (_y_top - _y) / 2
543
546
  self.ax.text(
544
547
  x0 + (x1 - x0) / 2,
545
548
  _y,
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: newsworthycharts
3
- Version: 1.74.0
3
+ Version: 1.74.2
4
4
  Summary: Matplotlib wrapper to create charts and publish them on Amazon S3
5
5
  Home-page: https://github.com/jplusplus/newsworthycharts
6
- Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.74.0.tar.gz
6
+ Download-URL: https://github.com/jplusplus/newsworthycharts/archive/1.74.2.tar.gz
7
7
  Author: Jens Finnäs and Leo Wallentin, J++ Stockholm
8
8
  Author-email: stockholm@jplusplus.org
9
9
  License: MIT
@@ -285,6 +285,15 @@ Roadmap
285
285
  Changelog
286
286
  ---------
287
287
 
288
+ - 1.74.2
289
+
290
+ - Improved positioning of x-range annotations in SerialChart
291
+
292
+ - 1.74.1
293
+
294
+ - Wait for data to be added before calculating dynamic heights and responsive typography
295
+ - Expose dataset from Map class
296
+
288
297
  - 1.74.0
289
298
 
290
299
  - Support quarterly data in SeasonalChart
@@ -1,15 +1,15 @@
1
- newsworthycharts/__init__.py,sha256=2uH1gMho-NJHOhmxW4GiOnvQOKY5E3MXH_0oYdQYHH8,1221
1
+ newsworthycharts/__init__.py,sha256=rzXGayG5WDpEr3V4WAe9kA0paK5FCLIDy8BDMpGK3is,1221
2
2
  newsworthycharts/bubblemap.py,sha256=nkocWmpiFgfjEuJGAsthjY5X7Q56jXWsZHUGXw4PwgE,2587
3
3
  newsworthycharts/categoricalchart.py,sha256=Vr-0yFms0hEVCeUa3vLt3FYBqpX4xLQ8YGPc4LGQN_A,18368
4
- newsworthycharts/chart.py,sha256=G4STYhHcqopOhZwjBczbpcuedMofqMsHlgTVcWa5KW4,35449
5
- newsworthycharts/choroplethmap.py,sha256=mhbN0XjP4GIgiZOjFWPMbyUI94iVOgwZc7wQSWPzMDM,9688
4
+ newsworthycharts/chart.py,sha256=QDvIo_HV9fDmadBKLsPJMXrIYL6ZbHnDbVjZuzX9Srw,35441
5
+ newsworthycharts/choroplethmap.py,sha256=eJiFcUpPFnkiF8VPiHTROdMuuRXHNX8_65rdowBskpc,9709
6
6
  newsworthycharts/datawrapper.py,sha256=RRkAVTpfP4updKxUIBaSmKuBi2RUVPaBRF8HDQhlGGA,11250
7
7
  newsworthycharts/map.py,sha256=EGh96tU10y7Kgu1e83_VWQSeABdjP6V-0VM6VTHDxu4,6089
8
8
  newsworthycharts/rangeplot.py,sha256=NE1W9TnmlpK6T3RvBJOU3nd73EXqkj17OY9i5zlw_cQ,8366
9
9
  newsworthycharts/rankchart.py,sha256=vMzNMVOv1jae6wuHC_riAdb1lm9oPltO3TT3YQpc0Oc,9376
10
10
  newsworthycharts/scatterplot.py,sha256=weHubdMsDGaBTXejg2TqBNPTQ1K-QBpZqJiyQ8EOEc4,5084
11
11
  newsworthycharts/seasonalchart.py,sha256=ttT8JpvWB3DL0EcTBQor_Uxlow_6tdcl7ibEmLCpUrQ,1982
12
- newsworthycharts/serialchart.py,sha256=Km1qxTumFq0GcKPzdaaU5mhq9f2BtusQ0tbpW6WsMiw,31936
12
+ newsworthycharts/serialchart.py,sha256=0soPp2hwCYNOv1c8iTBCkh6YwXlhTDqZlR5j4k3uh3Q,32079
13
13
  newsworthycharts/storage.py,sha256=myERhlpvXyExXxUByBq9eW1bWkCyfH9SwTZbsWSyy3Q,4301
14
14
  newsworthycharts/stripechart.py,sha256=9B6PX2MyLuKNQ8W0OGdKbP0-U32kju0K_NHHwwz_J68,1547
15
15
  newsworthycharts/custom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -29,8 +29,8 @@ newsworthycharts/rc/newsworthy,sha256=yOIZvYS6PG1u19VMcdtfj9vbihKQsey5IprwqK59Kg
29
29
  newsworthycharts/translations/datawrapper_regions.csv,sha256=fzZcQRX6RFMlNNP8mpgfYNdR3Y0QAlQxDXk8FXTaWWI,9214
30
30
  newsworthycharts/translations/regions.py,sha256=Nv1McQjggD4S3JRu82rDMTG3pqUVR13E5-FBpSYbm98,239
31
31
  newsworthycharts/translations/se_municipalities.csv,sha256=br_mm-IvzQtj_W55_ATREhJ97jWnCweBFlDAVY2EBxA,7098
32
- newsworthycharts-1.74.0.dist-info/licenses/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
33
- newsworthycharts-1.74.0.dist-info/METADATA,sha256=bT5jI6b86FYklmlXoIIXMMgbQ00GM02dzSXcU_vb5wU,35148
34
- newsworthycharts-1.74.0.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
35
- newsworthycharts-1.74.0.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
36
- newsworthycharts-1.74.0.dist-info/RECORD,,
32
+ newsworthycharts-1.74.2.dist-info/licenses/LICENSE.txt,sha256=Sq6kGICrehbhC_FolNdXf0djKjTpv3YqjFCIYsxdQN4,1069
33
+ newsworthycharts-1.74.2.dist-info/METADATA,sha256=-VsTp67U9vXLQx9pUYIwGtVlwGnjqyD8UIIeffC5pcw,35358
34
+ newsworthycharts-1.74.2.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
35
+ newsworthycharts-1.74.2.dist-info/top_level.txt,sha256=dn_kzIj8UgUCMsh1PHdVEQJHVGSsN7Z8YJF-8xXa8n0,17
36
+ newsworthycharts-1.74.2.dist-info/RECORD,,