axidio-styleguide-library1-v2 0.2.46 → 0.2.47

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.
@@ -6625,17 +6625,17 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6625
6625
  // Responsive zoom handling
6626
6626
  if (dataLength > this.CONSTANTS.ZOOM_THRESHOLD && this.isZoomedOut) {
6627
6627
  const minWidth = device.isMobile
6628
- ? dataLength * 12
6628
+ ? dataLength * 15 // Increased from 12
6629
6629
  : device.isTablet
6630
- ? dataLength * 20
6630
+ ? dataLength * 25 // Increased from 20
6631
6631
  : dataLength * 25;
6632
6632
  width = Math.max(width, minWidth);
6633
6633
  }
6634
6634
  if (dataLength > this.CONSTANTS.ZOOM_IN_THRESHOLD && !this.isZoomedOut) {
6635
6635
  width = device.isMobile
6636
- ? dataLength * 50
6636
+ ? dataLength * 60 // Increased from 50
6637
6637
  : device.isTablet
6638
- ? dataLength * 90
6638
+ ? dataLength * 100 // Increased from 90
6639
6639
  : dataLength * 130;
6640
6640
  }
6641
6641
  if (this.chartConfiguration.isFullScreen) {
@@ -6653,13 +6653,17 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6653
6653
  if (device.isMobile) {
6654
6654
  barWidth = this.CONSTANTS.MIN_MOBILE_BAR_WIDTH;
6655
6655
  barPadding = this.CONSTANTS.MOBILE_BAR_PADDING;
6656
- requiredSvgWidth = Math.max(width - this.CONSTANTS.RIGHT_SVG_WIDTH, (barWidth + barPadding) * dataLength + this.CONSTANTS.LEFT_RIGHT_SPACES * 2 +
6657
- this.CONSTANTS.RIGHT_SVG_WIDTH - barPadding);
6656
+ // FIX: Calculate total width needed for all bars + spacing
6657
+ const totalBarsWidth = (barWidth + barPadding) * dataLength;
6658
+ const sidePadding = this.CONSTANTS.LEFT_RIGHT_SPACES * 2;
6659
+ requiredSvgWidth = Math.max(width - this.CONSTANTS.RIGHT_SVG_WIDTH, totalBarsWidth + sidePadding);
6658
6660
  }
6659
6661
  else if (device.isTablet) {
6660
6662
  barWidth = this.CONSTANTS.TABLET_MIN_BAR_WIDTH;
6661
6663
  barPadding = this.CONSTANTS.TABLET_BAR_PADDING;
6662
- requiredSvgWidth = Math.max(width - this.CONSTANTS.RIGHT_SVG_WIDTH, (barWidth + barPadding) * dataLength + this.CONSTANTS.LEFT_RIGHT_SPACES * 2);
6664
+ const totalBarsWidth = (barWidth + barPadding) * dataLength;
6665
+ const sidePadding = this.CONSTANTS.LEFT_RIGHT_SPACES * 2;
6666
+ requiredSvgWidth = Math.max(width - this.CONSTANTS.RIGHT_SVG_WIDTH, totalBarsWidth + sidePadding);
6663
6667
  }
6664
6668
  else {
6665
6669
  barWidth = Math.max(this.CONSTANTS.DESKTOP_MIN_BAR_WIDTH, (width - this.CONSTANTS.RIGHT_SVG_WIDTH - this.CONSTANTS.LEFT_RIGHT_SPACES * 2) / dataLength);
@@ -6720,16 +6724,30 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6720
6724
  }
6721
6725
  createScales(data, layers, lineData, dimensions, device) {
6722
6726
  const { width, height, barWidth, barPadding } = dimensions;
6723
- // Adjust padding based on device
6724
- const padding = device.isMobile ? 0.15 : device.isTablet ? 0.3 : 0.5;
6725
- const xScale = d3
6726
- .scaleBand()
6727
- .rangeRound([
6728
- this.CONSTANTS.LEFT_RIGHT_SPACES,
6729
- width - this.CONSTANTS.RIGHT_SVG_WIDTH - this.CONSTANTS.LEFT_RIGHT_SPACES
6730
- ])
6731
- .domain(data.map(d => d.name).reverse())
6732
- .padding(padding);
6727
+ // For mobile and tablet, create a custom scale that matches bar positioning
6728
+ let xScale;
6729
+ if (device.isMobile || device.isTablet) {
6730
+ // Create a point scale for mobile/tablet that aligns with manual positioning
6731
+ xScale = d3
6732
+ .scalePoint()
6733
+ .domain(data.map(d => d.name).reverse())
6734
+ .range([
6735
+ this.CONSTANTS.LEFT_RIGHT_SPACES + barWidth / 2,
6736
+ width - this.CONSTANTS.RIGHT_SVG_WIDTH - this.CONSTANTS.LEFT_RIGHT_SPACES - barWidth / 2
6737
+ ])
6738
+ .padding(0);
6739
+ }
6740
+ else {
6741
+ // Desktop uses band scale
6742
+ xScale = d3
6743
+ .scaleBand()
6744
+ .rangeRound([
6745
+ this.CONSTANTS.LEFT_RIGHT_SPACES,
6746
+ width - this.CONSTANTS.RIGHT_SVG_WIDTH - this.CONSTANTS.LEFT_RIGHT_SPACES
6747
+ ])
6748
+ .domain(data.map(d => d.name).reverse())
6749
+ .padding(0.5);
6750
+ }
6733
6751
  const xScaleFromOrigin = d3
6734
6752
  .scaleBand()
6735
6753
  .rangeRound([width - this.CONSTANTS.RIGHT_SVG_WIDTH, 0])
@@ -6814,9 +6832,12 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6814
6832
  return 0;
6815
6833
  })
