axidio-styleguide-library1-v2 0.2.43 → 0.2.45

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.
@@ -6488,17 +6488,11 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6488
6488
  LONG_TICK_LENGTH: 16,
6489
6489
  SHORT_TICK_LENGTH_BG: 5,
6490
6490
  LONG_TICK_LENGTH_BG: 30,
6491
- // Mobile settings - larger bars with good spacing
6492
- MIN_MOBILE_BAR_WIDTH: 35,
6493
- MOBILE_BAR_PADDING: 15,
6494
- MOBILE_BAR_SPACING: 0.4, // 40% spacing between bars
6495
- // Tablet settings - balanced approach
6496
- TABLET_MIN_BAR_WIDTH: 45,
6497
- TABLET_BAR_PADDING: 18,
6498
- TABLET_BAR_SPACING: 0.35, // 35% spacing between bars
6499
- // Desktop settings
6500
- DESKTOP_MIN_BAR_WIDTH: 50,
6501
- DESKTOP_BAR_SPACING: 0.3, // 30% spacing between bars
6491
+ MIN_MOBILE_BAR_WIDTH: 35, // Increased from 28
6492
+ DESKTOP_MIN_BAR_WIDTH: 40,
6493
+ TABLET_MIN_BAR_WIDTH: 30, // Reduced from 35
6494
+ MOBILE_BAR_PADDING: 8, // Reduced from 10
6495
+ TABLET_BAR_PADDING: 6, // Reduced from 8
6502
6496
  ZOOM_THRESHOLD: 30,
6503
6497
  ZOOM_IN_THRESHOLD: 8,
6504
6498
  };
@@ -6566,36 +6560,37 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6566
6560
  getDeviceConfig() {
6567
6561
  const width = window.innerWidth;
6568
6562
  return {
6569
- isMobile: width < 768,
6570
- isTablet: width >= 768 && width < 1024,
6571
- isDesktop: width >= 1024,
6563
+ isMobile: width < 768, // Changed from 576 to 768 for better mobile coverage
6564
+ isTablet: width >= 768 && width < 1024, // Changed from 576-992 to 768-1024
6565
+ isDesktop: width >= 1024, // Changed from 992 to 1024
6572
6566
  };
6573
6567
  }
