axidio-styleguide-library1-v2 0.4.42 → 0.4.43

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.
@@ -3545,41 +3545,39 @@ class GroupChartComponent extends ComponentUniqueId {
3545
3545
  createScales(chartContext, dimensions) {
3546
3546
  const { data, metaData, lineData, keyList } = chartContext;
3547
3547
  const { width, height, margin } = dimensions;
3548
- // FIXED: Better calculation of available space
3549
- const leftAndRightSpaces = 60; // Increased for better label spacing
3548
+ const leftAndRightSpaces = 50;
3550
3549
  const rightSvgWidth = 60;
3551
3550
  const groups = d3.map(data, (d) => d.name).keys();
3552
- // FIXED: Improved X-scale calculation for centered bars
3553
3551
  let x;
3554
3552
  if (this.chartConfiguration.isMultiChartGridLine !== undefined) {
3555
3553
  x = d3
3556
3554
  .scaleBand()
3557
- .rangeRound([0, width - rightSvgWidth]) // FIXED: Start from 0 for proper alignment
3555
+ .rangeRound([0, width]) // FIXED: Changed range to start from 0
3558
3556
  .align(0.5)
3559
- .padding(0.3) // FIXED: Consistent padding
3557
+ .padding(0.5)
3560
3558
  .domain(data.map((d) => d.name.toLowerCase()));
3561
3559
  }
3562
3560
  else {
3563
3561
  x = d3
3564
3562
  .scaleBand()
3565
3563
  .domain(groups)
3566
- .range([leftAndRightSpaces, width - rightSvgWidth - leftAndRightSpaces])
3567
- .padding(0.3) // FIXED: Consistent padding
3568
- .align(0.5); // FIXED: Center alignment
3564
+ .range([0, width - rightSvgWidth]) // FIXED: Start from 0 for better centering
3565
+ .padding(0.3)
3566
+ .align(0.5); // FIXED: Center the bands
3567
+ }
3568
+ if (data.length === 1 && !this.chartConfiguration.isMultiChartGridLine) {
3569
+ const singleBarWidth = Math.min(80, (width - rightSvgWidth) * 0.6); // Max 60% of available width
3570
+ x.range([
3571
+ ((width - rightSvgWidth) - singleBarWidth) / 2,
3572
+ ((width - rightSvgWidth) - singleBarWidth) / 2 + singleBarWidth
3573
+ ]);
3569
3574
  }
3570
- // FIXED: X scale for proper label positioning
3571
- const xScaleFromOrigin = d3
3572
- .scaleBand()
3573
- .domain(groups)
3574
- .range([0, width - rightSvgWidth])
3575
- .padding(0.3)
3576
- .align(0.5);
3577
- const xSubgroup = d3
3578
- .scaleBand()
3575
+ const xScaleFromOrigin = d3.scaleBand().domain(groups).range([0, width - rightSvgWidth]);
3576
+ const xSubgroup = d3.scaleBand()
3579
3577
  .domain(keyList)
3580
3578
  .range([0, x.bandwidth()])
3581
- .padding(0.1); // FIXED: Add padding between grouped bars
3582
- // FIXED: Improved max value calculation
3579
+ .padding(0.1);
3580
+ // FIXED: Improved max value calculation that considers height
3583
3581
  const maxValue = this.calculateMaxValue(data, keyList, height);
3584
3582
  const y = d3.scaleLinear().domain([0, maxValue]).nice().rangeRound([height, 0]);
3585
3583
  let lineYscale = null;
@@ -3633,8 +3631,8 @@ class GroupChartComponent extends ComponentUniqueId {
3633
3631
  createSVGStructure(dimensions) {
3634
3632
  const { chartContainer, height, margin } = dimensions;
3635
3633
  const rightSvgWidth = 60;
3636
- // FIXED: Calculate total height including margins
3637
- const totalHeight = height + margin.top + margin.bottom + 20; // Added extra space for labels
3634
+ // FIXED: Calculate total height including margins and extra space
3635
+ const totalHeight = height + margin.top + margin.bottom; // Added extra 60px
3638
3636
  const outerContainer = chartContainer
3639
3637
  .append('div')
3640
3638
  .attr('id', this.uniqueId)
@@ -3642,10 +3640,12 @@ class GroupChartComponent extends ComponentUniqueId {
3642
3640
  .style('width', '100%')
3643
3641
  .style('height', `${totalHeight}px`)
3644
3642
  .style('overflow', 'hidden')
3643
+ .style('padding-left', '0') // Remove left padding from outer container
3645
3644
  .style('padding-right', `${rightSvgWidth}px`)
3645
+ .style('margin-left', '0') // Remove left margin
3646
3646
  .style('position', 'relative');
3647
3647
  const leftSvgWidth = margin.left + 20;
3648
- // FIXED: Y-axis SVG
3648
+ // FIXED: Y-axis SVG with proper height
3649
3649
  const svgYAxisLeft = outerContainer
3650
3650
  .append('svg')
3651
3651
  .attr('width', leftSvgWidth)
@@ -3653,7 +3653,7 @@ class GroupChartComponent extends ComponentUniqueId {
3653
3653
  .style('position', 'absolute')
3654
3654
  .style('left', '0')
3655
3655
  .style('top', '0')
3656
- .style('z-index', 2)
3656
+ .style('z-index', 2) // Increased z-index to ensure it stays above
3657
3657
  .append('g')
3658
3658
  .attr('transform', `translate(${margin.left + 5},${margin.top})`);
3659
3659
  const svgYAxisRight = outerContainer
@@ -3663,20 +3663,20 @@ class GroupChartComponent extends ComponentUniqueId {
3663
3663
  .style('position', 'absolute')
3664
3664
  .style('right', '40px')
3665
3665
  .style('top', '0')
3666
- .style('z-index', 2)
3666
+ .style('z-index', 2) // Increased z-index
3667
3667
  .append('g')
3668
3668
  .attr('transform', `translate(0,${margin.top})`);
3669
- // FIXED: Inner container with proper overflow handling
3669
+ // FIXED: Inner container starts AFTER the y-axis labels
3670
3670
  const innerContainer = outerContainer
3671
3671
  .append('div')
3672
3672
  .attr('class', 'inner-container')
3673
3673
  .style('width', `calc(100% - ${leftSvgWidth}px)`)
3674
3674
  .style('height', `${totalHeight}px`)
3675
- .style('margin-left', `${leftSvgWidth - 15}px`)
3675
+ .style('margin-left', `${leftSvgWidth - 15}px`) // Good adjustment for the 15px offset
3676
3676
  .style('overflow-x', 'auto')
3677
3677
  .style('overflow-y', 'hidden')
3678
- .style('position', 'relative');
3679
- // FIXED: Main SVG with proper dimensions for labels
3678
+ .style('position', 'relative'); // Add this for better positioning context
3679
+ // FIXED: Main SVG with increased height and proper positioning
3680
3680
  const svg = innerContainer
3681
3681
  .append('svg')
3682
3682
  .attr('width', dimensions.width - rightSvgWidth)
@@ -3704,51 +3704,27 @@ class GroupChartComponent extends ComponentUniqueId {
3704
3704
  }
3705
3705
  renderXAxis(svg, x, xScaleFromOrigin, height, chartContext, keyList) {
3706
3706
  const { data, metaData } = chartContext;
3707
- // FIXED: Always show X-axis labels regardless of scroll
3708
- const xAxis = svg
3709
- .append('g')
3710
- .attr('class', 'x1 axis1')
3711
- .attr('transform', `translate(0,${height})`)
3712
- .call(d3.axisBottom(x).tickSize(0));
3713
- // FIXED: Ensure X-axis line is visible
3714
- xAxis
3715
- .select('.domain')
3716
- .style('stroke', 'var(--chart-axis-color, #000000)')
3717
- .style('stroke-width', '1px')
3718
- .style('display', 'block');
3719
- xAxis.selectAll('g.tick line').remove();
3720
- // FIXED: Center align X-axis labels properly
3721
- const textSelection = xAxis
3722
- .selectAll('g.tick text')
3723
- .attr('class', 'lib-xaxis-labels-texts-drilldown')
3724
- .style('fill', 'var(--chart-text-color, #666666)')
3725
- .style('font-size', '11px')
3726
- .style('text-anchor', 'middle') // FIXED: Center alignment
3727
- .attr('dx', '0') // FIXED: Remove any horizontal offset
3728
- .attr('dy', '15px') // FIXED: Consistent vertical position
3729
- .text(d => {
3730
- // FIXED: Handle label formatting consistently
3731
- if (typeof d === 'string') {
3732
- return d.toLowerCase();
3733
- }
3734
- return d;
3735
- });
3736
- // FIXED: Apply consistent positioning for multi-key charts
3737
- if (keyList.length > 1 && !metaData.xLabel) {
3738
- textSelection.attr('y', 28);
3739
- }
3740
- // FIXED: Don't hide labels when zoomed out, just adjust styling
3741
- if (this.isZoomedOut) {
3742
- svg.selectAll('.lib-xaxis-labels-texts-drilldown')
3743
- .style('font-size', '9px')
3744
- .style('opacity', '0.8');
3707
+ if (this.chartConfiguration.isMultiChartGridLine === undefined) {
3708
+ const xAxis = svg
3709
+ .append('g')
3710
+ .attr('class', 'x1 axis1')
3711
+ .attr('transform', `translate(0,${height})`)
3712
+ .call(d3.axisBottom(x).tickSize(0));
3713
+ xAxis
3714
+ .selectAll('g.tick text')
3715
+ .attr('class', 'lib-xaxis-labels-texts-drilldown')
3716
+ .style('fill', 'var(--chart-text-color, #666666)')
3717
+ .style('font-size', '11px')
3718
+ .attr('text-anchor', 'middle')
3719
+ .attr('dx', x.bandwidth() / 2);
3745
3720
  }
3746
3721
  else {
3747
- svg.selectAll('.lib-xaxis-labels-texts-drilldown')
3748
- .style('font-size', '11px')
3749
- .style('opacity', '1');
3722
+ this.renderMultiChartXAxis(svg, x, height, data, metaData);
3723
+ }
3724
+ if (this.chartConfiguration.xLabelsOnSameLine) {
3725
+ this.renderXLabelsOnSameLine(svg, data, metaData);
3750
3726
  }
3751
- // FIXED: Render bottom X-axis with proper positioning
3727
+ // Bottom x-axis
3752
3728
  const xAxis2 = svg
3753
3729
  .append('g')
3754
3730
  .attr('class', 'x2 axis2')
@@ -3760,10 +3736,10 @@ class GroupChartComponent extends ComponentUniqueId {
3760
3736
  .style('stroke', 'var(--chart-axis-color, #000000)')
3761
3737
  .style('stroke-width', '1px')
3762
3738
  .attr('fill', 'none');
3763
- // FIXED: Keep X-axis labels visible but style them appropriately
3764
- svg.selectAll('g.x2.axis2 g.tick text')
3765
- .style('opacity', '0.6')
3766
- .style('font-size', '10px');
3739
+ svg.selectAll('g.x2.axis2 g.tick text').style('display', 'none');
3740
+ if (this.isZoomedOut) {
3741
+ svg.selectAll('.lib-xaxis-labels-texts-drilldown').attr('class', 'lib-display-hidden');
3742
+ }
3767
3743
  }
3768
3744
  renderMultiChartXAxis(svg, x, height, data, metaData) {
3769
3745
  let alternate_text = false;
@@ -3933,6 +3909,7 @@ class GroupChartComponent extends ComponentUniqueId {
3933
3909
  const { data, metaData, keyList, isRia } = chartContext;
3934
3910
  const { x, xSubgroup, y } = scales;
3935
3911
  const { height } = dimensions;
3912
+ // FIXED: Improved bar group positioning
3936
3913
  const state = svg
3937
3914
  .append('g')
3938
3915
  .selectAll('.state')
@@ -3947,15 +3924,19 @@ class GroupChartComponent extends ComponentUniqueId {
3947
3924
  .append('rect')
3948
3925
  .attr('class', 'bars')
3949
3926
  .on('click', (d) => this.handleBarClick(d, metaData))
3950
- .attr('x', (d) => this.getBarX(d, data, x, xSubgroup))
3927
+ .attr('x', (d) => {
3928
+ // FIXED: Improved X positioning for centering
3929
+ if (this.chartConfiguration.isDrilldownChart) {
3930
+ return this.calculateDrilldownBarX(d, data, x) - (this.getBarWidth(d, data, x, xSubgroup) / 2);
3931
+ }
3932
+ return xSubgroup(d.key);
3933
+ })
3951
3934
  .attr('y', (d) => {
3952
- // FIXED: Ensure bars start from correct Y position
3953
3935
  const value = d.value === -1 ? 0 : d.value;
3954
3936
  return y(value);
3955
3937
  })
3956
3938
  .attr('width', (d) => this.getBarWidth(d, data, x, xSubgroup))
3957
3939
  .attr('height', (d) => {
3958
- // FIXED: Improved height calculation
3959
3940
  const value = d.value === -1 ? 0 : d.value;
3960
3941
  return height - y(value);
3961
3942
  })
@@ -3986,7 +3967,10 @@ class GroupChartComponent extends ComponentUniqueId {
3986
3967
  if (this.chartConfiguration.isDrilldownChart) {
3987
3968
  return this.calculateDrilldownBarX(d, data, x);
3988
3969
  }
3989
- return xSubgroup(d.key);
3970
+ // FIXED: For non-drilldown charts, ensure proper positioning
3971
+ const basePosition = xSubgroup(d.key);
3972
+ const barWidth = xSubgroup.bandwidth();
3973
+ return basePosition + (barWidth / 2); // Center of the bar
3990
3974
  }
3991
3975
  calculateDrilldownBarX(d, data, x) {
3992
3976
  let tempScale;
@@ -3994,27 +3978,38 @@ class GroupChartComponent extends ComponentUniqueId {
3994
3978
  if (indiv.name === d.name) {
3995
3979
  const keys = Object.keys(indiv).filter((temp, i) => i !== 0);
3996
3980
  tempScale = d3.scaleBand().domain(keys).range([0, x.bandwidth()]);
3981
+ // FIXED: Better centering for single bar and multiple bars
3997
3982
  if (x.bandwidth() > 100) {
3998
3983
  tempScale = this.adjustDrilldownScale(tempScale, data, x);
3999
3984
  }
4000
3985
  }
4001
3986
  });
4002
- return tempScale ? tempScale(d.key) : 0;
3987
+ // FIXED: Ensure proper centering
3988
+ if (tempScale) {
3989
+ const barPosition = tempScale(d.key);
3990
+ const barWidth = tempScale.bandwidth();
3991
+ return barPosition + (barWidth / 2); // Center of the bar
3992
+ }
3993
+ return 0;
4003
3994
  }
4004
3995
  adjustDrilldownScale(tempScale, data, x) {
3996
+ // FIXED: Improved centering logic
4005
3997
  if (this.chartData.data.length === 1) {
4006
- const keysLength = Object.keys(this.chartData.data[0]).length;
4007
- const offset = keysLength === 2 ? 200 : 300;
3998
+ // Single bar - center it properly
3999
+ const keysLength = Object.keys(this.chartData.data[0]).length - 1; // Exclude 'name'
4000
+ const totalBarWidth = Math.min(keysLength * 40, x.bandwidth() * 0.8); // Max 80% of available width
4008
4001
  tempScale.range([
4009
- 0 + (x.bandwidth() - offset) / 2,
4010
- x.bandwidth() - (x.bandwidth() - offset) / 2,
4011
- ]);
4002
+ (x.bandwidth() - totalBarWidth) / 2,
4003
+ x.bandwidth() - (x.bandwidth() - totalBarWidth) / 2
4004
+ ]).padding(0.2);
4012
4005
  }
4013
4006
  else {
4007
+ // Multiple bars - distribute evenly with proper padding
4008
+ const totalBarWidth = Math.min(125, x.bandwidth() * 0.8);
4014
4009
  tempScale.range([
4015
- 0 + (x.bandwidth() - 125) / 2,
4016
- x.bandwidth() - (x.bandwidth() - 125) / 2,
4017
- ]);
4010
+ (x.bandwidth() - totalBarWidth) / 2,
4011
+ x.bandwidth() - (x.bandwidth() - totalBarWidth) / 2
4012
+ ]).padding(0.3);
4018
4013
  }
4019
4014
  return tempScale;
4020
4015
  }