6816
6834
  .attr('x', (d, i) => {
6817
- if (device.isMobile) {
6835
+ // FIX: Consistent positioning logic
6836
+ if (device.isMobile || device.isTablet) {
6837
+ // For mobile/tablet, calculate position based on index
6818
6838
  return this.CONSTANTS.LEFT_RIGHT_SPACES + i * (barWidth + barPadding);
6819
6839
  }
6840
+ // Desktop positioning
6820
6841
  if (!this.chartConfiguration.isMultiChartGridLine) {
6821
6842
  return xScale(d.data.name);
6822
6843
  }
@@ -6833,7 +6854,8 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6833
6854
  return 0;
6834
6855
  })
6835
6856
  .attr('width', (d) => {
6836
- if (device.isMobile)
6857
+ // FIX: Consistent width logic
6858
+ if (device.isMobile || device.isTablet)
6837
6859
  return barWidth;
6838
6860
  if (!this.chartConfiguration.isMultiChartGridLine)
6839
6861
  return xScale.bandwidth();
@@ -6893,25 +6915,36 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6893
6915
  if (isNaN(value))
6894
6916
  return;
6895
6917
  const device = this.getDeviceConfig();
6896
- const bandwidth = xScale.bandwidth();
6897
- // Responsive tooltip width
6918
+ // Get the bar's actual index to calculate position for mobile/tablet
6919
+ const dataIndex = this.chartData.data.findIndex((item) => item.name === d.data.name);
6920
+ const dimensions = this.currentDimensions; // Store dimensions as class property
6921
+ let tooltipX;
6898
6922
  let width;
6899
6923
  if (device.isMobile) {
6900
- width = Math.min(bandwidth + 40, 150);
6924
+ width = Math.min(dimensions.barWidth + 20, 120);
6925
+ // FIX: Calculate tooltip x to match bar position
6926
+ tooltipX = this.CONSTANTS.LEFT_RIGHT_SPACES +
6927
+ dataIndex * (dimensions.barWidth + dimensions.barPadding) +
6928
+ dimensions.barWidth / 2 - (typeof width === 'number' ? width : 120) / 2;
6901
6929
  }
6902
6930
  else if (device.isTablet) {
6903
- width = Math.min(bandwidth + 60, 200);
6931
+ width = Math.min(dimensions.barWidth + 40, 180);
6932
+ tooltipX = this.CONSTANTS.LEFT_RIGHT_SPACES +
6933
+ dataIndex * (dimensions.barWidth + dimensions.barPadding) +
6934
+ dimensions.barWidth / 2 - (typeof width === 'number' ? width : 180) / 2;
6904
6935
  }
6905
6936
  else {
6937
+ const bandwidth = xScale.bandwidth();
6906
6938
  width = /week/i.test(d.data.name) && /\d{4}-\d{2}-\d{2}/.test(d.data.name)
6907
6939
  ? '250px'
6908
6940
  : bandwidth + this.CONSTANTS.LEFT_RIGHT_SPACES * 2 > 180
6909
6941
  ? '180px'
6910
6942
  : bandwidth + this.CONSTANTS.LEFT_RIGHT_SPACES * 2;
6943
+ tooltipX = this.calculateTooltipX(d, xScale, width);
6911
6944
  }
6912
6945
  svg
6913
6946
  .append('foreignObject')
6914
- .attr('x', this.calculateTooltipX(d, xScale, width))
6947
+ .attr('x', tooltipX)
6915
6948
  .attr('class', 'lib-verticalstack-title-ontop')
6916
6949
  .attr('y', yScale(d[1]) - 51)
6917
6950
  .attr('width', width)
@@ -7039,6 +7072,7 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
7039
7072
  const verticalstackedcontainer = d3.select(this.verticalstackedcontainerElt.nativeElement);
7040
7073
  const margin = this.chartConfiguration.margin;
7041
7074
  const dimensions = this.calculateDimensions(chartContainer, verticalstackedcontainer, margin, device, data.length);
7075
+ this.currentDimensions = dimensions;
7042
7076
  const { svg, svgYAxisLeft, svgYAxisRight } = this.createSvgContainers(chartContainer, dimensions, margin);
7043
7077
  const stack = d3.stack().keys(keyList).offset(d3.stackOffsetNone);
7044
7078
  const layers = stack(data);
@@ -7140,20 +7174,20 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
7140
7174
  const maxLength = Math.max(...data.map(d => d.name.length));
7141
7175
  const fontSize = maxLength > 10 ? '8px' : '10px';
7142
7176
  data.forEach((d, i) => {
7177
+ // FIX: Calculate x position to match bar center
7143
7178
  const xVal = this.CONSTANTS.LEFT_RIGHT_SPACES +
7144
7179
  i * (dimensions.barWidth + dimensions.barPadding) +
7145
7180
  dimensions.barWidth / 2;
7146
7181
  svg
7147
7182
  .append('text')
7148
7183
  .attr('class', 'custom-x-label')
7149
- .attr('x', 0)
7150
- .attr('y', dimensions.height + 18)
7184
+ .attr('x', xVal)
7185
+ .attr('y', dimensions.height + 15) // Adjusted from 18
7151
7186
  .attr('text-anchor', 'middle')
7152
- .attr('transform', `translate(${xVal + 20},0)`)
7187
+ .attr('transform', `translate(0,0) rotate(-90, ${xVal}, ${dimensions.height + 15})`)
7153
7188
  .style('font-size', fontSize)
7154
7189
  .style('fill', 'var(--chart-text-color)')
7155
- .style('writing-mode', 'sideways-lr')
7156
- .text(d.name.length > 6 ? d.name.substring(0, 4) + '...' : d.name);
7190
+ .text(d.name.length > 8 ? d.name.substring(0, 6) + '...' : d.name);
7157
7191
  });
7158
7192
  }
7159
7193
  renderDrilldownAxes(svg, svgYAxisLeft, svgYAxisRight, axes, scales, dimensions) {