6574
6568
  configureResponsiveSettings(device) {
6575
6569
  if (device.isMobile) {
6576
- this.chartConfiguration.margin = { top: 20, right: 10, bottom: 50, left: 30 };
6570
+ this.chartConfiguration.margin = { top: 15, right: 5, bottom: 45, left: 25 }; // Increased bottom
6577
6571
  this.chartConfiguration.numberOfYTicks = 4;
6578
- this.chartConfiguration.svgHeight = 60;
6572
+ this.chartConfiguration.svgHeight = 55;
6579
6573
  }
6580
6574
  else if (device.isTablet) {
6581
- this.chartConfiguration.margin = { top: 25, right: 20, bottom: 55, left: 45 };
6575
+ this.chartConfiguration.margin = { top: 20, right: 15, bottom: 50, left: 35 }; // Increased bottom
6582
6576
  this.chartConfiguration.numberOfYTicks = 5;
6583
- this.chartConfiguration.svgHeight = 70;
6577
+ this.chartConfiguration.svgHeight = 65;
6584
6578
  }
6585
6579
  else {
6580
+ // Desktop/Large screens
6586
6581
  const width = window.innerWidth;
6587
6582
  if (width >= 1920) {
6588
- this.chartConfiguration.margin = { top: 35, right: 35, bottom: 60, left: 70 };
6583
+ this.chartConfiguration.margin = { top: 35, right: 35, bottom: 55, left: 70 };
6589
6584
  this.chartConfiguration.numberOfYTicks = 8;
6590
6585
  this.chartConfiguration.svgHeight = 85;
6591
6586
  }
6592
6587
  else if (width >= 1366) {
6593
- this.chartConfiguration.margin = { top: 30, right: 30, bottom: 55, left: 60 };
6588
+ this.chartConfiguration.margin = { top: 30, right: 30, bottom: 50, left: 60 };
6594
6589
  this.chartConfiguration.numberOfYTicks = 7;
6595
6590
  this.chartConfiguration.svgHeight = 80;
6596
6591
  }
6597
6592
  else {
6598
- this.chartConfiguration.margin = { top: 25, right: 25, bottom: 50, left: 50 };
6593
+ this.chartConfiguration.margin = { top: 25, right: 25, bottom: 45, left: 50 };
6599
6594
  this.chartConfiguration.numberOfYTicks = 6;
6600
6595
  this.chartConfiguration.svgHeight = 75;
6601
6596
  }
@@ -6624,33 +6619,20 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6624
6619
  const containerHeight = verticalContainer.node().getBoundingClientRect().height;
6625
6620
  let width = containerWidth - margin.left - margin.right;
6626
6621
  let height = containerHeight * (this.chartConfiguration.svgHeight / 100) - margin.top - margin.bottom;
6627
- // Calculate minimum width based on device and data length
6628
- if (device.isMobile) {
6629
- const minBarWidth = this.CONSTANTS.MIN_MOBILE_BAR_WIDTH;
6630
- const minPadding = this.CONSTANTS.MOBILE_BAR_PADDING;
6631
- const minWidthNeeded = (minBarWidth + minPadding) * dataLength + this.CONSTANTS.LEFT_RIGHT_SPACES * 2;
6632
- width = Math.max(width, minWidthNeeded);
6633
- }
6634
- else if (device.isTablet) {
6635
- const minBarWidth = this.CONSTANTS.TABLET_MIN_BAR_WIDTH;
6636
- const minPadding = this.CONSTANTS.TABLET_BAR_PADDING;
6637
- const minWidthNeeded = (minBarWidth + minPadding) * dataLength + this.CONSTANTS.LEFT_RIGHT_SPACES * 2;
6638
- width = Math.max(width, minWidthNeeded);
6639
- }
6640
- // Zoom handling with proper spacing
6622
+ // Responsive zoom handling
6641
6623
  if (dataLength > this.CONSTANTS.ZOOM_THRESHOLD && this.isZoomedOut) {
6642
6624
  const minWidth = device.isMobile
6643
- ? dataLength * 15
6625
+ ? dataLength * 15 // Increased from 12
6644
6626
  : device.isTablet
6645
- ? dataLength * 25
6646
- : dataLength * 30;
6627
+ ? dataLength * 22 // Increased from 20
6628
+ : dataLength * 25;
6647
6629
  width = Math.max(width, minWidth);
6648
6630
  }
6649
6631
  if (dataLength > this.CONSTANTS.ZOOM_IN_THRESHOLD && !this.isZoomedOut) {
6650
6632
  width = device.isMobile
6651
- ? dataLength * 60
6633
+ ? dataLength * 55 // Increased from 50
6652
6634
  : device.isTablet
6653
- ? dataLength * 100
6635
+ ? dataLength * 80 // Reduced from 90
6654
6636
  : dataLength * 130;
6655
6637
  }
6656
6638
  if (this.chartConfiguration.isFullScreen) {
@@ -6659,7 +6641,7 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6659
6641
  : containerHeight;
6660
6642
  }
6661
6643
  if (this.chartConfiguration.isDrilldownChart) {
6662
- const offset = device.isMobile ? 70 : device.isTablet ? 100 : 130;
6644
+ const offset = device.isMobile ? 70 : device.isTablet ? 80 : 130;
6663
6645
  height = containerHeight - margin.top - margin.bottom - offset;
6664
6646
  }
6665
6647
  let barWidth;
@@ -6668,21 +6650,17 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6668
6650
  if (device.isMobile) {
6669
6651
  barWidth = this.CONSTANTS.MIN_MOBILE_BAR_WIDTH;
6670
6652
  barPadding = this.CONSTANTS.MOBILE_BAR_PADDING;
6671
- // Calculate total width with proper spacing
6672
- const totalBarSpace = (barWidth + barPadding) * dataLength;
6673
- requiredSvgWidth = Math.max(width - this.CONSTANTS.RIGHT_SVG_WIDTH, totalBarSpace + this.CONSTANTS.LEFT_RIGHT_SPACES * 2);
6653
+ requiredSvgWidth = Math.max(width - this.CONSTANTS.RIGHT_SVG_WIDTH, (barWidth + barPadding) * dataLength + this.CONSTANTS.LEFT_RIGHT_SPACES * 2 +
6654
+ this.CONSTANTS.RIGHT_SVG_WIDTH - barPadding);
6674
6655
  }
6675
6656
  else if (device.isTablet) {
6676
6657
  barWidth = this.CONSTANTS.TABLET_MIN_BAR_WIDTH;
6677
6658
  barPadding = this.CONSTANTS.TABLET_BAR_PADDING;
6678
- const totalBarSpace = (barWidth + barPadding) * dataLength;
6679
- requiredSvgWidth = Math.max(width - this.CONSTANTS.RIGHT_SVG_WIDTH, totalBarSpace + this.CONSTANTS.LEFT_RIGHT_SPACES * 2);
6659
+ requiredSvgWidth = Math.max(width - this.CONSTANTS.RIGHT_SVG_WIDTH, (barWidth + barPadding) * dataLength + this.CONSTANTS.LEFT_RIGHT_SPACES * 2 +
6660
+ this.CONSTANTS.RIGHT_SVG_WIDTH);
6680
6661
  }
6681
6662
  else {
6682
- // Desktop: calculate dynamically but ensure minimum width
6683
- const availableWidth = width - this.CONSTANTS.RIGHT_SVG_WIDTH - this.CONSTANTS.LEFT_RIGHT_SPACES * 2;
6684
- barWidth = Math.max(this.CONSTANTS.DESKTOP_MIN_BAR_WIDTH, availableWidth / (dataLength * 1.3) // 1.3 factor accounts for spacing
6685
- );
6663
+ barWidth = Math.max(this.CONSTANTS.DESKTOP_MIN_BAR_WIDTH, (width - this.CONSTANTS.RIGHT_SVG_WIDTH - this.CONSTANTS.LEFT_RIGHT_SPACES * 2) / dataLength);
6686
6664
  barPadding = 0;
6687
6665
  requiredSvgWidth = width - this.CONSTANTS.RIGHT_SVG_WIDTH;
6688
6666
  }
@@ -6739,18 +6717,9 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6739
6717
  return { svg, svgYAxisLeft, svgYAxisRight, innerContainer };
6740
6718
  }
6741
6719
  createScales(data, layers, lineData, dimensions, device) {
6742
- const { width, height } = dimensions;
6743
- // Device-specific padding for proper spacing
6744
- let padding;
6745
- if (device.isMobile) {
6746
- padding = this.CONSTANTS.MOBILE_BAR_SPACING;
6747
- }
6748
- else if (device.isTablet) {
6749
- padding = this.CONSTANTS.TABLET_BAR_SPACING;
6750
- }
6751
- else {
6752
- padding = this.CONSTANTS.DESKTOP_BAR_SPACING;
6753
- }
6720
+ const { width, height, barWidth, barPadding } = dimensions;
6721
+ // Adjust padding based on device
6722
+ const padding = device.isMobile ? 0.15 : device.isTablet ? 0.3 : 0.5;
6754
6723
  const xScale = d3
6755
6724
  .scaleBand()
6756
6725
  .rangeRound([
@@ -6758,8 +6727,7 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6758
6727
  width - this.CONSTANTS.RIGHT_SVG_WIDTH - this.CONSTANTS.LEFT_RIGHT_SPACES
6759
6728
  ])
6760
6729
  .domain(data.map(d => d.name).reverse())
6761
- .padding(padding)
6762
- .paddingOuter(0.2); // Extra padding on the outer edges
6730
+ .padding(padding);
6763
6731
  const xScaleFromOrigin = d3
6764
6732
  .scaleBand()
6765
6733
  .rangeRound([width - this.CONSTANTS.RIGHT_SVG_WIDTH, 0])
@@ -6845,10 +6813,9 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6845
6813
  })
