briefing 0.2.1__tar.gz → 0.2.2__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 (105) hide show
  1. {briefing-0.2.1 → briefing-0.2.2}/CHANGELOG.md +31 -1
  2. {briefing-0.2.1 → briefing-0.2.2}/PKG-INFO +1 -1
  3. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/__init__.py +1 -1
  4. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/lab/_blocks.py +15 -1
  5. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/lab/_render_calendar.py +17 -6
  6. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/lab/static/calendar.js +57 -2
  7. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/static/report.css +8 -0
  8. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_calendar.py +95 -0
  9. {briefing-0.2.1 → briefing-0.2.2}/tests/test_contract.py +3 -0
  10. {briefing-0.2.1 → briefing-0.2.2}/tests/test_deprecations.py +21 -1
  11. {briefing-0.2.1 → briefing-0.2.2}/tests/test_lab/test_calendar.py +44 -2
  12. {briefing-0.2.1 → briefing-0.2.2}/.gitignore +0 -0
  13. {briefing-0.2.1 → briefing-0.2.2}/LICENSE +0 -0
  14. {briefing-0.2.1 → briefing-0.2.2}/README.md +0 -0
  15. {briefing-0.2.1 → briefing-0.2.2}/noxfile.py +0 -0
  16. {briefing-0.2.1 → briefing-0.2.2}/pyproject.toml +0 -0
  17. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/__main__.py +0 -0
  18. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/_cli.py +0 -0
  19. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/_error.py +0 -0
  20. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/_frames.py +0 -0
  21. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/_preview.py +0 -0
  22. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/blocks/__init__.py +0 -0
  23. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/blocks/asset.py +0 -0
  24. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/blocks/banner.py +0 -0
  25. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/blocks/base.py +0 -0
  26. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/blocks/layout.py +0 -0
  27. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/blocks/text.py +0 -0
  28. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/export/__init__.py +0 -0
  29. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/export/_image.py +0 -0
  30. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/export/_pdf.py +0 -0
  31. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/export/_render.py +0 -0
  32. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/lab/__init__.py +0 -0
  33. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/lab/_render_datadive.py +0 -0
  34. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/lab/_render_profile.py +0 -0
  35. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/lab/static/lab.js +0 -0
  36. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/py.typed +0 -0
  37. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/renderers/__init__.py +0 -0
  38. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/renderers/formatting.py +0 -0
  39. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/renderers/formula.py +0 -0
  40. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/renderers/html.py +0 -0
  41. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/renderers/normalize.py +0 -0
  42. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/renderers/plot.py +0 -0
  43. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/renderers/registry.py +0 -0
  44. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/renderers/script_json.py +0 -0
  45. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/renderers/table.py +0 -0
  46. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/static/export.css +0 -0
  47. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/static/export.js +0 -0
  48. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/static/report.js +0 -0
  49. {briefing-0.2.1 → briefing-0.2.2}/src/briefing/templates/report.html.j2 +0 -0
  50. {briefing-0.2.1 → briefing-0.2.2}/tests/__init__.py +0 -0
  51. {briefing-0.2.1 → briefing-0.2.2}/tests/banner_images.py +0 -0
  52. {briefing-0.2.1 → briefing-0.2.2}/tests/compat_reports.py +0 -0
  53. {briefing-0.2.1 → briefing-0.2.2}/tests/conftest.py +0 -0
  54. {briefing-0.2.1 → briefing-0.2.2}/tests/contract.py +0 -0
  55. {briefing-0.2.1 → briefing-0.2.2}/tests/html_helpers.py +0 -0
  56. {briefing-0.2.1 → briefing-0.2.2}/tests/image_helpers.py +0 -0
  57. {briefing-0.2.1 → briefing-0.2.2}/tests/pdf_reader.py +0 -0
  58. {briefing-0.2.1 → briefing-0.2.2}/tests/snapshots/compat_0_1_2/blocks.body.html +0 -0
  59. {briefing-0.2.1 → briefing-0.2.2}/tests/snapshots/compat_0_1_2/pages.body.html +0 -0
  60. {briefing-0.2.1 → briefing-0.2.2}/tests/test_blocks/__init__.py +0 -0
  61. {briefing-0.2.1 → briefing-0.2.2}/tests/test_blocks/test_banner.py +0 -0
  62. {briefing-0.2.1 → briefing-0.2.2}/tests/test_blocks/test_base.py +0 -0
  63. {briefing-0.2.1 → briefing-0.2.2}/tests/test_blocks/test_layout.py +0 -0
  64. {briefing-0.2.1 → briefing-0.2.2}/tests/test_blocks/test_text.py +0 -0
  65. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/__init__.py +0 -0
  66. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/conftest.py +0 -0
  67. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_banner.py +0 -0
  68. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_bignumber.py +0 -0
  69. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_cli_export.py +0 -0
  70. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_code.py +0 -0
  71. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_datadive.py +0 -0
  72. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_datatable.py +0 -0
  73. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_export_image.py +0 -0
  74. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_export_menu.py +0 -0
  75. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_export_pdf.py +0 -0
  76. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_formula.py +0 -0
  77. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_layout.py +0 -0
  78. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_notebook.py +0 -0
  79. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_plots.py +0 -0
  80. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_print.py +0 -0
  81. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_spacing.py +0 -0
  82. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_text.py +0 -0
  83. {briefing-0.2.1 → briefing-0.2.2}/tests/test_browser/test_toggle_theme.py +0 -0
  84. {briefing-0.2.1 → briefing-0.2.2}/tests/test_cli.py +0 -0
  85. {briefing-0.2.1 → briefing-0.2.2}/tests/test_compat.py +0 -0
  86. {briefing-0.2.1 → briefing-0.2.2}/tests/test_docs_gallery.py +0 -0
  87. {briefing-0.2.1 → briefing-0.2.2}/tests/test_docstrings.py +0 -0
  88. {briefing-0.2.1 → briefing-0.2.2}/tests/test_export.py +0 -0
  89. {briefing-0.2.1 → briefing-0.2.2}/tests/test_frames.py +0 -0
  90. {briefing-0.2.1 → briefing-0.2.2}/tests/test_lab/__init__.py +0 -0
  91. {briefing-0.2.1 → briefing-0.2.2}/tests/test_lab/test_datadive.py +0 -0
  92. {briefing-0.2.1 → briefing-0.2.2}/tests/test_lab/test_lab_boundary.py +0 -0
  93. {briefing-0.2.1 → briefing-0.2.2}/tests/test_lab/test_profile.py +0 -0
  94. {briefing-0.2.1 → briefing-0.2.2}/tests/test_no_viz_deps.py +0 -0
  95. {briefing-0.2.1 → briefing-0.2.2}/tests/test_pdf_reader.py +0 -0
  96. {briefing-0.2.1 → briefing-0.2.2}/tests/test_preview.py +0 -0
  97. {briefing-0.2.1 → briefing-0.2.2}/tests/test_readme.py +0 -0
  98. {briefing-0.2.1 → briefing-0.2.2}/tests/test_renderers/__init__.py +0 -0
  99. {briefing-0.2.1 → briefing-0.2.2}/tests/test_renderers/test_export_menu.py +0 -0
  100. {briefing-0.2.1 → briefing-0.2.2}/tests/test_renderers/test_formula.py +0 -0
  101. {briefing-0.2.1 → briefing-0.2.2}/tests/test_renderers/test_html.py +0 -0
  102. {briefing-0.2.1 → briefing-0.2.2}/tests/test_renderers/test_normalize.py +0 -0
  103. {briefing-0.2.1 → briefing-0.2.2}/tests/test_renderers/test_plot.py +0 -0
  104. {briefing-0.2.1 → briefing-0.2.2}/tests/test_renderers/test_reproducible.py +0 -0
  105. {briefing-0.2.1 → briefing-0.2.2}/tests/test_renderers/test_table.py +0 -0
