axidio-styleguide-library1-v2 0.1.26 → 0.1.28
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/group-chart/group-chart.component.mjs +21 -22
- package/esm2022/lib/horizontal-bars-with-scroll-zoom/horizontal-bars-with-scroll-zoom.component.mjs +260 -177
- package/esm2022/lib/horizontal-grouped-bar-with-scroll-zoom/horizontal-grouped-bar-with-scroll-zoom.component.mjs +60 -22
- package/fesm2022/axidio-styleguide-library1-v2.mjs +338 -218
- package/fesm2022/axidio-styleguide-library1-v2.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -3939,8 +3939,8 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
3939
3939
|
else {
|
|
3940
3940
|
x = d3
|
|
3941
3941
|
.scaleBand()
|
|
3942
|
+
.domain(groups)
|
|
3942
3943
|
.range([leftAndRightSpaces, width - rightSvgWidth - leftAndRightSpaces])
|
|
3943
|
-
.domain(groups).reverse()
|
|
3944
3944
|
.padding([0.3]);
|
|
3945
3945
|
}
|
|
3946
3946
|
// x.bandwidth(96);
|
|
@@ -4557,30 +4557,29 @@ class GroupChartComponent extends ComponentUniqueId {
|
|
|
4557
4557
|
.attr('class', 'title')
|
|
4558
4558
|
.style('z-index', 99)
|
|
4559
4559
|
.html(function () {
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
'<span class="title-bar-name">' +
|
|
4568
|
-
(d.data.name ? d.data.name : '') +
|
|
4569
|
-
'</span>';
|
|
4570
|
-
desiredText += metaData.unit
|
|
4571
|
-
? '<span class="title-top-text">' +
|
|
4572
|
-
metaData.unit +
|
|
4573
|
-
(d[1] - d[0]) +
|
|
4574
|
-
dataType +
|
|
4575
|
-
'</span>'
|
|
4576
|
-
: '<span class="title-top-text">' +
|
|
4577
|
-
(d[1] - d[0]) +
|
|
4560
|
+
let dataType = metaData.dataType ? metaData.dataType : '';
|
|
4561
|
+
if (!self.isZoomedOut) {
|
|
4562
|
+
let desiredText = '<span class="title-bar-name">' + d.name + '</span>';
|
|
4563
|
+
desiredText +=
|
|
4564
|
+
'<span class="title-bar-value"><span>' +
|
|
4565
|
+
d.Value +
|
|
4566
|
+
'</span>' +
|
|
4578
4567
|
dataType +
|
|
4579
4568
|
'</span>';
|
|
4580
4569
|
return desiredText;
|
|
4581
4570
|
}
|
|
4582
|
-
else
|
|
4583
|
-
|
|
4571
|
+
else {
|
|
4572
|
+
let tempKey = d.name.length <= 8 ? d.name : d.name.substring(0, 5) + '...';
|
|
4573
|
+
let desiredText = '<span class="title-bar-name">' +
|
|
4574
|
+
tempKey +
|
|
4575
|
+
':' +
|
|
4576
|
+
d.Value +
|
|
4577
|
+
dataType +
|
|
4578
|
+
'</span>';
|
|
4579
|
+
desiredText +=
|
|
4580
|
+
'<span class="title-bar-value">' + d.name + '</span>';
|
|
4581
|
+
return desiredText;
|
|
4582
|
+
}
|
|
4584
4583
|
});
|
|
4585
4584
|
}
|
|
4586
4585
|
function handleMouseOut(d, i) {
|
|
@@ -7120,10 +7119,10 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7120
7119
|
this.uniqueId = this.getUniqueId();
|
|
7121
7120
|
this.isTransparentBackground = false;
|
|
7122
7121
|
this.defaultConfiguration = {
|
|
7123
|
-
margin: { top:
|
|
7124
|
-
svgHeight:
|
|
7122
|
+
margin: { top: 20, right: 20, bottom: 20, left: 40 },
|
|
7123
|
+
svgHeight: 70,
|
|
7125
7124
|
legendHeight: '10%',
|
|
7126
|
-
numberOfYTicks:
|
|
7125
|
+
numberOfYTicks: 5,
|
|
7127
7126
|
labelFormatter: ChartHelper.defaultFormatter,
|
|
7128
7127
|
xAxisLabelFomatter: ChartHelper.defaultFormatter,
|
|
7129
7128
|
yAxisLabelFomatter: ChartHelper.defaultFormatter,
|
|
@@ -7199,6 +7198,27 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7199
7198
|
var tempObjectHolder = {};
|
|
7200
7199
|
var rightSvgWidth = 60;
|
|
7201
7200
|
var leftAndRightSpaces = 50;
|
|
7201
|
+
let isria = this.customChartConfiguration.isRia;
|
|
7202
|
+
// Responsive breakpoints
|
|
7203
|
+
const isMobile = window.innerWidth < 576;
|
|
7204
|
+
const isTablet = window.innerWidth >= 576 && window.innerWidth < 992;
|
|
7205
|
+
const isDesktop = window.innerWidth >= 992;
|
|
7206
|
+
// Adjust margins and font sizes based on device
|
|
7207
|
+
if (isMobile) {
|
|
7208
|
+
this.chartConfiguration.margin = { top: 20, right: 10, bottom: 40, left: 30 };
|
|
7209
|
+
this.chartConfiguration.numberOfYTicks = 4;
|
|
7210
|
+
this.chartConfiguration.svgHeight = 60;
|
|
7211
|
+
}
|
|
7212
|
+
else if (isTablet) {
|
|
7213
|
+
this.chartConfiguration.margin = { top: 25, right: 20, bottom: 45, left: 40 };
|
|
7214
|
+
this.chartConfiguration.numberOfYTicks = 6;
|
|
7215
|
+
this.chartConfiguration.svgHeight = 70;
|
|
7216
|
+
}
|
|
7217
|
+
else {
|
|
7218
|
+
this.chartConfiguration.margin = { top: 30, right: 30, bottom: 50, left: 60 };
|
|
7219
|
+
this.chartConfiguration.numberOfYTicks = 7;
|
|
7220
|
+
this.chartConfiguration.svgHeight = 80;
|
|
7221
|
+
}
|
|
7202
7222
|
for (var i in this.defaultConfiguration) {
|
|
7203
7223
|
this.chartConfiguration[i] = ChartHelper.getValueByConfigurationType(i, this.defaultConfiguration, this.customChartConfiguration);
|
|
7204
7224
|
}
|
|
@@ -7230,40 +7250,30 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7230
7250
|
}
|
|
7231
7251
|
}
|
|
7232
7252
|
var margin = this.chartConfiguration.margin;
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7253
|
+
// Responsive width and height
|
|
7254
|
+
var containerWidth = chartContainer.node().getBoundingClientRect().width;
|
|
7255
|
+
var containerHeight = verticalstackedcontainer.node().getBoundingClientRect().height;
|
|
7256
|
+
var width = containerWidth - margin.left - margin.right;
|
|
7257
|
+
var height = containerHeight * (self.chartConfiguration.svgHeight / 100) - margin.top - margin.bottom;
|
|
7258
|
+
// Adjust width for large datasets and zoom
|
|
7237
7259
|
if (this.chartData.data.length > 30 && this.isZoomedOut) {
|
|
7238
|
-
width =
|
|
7239
|
-
width
|
|
7240
|
-
|
|
7241
|
-
: this.chartData.data.length * 25;
|
|
7260
|
+
width = width > this.chartData.data.length * (isMobile ? 15 : 25)
|
|
7261
|
+
? width
|
|
7262
|
+
: this.chartData.data.length * (isMobile ? 15 : 25);
|
|
7242
7263
|
}
|
|
7243
7264
|
if (this.chartData.data.length > 8 && !this.isZoomedOut) {
|
|
7244
|
-
width = this.chartData.data.length * 130;
|
|
7265
|
+
width = this.chartData.data.length * (isMobile ? 60 : 130);
|
|
7245
7266
|
}
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
* entire height used in weekly charts as x axis needed to be displayed at the bottom of the chart
|
|
7252
|
-
*/
|
|
7253
|
-
if (this.chartConfiguration.isFullScreen != undefined &&
|
|
7254
|
-
this.chartConfiguration.isFullScreen) {
|
|
7255
|
-
height =
|
|
7256
|
-
this.chartConfiguration.svgHeight != 80
|
|
7257
|
-
? this.chartConfiguration.svgHeight
|
|
7258
|
-
: parseInt(verticalstackedcontainer.style('height'));
|
|
7267
|
+
// Fullscreen and drilldown adjustments
|
|
7268
|
+
if (this.chartConfiguration.isFullScreen != undefined && this.chartConfiguration.isFullScreen) {
|
|
7269
|
+
height = this.chartConfiguration.svgHeight != 80
|
|
7270
|
+
? this.chartConfiguration.svgHeight
|
|
7271
|
+
: containerHeight;
|
|
7259
7272
|
}
|
|
7260
7273
|
if (this.chartConfiguration.isDrilldownChart) {
|
|
7261
|
-
height =
|
|
7262
|
-
parseInt(verticalstackedcontainer.style('height')) -
|
|
7263
|
-
margin.top -
|
|
7264
|
-
margin.bottom -
|
|
7265
|
-
130;
|
|
7274
|
+
height = containerHeight - margin.top - margin.bottom - (isMobile ? 60 : 130);
|
|
7266
7275
|
}
|
|
7276
|
+
// ...existing code...
|
|
7267
7277
|
/**
|
|
7268
7278
|
* for hiding header
|
|
7269
7279
|
* used by weekly charts
|
|
@@ -7302,16 +7312,17 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7302
7312
|
.style('height', height)
|
|
7303
7313
|
.style('overflow-x', 'hidden')
|
|
7304
7314
|
.style('padding-left', `${margin.left}px`)
|
|
7315
|
+
.style('margin-left', '10px')
|
|
7305
7316
|
.style('padding-right', `${rightSvgWidth}px`);
|
|
7306
7317
|
var svgYAxisLeft = outerContainer
|
|
7307
7318
|
.append('svg')
|
|
7308
|
-
.attr('width', '
|
|
7319
|
+
.attr('width', '80')
|
|
7309
7320
|
.attr('height', height + margin.top + margin.bottom)
|
|
7310
7321
|
.style('position', 'absolute')
|
|
7311
7322
|
.style('left', '0')
|
|
7312
7323
|
.style('z-index', 1)
|
|
7313
7324
|
.append('g')
|
|
7314
|
-
.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
|
|
7325
|
+
.attr('transform', 'translate(' + (margin.left + 10) + ',' + margin.top + ')');
|
|
7315
7326
|
var svgYAxisRight = outerContainer
|
|
7316
7327
|
.append('svg')
|
|
7317
7328
|
.attr('width', rightSvgWidth)
|
|
@@ -7326,12 +7337,27 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7326
7337
|
.attr('class', 'inner-container')
|
|
7327
7338
|
.style('width', '100%')
|
|
7328
7339
|
.style('overflow-x', 'auto');
|
|
7340
|
+
// Calculate bar width and padding for mobile to avoid overlap and add space between bars
|
|
7341
|
+
let barWidth;
|
|
7342
|
+
let barPadding = 12; // px, space between bars on mobile
|
|
7343
|
+
let requiredSvgWidth;
|
|
7344
|
+
if (isMobile) {
|
|
7345
|
+
// Use a minimum width per bar and add padding between bars
|
|
7346
|
+
const minBarWidth = 32; // px, can adjust as needed
|
|
7347
|
+
barWidth = minBarWidth;
|
|
7348
|
+
requiredSvgWidth = Math.max(width - rightSvgWidth, (barWidth + barPadding) * data.length + leftAndRightSpaces * 2 + rightSvgWidth - barPadding // no padding after last bar
|
|
7349
|
+
);
|
|
7350
|
+
innerContainer.style('overflow-x', 'auto');
|
|
7351
|
+
}
|
|
7352
|
+
else {
|
|
7353
|
+
barWidth = Math.max(40, (width - rightSvgWidth - leftAndRightSpaces * 2) / data.length);
|
|
7354
|
+
barPadding = 0;
|
|
7355
|
+
requiredSvgWidth = width - rightSvgWidth;
|
|
7356
|
+
}
|
|
7329
7357
|
var svg = innerContainer
|
|
7330
7358
|
.append('svg')
|
|
7331
|
-
|
|
7332
|
-
.attr('
|
|
7333
|
-
.attr('height', height + margin.top + margin.bottom)
|
|
7334
|
-
// .call(ChartHelper.responsivefy)
|
|
7359
|
+
.attr('width', requiredSvgWidth)
|
|
7360
|
+
.attr('height', height + margin.top + margin.bottom + 30)
|
|
7335
7361
|
.append('g')
|
|
7336
7362
|
.attr('transform', 'translate(' + 0 + ',' + margin.top + ')');
|
|
7337
7363
|
let stackKey = keyList;
|
|
@@ -7356,31 +7382,25 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7356
7382
|
])
|
|
7357
7383
|
.range([height, 0]);
|
|
7358
7384
|
}
|
|
7385
|
+
// Calculate bar width for mobile to avoid overlap
|
|
7386
|
+
// ...barWidth is now calculated above, remove duplicate...
|
|
7359
7387
|
var xScale = d3
|
|
7360
7388
|
.scaleBand()
|
|
7361
7389
|
.rangeRound([
|
|
7362
|
-
width - rightSvgWidth - leftAndRightSpaces,
|
|
7363
7390
|
leftAndRightSpaces,
|
|
7391
|
+
width - rightSvgWidth - leftAndRightSpaces
|
|
7364
7392
|
])
|
|
7365
7393
|
.domain(data.map(function (d) {
|
|
7366
7394
|
return d.name;
|
|
7367
|
-
}))
|
|
7368
|
-
|
|
7395
|
+
}))
|
|
7396
|
+
.padding(isMobile ? 0.2 : 0.5);
|
|
7369
7397
|
var xScaleFromOrigin = d3
|
|
7370
7398
|
.scaleBand()
|
|
7371
7399
|
.rangeRound([width - rightSvgWidth, 0])
|
|
7372
7400
|
.domain(data.map(function (d) {
|
|
7373
7401
|
return d.name;
|
|
7374
7402
|
}));
|
|
7375
|
-
|
|
7376
|
-
* xScale for weekly charts does not need padding as this padding affects spacing between the dot and y axis
|
|
7377
|
-
*/
|
|
7378
|
-
if (this.chartConfiguration.isMultiChartGridLine == undefined) {
|
|
7379
|
-
xScale.padding(0.5);
|
|
7380
|
-
}
|
|
7381
|
-
else {
|
|
7382
|
-
xScale.align(0.5);
|
|
7383
|
-
}
|
|
7403
|
+
// ...existing code...
|
|
7384
7404
|
/**
|
|
7385
7405
|
* draw second x axis on top
|
|
7386
7406
|
*/
|
|
@@ -7408,9 +7428,10 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7408
7428
|
svg
|
|
7409
7429
|
.append('g')
|
|
7410
7430
|
.attr('class', `x${j + 2} axis${j + 2}`)
|
|
7411
|
-
.style('color', '
|
|
7431
|
+
.style('color', 'var(--chart-grid-color)') // Use CSS variable instead of hardcoded
|
|
7412
7432
|
.attr('transform', 'translate(0,' + height * this.chartConfiguration.xAxisGrid[j] + ')')
|
|
7413
|
-
.call(d3.axisBottom(xScale).tickSize(0).ticks(5).tickFormat(''))
|
|
7433
|
+
.call(d3.axisBottom(xScale).tickSize(0).ticks(5).tickFormat(''))
|
|
7434
|
+
.style('fill', 'var(--chart-text-color)');
|
|
7414
7435
|
}
|
|
7415
7436
|
}
|
|
7416
7437
|
let yScale = d3.scaleLinear().rangeRound([height, 0]);
|
|
@@ -7482,8 +7503,8 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7482
7503
|
.ticks(self.chartConfiguration.numberOfYTicks)
|
|
7483
7504
|
.tickSize(-width)
|
|
7484
7505
|
.tickFormat(''))
|
|
7485
|
-
//
|
|
7486
|
-
.style('color', '
|
|
7506
|
+
// Remove hardcoded colors and use CSS variables
|
|
7507
|
+
.style('color', 'var(--chart-grid-color)')
|
|
7487
7508
|
.style('opacity', '0.5')
|
|
7488
7509
|
.call((g) => g.select('.domain').remove());
|
|
7489
7510
|
}
|
|
@@ -7513,35 +7534,47 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7513
7534
|
}
|
|
7514
7535
|
})
|
|
7515
7536
|
.attr('y', function (d) {
|
|
7516
|
-
|
|
7537
|
+
if (!isNaN(d[0]) && !isNaN(d[1])) {
|
|
7538
|
+
const actualHeight = yScale(d[0]) - yScale(d[1]);
|
|
7539
|
+
return actualHeight < 3 ? yScale(d[0]) - 3 : yScale(d[1]);
|
|
7540
|
+
}
|
|
7541
|
+
return 0;
|
|
7517
7542
|
})
|
|
7518
|
-
.attr('x', function (d) {
|
|
7543
|
+
.attr('x', function (d, i) {
|
|
7544
|
+
if (isMobile) {
|
|
7545
|
+
// On mobile, position bars with padding
|
|
7546
|
+
return leftAndRightSpaces + i * (barWidth + barPadding);
|
|
7547
|
+
}
|
|
7519
7548
|
if (self.chartConfiguration.isMultiChartGridLine == undefined) {
|
|
7520
7549
|
return xScale(d.data.name);
|
|
7521
7550
|
}
|
|
7522
7551
|
else {
|
|
7523
7552
|
if (self.chartConfiguration.isDrilldownChart &&
|
|
7524
7553
|
self.chartData.data.length <= 3) {
|
|
7525
|
-
return xScale(d.data.name) + xScale.bandwidth() / 2 -
|
|
7554
|
+
return xScale(d.data.name) + xScale.bandwidth() / 2 - 35;
|
|
7526
7555
|
}
|
|
7527
7556
|
return xScale(d.data.name) + xScale.bandwidth() * 0.1;
|
|
7528
7557
|
}
|
|
7529
7558
|
})
|
|
7530
7559
|
.attr('height', function (d) {
|
|
7531
|
-
if (!isNaN(d[0]) && !isNaN(d[1]))
|
|
7532
|
-
|
|
7560
|
+
if (!isNaN(d[0]) && !isNaN(d[1])) {
|
|
7561
|
+
const actualHeight = yScale(d[0]) - yScale(d[1]);
|
|
7562
|
+
return actualHeight < 3 ? 3 : actualHeight;
|
|
7563
|
+
}
|
|
7533
7564
|
return 0;
|
|
7534
7565
|
})
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
self.
|
|
7543
|
-
|
|
7544
|
-
|
|
7566
|
+
.attr('width', function (d) {
|
|
7567
|
+
// Use calculated barWidth for mobile, otherwise scale
|
|
7568
|
+
if (isMobile) {
|
|
7569
|
+
return barWidth;
|
|
7570
|
+
}
|
|
7571
|
+
return self.chartConfiguration.isMultiChartGridLine == undefined
|
|
7572
|
+
? xScale.bandwidth()
|
|
7573
|
+
: self.chartConfiguration.isDrilldownChart &&
|
|
7574
|
+
self.chartData.data.length <= 3
|
|
7575
|
+
? 70
|
|
7576
|
+
: xScale.bandwidth() * 0.8;
|
|
7577
|
+
})
|
|
7545
7578
|
// .style('cursor', 'pointer');
|
|
7546
7579
|
.style('cursor', function (d) {
|
|
7547
7580
|
if (metaData.hasDrillDown) {
|
|
@@ -7655,98 +7688,56 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7655
7688
|
svg
|
|
7656
7689
|
.append('foreignObject')
|
|
7657
7690
|
.attr('x', function () {
|
|
7658
|
-
// if (metaData.hasDrillDown) {
|
|
7659
7691
|
if (xScale.bandwidth() + leftAndRightSpaces * 2 > 180) {
|
|
7660
7692
|
return (xScale(d.data.name) -
|
|
7661
7693
|
leftAndRightSpaces +
|
|
7662
7694
|
(xScale.bandwidth() + leftAndRightSpaces * 2 - 180) / 2);
|
|
7663
7695
|
}
|
|
7664
7696
|
return xScale(d.data.name) - leftAndRightSpaces;
|
|
7665
|
-
// } else return xScale(d.data.name) - leftAndRightSpaces;
|
|
7666
7697
|
})
|
|
7667
7698
|
.attr('class', 'lib-verticalstack-title-ontop')
|
|
7668
7699
|
.attr('y', function () {
|
|
7669
|
-
|
|
7700
|
+
// Increase the gap between the bar and the tooltip (was -1 - 40)
|
|
7701
|
+
return yScale(d[1]) - 1 - 50; // 10px more gap
|
|
7670
7702
|
})
|
|
7671
7703
|
.attr('dy', function () {
|
|
7672
7704
|
return d.class;
|
|
7673
7705
|
})
|
|
7674
7706
|
.attr('width', function () {
|
|
7675
|
-
// if (metaData.hasDrillDown) {
|
|
7676
7707
|
if (xScale.bandwidth() + leftAndRightSpaces * 2 > 180) {
|
|
7677
7708
|
return '180px';
|
|
7678
7709
|
}
|
|
7679
7710
|
return xScale.bandwidth() + leftAndRightSpaces * 2;
|
|
7680
|
-
// } else return xScale.bandwidth() + leftAndRightSpaces * 2;
|
|
7681
7711
|
})
|
|
7682
7712
|
.attr('height', 40)
|
|
7683
7713
|
.append('xhtml:div')
|
|
7684
7714
|
.attr('class', 'title')
|
|
7685
7715
|
.style('z-index', 99)
|
|
7686
7716
|
.html(function () {
|
|
7717
|
+
// Tooltip content without any arrow mark
|
|
7687
7718
|
if (!isNaN(d[1] - d[0])) {
|
|
7688
|
-
if (d[1] - d[0]
|
|
7689
|
-
return;
|
|
7719
|
+
if (d[1] - d[0] === 0) {
|
|
7720
|
+
return '<span class="title-top-text">0</span>';
|
|
7690
7721
|
}
|
|
7691
7722
|
var dataType = metaData.dataType ? metaData.dataType : '';
|
|
7692
7723
|
var desiredText = '';
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
formatFromBackend(d[1] - d[0]) +
|
|
7711
|
-
dataType +
|
|
7712
|
-
'</span>';
|
|
7713
|
-
if (metaData.hasDrillDown &&
|
|
7714
|
-
!self.isZoomedOut &&
|
|
7715
|
-
(!metaData.barWithoutClick ||
|
|
7716
|
-
!metaData.barWithoutClick.length ||
|
|
7717
|
-
!metaData.barWithoutClick.includes(d.data.name.toLowerCase()))) {
|
|
7718
|
-
desiredText +=
|
|
7719
|
-
'<span class="title-bottom-text">Click for more details</span>';
|
|
7720
|
-
return desiredText;
|
|
7721
|
-
}
|
|
7722
|
-
else {
|
|
7723
|
-
return desiredText;
|
|
7724
|
-
}
|
|
7725
|
-
}
|
|
7726
|
-
else {
|
|
7727
|
-
desiredText += metaData.unit
|
|
7728
|
-
? '<span class="title-top-text">' +
|
|
7729
|
-
metaData.unit +
|
|
7730
|
-
formatForHugeNumbers(d[1] - d[0]) +
|
|
7731
|
-
dataType +
|
|
7732
|
-
'</span>'
|
|
7733
|
-
: '<span class="title-top-text">' +
|
|
7734
|
-
formatForHugeNumbers(d[1] - d[0]) +
|
|
7735
|
-
dataType +
|
|
7736
|
-
'</span>';
|
|
7737
|
-
if (metaData.hasDrillDown &&
|
|
7738
|
-
!self.isZoomedOut &&
|
|
7739
|
-
(!metaData.barWithoutClick ||
|
|
7740
|
-
!metaData.barWithoutClick.length ||
|
|
7741
|
-
!metaData.barWithoutClick.includes(d.data.name.toLowerCase()))) {
|
|
7742
|
-
desiredText +=
|
|
7743
|
-
'<span class="title-bottom-text">Click for more details</span>';
|
|
7744
|
-
return desiredText;
|
|
7745
|
-
}
|
|
7746
|
-
else {
|
|
7747
|
-
return desiredText;
|
|
7748
|
-
}
|
|
7749
|
-
}
|
|
7724
|
+
// Always show the full x-axis label (category name) in the tooltip
|
|
7725
|
+
desiredText =
|
|
7726
|
+
'<span class="title-bar-name">' +
|
|
7727
|
+
(d.data.name ? d.data.name : '') +
|
|
7728
|
+
'</span>';
|
|
7729
|
+
desiredText += metaData.unit
|
|
7730
|
+
? '<span class="title-top-text">' +
|
|
7731
|
+
metaData.unit +
|
|
7732
|
+
(d[1] - d[0]) +
|
|
7733
|
+
dataType +
|
|
7734
|
+
'</span>'
|
|
7735
|
+
: '<span class="title-top-text">' +
|
|
7736
|
+
(d[1] - d[0]) +
|
|
7737
|
+
dataType +
|
|
7738
|
+
'</span>';
|
|
7739
|
+
// No arrow mark or arrow HTML/CSS in tooltip
|
|
7740
|
+
return desiredText;
|
|
7750
7741
|
}
|
|
7751
7742
|
else
|
|
7752
7743
|
return;
|
|
@@ -7874,25 +7865,54 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7874
7865
|
});
|
|
7875
7866
|
}
|
|
7876
7867
|
if (this.chartConfiguration.isMultiChartGridLine == undefined) {
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
.
|
|
7880
|
-
.
|
|
7881
|
-
|
|
7882
|
-
|
|
7868
|
+
if (isMobile) {
|
|
7869
|
+
// Custom x-axis label rendering for mobile: evenly distribute under each bar
|
|
7870
|
+
svg.selectAll('.custom-x-label').remove();
|
|
7871
|
+
data.forEach(function (d, i) {
|
|
7872
|
+
const xVal = leftAndRightSpaces + i * (barWidth + barPadding) + barWidth / 2;
|
|
7873
|
+
svg.append('text')
|
|
7874
|
+
.attr('class', 'custom-x-label')
|
|
7875
|
+
.attr('x', 0)
|
|
7876
|
+
.attr('y', height + 18)
|
|
7877
|
+
.attr('text-anchor', 'middle')
|
|
7878
|
+
.attr('transform', 'translate(' + (xVal + 20) + ',0)') // current value + 20
|
|
7879
|
+
.style('font-size', '10px')
|
|
7880
|
+
.style('fill', 'var(--chart-text-color)')
|
|
7881
|
+
.style('writing-mode', 'sideways-lr') // writing mode for mobile
|
|
7882
|
+
.text(d.name.substring(0, 3));
|
|
7883
|
+
});
|
|
7884
|
+
}
|
|
7885
|
+
else {
|
|
7886
|
+
svg
|
|
7887
|
+
.append('g')
|
|
7888
|
+
.attr('transform', 'translate(0,' + height + ')')
|
|
7889
|
+
.attr('class', 'lib-stacked-x-axis-text')
|
|
7890
|
+
.call(xAxis)
|
|
7891
|
+
.selectAll('text')
|
|
7892
|
+
.style('fill', 'var(--chart-text-color)')
|
|
7893
|
+
.style('font-size', '12px')
|
|
7894
|
+
.attr('text-anchor', 'middle')
|
|
7895
|
+
.attr('dx', '0')
|
|
7896
|
+
.attr('dy', '0.71em')
|
|
7897
|
+
.attr('transform', null)
|
|
7898
|
+
.text(function (d) {
|
|
7899
|
+
return d;
|
|
7900
|
+
});
|
|
7901
|
+
}
|
|
7883
7902
|
svg
|
|
7884
7903
|
.append('g')
|
|
7885
7904
|
.attr('class', 'lib-stacked-y-axis-text')
|
|
7886
7905
|
.attr('style', self.chartConfiguration.yAxisCustomTextStyles)
|
|
7887
7906
|
.attr('transform', 'translate(0,0)')
|
|
7888
|
-
.call(yAxis)
|
|
7907
|
+
.call(yAxis)
|
|
7908
|
+
.selectAll('text')
|
|
7909
|
+
.style('fill', 'var(--chart-text-color)');
|
|
7889
7910
|
}
|
|
7890
7911
|
else if (this.chartConfiguration.isDrilldownChart) {
|
|
7891
7912
|
svg
|
|
7892
7913
|
.append('g')
|
|
7893
7914
|
.attr('transform', 'translate(0,' + height + ')')
|
|
7894
7915
|
.attr('class', 'lib-stacked-x-axis-text multichart1')
|
|
7895
|
-
// .attr('transform', 'translate(0,' + height + ')')
|
|
7896
7916
|
.call(xAxis)
|
|
7897
7917
|
.style('display', 'none');
|
|
7898
7918
|
svgYAxisLeft
|
|
@@ -7900,7 +7920,9 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7900
7920
|
.attr('class', 'lib-yaxis-labels-texts-drilldown yaxis-dashed')
|
|
7901
7921
|
.attr('style', self.chartConfiguration.yAxisCustomTextStyles)
|
|
7902
7922
|
.attr('transform', 'translate(0,0)')
|
|
7903
|
-
.call(yAxis)
|
|
7923
|
+
.call(yAxis)
|
|
7924
|
+
.selectAll('text')
|
|
7925
|
+
.style('fill', 'var(--chart-text-color)');
|
|
7904
7926
|
svgYAxisRight
|
|
7905
7927
|
.append('g')
|
|
7906
7928
|
.attr('class', 'lib-yaxis-labels-texts-drilldown yaxis-dashed')
|
|
@@ -7915,14 +7937,17 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
7915
7937
|
.attr('transform', 'translate(0,' + height + ')')
|
|
7916
7938
|
.attr('class', 'lib-stacked-x-axis-text multichart')
|
|
7917
7939
|
.attr('transform', 'translate(0,' + height + ')')
|
|
7918
|
-
.call(xAxis)
|
|
7919
|
-
|
|
7940
|
+
.call(xAxis)
|
|
7941
|
+
.selectAll('text')
|
|
7942
|
+
.style('fill', 'var(--chart-text-color)');
|
|
7920
7943
|
svg
|
|
7921
7944
|
.append('g')
|
|
7922
7945
|
.attr('class', 'lib-stacked-y-axis-text yaxis-dashed')
|
|
7923
7946
|
.attr('style', self.chartConfiguration.yAxisCustomTextStyles)
|
|
7924
7947
|
.attr('transform', 'translate(0,0)')
|
|
7925
|
-
.call(yAxis)
|
|
7948
|
+
.call(yAxis)
|
|
7949
|
+
.selectAll('text')
|
|
7950
|
+
.style('fill', 'var(--chart-text-color)');
|
|
7926
7951
|
}
|
|
7927
7952
|
/**
|
|
7928
7953
|
* for existing charts, place xaxis labels nearer to xaxis
|
|
@@ -8020,11 +8045,31 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8020
8045
|
.selectAll('g.x1.axis1 g.tick text')
|
|
8021
8046
|
.attr('class', 'lib-xaxis-labels-texts-drilldown')
|
|
8022
8047
|
.attr('y', short_tick_length_bg)
|
|
8023
|
-
.text(function (d) {
|
|
8048
|
+
.text(function (d, i) {
|
|
8049
|
+
if (isMobile) {
|
|
8050
|
+
// If label has more than one word, show only first 3 letters of first word
|
|
8051
|
+
var firstWord = d.split(' ')[0];
|
|
8052
|
+
return firstWord.substring(0, 3);
|
|
8053
|
+
}
|
|
8024
8054
|
if (d.trim().indexOf(' ') > -1) {
|
|
8025
8055
|
return d.trim().substring(0, d.indexOf(' ')).toLowerCase();
|
|
8026
8056
|
}
|
|
8027
8057
|
return d.toLowerCase();
|
|
8058
|
+
})
|
|
8059
|
+
.attr('transform', function (d, i) {
|
|
8060
|
+
if (isMobile) {
|
|
8061
|
+
var totalBars = 0;
|
|
8062
|
+
if (this.parentNode && this.parentNode.parentNode) {
|
|
8063
|
+
totalBars = d3.select(this.parentNode.parentNode).selectAll('g.tick').size();
|
|
8064
|
+
}
|
|
8065
|
+
if (totalBars === 2) {
|
|
8066
|
+
return 'translate(0,0)';
|
|
8067
|
+
}
|
|
8068
|
+
else {
|
|
8069
|
+
return 'translate(' + (i * 30) + ',0)';
|
|
8070
|
+
}
|
|
8071
|
+
}
|
|
8072
|
+
return null;
|
|
8028
8073
|
});
|
|
8029
8074
|
svg
|
|
8030
8075
|
.selectAll('g.x1.axis1 g.tick')
|
|
@@ -8033,10 +8078,20 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8033
8078
|
.attr('y', long_tick_length_bg)
|
|
8034
8079
|
.attr('fill', 'currentColor')
|
|
8035
8080
|
.text(function (d) {
|
|
8081
|
+
// For mobile, do not print the second word at all
|
|
8082
|
+
if (isMobile) {
|
|
8083
|
+
return '';
|
|
8084
|
+
}
|
|
8036
8085
|
if (d.trim().indexOf(' ') > -1) {
|
|
8037
8086
|
return d.trim().substring(d.indexOf(' '), d.length).toLowerCase();
|
|
8038
8087
|
}
|
|
8039
8088
|
return '';
|
|
8089
|
+
})
|
|
8090
|
+
.attr('transform', function (d, i) {
|
|
8091
|
+
if (isMobile && i === 0) {
|
|
8092
|
+
return 'translate(20,0)';
|
|
8093
|
+
}
|
|
8094
|
+
return null;
|
|
8040
8095
|
});
|
|
8041
8096
|
}
|
|
8042
8097
|
/**
|
|
@@ -8064,14 +8119,14 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8064
8119
|
this.chartConfiguration.isYaxisDashed) {
|
|
8065
8120
|
d3.selectAll('.yaxis-dashed')
|
|
8066
8121
|
.style('stroke-dasharray', '5 5')
|
|
8067
|
-
.style('color', '
|
|
8122
|
+
.style('color', 'var(--chart-grid-color)'); // Use CSS variable
|
|
8068
8123
|
}
|
|
8069
8124
|
/**
|
|
8070
8125
|
* x axis color
|
|
8071
8126
|
* used by weekly charts
|
|
8072
8127
|
*/
|
|
8073
8128
|
if (this.chartConfiguration.isXaxisColor != undefined) {
|
|
8074
|
-
d3.selectAll('.multichart').style('color', this.chartConfiguration.isXaxisColor);
|
|
8129
|
+
d3.selectAll('.multichart').style('color', this.chartConfiguration.isXaxisColor || 'var(--chart-text-color)');
|
|
8075
8130
|
}
|
|
8076
8131
|
/**
|
|
8077
8132
|
* used to display y label
|
|
@@ -8079,30 +8134,51 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8079
8134
|
if (this.isZoomedOut) {
|
|
8080
8135
|
svg
|
|
8081
8136
|
.selectAll('.lib-xaxis-labels-texts-drilldown')
|
|
8082
|
-
.attr('
|
|
8137
|
+
.attr('transform', 'rotate(-90)')
|
|
8138
|
+
.attr('text-anchor', 'end')
|
|
8139
|
+
.attr('x', '-5')
|
|
8140
|
+
.attr('dy', null);
|
|
8141
|
+
}
|
|
8142
|
+
function styleAxisDomain() {
|
|
8143
|
+
svg.selectAll('.domain')
|
|
8144
|
+
.style('stroke', 'var(--chart-axis-color)')
|
|
8145
|
+
.style('stroke-width', '1px');
|
|
8146
|
+
svgYAxisLeft.selectAll('.domain')
|
|
8147
|
+
.style('stroke', 'var(--chart-axis-color)')
|
|
8148
|
+
.style('stroke-width', '1px');
|
|
8149
|
+
svgYAxisRight.selectAll('.domain')
|
|
8150
|
+
.style('stroke', 'var(--chart-axis-color)')
|
|
8151
|
+
.style('stroke-width', '1px');
|
|
8083
8152
|
}
|
|
8153
|
+
styleAxisDomain();
|
|
8084
8154
|
if (metaData.yLabel) {
|
|
8155
|
+
svgYAxisLeft.selectAll('.lib-axis-group-label, .lib-ylabel-drilldowncharts, .lib-ylabel-weeklyCharts').remove();
|
|
8156
|
+
function isAcronym(label) {
|
|
8157
|
+
return (label.length <= 4 && /^[A-Z]+$/.test(label)) || (label === label.toUpperCase() && /[A-Z]/.test(label));
|
|
8158
|
+
}
|
|
8159
|
+
const yLabelText = metaData.yLabel;
|
|
8160
|
+
const isAcr = isAcronym(yLabelText.replace(/[^A-Za-z]/g, ''));
|
|
8161
|
+
const yPosition = isria ? 0 - margin.left / 2 - 30 : 0 - margin.left / 2 - 40;
|
|
8085
8162
|
svgYAxisLeft
|
|
8086
8163
|
.append('text')
|
|
8087
|
-
.attr('class',
|
|
8164
|
+
.attr('class', function () {
|
|
8165
|
+
let baseClass = 'lib-axis-group-label font-size-1';
|
|
8166
|
+
if (self.chartConfiguration.isDrilldownChart)
|
|
8167
|
+
return baseClass + ' lib-ylabel-drilldowncharts';
|
|
8168
|
+
if (self.chartConfiguration.isMultiChartGridLine != undefined)
|
|
8169
|
+
return baseClass + ' lib-ylabel-weeklyCharts';
|
|
8170
|
+
return baseClass + ' lib-axis-waterfall-label';
|
|
8171
|
+
})
|
|
8088
8172
|
.attr('style', self.chartConfiguration.yAxisCustomlabelStyles)
|
|
8089
8173
|
.attr('transform', 'rotate(-90)')
|
|
8090
|
-
.attr('y',
|
|
8174
|
+
.attr('y', yPosition)
|
|
8091
8175
|
.attr('x', 0 - height / 2)
|
|
8092
8176
|
.attr('dy', '1em')
|
|
8093
8177
|
.style('text-anchor', 'middle')
|
|
8094
|
-
.
|
|
8095
|
-
.style('
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
.selectAll('.lib-axis-group-label')
|
|
8099
|
-
.attr('class', 'lib-ylabel-drilldowncharts');
|
|
8100
|
-
}
|
|
8101
|
-
else if (this.chartConfiguration.isMultiChartGridLine != undefined) {
|
|
8102
|
-
svg
|
|
8103
|
-
.selectAll('.lib-axis-group-label')
|
|
8104
|
-
.attr('class', 'lib-ylabel-weeklyCharts');
|
|
8105
|
-
}
|
|
8178
|
+
.style('fill', 'var(--chart-text-color)')
|
|
8179
|
+
.style('color', 'var(--chart-text-color)')
|
|
8180
|
+
.text(isAcr ? yLabelText.toUpperCase() : yLabelText.toLowerCase())
|
|
8181
|
+
.style('text-transform', isAcr ? 'none' : 'capitalize');
|
|
8106
8182
|
}
|
|
8107
8183
|
if (this.chartData.targetLineData) {
|
|
8108
8184
|
const yZero = yScale(parsedNum);
|
|
@@ -8128,7 +8204,7 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8128
8204
|
.attr('height', 50)
|
|
8129
8205
|
.append('xhtml:div')
|
|
8130
8206
|
.attr('class', 'target-display')
|
|
8131
|
-
.style('color',
|
|
8207
|
+
.style('color', 'var(--chart-text-color)')
|
|
8132
8208
|
.html(function (d, i) {
|
|
8133
8209
|
let dataTypeTemp = '';
|
|
8134
8210
|
let targetLineName = 'target';
|
|
@@ -8164,23 +8240,29 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8164
8240
|
.text(metaData.lineyLabel);
|
|
8165
8241
|
}
|
|
8166
8242
|
if (metaData.xLabel) {
|
|
8243
|
+
function isAcronym(label) {
|
|
8244
|
+
return ((label.length <= 4 && /^[A-Z]+$/.test(label)) ||
|
|
8245
|
+
(label === label.toUpperCase() && /[A-Z]/.test(label)));
|
|
8246
|
+
}
|
|
8247
|
+
const xLabelText = metaData.xLabel;
|
|
8248
|
+
const isAcr = isAcronym(xLabelText.replace(/[^A-Za-z]/g, ''));
|
|
8249
|
+
const xPosition = isria ? (height + margin.top + margin.bottom) : (height + margin.top + margin.bottom + 10);
|
|
8167
8250
|
svg
|
|
8168
8251
|
.append('text')
|
|
8169
|
-
.attr('class',
|
|
8170
|
-
|
|
8252
|
+
.attr('class', function () {
|
|
8253
|
+
let baseClass = 'lib-axis-group-label font-size-1';
|
|
8254
|
+
if (self.chartConfiguration.isDrilldownChart)
|
|
8255
|
+
return baseClass + ' lib-xlabel-drilldowncharts';
|
|
8256
|
+
if (self.chartConfiguration.isMultiChartGridLine != undefined)
|
|
8257
|
+
return baseClass + ' lib-xlabel-weeklyCharts';
|
|
8258
|
+
return baseClass + ' lib-axis-waterfall-label';
|
|
8259
|
+
})
|
|
8260
|
+
.attr('style', self.chartConfiguration.xAxisCustomlabelStyles)
|
|
8261
|
+
.attr('transform', 'translate(' + width / 2 + ' ,' + xPosition + ')')
|
|
8171
8262
|
.style('text-anchor', 'middle')
|
|
8172
|
-
.
|
|
8173
|
-
.
|
|
8174
|
-
|
|
8175
|
-
if (yLineAxis != null) {
|
|
8176
|
-
if (lineData && self.chartConfiguration.showLineChartAxis) {
|
|
8177
|
-
svg
|
|
8178
|
-
.append('g')
|
|
8179
|
-
.attr('class', 'lib-stacked-y-axis-text')
|
|
8180
|
-
.attr('style', self.chartConfiguration.yAxisCustomTextStyles)
|
|
8181
|
-
.attr('transform', 'translate(' + width + ',0)')
|
|
8182
|
-
.call(yLineAxis);
|
|
8183
|
-
}
|
|
8263
|
+
.style('fill', 'var(--chart-text-color)')
|
|
8264
|
+
.text(isAcr ? xLabelText.toUpperCase() : xLabelText.toLowerCase())
|
|
8265
|
+
.style('text-transform', isAcr ? 'none' : 'capitalize');
|
|
8184
8266
|
}
|
|
8185
8267
|
if (lineData && colors) {
|
|
8186
8268
|
var dataGroup = d3
|
|
@@ -8469,7 +8551,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8469
8551
|
var height = parseInt(verticalstackedcontainer.style('height')) *
|
|
8470
8552
|
(self.chartConfiguration.svgHeight / 100) -
|
|
8471
8553
|
margin.top -
|
|
8472
|
-
margin.bottom
|
|
8554
|
+
margin.bottom;
|
|
8473
8555
|
/**
|
|
8474
8556
|
* entire height used in weekly charts as x axis needed to be displayed at the bottom of the chart
|
|
8475
8557
|
*/
|
|
@@ -8560,7 +8642,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8560
8642
|
.append('svg')
|
|
8561
8643
|
// .attr('id', self.uniqueId)
|
|
8562
8644
|
.attr('width', width - rightSvgWidth)
|
|
8563
|
-
.attr('height', height + margin.top + margin.bottom +
|
|
8645
|
+
.attr('height', height + margin.top + margin.bottom + 60)
|
|
8564
8646
|
// .call(ChartHelper.responsivefy)
|
|
8565
8647
|
.append('g')
|
|
8566
8648
|
.attr('transform', 'translate(' + 0 + ',' + margin.top + ')');
|
|
@@ -8696,18 +8778,19 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8696
8778
|
});
|
|
8697
8779
|
}
|
|
8698
8780
|
if (self.chartConfiguration.xLabelsOnSameLine) {
|
|
8699
|
-
svg
|
|
8781
|
+
const xAxisLabels = svg
|
|
8700
8782
|
.selectAll('g.x1.axis1 g.tick text')
|
|
8701
8783
|
.attr('class', 'lib-xaxis-labels-texts-drilldown')
|
|
8702
8784
|
.style('font-size', this.isHeaderVisible ? '18px' : '14px')
|
|
8785
|
+
.attr('text-anchor', 'middle')
|
|
8703
8786
|
.attr('y', function (d) {
|
|
8704
|
-
// For grouped bar charts with many bars and xLabel present,
|
|
8787
|
+
// For grouped bar charts with many bars and xLabel present, only add 5 if the label is a date
|
|
8705
8788
|
if (subgroups.length > 1 && data.length > 8 && metaData.xLabel) {
|
|
8706
|
-
|
|
8789
|
+
const isDateLabel = /\d{2,4}[-\/]/.test(d);
|
|
8707
8790
|
if (self.chartConfiguration.isFullScreen) {
|
|
8708
|
-
return short_tick_length_bg;
|
|
8791
|
+
return isDateLabel ? short_tick_length_bg + 14 : short_tick_length_bg;
|
|
8709
8792
|
}
|
|
8710
|
-
return short_tick_length_bg;
|
|
8793
|
+
return isDateLabel ? short_tick_length_bg + 14 : short_tick_length_bg;
|
|
8711
8794
|
}
|
|
8712
8795
|
// For grouped bar charts with many bars and NO xLabel, add space as before, but reduce in fullscreen
|
|
8713
8796
|
if (subgroups.length > 1 && data.length > 8 && !metaData.xLabel) {
|
|
@@ -8756,8 +8839,37 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8756
8839
|
if (isValueToBeIgnored) {
|
|
8757
8840
|
return '';
|
|
8758
8841
|
}
|
|
8759
|
-
//
|
|
8842
|
+
// Always add space before and after hyphen for date range labels, even when header is visible and label is single line
|
|
8843
|
+
// Apply for grouped bar charts and single bar charts, header visible, single line
|
|
8844
|
+
const dateRangeRegex = /(\d{2,4}[-\/]\d{2}[-\/]\d{2,4})\s*-\s*(\d{2,4}[-\/]\d{2}[-\/]\d{2,4})/;
|
|
8845
|
+
if (dateRangeRegex.test(d.trim())) {
|
|
8846
|
+
return d.trim().replace(dateRangeRegex, (m, d1, d2) => `${d1} - ${d2}`);
|
|
8847
|
+
}
|
|
8848
|
+
// Split date and week labels into two lines in grouped bar zoom-in view (and minimized view)
|
|
8760
8849
|
const isDateLabel = /\d{2,4}[-\/]/.test(d);
|
|
8850
|
+
const isWeekLabel = /week|wk|w\d+/i.test(d);
|
|
8851
|
+
if (subgroups.length > 1 && !self.isZoomedOut && data.length > 8 && d.indexOf(' ') > -1 && (isDateLabel || isWeekLabel)) {
|
|
8852
|
+
var first = d.substring(0, d.indexOf(' '));
|
|
8853
|
+
var second = d.substring(d.indexOf(' ') + 1).trim();
|
|
8854
|
+
return first + '\n' + second;
|
|
8855
|
+
}
|
|
8856
|
+
// Also keep previous logic for minimized view
|
|
8857
|
+
if (isDateLabel) {
|
|
8858
|
+
if (!self.isHeaderVisible && data.length > 8 && d.indexOf(' ') > -1) {
|
|
8859
|
+
var first = d.substring(0, d.indexOf(' '));
|
|
8860
|
+
var second = d.substring(d.indexOf(' ') + 1).trim();
|
|
8861
|
+
return first + '\n' + second;
|
|
8862
|
+
}
|
|
8863
|
+
else {
|
|
8864
|
+
return d;
|
|
8865
|
+
}
|
|
8866
|
+
}
|
|
8867
|
+
if (d.trim().indexOf(' ') > -1) {
|
|
8868
|
+
return d.trim().substring(0, d.indexOf(' ')).toLowerCase();
|
|
8869
|
+
}
|
|
8870
|
+
return d.toLowerCase();
|
|
8871
|
+
// If label looks like a date (contains digits and - or /)
|
|
8872
|
+
const isDateLabel2 = /\d{2,4}[-\/]/.test(d);
|
|
8761
8873
|
// Only split date/week labels if there are many grouped bars and header is not visible
|
|
8762
8874
|
if (isDateLabel) {
|
|
8763
8875
|
if (!self.isHeaderVisible && data.length > 8 && d.indexOf(' ') > -1) {
|
|
@@ -8774,6 +8886,15 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8774
8886
|
}
|
|
8775
8887
|
return d.toLowerCase();
|
|
8776
8888
|
});
|
|
8889
|
+
// Now apply writing-mode: sideways-lr for grouped charts with date labels in zoomed-out view and many bars
|
|
8890
|
+
xAxisLabels.each(function (d) {
|
|
8891
|
+
// Only apply writing-mode for exact date labels, not those containing 'week' or similar
|
|
8892
|
+
const isDateLabel = /^(\d{2,4}[-\/])?\d{2,4}[-\/]\d{2,4}$/.test(d.trim());
|
|
8893
|
+
const isWeekLabel = /week|wk|w\d+/i.test(d);
|
|
8894
|
+
if (subgroups.length > 1 && self.isZoomedOut && data.length > 8 && isDateLabel && !isWeekLabel) {
|
|
8895
|
+
d3.select(this).style('writing-mode', 'sideways-lr');
|
|
8896
|
+
}
|
|
8897
|
+
});
|
|
8777
8898
|
if (!isMobile) {
|
|
8778
8899
|
svg
|
|
8779
8900
|
.selectAll('g.x1.axis1 g.tick')
|
|
@@ -8926,20 +9047,19 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8926
9047
|
});
|
|
8927
9048
|
}
|
|
8928
9049
|
var xSubgroup = d3.scaleBand().domain(subgroups);
|
|
8929
|
-
|
|
8930
|
-
if (subgroups.length > 1 && this.chartConfiguration.isMultiChartGridLine) {
|
|
8931
|
-
xSubgroup.range([0, x.bandwidth() * 1.2]).padding(0.05);
|
|
8932
|
-
}
|
|
8933
|
-
else if (subgroups.length > 1 && !this.isZoomedOut) {
|
|
9050
|
+
if (subgroups.length > 1 && !this.isZoomedOut) {
|
|
8934
9051
|
// For grouped bar charts in zoom-in view, reduce padding between bars
|
|
8935
|
-
xSubgroup.range([0, x.bandwidth()])
|
|
9052
|
+
xSubgroup.range([0, x.bandwidth()]);
|
|
8936
9053
|
}
|
|
8937
9054
|
else if (subgroups.length === 1 && !this.isZoomedOut) {
|
|
8938
|
-
// For single-bar (non-grouped) charts in zoom-in view, set bar width to 80
|
|
8939
|
-
xSubgroup.range([0,
|
|
9055
|
+
// For single-bar (non-grouped) charts in zoom-in view, set bar width to 100 (increased from 80)
|
|
9056
|
+
xSubgroup.range([0, 100]);
|
|
9057
|
+
}
|
|
9058
|
+
else if (this.chartConfiguration.isMultiChartGridLine == undefined) {
|
|
9059
|
+
xSubgroup.range([0, x.bandwidth()]);
|
|
8940
9060
|
}
|
|
8941
9061
|
else {
|
|
8942
|
-
//
|
|
9062
|
+
// used to make grouped bars with lesser width as we are not using padding for width
|
|
8943
9063
|
xSubgroup.range([0, x.bandwidth()]);
|
|
8944
9064
|
}
|
|
8945
9065
|
// if (this.chartConfiguration.isDrilldownChart) {
|
|
@@ -8996,7 +9116,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8996
9116
|
// Increase bar width a bit in zoom-in view
|
|
8997
9117
|
let reducedBarWidth = 60;
|
|
8998
9118
|
if (!self.isZoomedOut) {
|
|
8999
|
-
reducedBarWidth =
|
|
9119
|
+
reducedBarWidth = 30;
|
|
9000
9120
|
}
|
|
9001
9121
|
if (self.chartData.data.length == 1) {
|
|
9002
9122
|
if (Object.keys(self.chartData.data[0]).length == 2) {
|
|
@@ -9037,7 +9157,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
9037
9157
|
.attr('width', function (d) {
|
|
9038
9158
|
// For grouped bar charts in zoom-in view, slightly increase bar width for both bars (shipped and planned)
|
|
9039
9159
|
if (subgroups.length > 1 && !self.isZoomedOut) {
|
|
9040
|
-
return xSubgroup.bandwidth() * 0.
|
|
9160
|
+
return xSubgroup.bandwidth() * 0.25;
|
|
9041
9161
|
}
|
|
9042
9162
|
// For single-bar (non-grouped) charts in zoom-in view, set bar width to 80
|
|
9043
9163
|
if (subgroups.length === 1 && !self.isZoomedOut) {
|
|
@@ -9053,7 +9173,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
9053
9173
|
// Increase bar width a bit in zoom-in view
|
|
9054
9174
|
let reducedBarWidth = 60;
|
|
9055
9175
|
if (!self.isZoomedOut) {
|
|
9056
|
-
reducedBarWidth =
|
|
9176
|
+
reducedBarWidth = 100;
|
|
9057
9177
|
}
|
|
9058
9178
|
if (self.chartData.data.length == 1) {
|
|
9059
9179
|
if (Object.keys(self.chartData.data[0]).length == 2) {
|
|
@@ -9574,7 +9694,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
9574
9694
|
}
|
|
9575
9695
|
const xLabelText = metaData.xLabel;
|
|
9576
9696
|
const isAcr = isAcronym(xLabelText.replace(/[^A-Za-z]/g, ''));
|
|
9577
|
-
const xPosition = isria ? (height + margin.top + margin.bottom) : (height + margin.top + margin.bottom +
|
|
9697
|
+
const xPosition = isria ? (height + margin.top + margin.bottom) : (height + margin.top + margin.bottom + 40);
|
|
9578
9698
|
svg
|
|
9579
9699
|
.append('text')
|
|
9580
9700
|
.attr('class', function () {
|