@opendata-ai/openchart-vanilla 6.17.0 → 6.19.0

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/dist/index.js CHANGED
@@ -6893,7 +6893,27 @@ function renderLabels(parent, nodes) {
6893
6893
  const text = createSVGElement2("text");
6894
6894
  setAttrs2(text, { x: label.x, y: label.y });
6895
6895
  applyTextStyle2(text, label.style);
6896
- text.textContent = label.text;
6896
+ if (label.maxWidth !== void 0 && label.maxWidth > 0) {
6897
+ const fontSize = label.style.fontSize ?? 12;
6898
+ const fontWeight = label.style.fontWeight ?? 400;
6899
+ const lines = wrapText2(label.text, fontSize, fontWeight, label.maxWidth);
6900
+ if (lines.length > 1) {
6901
+ const lineHeight = fontSize * (label.style.lineHeight ?? 1.3);
6902
+ const totalHeight = (lines.length - 1) * lineHeight;
6903
+ const startY = label.y - totalHeight / 2;
6904
+ for (let i = 0; i < lines.length; i++) {
6905
+ const tspan = createSVGElement2("tspan");
6906
+ tspan.setAttribute("x", String(label.x));
6907
+ tspan.setAttribute("y", String(startY + i * lineHeight));
6908
+ tspan.textContent = lines[i];
6909
+ text.appendChild(tspan);
6910
+ }
6911
+ } else {
6912
+ text.textContent = label.text;
6913
+ }
6914
+ } else {
6915
+ text.textContent = label.text;
6916
+ }
6897
6917
  g.appendChild(text);
6898
6918
  }
6899
6919
  parent.appendChild(g);