@@ -10,6 +10,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.2.2] - 2026-11-04
14
+
15
+ ### Added
16
+
17
+ - `lab.CalendarHeatmap`: hovering a day, an hour or an event band shows a tooltip at once,
18
+ styled with the theme: the date (now with its weekday) in bold, the exact value, "below
19
+ target …" and the day's events. It also opens on keyboard focus and on tap, stays inside
20
+ the window, and never prints. The browser's slower built-in tooltip no longer doubles up;
21
+ without JavaScript it is still there (#109).
22
+
23
+ ### Changed
24
+
25
+ - `lab.CalendarHeatmap` names every weekday row of the day calendar, not just Mon, Wed
26
+ and Fri (#113).
27
+
28
+ ### Deprecated
29
+
30
+ - `lab.CalendarHeatmap`'s hour view, `views=("hours",)` or `("days", "hours")`, raises a
31
+ `DeprecationWarning`. It still works; a dedicated time-pattern heatmap (weekday × hour,
32
+ weekday × month, …) is planned to replace it, and the hour view will be removed in 0.4.0
33
+ at the earliest, never before that replacement ships (#111).
34
+
35
+ ### Fixed
36
+
37
+ - `lab.CalendarHeatmap(week_start="sunday")` put each weekday label one row off ("Sun"
38
+ on the Monday row); every label now sits on its own row (#113).
39
+ - `lab.CalendarHeatmap` shows values exactly: a non-integer of 10,000 or more read
40
+ `1.235e+04` in the tooltip and the legend; it now reads `12,345.67` (#109).
41
+
13
42
  ## [0.2.1] - 2026-11-04
14
43
 
15
44
  ### Changed
@@ -211,7 +240,8 @@ First public release.
211
240
  inherits its base's renderer.
212
241
  - Ships inline type hints (`py.typed`). Python 3.11+.
213
242
 
214
- [Unreleased]: https://github.com/jeanmidevacc/briefing/compare/v0.2.1...HEAD
243
+ [Unreleased]: https://github.com/jeanmidevacc/briefing/compare/v0.2.2...HEAD
244
+ [0.2.2]: https://github.com/jeanmidevacc/briefing/compare/v0.2.1...v0.2.2
215
245
  [0.2.1]: https://github.com/jeanmidevacc/briefing/compare/v0.2.0...v0.2.1
216
246
  [0.2.0]: https://github.com/jeanmidevacc/briefing/compare/v0.1.2...v0.2.0
217
247
  [0.1.2]: https://github.com/jeanmidevacc/briefing/compare/v0.1.1...v0.1.2
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: briefing
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Build beautiful self-contained HTML reports from Python analysis
5
5
  Project-URL: Homepage, https://github.com/jeanmidevacc/briefing
6
6
  Project-URL: Documentation, https://briefing.readthedocs.io
@@ -134,7 +134,7 @@ def stringify(
134
134
  return render_report(wrapped, name=name, formatting=formatting, now=now)
135
135
 
136
136
 
137
- __version__ = "0.2.1"
137
+ __version__ = "0.2.2"
138
138
 
139
139
  __all__: list[str] = [
140
140
  # error
@@ -155,6 +155,15 @@ class DataDive(Block):
155
155
  self.max_rows = max_rows
156
156
 
157
157
 
158
+ #: Shown once per CalendarHeatmap built with the hour view (#111).
159
+ HOURS_VIEW_DEPRECATION = (
160
+ "CalendarHeatmap: the hour view (views=('hours',) or ('days', 'hours')) is deprecated since briefing "
161
+ "0.2.2. A dedicated time-pattern heatmap (weekday x hour, weekday x month, ...) will replace it, and the "
162
+ "hour view will be removed in 0.4.0 at the earliest, never before that replacement ships. Follow "
163
+ "https://github.com/jeanmidevacc/briefing/issues/111; use views=('days',) for the day calendar alone."
164
+ )
165
+
166
+
158
167
  class CalendarHeatmap(Block):
159
168
  """GitHub-style calendar heatmap: one cell per day, weeks as columns.
160
169
 
@@ -163,6 +172,7 @@ class CalendarHeatmap(Block):
163
172
  continuously across a year boundary, with month labels and a year marker.
164
173
  The calendar fits the width available (the report or a ``Group`` column),
165
174
  between 0.6x and 2x its natural size; below that it scrolls sideways.
175
+ Hovering a cell shows its date and exact value.
166
176
 
167
177
  Args:
168
178
  df: The data, as any dataframe briefing accepts (pandas, polars, pyarrow…).
@@ -173,7 +183,9 @@ class CalendarHeatmap(Block):
173
183
  group: Column to split by: one calendar per group, stacked, on one shared colour scale.
174
184
  views: ``("days",)``, ``("hours",)`` or ``("days", "hours")``: the day calendar
175
185
  and/or a 7 × 24 weekday-by-hour grid; with both, tabs switch between them.
176
- The hour view needs timestamps with a time of day.
186
+ The hour view needs timestamps with a time of day. *Deprecated since
187
+ 0.2.2:* the hour view raises a ``DeprecationWarning`` and will be replaced
188
+ by a dedicated time-pattern heatmap (issue #111).
177
189
  tz: A time zone such as ``"America/Montreal"``. Converts timezone-aware
178
190
  timestamps only; naive timestamps and plain dates are taken as already
179
191
  local, so a date at midnight never moves to the previous day.
@@ -241,6 +253,8 @@ class CalendarHeatmap(Block):
241
253
  )
242
254
  if tz is not None:
243
255
  _check_tz(tz)
256
+ if "hours" in views:
257
+ warnings.warn(HOURS_VIEW_DEPRECATION, DeprecationWarning, stacklevel=2)
244
258
  if "hours" in views and not _has_times(frame[date]):
245
259
  raise BriefingError(
246
260
  f"CalendarHeatmap: the hour view needs a time of day, but {date!r} holds dates only. "
@@ -188,7 +188,18 @@ def _group_attr(block: CalendarHeatmap, group: str | None) -> str:
188
188
 
189
189
 
190
190
  def _fmt(v: float) -> str:
191
- return f"{int(v):,}" if float(v).is_integer() else f"{v:,.4g}"
191
+ """A value as the reader should see it, in the tooltip and the legend (#109).
192
+
193
+ Whole numbers get thousands separators; other values of 1 or more are rounded to
194
+ 2 decimals (trailing zeros dropped) and never use scientific notation; values
195
+ below 1 keep 4 significant digits, and only those below 0.0001 use an exponent.
196
+ """
197
+ v = float(v)
198
+ if v.is_integer():
199
+ return f"{int(v):,}"
200
+ if abs(v) >= 1:
201
+ return f"{v:,.2f}".rstrip("0").rstrip(".")
202
+ return f"{v:.4g}" if abs(v) >= 1e-4 else f"{v:.2e}"
192
203
 
193
204
 
194
205
  def _what(block: CalendarHeatmap) -> str:
@@ -227,9 +238,8 @@ def _days_svg(
227
238
  height = _TOP + grid_h + (len(lanes) * _LANE + 6 if lanes else 0)
228
239
  parts = [_svg_open("bf-cal__days", width, height, "Calendar heatmap")]
229
240
 
230
- for row in (0, 2, 4): # Mon, Wed, Fri
231
- name = _WEEKDAYS[(row - shift) % 7]
232
- y = _TOP + ((row + shift) % 7) * _STEP + _CELL - 1
241
+ for weekday, name in enumerate(_WEEKDAYS): # every row named, on its own row (#113)
242
+ y = _TOP + ((weekday + shift) % 7) * _STEP + _CELL - 1
233
243
  parts.append(f'<text class="bf-cal__weekday" x="0" y="{y}">{name}</text>')
234
244
 
235
245
  year_shown: int | None = None
@@ -256,16 +266,17 @@ def _days_svg(
256
266
  col, row = pos(day)
257
267
  x, y = _LEFT + col * _STEP, _TOP + row * _STEP
258
268
  value, goal = data.get(day), target(day)
269
+ when = f"{_WEEKDAYS[day.weekday()]} {day.isoformat()}"
259
270
  cls = ["bf-cal__day"]
260
271
  fill = ""
261
272
  if value is None:
262
273
  cls.append("bf-cal__day--empty")
263
- tip = f"{day.isoformat()} · no data"
274
+ tip = f"{when} · no data"
264
275
  else:
265
276
  fill, extra = colour(value)
266
277
  if extra:
267
278
  cls.append(extra)
268
- tip = f"{day.isoformat()} · {_fmt(value)} {what}"
279
+ tip = f"{when} · {_fmt(value)} {what}"
269
280
  # No data falls short of a positive target only: nothing is below a target of 0.
270
281
  if goal is not None and ((value is None and goal > 0) or (value is not None and value < goal)):
271
282
  cls.append("bf-cal__day--below")
@@ -1,4 +1,5 @@
1
- /* briefing lab: CalendarHeatmap — sizing, and on_click="rows" (click a day or an hour to list its rows). Vanilla JS. */
1
+ /* briefing lab: CalendarHeatmap — sizing, hover tooltip, and on_click="rows" (click a day or an hour to
2
+ list its rows). Vanilla JS. */
2
3
  (function () {
3
4
  'use strict';
4
5
 
@@ -27,6 +28,60 @@
27
28
  });
28
29
  });
29
30
 
31
+ // Hover tooltip (#109): instant, themed, and shown on keyboard focus and tap too. Its text comes
32
+ // from each cell's <title>, which is then removed so the browser's own slow tooltip doesn't double
33
+ // up; clickable cells keep the text as their aria-label. Built with textContent only.
34
+ var tips = [];
35
+ function hideTips() { tips.forEach(function (tip) { tip.hidden = true; }); }
36
+ function showTip(tip, cell) {
37
+ var lines = (cell.getAttribute('data-tip') || '').split(' \u00b7 ');
38
+ tip.textContent = '';
39
+ lines.forEach(function (line, i) {
40
+ var el = document.createElement(i === 0 ? 'strong' : 'div');
41
+ el.textContent = line;
42
+ tip.appendChild(el);
43
+ });
44
+ hideTips();
45
+ tip.hidden = false;
46
+ // Above the cell, centred; below it when there is no room above; always inside the window.
47
+ var box = cell.getBoundingClientRect(), gap = 6, edge = 4;
48
+ var width = tip.offsetWidth, height = tip.offsetHeight;
49
+ var left = box.left + box.width / 2 - width / 2;
50
+ left = Math.max(edge, Math.min(left, document.documentElement.clientWidth - width - edge));
51
+ var top = box.top - height - gap;
52
+ if (top < edge) top = box.bottom + gap;
53
+ tip.style.left = left + 'px';
54
+ tip.style.top = top + 'px';
55
+ }
56
+ document.querySelectorAll('.bf-calendar').forEach(function (figure) {
57
+ var tip = document.createElement('div');
58
+ tip.className = 'bf-cal__tip';
59
+ tip.setAttribute('role', 'tooltip');
60
+ tip.hidden = true;
61
+ figure.appendChild(tip);
62
+ tips.push(tip);
63
+ figure.querySelectorAll('rect.bf-cal__day, rect.bf-cal__hour, g.bf-cal__event').forEach(function (cell) {
64
+ var title = cell.querySelector('title');
65
+ if (!title) return;
66
+ cell.setAttribute('data-tip', title.textContent);
67
+ if (cell.getAttribute('role') === 'button') cell.setAttribute('aria-label', title.textContent);
68
+ cell.removeChild(title);
69
+ cell.addEventListener('mouseenter', function () { showTip(tip, cell); });
70
+ cell.addEventListener('mouseleave', hideTips);
71
+ cell.addEventListener('focus', function () { showTip(tip, cell); });
72
+ cell.addEventListener('blur', hideTips);
73
+ cell.addEventListener('pointerdown', function (e) { if (e.pointerType !== 'mouse') showTip(tip, cell); });
74
+ });
75
+ });
76
+ if (tips.length) {
77
+ // A tap elsewhere, scrolling (the page or a calendar's own scroll box) or Escape hides it.
78
+ document.addEventListener('pointerdown', function (e) {
79
+ if (!(e.target.closest && e.target.closest('[data-tip]'))) hideTips();
80
+ });
81
+ window.addEventListener('scroll', hideTips, true);
82
+ document.addEventListener('keydown', function (e) { if (e.key === 'Escape') hideTips(); });
83
+ }
84
+
30
85
  document.querySelectorAll('.bf-calendar').forEach(function (figure) {
31
86
  var dataEl = figure.querySelector('script.bf-cal__rows');
32
87
  if (!dataEl) return;
@@ -42,7 +97,7 @@
42
97
  var date = cell.getAttribute('data-date');
43
98
  var key = (date ? 'd|' + date : 'h|' + cell.getAttribute('data-hour')) + (group !== null ? '|' + group : '');
44
99
  var entry = data.cells[key];
45
- var when = cell.querySelector('title').textContent.split(' · ')[0];
100
+ var when = (cell.getAttribute('data-tip') || '').split(' \u00b7 ')[0];
46
101
  var count = entry ? entry.total + (entry.total === 1 ? ' row' : ' rows') : 'no rows';
47
102
  title.textContent = [when, group, count].filter(function (x) { return x !== null; }).join(' · ');
48
103
  body.textContent = '';
@@ -736,6 +736,13 @@ body {
736
736
  .bf-cal__swatch--empty { border: 1px dashed var(--bf-border); }
737
737
  .bf-cal__swatch--below { border: 1.5px solid #dc2626; }
738
738
  .bf-calendar rect[role="button"] { cursor: pointer; outline: none; }
739
+ /* Hover tooltip (#109), positioned by calendar.js in window coordinates. */
740
+ .bf-cal__tip { position: fixed; z-index: 20; max-width: 260px; padding: 0.35rem 0.55rem;
741
+ background: var(--bf-text); color: var(--bf-bg); font-size: 0.75rem; line-height: 1.45;
742
+ border-radius: 0.375rem; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); pointer-events: none; }
743
+ .bf-cal__tip[hidden] { display: none; }
744
+ .bf-cal__tip strong { display: block; font-weight: 600; }
745
+ .bf-calendar rect.bf-cal__day:hover, .bf-calendar rect.bf-cal__hour:hover { stroke: var(--bf-text); stroke-width: 1.5; }
739
746
  .bf-calendar rect[role="button"]:focus-visible { stroke: var(--bf-accent); stroke-width: 2; }
740
747
  .bf-cal__panel { margin-top: 0.75rem; border: 1px solid var(--bf-border); border-radius: var(--bf-radius);
741
748
  padding: 0.6rem 0.75rem; }
@@ -787,4 +794,5 @@ html.bf-printing .bf-print-label {
787
794
  /* A calendar may shrink to fit the sheet instead of being clipped (#106). */
788
795
  .bf-cal__days, .bf-cal__hours { min-width: 0; --bf-cal-text: 1; }
789
796
  .bf-cal__swatch { width: 11px; height: 11px; }
797
+ .bf-cal__tip { display: none !important; }
790
798
  }
@@ -8,6 +8,9 @@ from playwright.sync_api import Page
8
8
  import briefing as bf
9
9
  from tests.test_browser.conftest import Viewer
10
10
 
11
+ # The hour view is deprecated (#111) but still supported: its tests keep running without the warning.
12
+ pytestmark = pytest.mark.filterwarnings("ignore:CalendarHeatmap. the hour view:DeprecationWarning")
13
+
11
14
 
12
15
  @pytest.mark.parametrize("theme", ["default", "dark"])
13
16
  def test_zero_no_data_and_below_target_are_visibly_different(viewer: Viewer, df_pipeline_log: pd.DataFrame,
@@ -145,3 +148,95 @@ def test_capped_cells_say_so_and_values_stay_text(viewer: Viewer) -> None:
145
148
  assert panel.locator("tbody tr").count() == 50
146
149
  assert "first 50 of 120 rows" in panel.inner_text()
147
150
  assert panel.locator("img").count() == 0 and page.evaluate("() => window.__hit") is None
151
+
152
+
153
+ # ── hover tooltip (#109) ──────────────────────────────────────────────────────
154
+
155
+
156
+ def _tip_box(page: Page) -> dict[str, float]:
157
+ tip = page.locator(".bf-cal__tip")
158
+ assert tip.is_visible()
159
+ box = tip.bounding_box()
160
+ assert box is not None
161
+ return {"x": box["x"], "y": box["y"], "width": box["width"], "height": box["height"]}
162
+
163
+
164
+ def test_hovering_a_day_shows_its_exact_value_at_once(viewer: Viewer) -> None:
165
+ df = pd.DataFrame({"day": pd.to_datetime(["2026-01-05", "2026-01-06"]), "amount": [12345.67, 3.0]})
166
+ page = viewer.open(bf.Briefing(bf.lab.CalendarHeatmap(df, date="day", value="amount")))
167
+ tip = page.locator(".bf-cal__tip")
168
+ assert not tip.is_visible()
169
+ cell = page.locator('rect[data-date="2026-01-05"]')
170
+ cell.hover()
171
+ assert tip.is_visible() # no delay: visible as soon as the pointer is over the cell
172
+ assert tip.locator("strong").inner_text() == "Mon 2026-01-05"
173
+ assert "12,345.67 amount" in tip.inner_text()
174
+ cell_box, box = cell.bounding_box(), _tip_box(page)
175
+ assert cell_box is not None and box["y"] + box["height"] <= cell_box["y"] # above the cell
176
+ page.mouse.move(0, 0)
177
+ assert not tip.is_visible()
178
+
179
+
180
+ def test_the_native_tooltip_no_longer_doubles_up(viewer: Viewer, df_pipeline_log: pd.DataFrame) -> None:
181
+ page = viewer.open(bf.Briefing(bf.lab.CalendarHeatmap(df_pipeline_log, date="run_at", views=("days", "hours"))))
182
+ assert page.locator(".bf-calendar svg title").count() == 0
183
+ assert page.locator("rect.bf-cal__hour[data-tip]").count() == 7 * 24
184
+
185
+
186
+ def test_hour_cells_and_event_bands_have_tooltips(viewer: Viewer, df_pipeline_log: pd.DataFrame) -> None:
187
+ events = pd.DataFrame({"start": ["2025-12-22"], "end": ["2026-01-02"], "label": ["Freeze"]})
188
+ page = viewer.open(bf.Briefing(bf.lab.CalendarHeatmap(df_pipeline_log, date="run_at", events=events,
189
+ views=("days", "hours"))))
190
+ page.locator("g.bf-cal__event").first.hover()
191
+ assert "Freeze" in page.locator(".bf-cal__tip").inner_text()
192
+ page.get_by_role("tab", name="Hours").click()
193
+ page.locator('rect[data-hour="0-6"]').hover()
194
+ assert page.locator(".bf-cal__tip strong").inner_text().startswith("Mon 06:00")
195
+
196
+
197
+ def test_keyboard_focus_and_tap_show_the_tooltip(viewer: Viewer, df_pipeline_log: pd.DataFrame) -> None:
198
+ page = viewer.open(bf.Briefing(bf.lab.CalendarHeatmap(df_pipeline_log, date="run_at", on_click="rows")))
199
+ cell = page.locator('rect[data-date="2025-12-07"]')
200
+ cell.focus()
201
+ assert page.locator(".bf-cal__tip strong").inner_text() == "Sun 2025-12-07"
202
+ assert cell.get_attribute("aria-label") is not None # clickable cells keep their name
203
+ page.keyboard.press("Escape")
204
+ assert not page.locator(".bf-cal__tip").is_visible()
205
+ other = page.locator('rect[data-date="2025-12-08"]')
206
+ other.dispatch_event("pointerdown", {"pointerType": "touch", "bubbles": True})
207
+ assert page.locator(".bf-cal__tip strong").inner_text() == "Mon 2025-12-08"
208
+ cell.click() # the rows panel still opens, titled from the same text
209
+ assert "2025-12-07" in page.locator(".bf-cal__panel-title").inner_text()
210
+
211
+
212
+ def test_the_tooltip_stays_inside_the_window(viewer: Viewer) -> None:
213
+ viewer.page.set_viewport_size({"width": 375, "height": 800})
214
+ days = pd.date_range("2025-01-01", "2025-12-31", freq="D")
215
+ page = viewer.open(bf.Briefing(bf.lab.CalendarHeatmap(pd.DataFrame({"run_at": days}), date="run_at")))
216
+ page.locator('rect[data-date="2025-01-06"]').scroll_into_view_if_needed()
217
+ page.evaluate("() => window.scrollTo(0, document.querySelector('svg.bf-cal__days').getBoundingClientRect().top"
218
+ " + window.scrollY - 30)") # the first row sits right under the top of the window
219
+ cell = page.locator('rect[data-date="2025-01-06"]')
220
+ cell.hover()
221
+ cell_box, box = cell.bounding_box(), _tip_box(page)
222
+ assert cell_box is not None and box["y"] >= cell_box["y"] + cell_box["height"] # flipped below the cell
223
+ assert box["x"] >= 0 and box["x"] + box["width"] <= 375
224
+
225
+
226
+ def test_the_tooltip_never_prints(viewer: Viewer, df_pipeline_log: pd.DataFrame) -> None:
227
+ page = viewer.open(bf.Briefing(bf.lab.CalendarHeatmap(df_pipeline_log, date="run_at")))
228
+ page.locator('rect[data-date="2025-12-07"]').hover()
229
+ page.emulate_media(media="print")
230
+ assert not page.locator(".bf-cal__tip").is_visible()
231
+
232
+
233
+ def test_weekday_labels_do_not_overlap_when_shrunk(viewer: Viewer) -> None:
234
+ viewer.page.set_viewport_size({"width": 375, "height": 800}) # a year at the 0.6x floor (#113)
235
+ page = viewer.open(bf.Briefing(bf.lab.CalendarHeatmap(_year(), date="run_at")))
236
+ boxes = page.locator("svg.bf-cal__days text.bf-cal__weekday").evaluate_all(
237
+ "els => els.map(e => { const b = e.getBoundingClientRect(); return [b.top, b.height]; })")
238
+ assert len(boxes) == 7
239
+ boxes.sort()
240
+ # A text box includes line spacing (about 1.25x the glyphs); the glyphs stay apart when the
241
+ # rows are at least 0.8 of a box apart.
242
+ assert all(below[0] - above[0] >= 0.8 * above[1] for above, below in zip(boxes, boxes[1:], strict=False))
@@ -27,6 +27,9 @@ from tests.contract import (
27
27
  parse_report,
28
28
  )
29
29
 
30
+ # The "calendar" scenario keeps the deprecated hour view (#111) so the contract still covers it.
31
+ pytestmark = pytest.mark.filterwarnings("ignore:CalendarHeatmap. the hour view:DeprecationWarning")
32
+
30
33
  Frames = Callable[[str], pd.DataFrame]
31
34
  Build = Callable[[Frames], bf.Briefing]
32
35
 
@@ -1,6 +1,7 @@
1
- """Deprecated aliases kept for one release after the folio -> bulletin -> briefing rename."""
1
+ """Deprecated names and features: the folio -> bulletin -> briefing aliases, and the calendar hour view."""
2
2
  from __future__ import annotations
3
3
 
4
+ import typing as t
4
5
  import warnings
5
6
 
6
7
  import pytest
@@ -72,3 +73,22 @@ def test_plot_scale_is_gone_after_0_2() -> None:
72
73
  version = tuple(int(part) for part in bf.__version__.split(".")[:2])
73
74
  if version >= (0, 3):
74
75
  assert "scale" not in inspect.signature(bf.Plot).parameters
76
+
77
+
78
+ # ── CalendarHeatmap's hour view (#111) ────────────────────────────────────────
79
+
80
+
81
+ @pytest.mark.parametrize("views", [("hours",), ("days", "hours"), ["hours", "days"]])
82
+ def test_the_calendar_hour_view_warns_and_still_renders(views: tuple[str, ...], df_pipeline_log: t.Any) -> None:
83
+ expected = r"hour view .* deprecated since briefing 0\.2\.2.*issues/111"
84
+ with pytest.warns(DeprecationWarning, match=expected) as caught:
85
+ block = bf.lab.CalendarHeatmap(df_pipeline_log, date="run_at", views=views)
86
+ assert caught[0].filename == __file__ # points at the caller's line (stacklevel=2)
87
+ assert "bf-cal__hours" in bf.stringify(bf.Briefing(block))
88
+
89
+
90
+ def test_the_day_calendar_alone_does_not_warn(df_pipeline_log: t.Any) -> None:
91
+ with warnings.catch_warnings():
92
+ warnings.simplefilter("error")
93
+ bf.lab.CalendarHeatmap(df_pipeline_log, date="run_at")
94
+ bf.lab.CalendarHeatmap(df_pipeline_log, date="run_at", views=("days",))
@@ -10,9 +10,12 @@ from bs4 import BeautifulSoup, Tag
10
10
 
11
11
  import briefing as bf
12
12
  from briefing.lab import CalendarHeatmap
13
- from briefing.lab._render_calendar import GITHUB, render_calendar
13
+ from briefing.lab._render_calendar import GITHUB, _fmt, render_calendar
14
14
  from tests.html_helpers import attr, classes, find_one
15
15
 
16
+ # The hour view is deprecated (#111) but still supported: its tests keep running without the warning.
17
+ pytestmark = pytest.mark.filterwarnings("ignore:CalendarHeatmap. the hour view:DeprecationWarning")
18
+
16
19
 
17
20
  def _soup(block: CalendarHeatmap) -> BeautifulSoup:
18
21
  return BeautifulSoup(render_calendar(block), "html.parser")
@@ -169,7 +172,7 @@ def test_week_start(df_pipeline_log: pd.DataFrame, week_start: str, weekday: int
169
172
  def test_tooltips_show_date_and_value(df_pipeline_log: pd.DataFrame) -> None:
170
173
  cells = _cells(_soup(CalendarHeatmap(df_pipeline_log, date="run_at", value="rows", agg="sum")))
171
174
  title = find_one(cells["2025-12-07"], "title").get_text()
172
- assert title.startswith("2025-12-07") and "rows" in title
175
+ assert title.startswith("Sun 2025-12-07 · ") and "rows" in title # weekday first, for the tooltip (#109)
173
176
 
174
177
 
175
178
  def test_labels_are_escaped(df_pipeline_log: pd.DataFrame) -> None:
@@ -301,3 +304,42 @@ def test_rows_json_cannot_close_its_script(df_pipeline_log: pd.DataFrame) -> Non
301
304
  soup = _soup(CalendarHeatmap(df, date="run_at", on_click="rows"))
302
305
  assert soup.find("img") is None and "<" not in find_one(soup, "script.bf-cal__rows").get_text()
303
306
  assert _rows(soup)["cells"]["d|2026-01-05"]["rows"][0][1] == "</script><img src=x onerror=y()>"
307
+
308
+
309
+ # ── exact values in tooltips and the legend (#109) ────────────────────────────
310
+
311
+
312
+ @pytest.mark.parametrize(("value", "shown"), [
313
+ (3, "3"), (1234, "1,234"), (12345.67, "12,345.67"), (-12345.678, "-12,345.68"), (1234.5, "1,234.5"),
314
+ (10_000_000.5, "10,000,000.5"), (0.12345, "0.1235"), (-0.5, "-0.5"), (0.00001234, "1.23e-05"),
315
+ ])
316
+ def test_values_are_shown_exactly(value: float, shown: str) -> None:
317
+ assert _fmt(value) == shown
318
+
319
+
320
+ def test_a_large_fractional_value_has_no_exponent_in_tooltip_or_legend() -> None:
321
+ df = pd.DataFrame({"day": pd.to_datetime(["2026-01-05", "2026-01-06"]), "amount": [12345.67, 20000.25]})
322
+ soup = _soup(CalendarHeatmap(df, date="day", value="amount", colors=["#eee", "#333"]))
323
+ tip = find_one(find_one(soup, 'rect[data-date="2026-01-05"]'), "title").get_text()
324
+ assert tip == "Mon 2026-01-05 · 12,345.67 amount"
325
+ legend = find_one(soup, ".bf-cal__legend").get_text()
326
+ assert "e+0" not in legend and "12,345.67" in legend
327
+
328
+
329
+ # ── weekday labels (#113) ─────────────────────────────────────────────────────
330
+
331
+
332
+ @pytest.mark.parametrize("week_start", ["monday", "sunday"])
333
+ def test_every_weekday_is_named_on_its_own_row(week_start: str) -> None:
334
+ df = pd.DataFrame({"d": pd.date_range("2026-01-05", "2026-01-18")}) # two full weeks from a Monday
335
+ soup = _soup(CalendarHeatmap(df, date="d", week_start=week_start))
336
+ row_of_day = {float(attr(r, "y")): pd.Timestamp(attr(r, "data-date")).strftime("%a")
337
+ for r in soup.select("rect.bf-cal__day")}
338
+ labels = soup.select("svg.bf-cal__days text.bf-cal__weekday")
339
+ assert [t.get_text() for t in labels] == ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
340
+ for label in labels: # a label's baseline sits inside its row: y = row top + cell - 1
341
+ row_top = float(attr(label, "y")) - 10
342
+ assert row_of_day[row_top] == label.get_text()
343
+ tops = sorted(float(attr(t, "y")) for t in labels)
344
+ first = "Sun" if week_start == "sunday" else "Mon"
345
+ assert next(t.get_text() for t in labels if float(attr(t, "y")) == tops[0]) == first
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes