axidio-styleguide-library1-v2 0.4.41 → 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.
|
@@ -3498,7 +3498,6 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
3498
3498
|
const containerWidth = parseInt(chartContainer.style('width'));
|
|
3499
3499
|
const leftSvgWidth = margin.left + 20;
|
|
3500
3500
|
const rightSvgWidth = 60;
|
|
3501
|
-
// Calculate available width excluding fixed y-axis elements
|
|
3502
3501
|
const baseWidth = containerWidth - leftSvgWidth - rightSvgWidth;
|
|
3503
3502
|
const dataLength = this.chartData.data.length;
|
|
3504
3503
|
let width = baseWidth;
|
|
@@ -3553,7 +3552,7 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
3553
3552
|
if (this.chartConfiguration.isMultiChartGridLine !== undefined) {
|
|
3554
3553
|
x = d3
|
|
3555
3554
|
.scaleBand()
|
|
3556
|
-
.rangeRound([
|
|
3555
|
+
.rangeRound([0, width]) // FIXED: Changed range to start from 0
|
|
3557
3556
|
.align(0.5)
|
|
3558
3557
|
.padding(0.5)
|
|
3559
3558
|
.domain(data.map((d) => d.name.toLowerCase()));
|
|
@@ -3562,11 +3561,22 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
3562
3561
|
x = d3
|
|
3563
3562
|
.scaleBand()
|
|
3564
3563
|
.domain(groups)
|
|
3565
|
-
.range([
|
|
3566
|
-
.padding(0.3)
|
|
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
|
+
]);
|
|
3567
3574
|
}
|
|
3568
3575
|
const xScaleFromOrigin = d3.scaleBand().domain(groups).range([0, width - rightSvgWidth]);
|
|
3569
|
-
const xSubgroup = d3.scaleBand()
|
|
3576
|
+
const xSubgroup = d3.scaleBand()
|
|
3577
|
+
.domain(keyList)
|
|
3578
|
+
.range([0, x.bandwidth()])
|
|
3579
|
+
.padding(0.1);
|
|
3570
3580
|
// FIXED: Improved max value calculation that considers height
|
|
3571
3581
|
const maxValue = this.calculateMaxValue(data, keyList, height);
|
|
3572
3582
|
const y = d3.scaleLinear().domain([0, maxValue]).nice().rangeRound([height, 0]);
|
|
@@ -3700,22 +3710,13 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
3700
3710
|
.attr('class', 'x1 axis1')
|
|
3701
3711
|
.attr('transform', `translate(0,${height})`)
|
|
3702
3712
|
.call(d3.axisBottom(x).tickSize(0));
|
|
3703
|
-
// FIXED: Show X-axis line
|
|
3704
3713
|
xAxis
|
|
3705
|
-
.select('.domain')
|
|
3706
|
-
.style('stroke', 'var(--chart-axis-color, #000000)')
|
|
3707
|
-
.style('stroke-width', '1px')
|
|
3708
|
-
.style('display', 'block');
|
|
3709
|
-
xAxis.selectAll('g.tick line').remove();
|
|
3710
|
-
const textClass = 'lib-xaxis-labels-texts-drilldown';
|
|
3711
|
-
const textSelection = xAxis
|
|
3712
3714
|
.selectAll('g.tick text')
|
|
3713
|
-
.attr('class',
|
|
3715
|
+
.attr('class', 'lib-xaxis-labels-texts-drilldown')
|
|
3714
3716
|
.style('fill', 'var(--chart-text-color, #666666)')
|
|
3715
|
-
.style('font-size', '11px')
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
}
|
|
3717
|
+
.style('font-size', '11px')
|
|
3718
|
+
.attr('text-anchor', 'middle')
|
|
3719
|
+
.attr('dx', x.bandwidth() / 2);
|
|
3719
3720
|
}
|
|
3720
3721
|
else {
|
|
3721
3722
|
this.renderMultiChartXAxis(svg, x, height, data, metaData);
|
|
@@ -3908,6 +3909,7 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
3908
3909
|
const { data, metaData, keyList, isRia } = chartContext;
|
|
3909
3910
|
const { x, xSubgroup, y } = scales;
|
|
3910
3911
|
const { height } = dimensions;
|
|
3912
|
+
// FIXED: Improved bar group positioning
|
|
3911
3913
|
const state = svg
|
|
3912
3914
|
.append('g')
|
|
3913
3915
|
.selectAll('.state')
|
|
@@ -3922,15 +3924,19 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
3922
3924
|
.append('rect')
|
|
3923
3925
|
.attr('class', 'bars')
|
|
3924
3926
|
.on('click', (d) => this.handleBarClick(d, metaData))
|
|
3925
|
-
.attr('x', (d) =>
|
|
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
|
+
})
|
|
3926
3934
|
.attr('y', (d) => {
|
|
3927
|
-
// FIXED: Ensure bars start from correct Y position
|
|
3928
3935
|
const value = d.value === -1 ? 0 : d.value;
|
|
3929
3936
|
return y(value);
|
|
3930
3937
|
})
|
|
3931
3938
|
.attr('width', (d) => this.getBarWidth(d, data, x, xSubgroup))
|
|
3932
3939
|
.attr('height', (d) => {
|
|
3933
|
-
// FIXED: Improved height calculation
|
|
3934
3940
|
const value = d.value === -1 ? 0 : d.value;
|
|
3935
3941
|
return height - y(value);
|
|
3936
3942
|
})
|
|
@@ -3961,7 +3967,10 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
3961
3967
|
if (this.chartConfiguration.isDrilldownChart) {
|
|
3962
3968
|
return this.calculateDrilldownBarX(d, data, x);
|
|
3963
3969
|
}
|
|
3964
|
-
|
|
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
|
|
3965
3974
|
}
|
|
3966
3975
|
calculateDrilldownBarX(d, data, x) {
|
|
3967
3976
|
let tempScale;
|
|
@@ -3969,27 +3978,38 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
3969
3978
|
if (indiv.name === d.name) {
|
|
3970
3979
|
const keys = Object.keys(indiv).filter((temp, i) => i !== 0);
|
|
3971
3980
|
tempScale = d3.scaleBand().domain(keys).range([0, x.bandwidth()]);
|
|
3981
|
+
// FIXED: Better centering for single bar and multiple bars
|
|
3972
3982
|
if (x.bandwidth() > 100) {
|
|
3973
3983
|
tempScale = this.adjustDrilldownScale(tempScale, data, x);
|
|
3974
3984
|
}
|
|
3975
3985
|
}
|
|
3976
3986
|
});
|
|
3977
|
-
|
|
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;
|
|
3978
3994
|
}
|
|
3979
3995
|
adjustDrilldownScale(tempScale, data, x) {
|
|
3996
|
+
// FIXED: Improved centering logic
|
|
3980
3997
|
if (this.chartData.data.length === 1) {
|
|
3981
|
-
|
|
3982
|
-
const
|
|
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
|
|
3983
4001
|
tempScale.range([
|
|
3984
|
-
|
|
3985
|
-
x.bandwidth() - (x.bandwidth() -
|
|
3986
|
-
]);
|
|
4002
|
+
(x.bandwidth() - totalBarWidth) / 2,
|
|
4003
|
+
x.bandwidth() - (x.bandwidth() - totalBarWidth) / 2
|
|
4004
|
+
]).padding(0.2);
|
|
3987
4005
|
}
|
|
3988
4006
|
else {
|
|
4007
|
+
// Multiple bars - distribute evenly with proper padding
|
|
4008
|
+
const totalBarWidth = Math.min(125, x.bandwidth() * 0.8);
|
|
3989
4009
|
tempScale.range([
|
|
3990
|
-
|
|
3991
|
-
x.bandwidth() - (x.bandwidth() -
|
|
3992
|
-
]);
|
|
4010
|
+
(x.bandwidth() - totalBarWidth) / 2,
|
|
4011
|
+
x.bandwidth() - (x.bandwidth() - totalBarWidth) / 2
|
|
4012
|
+
]).padding(0.3);
|
|
3993
4013
|
}
|
|
3994
4014
|
return tempScale;
|
|
3995
4015
|
}
|