axidio-styleguide-library1-v2 0.2.41 → 0.2.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.
- package/esm2022/lib/horizontal-bars-with-scroll-zoom/horizontal-bars-with-scroll-zoom.component.mjs +128 -59
- package/fesm2022/axidio-styleguide-library1-v2.mjs +127 -58
- package/fesm2022/axidio-styleguide-library1-v2.mjs.map +1 -1
- package/lib/horizontal-bars-with-scroll-zoom/horizontal-bars-with-scroll-zoom.component.d.ts +1 -0
- package/package.json +1 -1
|
@@ -6488,11 +6488,17 @@ 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
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
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
|
|
6496
6502
|
ZOOM_THRESHOLD: 30,
|
|
6497
6503
|
ZOOM_IN_THRESHOLD: 8,
|
|
6498
6504
|
};
|
|
@@ -6560,40 +6566,36 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
6560
6566
|
getDeviceConfig() {
|
|
6561
6567
|
const width = window.innerWidth;
|
|
6562
6568
|
return {
|
|
6563
|
-
isMobile: width < 768,
|
|
6564
|
-
isTablet: width >= 768 && width < 1024,
|
|
6565
|
-
isDesktop: width >= 1024,
|
|
6569
|
+
isMobile: width < 768,
|
|
6570
|
+
isTablet: width >= 768 && width < 1024,
|
|
6571
|
+
isDesktop: width >= 1024,
|
|
6566
6572
|
};
|
|
6567
6573
|
}
|
|
6568
6574
|
configureResponsiveSettings(device) {
|
|
6569
6575
|
if (device.isMobile) {
|
|
6570
|
-
this.chartConfiguration.margin = { top:
|
|
6576
|
+
this.chartConfiguration.margin = { top: 20, right: 10, bottom: 50, left: 30 };
|
|
6571
6577
|
this.chartConfiguration.numberOfYTicks = 4;
|
|
6572
|
-
this.chartConfiguration.svgHeight =
|
|
6578
|
+
this.chartConfiguration.svgHeight = 60;
|
|
6573
6579
|
}
|
|
6574
6580
|
else if (device.isTablet) {
|
|
6575
|
-
this.chartConfiguration.margin = { top:
|
|
6581
|
+
this.chartConfiguration.margin = { top: 25, right: 20, bottom: 55, left: 45 };
|
|
6576
6582
|
this.chartConfiguration.numberOfYTicks = 5;
|
|
6577
|
-
this.chartConfiguration.svgHeight =
|
|
6583
|
+
this.chartConfiguration.svgHeight = 70;
|
|
6578
6584
|
}
|
|
6579
6585
|
else {
|
|
6580
|
-
// Desktop/Large screens
|
|
6581
6586
|
const width = window.innerWidth;
|
|
6582
6587
|
if (width >= 1920) {
|
|
6583
|
-
|
|
6584
|
-
this.chartConfiguration.margin = { top: 35, right: 35, bottom: 55, left: 70 };
|
|
6588
|
+
this.chartConfiguration.margin = { top: 35, right: 35, bottom: 60, left: 70 };
|
|
6585
6589
|
this.chartConfiguration.numberOfYTicks = 8;
|
|
6586
6590
|
this.chartConfiguration.svgHeight = 85;
|
|
6587
6591
|
}
|
|
6588
6592
|
else if (width >= 1366) {
|
|
6589
|
-
|
|
6590
|
-
this.chartConfiguration.margin = { top: 30, right: 30, bottom: 50, left: 60 };
|
|
6593
|
+
this.chartConfiguration.margin = { top: 30, right: 30, bottom: 55, left: 60 };
|
|
6591
6594
|
this.chartConfiguration.numberOfYTicks = 7;
|
|
6592
6595
|
this.chartConfiguration.svgHeight = 80;
|
|
6593
6596
|
}
|
|
6594
6597
|
else {
|
|
6595
|
-
|
|
6596
|
-
this.chartConfiguration.margin = { top: 25, right: 25, bottom: 45, left: 50 };
|
|
6598
|
+
this.chartConfiguration.margin = { top: 25, right: 25, bottom: 50, left: 50 };
|
|
6597
6599
|
this.chartConfiguration.numberOfYTicks = 6;
|
|
6598
6600
|
this.chartConfiguration.svgHeight = 75;
|
|
6599
6601
|
}
|
|
@@ -6622,20 +6624,33 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
6622
6624
|
const containerHeight = verticalContainer.node().getBoundingClientRect().height;
|
|
6623
6625
|
let width = containerWidth - margin.left - margin.right;
|
|
6624
6626
|
let height = containerHeight * (this.chartConfiguration.svgHeight / 100) - margin.top - margin.bottom;
|
|
6625
|
-
//
|
|
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
|
|
6626
6641
|
if (dataLength > this.CONSTANTS.ZOOM_THRESHOLD && this.isZoomedOut) {
|
|
6627
6642
|
const minWidth = device.isMobile
|
|
6628
|
-
? dataLength *
|
|
6643
|
+
? dataLength * 15
|
|
6629
6644
|
: device.isTablet
|
|
6630
|
-
? dataLength *
|
|
6631
|
-
: dataLength *
|
|
6645
|
+
? dataLength * 25
|
|
6646
|
+
: dataLength * 30;
|
|
6632
6647
|
width = Math.max(width, minWidth);
|
|
6633
6648
|
}
|
|
6634
6649
|
if (dataLength > this.CONSTANTS.ZOOM_IN_THRESHOLD && !this.isZoomedOut) {
|
|
6635
6650
|
width = device.isMobile
|
|
6636
|
-
? dataLength *
|
|
6651
|
+
? dataLength * 60
|
|
6637
6652
|
: device.isTablet
|
|
6638
|
-
? dataLength *
|
|
6653
|
+
? dataLength * 100
|
|
6639
6654
|
: dataLength * 130;
|
|
6640
6655
|
}
|
|
6641
6656
|
if (this.chartConfiguration.isFullScreen) {
|
|
@@ -6644,7 +6659,7 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
6644
6659
|
: containerHeight;
|
|
6645
6660
|
}
|
|
6646
6661
|
if (this.chartConfiguration.isDrilldownChart) {
|
|
6647
|
-
const offset = device.isMobile ?
|
|
6662
|
+
const offset = device.isMobile ? 70 : device.isTablet ? 100 : 130;
|
|
6648
6663
|
height = containerHeight - margin.top - margin.bottom - offset;
|
|
6649
6664
|
}
|
|
6650
6665
|
let barWidth;
|
|
@@ -6653,16 +6668,21 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
6653
6668
|
if (device.isMobile) {
|
|
6654
6669
|
barWidth = this.CONSTANTS.MIN_MOBILE_BAR_WIDTH;
|
|
6655
6670
|
barPadding = this.CONSTANTS.MOBILE_BAR_PADDING;
|
|
6656
|
-
|
|
6657
|
-
|
|
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);
|
|
6658
6674
|
}
|
|
6659
6675
|
else if (device.isTablet) {
|
|
6660
6676
|
barWidth = this.CONSTANTS.TABLET_MIN_BAR_WIDTH;
|
|
6661
6677
|
barPadding = this.CONSTANTS.TABLET_BAR_PADDING;
|
|
6662
|
-
|
|
6678
|
+
const totalBarSpace = (barWidth + barPadding) * dataLength;
|
|
6679
|
+
requiredSvgWidth = Math.max(width - this.CONSTANTS.RIGHT_SVG_WIDTH, totalBarSpace + this.CONSTANTS.LEFT_RIGHT_SPACES * 2);
|
|
6663
6680
|
}
|
|
6664
6681
|
else {
|
|
6665
|
-
|
|
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
|
+
);
|
|
6666
6686
|
barPadding = 0;
|
|
6667
6687
|
requiredSvgWidth = width - this.CONSTANTS.RIGHT_SVG_WIDTH;
|
|
6668
6688
|
}
|
|
@@ -6719,9 +6739,18 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
6719
6739
|
return { svg, svgYAxisLeft, svgYAxisRight, innerContainer };
|
|
6720
6740
|
}
|
|
6721
6741
|
createScales(data, layers, lineData, dimensions, device) {
|
|
6722
|
-
const { width, height
|
|
6723
|
-
//
|
|
6724
|
-
|
|
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
|
+
}
|
|
6725
6754
|
const xScale = d3
|
|
6726
6755
|
.scaleBand()
|
|
6727
6756
|
.rangeRound([
|
|
@@ -6729,7 +6758,8 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
6729
6758
|
width - this.CONSTANTS.RIGHT_SVG_WIDTH - this.CONSTANTS.LEFT_RIGHT_SPACES
|
|
6730
6759
|
])
|
|
6731
6760
|
.domain(data.map(d => d.name).reverse())
|
|
6732
|
-
.padding(padding)
|
|
6761
|
+
.padding(padding)
|
|
6762
|
+
.paddingOuter(0.2); // Extra padding on the outer edges
|
|
6733
6763
|
const xScaleFromOrigin = d3
|
|
6734
6764
|
.scaleBand()
|
|
6735
6765
|
.rangeRound([width - this.CONSTANTS.RIGHT_SVG_WIDTH, 0])
|
|
@@ -6814,9 +6844,11 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
6814
6844
|
return 0;
|
|
6815
6845
|
})
|
|
6816
6846
|
.attr('x', (d, i) => {
|
|
6817
|
-
if (device.isMobile) {
|
|
6847
|
+
if (device.isMobile || device.isTablet) {
|
|
6848
|
+
// For mobile and tablet: use manual positioning with exact spacing
|
|
6818
6849
|
return this.CONSTANTS.LEFT_RIGHT_SPACES + i * (barWidth + barPadding);
|
|
6819
6850
|
}
|
|
6851
|
+
// For desktop: use D3's scaleBand positioning
|
|
6820
6852
|
if (!this.chartConfiguration.isMultiChartGridLine) {
|
|
6821
6853
|
return xScale(d.data.name);
|
|
6822
6854
|
}
|
|
@@ -6833,10 +6865,14 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
6833
6865
|
return 0;
|
|
6834
6866
|
})
|
|
6835
6867
|
.attr('width', (d) => {
|
|
6836
|
-
if (device.isMobile)
|
|
6868
|
+
if (device.isMobile || device.isTablet) {
|
|
6869
|
+
// Fixed width for mobile/tablet
|
|
6837
6870
|
return barWidth;
|
|
6838
|
-
|
|
6871
|
+
}
|
|
6872
|
+
// Dynamic width for desktop
|
|
6873
|
+
if (!this.chartConfiguration.isMultiChartGridLine) {
|
|
6839
6874
|
return xScale.bandwidth();
|
|
6875
|
+
}
|
|
6840
6876
|
if (this.chartConfiguration.isDrilldownChart && this.chartData.data.length <= 3) {
|
|
6841
6877
|
return 70;
|
|
6842
6878
|
}
|
|
@@ -6893,14 +6929,16 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
6893
6929
|
if (isNaN(value))
|
|
6894
6930
|
return;
|
|
6895
6931
|
const device = this.getDeviceConfig();
|
|
6896
|
-
const bandwidth =
|
|
6897
|
-
|
|
6932
|
+
const bandwidth = device.isMobile || device.isTablet
|
|
6933
|
+
? this.CONSTANTS.MIN_MOBILE_BAR_WIDTH
|
|
6934
|
+
: xScale.bandwidth();
|
|
6935
|
+
// Responsive tooltip width with better sizing
|
|
6898
6936
|
let width;
|
|
6899
6937
|
if (device.isMobile) {
|
|
6900
|
-
width = Math.min(bandwidth
|
|
6938
|
+
width = Math.min(120, bandwidth * 2);
|
|
6901
6939
|
}
|
|
6902
6940
|
else if (device.isTablet) {
|
|
6903
|
-
width = Math.min(bandwidth
|
|
6941
|
+
width = Math.min(160, bandwidth * 1.8);
|
|
6904
6942
|
}
|
|
6905
6943
|
else {
|
|
6906
6944
|
width = /week/i.test(d.data.name) && /\d{4}-\d{2}-\d{2}/.test(d.data.name)
|
|
@@ -6909,9 +6947,16 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
6909
6947
|
? '180px'
|
|
6910
6948
|
: bandwidth + this.CONSTANTS.LEFT_RIGHT_SPACES * 2;
|
|
6911
6949
|
}
|
|
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);
|
|
6912
6957
|
svg
|
|
6913
6958
|
.append('foreignObject')
|
|
6914
|
-
.attr('x',
|
|
6959
|
+
.attr('x', xPosition)
|
|
6915
6960
|
.attr('class', 'lib-verticalstack-title-ontop')
|
|
6916
6961
|
.attr('y', yScale(d[1]) - 51)
|
|
6917
6962
|
.attr('width', width)
|
|
@@ -7110,10 +7155,12 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7110
7155
|
this.applyAxisConfigurations(svg, scales, dimensions, data);
|
|
7111
7156
|
}
|
|
7112
7157
|
renderStandardAxes(svg, axes, scales, dimensions, device, data) {
|
|
7113
|
-
if (device.isMobile) {
|
|
7114
|
-
|
|
7158
|
+
if (device.isMobile || device.isTablet) {
|
|
7159
|
+
// Use custom rendering for mobile and tablet
|
|
7160
|
+
this.renderMobileXAxis(svg, data, dimensions, device);
|
|
7115
7161
|
}
|
|
7116
7162
|
else {
|
|
7163
|
+
// Standard desktop rendering
|
|
7117
7164
|
svg
|
|
7118
7165
|
.append('g')
|
|
7119
7166
|
.attr('transform', `translate(0,${dimensions.height})`)
|
|
@@ -7127,6 +7174,7 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7127
7174
|
.attr('dy', '0.71em')
|
|
7128
7175
|
.attr('transform', null);
|
|
7129
7176
|
}
|
|
7177
|
+
// Y-axis remains the same for all devices
|
|
7130
7178
|
svg
|
|
7131
7179
|
.append('g')
|
|
7132
7180
|
.attr('class', 'lib-stacked-y-axis-text')
|
|
@@ -7135,27 +7183,48 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7135
7183
|
.selectAll('text')
|
|
7136
7184
|
.style('fill', 'var(--chart-text-color)');
|
|
7137
7185
|
}
|
|
7138
|
-
renderMobileXAxis(svg, data, dimensions) {
|
|
7186
|
+
renderMobileXAxis(svg, data, dimensions, device) {
|
|
7139
7187
|
svg.selectAll('.custom-x-label').remove();
|
|
7140
|
-
const
|
|
7141
|
-
const
|
|
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;
|
|
7142
7192
|
data.forEach((d, i) => {
|
|
7143
|
-
const
|
|
7144
|
-
i * (
|
|
7145
|
-
|
|
7146
|
-
svg
|
|
7193
|
+
const xPosition = this.CONSTANTS.LEFT_RIGHT_SPACES +
|
|
7194
|
+
i * (barWidth + barPadding) +
|
|
7195
|
+
barWidth / 2;
|
|
7196
|
+
const label = svg
|
|
7147
7197
|
.append('text')
|
|
7148
7198
|
.attr('class', 'custom-x-label')
|
|
7149
|
-
.attr('x',
|
|
7150
|
-
.attr('y', dimensions.height +
|
|
7151
|
-
.attr('text-anchor', 'middle')
|
|
7152
|
-
.
|
|
7153
|
-
.style('font-size', fontSize)
|
|
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')
|
|
7154
7203
|
.style('fill', 'var(--chart-text-color)')
|
|
7155
|
-
.
|
|
7156
|
-
|
|
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
|
+
}
|
|
7157
7210
|
});
|
|
7158
7211
|
}
|
|
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
|
+
}
|
|
7159
7228
|
renderDrilldownAxes(svg, svgYAxisLeft, svgYAxisRight, axes, scales, dimensions) {
|
|
7160
7229
|
svg
|
|
7161
7230
|
.append('g')
|