@fundar/data-chart-telling 0.0.38 → 0.0.39

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.
@@ -37,12 +37,21 @@ export function watchLabelOverflow(args) {
37
37
  catch {
38
38
  return;
39
39
  }
40
- const overflow = {
41
- left: Math.ceil(Math.max(0, bounds.left - box.x)),
42
- right: Math.ceil(Math.max(0, box.x + box.width - bounds.right)),
43
- top: Math.ceil(Math.max(0, bounds.top - box.y)),
44
- bottom: Math.ceil(Math.max(0, box.y + box.height - bounds.bottom)),
45
- };
40
+ // An empty group (no labels currently rendered, e.g. every series is
41
+ // scrubbed/filtered out of view) reports getBBox() as (0,0,0,0) the
42
+ // SVG origin, not "no content". Reading that literally as a box sitting
43
+ // at (0,0) would report overflow proportional to the *current* margins
44
+ // themselves, which grows them, which remounts this group against the
45
+ // new, larger bounds, which reports overflow again — an unbounded loop
46
+ // with nothing rendered to justify it.
47
+ const overflow = box.width === 0 && box.height === 0
48
+ ? NO_OVERFLOW
49
+ : {
50
+ left: Math.ceil(Math.max(0, bounds.left - box.x)),
51
+ right: Math.ceil(Math.max(0, box.x + box.width - bounds.right)),
52
+ top: Math.ceil(Math.max(0, bounds.top - box.y)),
53
+ bottom: Math.ceil(Math.max(0, box.y + box.height - bounds.bottom))
54
+ };
46
55
  attempt += 1;
47
56
  const stable = lastReading != null &&
48
57
  lastReading.left === overflow.left &&
@@ -86,7 +95,7 @@ export function createLabelMarginTracker(margins) {
86
95
  left: Math.max(measured.left, overflow.left),
87
96
  right: Math.max(measured.right, overflow.right),
88
97
  top: Math.max(measured.top, overflow.top),
89
- bottom: Math.max(measured.bottom, overflow.bottom),
98
+ bottom: Math.max(measured.bottom, overflow.bottom)
90
99
  };
91
100
  if (next.left !== measured.left ||
92
101
  next.right !== measured.right ||
@@ -126,11 +135,15 @@ export function createLabelMarginTracker(margins) {
126
135
  // must track.
127
136
  const plotProps = $derived.by(() => ({
128
137
  margins: resolvedMargins,
129
- marginRemountKey: JSON.stringify(measured),
138
+ marginRemountKey: JSON.stringify(measured)
130
139
  }));
131
140
  return {
132
141
  report,
133
- get resolvedMargins() { return resolvedMargins; },
134
- get plotProps() { return plotProps; },
142
+ get resolvedMargins() {
143
+ return resolvedMargins;
144
+ },
145
+ get plotProps() {
146
+ return plotProps;
147
+ }
135
148
  };
136
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fundar/data-chart-telling",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"