6846
6814
  .attr('x', (d, i) => {
6847
6815
  if (device.isMobile || device.isTablet) {
6848
- // For mobile and tablet: use manual positioning with exact spacing
6816
+ // Use consistent positioning for mobile and tablet
6849
6817
  return this.CONSTANTS.LEFT_RIGHT_SPACES + i * (barWidth + barPadding);
6850
6818
  }
6851
- // For desktop: use D3's scaleBand positioning
6852
6819
  if (!this.chartConfiguration.isMultiChartGridLine) {
6853
6820
  return xScale(d.data.name);
6854
6821
  }
@@ -6865,14 +6832,10 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6865
6832
  return 0;
6866
6833
  })
6867
6834
  .attr('width', (d) => {
6868
- if (device.isMobile || device.isTablet) {
6869
- // Fixed width for mobile/tablet
6835
+ if (device.isMobile || device.isTablet)
6870
6836
  return barWidth;
6871
- }
6872
- // Dynamic width for desktop
6873
- if (!this.chartConfiguration.isMultiChartGridLine) {
6837
+ if (!this.chartConfiguration.isMultiChartGridLine)
6874
6838
  return xScale.bandwidth();
6875
- }
6876
6839
  if (this.chartConfiguration.isDrilldownChart && this.chartData.data.length <= 3) {
6877
6840
  return 70;
6878
6841
  }
@@ -6929,16 +6892,14 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6929
6892
  if (isNaN(value))
6930
6893
  return;
6931
6894
  const device = this.getDeviceConfig();
6932
- const bandwidth = device.isMobile || device.isTablet
6933
- ? this.CONSTANTS.MIN_MOBILE_BAR_WIDTH
6934
- : xScale.bandwidth();
6935
- // Responsive tooltip width with better sizing
6895
+ const bandwidth = xScale.bandwidth();
6896
+ // Responsive tooltip width
6936
6897
  let width;
6937
6898
  if (device.isMobile) {
6938
- width = Math.min(120, bandwidth * 2);
6899
+ width = Math.min(bandwidth + 40, 150);
6939
6900
  }
6940
6901
  else if (device.isTablet) {
6941
- width = Math.min(160, bandwidth * 1.8);
6902
+ width = Math.min(bandwidth + 60, 200);
6942
6903
  }
6943
6904
  else {
6944
6905
  width = /week/i.test(d.data.name) && /\d{4}-\d{2}-\d{2}/.test(d.data.name)
@@ -6947,16 +6908,9 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6947
6908
  ? '180px'
6948
6909
  : bandwidth + this.CONSTANTS.LEFT_RIGHT_SPACES * 2;
6949
6910
  }
6950
- const xPosition = device.isMobile || device.isTablet
6951
- ? this.CONSTANTS.LEFT_RIGHT_SPACES +
6952
- scales.xScale.domain().reverse().indexOf(d.data.name) *
6953
- (this.CONSTANTS.MIN_MOBILE_BAR_WIDTH + this.CONSTANTS.MOBILE_BAR_PADDING) +
6954
- this.CONSTANTS.MIN_MOBILE_BAR_WIDTH / 2 -
6955
- (typeof width === 'number' ? width : parseInt(width)) / 2
6956
- : this.calculateTooltipX(d, xScale, width);
6957
6911
  svg
6958
6912
  .append('foreignObject')
6959
- .attr('x', xPosition)
6913
+ .attr('x', this.calculateTooltipX(d, xScale, width))
6960
6914
  .attr('class', 'lib-verticalstack-title-ontop')
6961
6915
  .attr('y', yScale(d[1]) - 51)
6962
6916
  .attr('width', width)
@@ -7155,12 +7109,30 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
7155
7109
  this.applyAxisConfigurations(svg, scales, dimensions, data);
7156
7110
  }
7157
7111
  renderStandardAxes(svg, axes, scales, dimensions, device, data) {
7158
- if (device.isMobile || device.isTablet) {
7159
- // Use custom rendering for mobile and tablet
7160
- this.renderMobileXAxis(svg, data, dimensions, device);
7112
+ if (device.isMobile) {
7113
+ this.renderMobileXAxis(svg, data, dimensions);
7114
+ }
7115
+ else if (device.isTablet) {
7116
+ // Tablet: Render with rotation
7117
+ svg
7118
+ .append('g')
7119
+ .attr('transform', `translate(0,${dimensions.height})`)
7120
+ .attr('class', 'lib-stacked-x-axis-text')
7121
+ .call(axes.xAxis)
7122
+ .selectAll('text')
7123
+ .style('fill', 'var(--chart-text-color)')
7124
+ .style('font-size', '10px')
7125
+ .attr('text-anchor', 'end')
7126
+ .attr('dx', '-.8em')
7127
+ .attr('dy', '.15em')
7128
+ .attr('transform', 'rotate(-45)')
7129
+ .text((d) => {
7130
+ // Truncate long labels for tablet
7131
+ return d.length > 12 ? d.substring(0, 10) + '...' : d;
7132
+ });
7161
7133
  }
7162
7134
  else {
7163
- // Standard desktop rendering
7135
+ // Desktop: Standard horizontal labels
7164
7136
  svg
7165
7137
  .append('g')
7166
7138
  .attr('transform', `translate(0,${dimensions.height})`)
@@ -7174,7 +7146,6 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
7174
7146
  .attr('dy', '0.71em')
7175
7147
  .attr('transform', null);
7176
7148
  }
7177
- // Y-axis remains the same for all devices
7178
7149
  svg
7179
7150
  .append('g')
7180
7151
  .attr('class', 'lib-stacked-y-axis-text')
@@ -7183,48 +7154,44 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
7183
7154
  .selectAll('text')
7184
7155
  .style('fill', 'var(--chart-text-color)');
7185
7156
  }
7186
- renderMobileXAxis(svg, data, dimensions, device) {
7157
+ renderMobileXAxis(svg, data, dimensions) {
7187
7158
  svg.selectAll('.custom-x-label').remove();
7188
- const { barWidth, barPadding } = dimensions;
7189
- const maxLabelLength = Math.max(...data.map(d => d.name.length));
7190
- // Determine if we need to rotate labels
7191
- const shouldRotate = data.length > 6 || maxLabelLength > 8;
7159
+ // Adaptive font size based on label length
7160
+ const maxLength = Math.max(...data.map(d => d.name.length));
7161
+ let fontSize = '9px';
7162
+ if (maxLength > 15)
7163
+ fontSize = '7px';
7164
+ else if (maxLength > 10)
7165
+ fontSize = '8px';
7192
7166
  data.forEach((d, i) => {
7193
- const xPosition = this.CONSTANTS.LEFT_RIGHT_SPACES +
7194
- i * (barWidth + barPadding) +
7195
- barWidth / 2;
7196
- const label = svg
7167
+ const xVal = this.CONSTANTS.LEFT_RIGHT_SPACES +
7168
+ i * (dimensions.barWidth + dimensions.barPadding) +
7169
+ dimensions.barWidth / 2;
7170
+ // Truncate labels intelligently for mobile
7171
+ let labelText = d.name;
7172
+ if (labelText.length > 8) {
7173
+ // Try to truncate at word boundary
7174
+ const words = labelText.split(' ');
7175
+ if (words.length > 1) {
7176
+ labelText = words[0].substring(0, 4) + '...';
7177
+ }
7178
+ else {
7179
+ labelText = labelText.substring(0, 6) + '...';
7180
+ }
7181
+ }
7182
+ svg
7197
7183
  .append('text')
7198
7184
  .attr('class', 'custom-x-label')
7199
- .attr('x', xPosition)
7200
- .attr('y', dimensions.height + (shouldRotate ? 12 : 20))
7201
- .attr('text-anchor', shouldRotate ? 'end' : 'middle')
7202
- .style('font-size', device.isMobile ? '9px' : '10px')
7185
+ .attr('x', 0)
7186
+ .attr('y', dimensions.height + 15) // Adjusted positioning
7187
+ .attr('text-anchor', 'middle')
7188
+ .attr('transform', `translate(${xVal + 15},0)`)
7189
+ .style('font-size', fontSize)
7203
7190
  .style('fill', 'var(--chart-text-color)')
7204
- .text(this.formatXAxisLabel(d.name, device));
7205
- if (shouldRotate) {
7206
- label
7207
- .attr('transform', `rotate(-45, ${xPosition}, ${dimensions.height + 12})`)
7208
- .attr('dx', '-0.5em');
7209
- }
7191
+ .style('writing-mode', 'sideways-lr')
7192
+ .text(labelText);
7210
7193
  });
7211
7194
  }
7212
- formatXAxisLabel(label, device) {
7213
- if (device.isMobile) {
7214
- // Mobile: truncate longer labels
7215
- if (label.length > 8) {
7216
- return label.substring(0, 6) + '...';
7217
- }
7218
- return label;
7219
- }
7220
- else {
7221
- // Tablet: slightly longer labels allowed
7222
- if (label.length > 12) {
7223
- return label.substring(0, 10) + '...';
7224
- }
7225
- return label;
7226
- }
7227
- }
7228
7195
  renderDrilldownAxes(svg, svgYAxisLeft, svgYAxisRight, axes, scales, dimensions) {
7229
7196
  svg
7230
7197
  .append('g')