axidio-styleguide-library1-v2 0.3.22 → 0.3.23

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.
@@ -7902,7 +7902,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
7902
7902
  textNodes.classed('mobile-xaxis-override', true);
7903
7903
  }
7904
7904
  }
7905
- // Tablet view: try to wrap long labels into two lines first; fall back to vertical rotation
7905
+ // Tablet view: auto-rotate labels vertically when they overlap or are too long
7906
7906
  if (isTablet) {
7907
7907
  const textNodes = svg.selectAll('g.x1.axis1 g.tick text');
7908
7908
  // Measure max label width
@@ -7918,61 +7918,17 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
7918
7918
  // ignore measurement errors
7919
7919
  }
7920
7920
  });
7921
+ // Determine available tick slot width
7921
7922
  const slotWidth = (typeof x.bandwidth === 'function') ? x.bandwidth() : 0;
7922
7923
  const labelCount = textNodes.size ? textNodes.size() : 0;
7923
- // If labels are too wide or many, attempt wrapping
7924
+ // If labels are wider than the slot or there are many labels, rotate vertically
7924
7925
  if ((slotWidth > 0 && maxLabelWidth > slotWidth * 0.75) || labelCount > 3) {
7925
- let wrapped = 0;
7926
- textNodes.each(function (d) {
7927
- const t = d3.select(this);
7928
- let label = (typeof d === 'string') ? d : t.text();
7929
- if (!label || label.indexOf('\n') > -1)
7930
- return;
7931
- // Try splitting on spaces into two roughly equal parts
7932
- if (label.indexOf(' ') > -1) {
7933
- const words = label.trim().split(/\s+/);
7934
- const mid = Math.ceil(words.length / 2);
7935
- const first = words.slice(0, mid).join(' ');
7936
- const second = words.slice(mid).join(' ');
7937
- if (second && second.length > 0) {
7938
- t.text(null);
7939
- t.append('tspan').attr('x', 0).attr('dy', '0em').text(first);
7940
- t.append('tspan').attr('x', 0).attr('dy', '1.1em').text(second);
7941
- wrapped++;
7942
- return;
7943
- }
7944
- }
7945
- // If no spaces, try splitting on slash or dash
7946
- const sepIdx = Math.max(label.lastIndexOf('/'), label.lastIndexOf('-'));
7947
- if (sepIdx > 0 && sepIdx < label.length - 1) {
7948
- const first = label.substring(0, sepIdx + 1);
7949
- const second = label.substring(sepIdx + 1);
7950
- t.text(null);
7951
- t.append('tspan').attr('x', 0).attr('dy', '0em').text(first);
7952
- t.append('tspan').attr('x', 0).attr('dy', '1.1em').text(second);
7953
- wrapped++;
7954
- return;
7955
- }
7956
- // Fallback: split roughly in the middle
7957
- if (label.length > 8) {
7958
- const mid = Math.floor(label.length / 2);
7959
- const first = label.substring(0, mid);
7960
- const second = label.substring(mid);
7961
- t.text(null);
7962
- t.append('tspan').attr('x', 0).attr('dy', '0em').text(first);
7963
- t.append('tspan').attr('x', 0).attr('dy', '1.1em').text(second);
7964
- wrapped++;
7965
- }
7966
- });
7967
- // If very few labels were wrapped, it's better to rotate vertically instead
7968
- if (wrapped < Math.max(1, Math.floor(labelCount / 3))) {
7969
- textNodes
7970
- .style('writing-mode', 'sideways-lr')
7971
- .style('text-anchor', 'middle')
7972
- .attr('y', 30)
7973
- .attr('x', 0)
7974
- .classed('mobile-xaxis-override', true);
7975
- }
7926
+ textNodes
7927
+ .style('writing-mode', 'sideways-lr')
7928
+ .style('text-anchor', 'middle')
7929
+ .attr('y', 30)
7930
+ .attr('x', 0)
7931
+ .classed('mobile-xaxis-override', true);
7976
7932
  }
7977
7933
  }
7978
7934
  }