@opendata-ai/openchart-vanilla 6.25.0 → 6.25.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendata-ai/openchart-vanilla",
3
- "version": "6.25.0",
3
+ "version": "6.25.2",
4
4
  "description": "Vanilla JS renderer for openchart: SVG charts, HTML tables, force-directed graphs",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Riley Hilliard",
@@ -50,8 +50,8 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@floating-ui/dom": "^1.7.6",
53
- "@opendata-ai/openchart-core": "6.25.0",
54
- "@opendata-ai/openchart-engine": "6.25.0",
53
+ "@opendata-ai/openchart-core": "6.25.2",
54
+ "@opendata-ai/openchart-engine": "6.25.2",
55
55
  "d3-force": "^3.0.0",
56
56
  "d3-quadtree": "^3.0.1"
57
57
  },
@@ -3,7 +3,11 @@
3
3
  */
4
4
 
5
5
  import type { AxisLayout, ChartLayout } from '@opendata-ai/openchart-core';
6
- import { estimateTextWidth } from '@opendata-ai/openchart-core';
6
+ import {
7
+ estimateTextWidth,
8
+ getAxisTitleOffset,
9
+ TICK_LABEL_OFFSET,
10
+ } from '@opendata-ai/openchart-core';
7
11
  import { applyTextStyle, createSVGElement, setAttrs } from './svg-dom';
8
12
 
9
13
  function renderAxis(
@@ -70,7 +74,7 @@ function renderAxis(
70
74
  const label = createSVGElement('text');
71
75
  label.setAttribute('class', 'oc-axis-tick');
72
76
  setAttrs(label, {
73
- x: isRight ? area.x + area.width + 6 : area.x - 6,
77
+ x: isRight ? area.x + area.width + TICK_LABEL_OFFSET : area.x - TICK_LABEL_OFFSET,
74
78
  y: tick.position,
75
79
  'text-anchor': isRight ? 'start' : 'end',
76
80
  'dominant-baseline': 'central',
@@ -78,7 +82,7 @@ function renderAxis(
78
82
  applyTextStyle(label, axis.tickLabelStyle);
79
83
  if (!isRight) {
80
84
  // Truncate categorical left y-axis labels that exceed available space
81
- const availableWidth = area.x - 6;
85
+ const availableWidth = area.x - TICK_LABEL_OFFSET;
82
86
  const fontSize = axis.tickLabelStyle.fontSize;
83
87
  const fontWeight = axis.tickLabelStyle.fontWeight;
84
88
  const fullWidth = estimateTextWidth(tick.label, fontSize, fontWeight);
@@ -175,8 +179,9 @@ function renderAxis(
175
179
  'text-anchor': 'middle',
176
180
  });
177
181
  } else if (isRight) {
178
- // Rotated right y-axis label
179
- const titleX = area.x + area.width + 45;
182
+ // Rotated right y-axis label (tighter offset on compact viewports)
183
+ const titleOffset = getAxisTitleOffset(layout.dimensions.width);
184
+ const titleX = area.x + area.width + titleOffset;
180
185
  setAttrs(axisLabel, {
181
186
  x: titleX,
182
187
  y: area.y + area.height / 2,
@@ -184,12 +189,13 @@ function renderAxis(
184
189
  transform: `rotate(90, ${titleX}, ${area.y + area.height / 2})`,
185
190
  });
186
191
  } else {
187
- // Rotated left y-axis label
192
+ // Rotated left y-axis label (tighter offset on compact viewports)
193
+ const titleOffset = getAxisTitleOffset(layout.dimensions.width);
188
194
  setAttrs(axisLabel, {
189
- x: area.x - 45,
195
+ x: area.x - titleOffset,
190
196
  y: area.y + area.height / 2,
191
197
  'text-anchor': 'middle',
192
- transform: `rotate(-90, ${area.x - 45}, ${area.y + area.height / 2})`,
198
+ transform: `rotate(-90, ${area.x - titleOffset}, ${area.y + area.height / 2})`,
193
199
  });
194
200
  }
195
201
  g.appendChild(axisLabel);