axidio-styleguide-library1-v2 0.3.7 → 0.3.9

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.
@@ -6639,7 +6639,11 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6639
6639
  requiredSvgWidth,
6640
6640
  };
6641
6641
  }
6642
- createSvgContainers(chartContainer, dimensions, margin) {
6642
+ createSvgContainers(chartContainer, dimensions, margin, hasXLabel // Add this parameter
6643
+ ) {
6644
+ // Calculate total height including space for X-axis label if present
6645
+ const xLabelSpace = hasXLabel ? 30 : 0;
6646
+ const totalHeight = dimensions.height + margin.top + margin.bottom + xLabelSpace;
6643
6647
  // Main wrapper
6644
6648
  const chartWrapper = chartContainer
6645
6649
  .append('div')
@@ -6647,7 +6651,7 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6647
6651
  .attr('class', 'chart-wrapper-main')
6648
6652
  .style('position', 'relative')
6649
6653
  .style('width', '100%')
6650
- .style('height', `${dimensions.height + margin.top + margin.bottom}px`);
6654
+ .style('height', `${totalHeight}px`); // Include X-label space
6651
6655
  // Left Y-axis - Fixed
6652
6656
  const leftAxisContainer = chartWrapper
6653
6657
  .append('div')
@@ -6656,7 +6660,7 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6656
6660
  .style('left', '0')
6657
6661
  .style('top', '0')
6658
6662
  .style('width', '80px')
6659
- .style('height', `${dimensions.height + margin.top + margin.bottom}px`)
6663
+ .style('height', `${dimensions.height + margin.top + margin.bottom}px`) // Exclude X-label space
6660
6664
  .style('background-color', 'var(--card-bg)')
6661
6665
  .style('z-index', '10');
6662
6666
  const svgYAxisLeft = leftAxisContainer
@@ -6673,7 +6677,7 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6673
6677
  .style('right', '0')
6674
6678
  .style('top', '0')
6675
6679
  .style('width', `${this.CONSTANTS.RIGHT_SVG_WIDTH}px`)
6676
- .style('height', `${dimensions.height + margin.top + margin.bottom}px`)
6680
+ .style('height', `${dimensions.height + margin.top + margin.bottom}px`) // Exclude X-label space
6677
6681
  .style('background-color', 'var(--card-bg)')
6678
6682
  .style('z-index', '10');
6679
6683
  const svgYAxisRight = rightAxisContainer
@@ -6691,7 +6695,7 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6691
6695
  .style('right', `${this.CONSTANTS.RIGHT_SVG_WIDTH}px`)
6692
6696
  .style('top', '0')
6693
6697
  .style('width', 'auto')
6694
- .style('height', `${dimensions.height + margin.top + margin.bottom}px`)
6698
+ .style('height', `${dimensions.height + margin.top + margin.bottom}px`) // Exclude X-label space
6695
6699
  .style('overflow-x', 'auto')
6696
6700
  .style('overflow-y', 'hidden');
6697
6701
  const innerContainer = scrollableContainer
@@ -6704,7 +6708,21 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6704
6708
  .attr('height', dimensions.height + margin.top + margin.bottom + 30)
6705
6709
  .append('g')
6706
6710
  .attr('transform', `translate(0,${margin.top})`);
6707
- return { svg, svgYAxisLeft, svgYAxisRight, innerContainer };
6711
+ // Fixed bottom container for X-axis label
6712
+ const bottomLabelContainer = chartWrapper
6713
+ .append('div')
6714
+ .attr('class', 'bottom-label-container')
6715
+ .style('position', 'absolute')
6716
+ .style('left', '80px')
6717
+ .style('right', `${this.CONSTANTS.RIGHT_SVG_WIDTH}px`)
6718
+ .style('bottom', '0')
6719
+ .style('height', `${xLabelSpace}px`)
6720
+ .style('display', 'flex')
6721
+ .style('justify-content', 'center')
6722
+ .style('align-items', 'center')
6723
+ .style('background-color', 'var(--card-bg)')
6724
+ .style('z-index', '10');
6725
+ return { svg, svgYAxisLeft, svgYAxisRight, innerContainer, bottomLabelContainer };
6708
6726
  }
6709
6727
  createScales(data, layers, lineData, dimensions) {
6710
6728
  const { width, height, barWidth, barPadding } = dimensions;
@@ -6714,9 +6732,10 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6714
6732
  const requiredWidth = totalBarsWidth + totalSpacing + (this.CONSTANTS.LEFT_RIGHT_SPACES * 2);
6715
6733
  const effectiveWidth = Math.max(width, requiredWidth);
6716
6734
  const paddingRatio = barPadding / (barWidth + barPadding);
6735
+ // X-scale starts from 0 (no left spacing for grid alignment)
6717
6736
  const xScale = d3
6718
6737
  .scaleBand()
6719
- .rangeRound([0, dimensions.requiredSvgWidth])
6738
+ .rangeRound([0, dimensions.requiredSvgWidth]) // Full width from 0
6720
6739
  .domain(data.map(d => d.name).reverse())
6721
6740
  .paddingInner(paddingRatio)
6722
6741
  .paddingOuter(0.5)
@@ -6926,12 +6945,12 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6926
6945
  .style('fill', (d) => this.getBarColor(d, metaData));
6927
6946
  svg.selectAll('.lib-verticalstack-title-ontop').remove();
6928
6947
  }
6929
- renderAxisLabels(svg, svgYAxisLeft, metaData, dimensions, margin) {
6948
+ renderAxisLabels(svg, svgYAxisLeft, bottomLabelContainer, metaData, dimensions, margin) {
6930
6949
  if (metaData.yLabel) {
6931
6950
  this.addYAxisLabel(svgYAxisLeft, metaData.yLabel, dimensions.height, margin);
6932
6951
  }
6933
6952
  if (metaData.xLabel) {
6934
- this.addXAxisLabel(svg, metaData.xLabel, dimensions.width, dimensions.height, margin);
6953
+ this.addXAxisLabel(bottomLabelContainer, metaData.xLabel);
6935
6954
  }
6936
6955
  }
6937
6956
  addYAxisLabel(svgYAxisLeft, label, height, margin) {
@@ -6952,21 +6971,18 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6952
6971
  .text(isAcronym ? label.toUpperCase() : label.toLowerCase())
6953
6972
  .style('text-transform', isAcronym ? 'none' : 'capitalize');
6954
6973
  }
6955
- addXAxisLabel(svg, label, width, height, margin) {
6956
- const isria = this.customChartConfiguration?.isRia;
6974
+ addXAxisLabel(bottomLabelContainer, label) {
6957
6975
  const isAcronym = this.isAcronymLabel(label);
6958
- const xPosition = isria
6959
- ? height + margin.top + margin.bottom
6960
- : height + margin.top + margin.bottom + 10;
6961
- svg
6962
- .append('text')
6963
- .attr('class', this.getXAxisLabelClass())
6964
- .attr('style', this.chartConfiguration.xAxisCustomlabelStyles)
6965
- .attr('transform', `translate(${width / 2},${xPosition})`)
6966
- .style('text-anchor', 'middle')
6967
- .style('fill', 'var(--chart-text-color)')
6968
- .text(isAcronym ? label.toUpperCase() : label.toLowerCase())
6969
- .style('text-transform', isAcronym ? 'none' : 'capitalize');
6976
+ bottomLabelContainer
6977
+ .append('div')
6978
+ .style('width', '100%')
6979
+ .style('text-align', 'center')
6980
+ .style('font-size', '12px')
6981
+ .style('font-weight', '600')
6982
+ .style('font-family', 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto')
6983
+ .style('color', 'var(--chart-text-color)')
6984
+ .style('text-transform', isAcronym ? 'none' : 'capitalize')
6985
+ .text(isAcronym ? label.toUpperCase() : label.toLowerCase());
6970
6986
  }
6971
6987
  isAcronymLabel(label) {
6972
6988
  const cleanLabel = label.replace(/[^A-Za-z]/g, '');
@@ -7020,7 +7036,8 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
7020
7036
  const verticalstackedcontainer = d3.select(this.verticalstackedcontainerElt.nativeElement);
7021
7037
  const margin = this.chartConfiguration.margin;
7022
7038
  const dimensions = this.calculateDimensions(chartContainer, verticalstackedcontainer, margin, data.length);
7023
- const { svg, svgYAxisLeft, svgYAxisRight } = this.createSvgContainers(chartContainer, dimensions, margin);
7039
+ const hasXLabel = !!metaData.xLabel;
7040
+ const { svg, svgYAxisLeft, svgYAxisRight, bottomLabelContainer } = this.createSvgContainers(chartContainer, dimensions, margin, hasXLabel);
7024
7041
  const stack = d3.stack().keys(keyList).offset(d3.stackOffsetNone);
7025
7042
  const layers = stack(data);
7026
7043
  data.sort((a, b) => b.total - a.total);
@@ -7029,7 +7046,7 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
7029
7046
  this.renderGrids(svg, scales, dimensions);
7030
7047
  const rect = this.renderBars(svg, layers, scales, metaData, dimensions);
7031
7048
  this.renderAxes(svg, svgYAxisLeft, svgYAxisRight, axes, scales, dimensions, data);
7032
- this.renderAxisLabels(svg, svgYAxisLeft, metaData, dimensions, margin);
7049
+ this.renderAxisLabels(svg, svgYAxisLeft, bottomLabelContainer, metaData, dimensions, margin);
7033
7050
  this.renderTargetLine(svg, svgYAxisRight, scales, dimensions, metaData);
7034
7051
  this.renderDataLabels(rect, scales, metaData, dimensions);
7035
7052
  this.renderLineChart(svg, lineData, scales, colors, metaData);
@@ -7098,20 +7115,19 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
7098
7115
  }
7099
7116
  renderStandardAxes(svg, axes, scales, dimensions, data) {
7100
7117
  const isMobileOrTablet = window.innerWidth < 1024;
7101
- // X-axis with labels - positioned at the bottom
7118
+ // X-axis with labels
7102
7119
  const xAxisGroup = svg
7103
7120
  .append('g')
7104
7121
  .attr('transform', `translate(0,${dimensions.height})`)
7105
7122
  .attr('class', 'lib-stacked-x-axis-text')
7106
7123
  .call(axes.xAxis);
7107
- // Style X-axis labels - make them visible
7124
+ // Style X-axis labels
7108
7125
  xAxisGroup
7109
7126
  .selectAll('text')
7110
7127
  .style('fill', 'var(--chart-text-color)')
7111
7128
  .style('font-size', isMobileOrTablet ? '10px' : '12px')
7112
7129
  .attr('text-anchor', 'middle')
7113
7130
  .attr('dy', '1em')
7114
- .style('display', 'block') // Ensure labels are visible
7115
7131
  .each(function (d) {
7116
7132
  const textElement = d3.select(this);
7117
7133
  const text = textElement.text();
@@ -7119,16 +7135,19 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
7119
7135
  textElement.text(text.substring(0, 10) + '...');
7120
7136
  }
7121
7137
  });
7122
- // Ensure X-axis line (domain) is visible
7138
+ // Ensure X-axis line is visible
7123
7139
  xAxisGroup
7124
7140
  .select('.domain')
7125
7141
  .style('stroke', 'var(--chart-axis-color)')
7126
- .style('stroke-width', '1px')
7127
- .style('display', 'block');
7128
- // Remove any hiding of tick marks
7129
- xAxisGroup
7130
- .selectAll('.tick line')
7131
- .style('display', 'block');
7142
+ .style('stroke-width', '1px');
7143
+ // Y-axis
7144
+ svg
7145
+ .append('g')
7146
+ .attr('class', 'lib-stacked-y-axis-text')
7147
+ .attr('style', this.chartConfiguration.yAxisCustomTextStyles)
7148
+ .call(axes.yAxis)
7149
+ .selectAll('text')
7150
+ .style('fill', 'var(--chart-text-color)');
7132
7151
  }
7133
7152
  renderDrilldownAxes(svg, svgYAxisLeft, svgYAxisRight, axes, scales, dimensions) {
7134
7153
  svg
@@ -7186,22 +7205,13 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
7186
7205
  }
7187
7206
  }
7188
7207
  applyAxisConfigurations(svg, scales, dimensions, data) {
7189
- // Only hide labels if explicitly configured
7190
- if (this.chartConfiguration.isMultiChartGridLine !== undefined &&
7191
- this.chartConfiguration.isXaxisLabelHidden !== false) {
7208
+ if (this.chartConfiguration.isMultiChartGridLine !== undefined) {
7192
7209
  d3.selectAll('.multichart > g > text').attr('class', 'lib-display-hidden');
7193
7210
  }
7194
- if (this.chartConfiguration.isXaxisLabelHidden === true) {
7195
- svg.selectAll('.lib-stacked-x-axis-text > g > text').attr('class', 'lib-display-hidden');
7196
- }
7197
- else if (this.chartConfiguration.isXaxisLabelHidden === false) {
7198
- // Explicitly show X-axis labels
7199
- svg.selectAll('.lib-stacked-x-axis-text > g > text')
7200
- .style('display', 'block')
7201
- .attr('class', '');
7211
+ if (this.chartConfiguration.isXaxisLabelHidden) {
7212
+ d3.selectAll('.multichart > g > text').attr('class', 'lib-display-hidden');
7202
7213
  }
7203
- else if (this.chartConfiguration.isMultiChartGridLine === undefined) {
7204
- // For standard charts, render custom X-axis if needed
7214
+ else if (this.chartConfiguration.isXaxisLabelHidden !== undefined) {
7205
7215
  this.renderCustomXAxis(svg, scales, dimensions, data);
7206
7216
  }
7207
7217
  if (this.chartConfiguration.isYaxisLabelHidden) {