axidio-styleguide-library1-v2 0.2.26 → 0.2.27
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-grouped-bar-with-scroll-zoom/horizontal-grouped-bar-with-scroll-zoom.component.mjs +300 -170
- package/fesm2022/axidio-styleguide-library1-v2.mjs +299 -169
- package/fesm2022/axidio-styleguide-library1-v2.mjs.map +1 -1
- package/lib/horizontal-grouped-bar-with-scroll-zoom/horizontal-grouped-bar-with-scroll-zoom.component.d.ts +0 -8
- package/package.json +1 -1
|
@@ -8218,6 +8218,9 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8218
8218
|
data = this.chartData.data;
|
|
8219
8219
|
metaData = this.chartData.metaData;
|
|
8220
8220
|
lineData = this.chartData.lineData;
|
|
8221
|
+
// if (lineData || this.chartData.targetLineData) {
|
|
8222
|
+
// rightSvgWidth = 60;
|
|
8223
|
+
// }
|
|
8221
8224
|
if (!metaData.colorAboveTarget) {
|
|
8222
8225
|
metaData['colorAboveTarget'] = metaData.colors;
|
|
8223
8226
|
}
|
|
@@ -8227,15 +8230,30 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8227
8230
|
var verticalstackedcontainer = d3.select(this.groupcontainerElt.nativeElement);
|
|
8228
8231
|
var margin = this.chartConfiguration.margin;
|
|
8229
8232
|
const { width, height } = this.calculateChartDimensions(chartContainer, verticalstackedcontainer, margin, self);
|
|
8233
|
+
/**
|
|
8234
|
+
* for hiding header
|
|
8235
|
+
* used by weekly charts
|
|
8236
|
+
*/
|
|
8230
8237
|
if (this.chartConfiguration.isHeaderVisible != undefined)
|
|
8231
8238
|
this.isHeaderVisible = this.chartConfiguration.isHeaderVisible;
|
|
8239
|
+
/**
|
|
8240
|
+
* for hiding legends
|
|
8241
|
+
* used by weekly charts
|
|
8242
|
+
*/
|
|
8232
8243
|
if (this.chartConfiguration.legendVisible != undefined) {
|
|
8233
8244
|
this.legendVisible = this.chartConfiguration.legendVisible;
|
|
8234
8245
|
}
|
|
8246
|
+
/**
|
|
8247
|
+
* for removing background color so that it can take parents color
|
|
8248
|
+
*
|
|
8249
|
+
*/
|
|
8235
8250
|
if (this.chartConfiguration.isTransparentBackground != undefined) {
|
|
8236
8251
|
this.isTransparentBackground =
|
|
8237
8252
|
this.chartConfiguration.isTransparentBackground;
|
|
8238
8253
|
}
|
|
8254
|
+
/**
|
|
8255
|
+
* format data values based on configuration received
|
|
8256
|
+
*/
|
|
8239
8257
|
if (this.chartConfiguration.textFormatter != undefined) {
|
|
8240
8258
|
formatFromBackend = ChartHelper.dataValueFormatter(this.chartConfiguration.textFormatter);
|
|
8241
8259
|
formatForHugeNumbers = ChartHelper.dataValueFormatter('.2s');
|
|
@@ -8247,6 +8265,9 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8247
8265
|
return d.name;
|
|
8248
8266
|
})
|
|
8249
8267
|
.keys();
|
|
8268
|
+
/**
|
|
8269
|
+
* x axis range made similar to line chart or vertical stack so that all the charts will get aligned with each other.
|
|
8270
|
+
*/
|
|
8250
8271
|
if (this.chartConfiguration.isMultiChartGridLine != undefined) {
|
|
8251
8272
|
x = d3
|
|
8252
8273
|
.scaleBand()
|
|
@@ -8264,16 +8285,266 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8264
8285
|
.range([leftAndRightSpaces, width - rightSvgWidth - leftAndRightSpaces])
|
|
8265
8286
|
.padding([0.3]);
|
|
8266
8287
|
}
|
|
8288
|
+
// x.bandwidth(96);
|
|
8267
8289
|
var xScaleFromOrigin = d3
|
|
8268
8290
|
.scaleBand()
|
|
8269
8291
|
.domain(groups)
|
|
8270
8292
|
.range([0, width - rightSvgWidth]);
|
|
8271
|
-
|
|
8272
|
-
|
|
8293
|
+
// .padding([0.2]);
|
|
8294
|
+
if (this.chartConfiguration.isMultiChartGridLine == undefined) {
|
|
8295
|
+
/**
|
|
8296
|
+
* normal ticks for all dashboard charts
|
|
8297
|
+
*/
|
|
8298
|
+
svg
|
|
8299
|
+
.append('g')
|
|
8300
|
+
.attr('class', 'x1 axis1')
|
|
8301
|
+
.attr('transform', 'translate(0,' + height + ')')
|
|
8302
|
+
.call(d3.axisBottom(x))
|
|
8303
|
+
.call((g) => g.select('.domain').remove());
|
|
8304
|
+
svg.selectAll('g.x1.axis1 g.tick line').remove();
|
|
8305
|
+
// Only move x-axis labels further down for grouped charts if there is no xLabel
|
|
8306
|
+
if (subgroups.length > 1 && !metaData.xLabel) {
|
|
8307
|
+
svg
|
|
8308
|
+
.selectAll('g.x1.axis1 g.tick text')
|
|
8309
|
+
.attr('class', 'lib-xaxis-labels-texts-drilldown')
|
|
8310
|
+
.style('fill', 'var(--chart-text-color)')
|
|
8311
|
+
.attr('y', 32); // Increase distance from bars (default is ~9)
|
|
8312
|
+
}
|
|
8313
|
+
else {
|
|
8314
|
+
svg
|
|
8315
|
+
.selectAll('g.x1.axis1 g.tick text')
|
|
8316
|
+
.attr('class', 'lib-xaxis-labels-texts-drilldown')
|
|
8317
|
+
.style('fill', 'var(--chart-text-color)');
|
|
8318
|
+
}
|
|
8319
|
+
}
|
|
8320
|
+
else {
|
|
8321
|
+
/**
|
|
8322
|
+
* bigger ticks for weekly charts and more space from x axis to labels
|
|
8323
|
+
*/
|
|
8324
|
+
/**
|
|
8325
|
+
* draw x axis
|
|
8326
|
+
*/
|
|
8327
|
+
svg
|
|
8328
|
+
.append('g')
|
|
8329
|
+
.attr('class', 'x1 axis1')
|
|
8330
|
+
.attr('transform', 'translate(0,' + height + ')')
|
|
8331
|
+
.call(d3.axisBottom(x).tickSize(0))
|
|
8332
|
+
.call((g) => g.select('.domain').attr('fill', 'none'));
|
|
8333
|
+
/**
|
|
8334
|
+
* tick line size in alternate fashion
|
|
8335
|
+
*/
|
|
8336
|
+
svg.selectAll('g.x1.axis1 g.tick line').attr('y2', function () {
|
|
8337
|
+
if (alternate_text &&
|
|
8338
|
+
self.chartConfiguration.isNoAlternateXaxisText == undefined) {
|
|
8339
|
+
alternate_text = false;
|
|
8340
|
+
return long_tick_length_bg - 7;
|
|
8341
|
+
}
|
|
8342
|
+
else {
|
|
8343
|
+
alternate_text = true;
|
|
8344
|
+
return short_tick_length_bg - 4;
|
|
8345
|
+
}
|
|
8346
|
+
});
|
|
8347
|
+
/**
|
|
8348
|
+
* reset the flag so that values can be shown in same alternate fashion
|
|
8349
|
+
*/
|
|
8350
|
+
alternate_text = false;
|
|
8351
|
+
/**
|
|
8352
|
+
* print x-axis label texts
|
|
8353
|
+
* used by weekly charts
|
|
8354
|
+
*/
|
|
8355
|
+
svg
|
|
8356
|
+
.selectAll('g.x1.axis1 g.tick text')
|
|
8357
|
+
.attr('class', 'lib-xaxis-labels-texts-weeklycharts')
|
|
8358
|
+
.attr('y', function () {
|
|
8359
|
+
// Minimize gap in maximized (fullscreen) view for weekly charts
|
|
8360
|
+
if (self.chartConfiguration.isFullScreen) {
|
|
8361
|
+
return short_tick_length_bg;
|
|
8362
|
+
}
|
|
8363
|
+
if (alternate_text) {
|
|
8364
|
+
alternate_text = false;
|
|
8365
|
+
return long_tick_length_bg;
|
|
8366
|
+
}
|
|
8367
|
+
else {
|
|
8368
|
+
alternate_text = true;
|
|
8369
|
+
return short_tick_length_bg;
|
|
8370
|
+
}
|
|
8371
|
+
});
|
|
8372
|
+
}
|
|
8373
|
+
if (self.chartConfiguration.xLabelsOnSameLine) {
|
|
8374
|
+
const xAxisLabels = svg
|
|
8375
|
+
.selectAll('g.x1.axis1 g.tick text')
|
|
8376
|
+
.attr('class', 'lib-xaxis-labels-texts-drilldown')
|
|
8377
|
+
.style('font-size', this.isHeaderVisible ? '18px' : '14px')
|
|
8378
|
+
.attr('text-anchor', 'middle')
|
|
8379
|
+
.attr('y', function (d) {
|
|
8380
|
+
// For grouped bar charts with many bars and xLabel present, only add 5 if the label is a date
|
|
8381
|
+
if (subgroups.length > 1 && data.length > 8 && metaData.xLabel) {
|
|
8382
|
+
const isDateLabel = /\d{2,4}[-\/]/.test(d);
|
|
8383
|
+
if (self.chartConfiguration.isFullScreen) {
|
|
8384
|
+
return isDateLabel ? short_tick_length_bg + 14 : short_tick_length_bg;
|
|
8385
|
+
}
|
|
8386
|
+
return isDateLabel ? short_tick_length_bg + 14 : short_tick_length_bg;
|
|
8387
|
+
}
|
|
8388
|
+
// For grouped bar charts with many bars and NO xLabel, add space as before, but reduce in fullscreen
|
|
8389
|
+
if (subgroups.length > 1 && data.length > 8 && !metaData.xLabel) {
|
|
8390
|
+
const chartHasExtraBottom = (self.chartConfiguration.margin && self.chartConfiguration.margin.bottom >= 40);
|
|
8391
|
+
if (self.chartConfiguration.isFullScreen) {
|
|
8392
|
+
// Reduce extra gap in maximized view
|
|
8393
|
+
return short_tick_length_bg + 2;
|
|
8394
|
+
}
|
|
8395
|
+
return chartHasExtraBottom ? short_tick_length_bg : short_tick_length_bg + 10;
|
|
8396
|
+
}
|
|
8397
|
+
// Default/fallback logic for other cases
|
|
8398
|
+
let baseY = self.isHeaderVisible ? short_tick_length_bg + 25 : short_tick_length_bg;
|
|
8399
|
+
if (subgroups.length > 1 &&
|
|
8400
|
+
!metaData.xLabel &&
|
|
8401
|
+
(/\d{2,4}[-\/]\d{2}[-\/]\d{2,4}/.test(d) || /\d{2,4}[-\/]\d{2,4}/.test(d))) {
|
|
8402
|
+
baseY = self.isHeaderVisible ? short_tick_length_bg + 15 : short_tick_length_bg + 25;
|
|
8403
|
+
}
|
|
8404
|
+
if (/\d{2,4}[-\/]\d{2,4}/.test(d) && d.indexOf(' ') > -1) {
|
|
8405
|
+
baseY += 4;
|
|
8406
|
+
}
|
|
8407
|
+
// In maximized view, reduce baseY slightly for grouped bars
|
|
8408
|
+
if (self.chartConfiguration.isFullScreen && subgroups.length > 1) {
|
|
8409
|
+
baseY = Math.max(short_tick_length_bg, baseY - 10);
|
|
8410
|
+
}
|
|
8411
|
+
return baseY;
|
|
8412
|
+
})
|
|
8413
|
+
.attr('x', function (d) {
|
|
8414
|
+
if (self.chartData.data.length > 8 && !self.isZoomedOut) {
|
|
8415
|
+
return 1; // Move first line text slightly to the left in zoom-in view for better alignment
|
|
8416
|
+
}
|
|
8417
|
+
return 0; // Default position
|
|
8418
|
+
})
|
|
8419
|
+
.text(function (d) {
|
|
8420
|
+
var isValueToBeIgnored = false;
|
|
8421
|
+
if (isMobile && !self.isHeaderVisible) {
|
|
8422
|
+
let firstPart = d.split(/[\s\-]+/)[0];
|
|
8423
|
+
return firstPart.substring(0, 3).toLowerCase();
|
|
8424
|
+
}
|
|
8425
|
+
data.map((indiv) => {
|
|
8426
|
+
if (indiv.name &&
|
|
8427
|
+
indiv.name.toLowerCase() == d.trim().toLowerCase() &&
|
|
8428
|
+
indiv[metaData.keyList[0]] == -1) {
|
|
8429
|
+
isValueToBeIgnored = true;
|
|
8430
|
+
}
|
|
8431
|
+
});
|
|
8432
|
+
if (isValueToBeIgnored) {
|
|
8433
|
+
return '';
|
|
8434
|
+
}
|
|
8435
|
+
// Always add space before and after hyphen for date range labels, even when header is visible and label is single line
|
|
8436
|
+
// Apply for grouped bar charts and single bar charts, header visible, single line
|
|
8437
|
+
const dateRangeRegex = /(\d{2,4}[-\/]\d{2}[-\/]\d{2,4})\s*-\s*(\d{2,4}[-\/]\d{2}[-\/]\d{2,4})/;
|
|
8438
|
+
if (dateRangeRegex.test(d.trim())) {
|
|
8439
|
+
return d.trim().replace(dateRangeRegex, (m, d1, d2) => `${d1} - ${d2}`);
|
|
8440
|
+
}
|
|
8441
|
+
// Split date and week labels into two lines in grouped bar zoom-in view (and minimized view)
|
|
8442
|
+
const isDateLabel = /\d{2,4}[-\/]/.test(d);
|
|
8443
|
+
const isWeekLabel = /week|wk|w\d+/i.test(d);
|
|
8444
|
+
if (subgroups.length > 1 && !self.isZoomedOut && data.length > 8 && d.indexOf(' ') > -1 && (isDateLabel || isWeekLabel)) {
|
|
8445
|
+
var first = d.substring(0, d.indexOf(' '));
|
|
8446
|
+
var second = d.substring(d.indexOf(' ') + 1).trim();
|
|
8447
|
+
return first + '\n' + second;
|
|
8448
|
+
}
|
|
8449
|
+
// Also keep previous logic for minimized view
|
|
8450
|
+
if (isDateLabel) {
|
|
8451
|
+
if (!self.isHeaderVisible && data.length > 8 && d.indexOf(' ') > -1) {
|
|
8452
|
+
var first = d.substring(0, d.indexOf(' '));
|
|
8453
|
+
var second = d.substring(d.indexOf(' ') + 1).trim();
|
|
8454
|
+
return first + '\n' + second;
|
|
8455
|
+
}
|
|
8456
|
+
else {
|
|
8457
|
+
return d;
|
|
8458
|
+
}
|
|
8459
|
+
}
|
|
8460
|
+
if (d.trim().indexOf(' ') > -1) {
|
|
8461
|
+
return d.trim().substring(0, d.indexOf(' ')).toLowerCase();
|
|
8462
|
+
}
|
|
8463
|
+
return d.toLowerCase();
|
|
8464
|
+
// If label looks like a date (contains digits and - or /)
|
|
8465
|
+
const isDateLabel2 = /\d{2,4}[-\/]/.test(d);
|
|
8466
|
+
// Only split date/week labels if there are many grouped bars and header is not visible
|
|
8467
|
+
if (isDateLabel) {
|
|
8468
|
+
if (!self.isHeaderVisible && data.length > 8 && d.indexOf(' ') > -1) {
|
|
8469
|
+
var first = d.substring(0, d.indexOf(' '));
|
|
8470
|
+
var second = d.substring(d.indexOf(' ') + 1).trim();
|
|
8471
|
+
return first + '\n' + second;
|
|
8472
|
+
}
|
|
8473
|
+
else {
|
|
8474
|
+
return d;
|
|
8475
|
+
}
|
|
8476
|
+
}
|
|
8477
|
+
if (d.trim().indexOf(' ') > -1) {
|
|
8478
|
+
return d.trim().substring(0, d.indexOf(' ')).toLowerCase();
|
|
8479
|
+
}
|
|
8480
|
+
return d.toLowerCase();
|
|
8481
|
+
});
|
|
8482
|
+
// Now apply writing-mode: sideways-lr for grouped charts with date labels in zoomed-out view and many bars
|
|
8483
|
+
xAxisLabels.each(function (d) {
|
|
8484
|
+
// Only apply writing-mode for exact date labels, not those containing 'week' or similar
|
|
8485
|
+
const isDateLabel = /^(\d{2,4}[-\/])?\d{2,4}[-\/]\d{2,4}$/.test(d.trim());
|
|
8486
|
+
const isWeekLabel = /week|wk|w\d+/i.test(d);
|
|
8487
|
+
if (subgroups.length > 1 && self.isZoomedOut && data.length > 8 && isDateLabel && !isWeekLabel) {
|
|
8488
|
+
d3.select(this).style('writing-mode', 'sideways-lr');
|
|
8489
|
+
}
|
|
8490
|
+
});
|
|
8491
|
+
if (!isMobile) {
|
|
8492
|
+
svg
|
|
8493
|
+
.selectAll('g.x1.axis1 g.tick')
|
|
8494
|
+
.filter(function (d) {
|
|
8495
|
+
return !/\d{2,4}[-\/]/.test(d); // Only process non-date labels
|
|
8496
|
+
})
|
|
8497
|
+
.append('text')
|
|
8498
|
+
.attr('class', 'lib-xaxis-labels-texts-drilldown')
|
|
8499
|
+
.attr('y', long_tick_length_bg)
|
|
8500
|
+
.attr('fill', 'var(--chart-text-color)')
|
|
8501
|
+
.attr('x', function (d) {
|
|
8502
|
+
if (self.chartData.data.length > 8 && !self.isZoomedOut) {
|
|
8503
|
+
return 1; // Move text slightly to the left
|
|
8504
|
+
}
|
|
8505
|
+
return 0; // Default position
|
|
8506
|
+
})
|
|
8507
|
+
.text(function (d) {
|
|
8508
|
+
if (d.trim().indexOf(' ') > -1) {
|
|
8509
|
+
return d.trim().substring(d.indexOf(' '), d.length).toLowerCase();
|
|
8510
|
+
}
|
|
8511
|
+
return '';
|
|
8512
|
+
});
|
|
8513
|
+
}
|
|
8514
|
+
}
|
|
8515
|
+
if (isria && self.chartData.data.length > 8) {
|
|
8516
|
+
svg
|
|
8517
|
+
.selectAll('g.x1.axis1 g.tick text')
|
|
8518
|
+
.classed('mobile-xaxis-override', true)
|
|
8519
|
+
.text(function (d) {
|
|
8520
|
+
return d.substring(0, 3);
|
|
8521
|
+
})
|
|
8522
|
+
.style('font-size', '12px')
|
|
8523
|
+
.attr('y', 5)
|
|
8524
|
+
.attr('x', 5)
|
|
8525
|
+
.style('text-anchor', 'middle');
|
|
8526
|
+
}
|
|
8527
|
+
if (isMobile && !this.isHeaderVisible) {
|
|
8528
|
+
svg
|
|
8529
|
+
.selectAll('g.x1.axis1 g.tick text')
|
|
8530
|
+
.classed('mobile-xaxis-override', true);
|
|
8531
|
+
}
|
|
8532
|
+
/**y scale for left y axis */
|
|
8273
8533
|
var y = d3.scaleLinear().rangeRound([height, 0]);
|
|
8274
8534
|
var maxValue = d3.max(data, (d) => d3.max(keyList, (key) => +d[key]));
|
|
8275
|
-
maxValue
|
|
8535
|
+
if (maxValue == 0) {
|
|
8536
|
+
if (this.chartData.targetLineData) {
|
|
8537
|
+
maxValue = this.chartData.targetLineData.target + 20;
|
|
8538
|
+
}
|
|
8539
|
+
else {
|
|
8540
|
+
maxValue = 100;
|
|
8541
|
+
}
|
|
8542
|
+
}
|
|
8276
8543
|
if (this.chartConfiguration.customYscale) {
|
|
8544
|
+
/**
|
|
8545
|
+
* increase y-scale so that values wont cross or exceed out of range
|
|
8546
|
+
* used in weekly charts
|
|
8547
|
+
*/
|
|
8277
8548
|
maxValue = maxValue * this.chartConfiguration.customYscale;
|
|
8278
8549
|
}
|
|
8279
8550
|
if (this.chartData.targetLineData &&
|
|
@@ -8311,6 +8582,10 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8311
8582
|
.tickSize(0)
|
|
8312
8583
|
.tickFormat(self.chartConfiguration.yLineAxisLabelFomatter);
|
|
8313
8584
|
}
|
|
8585
|
+
/**
|
|
8586
|
+
* show x-axis grid between labels
|
|
8587
|
+
* used by weekly charts
|
|
8588
|
+
*/
|
|
8314
8589
|
if (self.chartConfiguration.isXgridBetweenLabels) {
|
|
8315
8590
|
svg
|
|
8316
8591
|
.append('g')
|
|
@@ -8318,7 +8593,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8318
8593
|
.attr('transform', 'translate(' + x.bandwidth() / 2 + ',' + height + ')')
|
|
8319
8594
|
.call(d3.axisBottom(x).tickSize(-height).tickFormat(''))
|
|
8320
8595
|
.style('stroke-dasharray', '5 5')
|
|
8321
|
-
.style('color', 'var(--chart-grid-color, #999999)')
|
|
8596
|
+
.style('color', 'var(--chart-grid-color, #999999)') // Use CSS variable
|
|
8322
8597
|
.call((g) => g.select('.domain').remove());
|
|
8323
8598
|
}
|
|
8324
8599
|
if (this.chartConfiguration.yAxisGrid) {
|
|
@@ -8333,7 +8608,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8333
8608
|
.call((g) => {
|
|
8334
8609
|
g.select('.domain')
|
|
8335
8610
|
.remove()
|
|
8336
|
-
.style('stroke', 'var(--chart-domain-color, #000000)');
|
|
8611
|
+
.style('stroke', 'var(--chart-domain-color, #000000)'); // Add CSS variable for domain
|
|
8337
8612
|
});
|
|
8338
8613
|
}
|
|
8339
8614
|
else {
|
|
@@ -8344,27 +8619,36 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8344
8619
|
.style('opacity', '0.5')
|
|
8345
8620
|
.call((g) => {
|
|
8346
8621
|
g.select('.domain')
|
|
8347
|
-
.style('stroke', 'var(--chart-domain-color, #000000)')
|
|
8348
|
-
.style('stroke-width', '1px');
|
|
8622
|
+
.style('stroke', 'var(--chart-domain-color, #000000)') // Add CSS variable for domain
|
|
8623
|
+
.style('stroke-width', '1px'); // Ensure visibility
|
|
8349
8624
|
});
|
|
8350
8625
|
}
|
|
8351
8626
|
var xSubgroup = d3.scaleBand().domain(subgroups);
|
|
8352
8627
|
if (subgroups.length > 1 && !this.isZoomedOut) {
|
|
8628
|
+
// For grouped bar charts in zoom-in view, use full x.bandwidth() for subgroups
|
|
8353
8629
|
xSubgroup.range([0, x.bandwidth()]);
|
|
8354
8630
|
}
|
|
8355
8631
|
else if (subgroups.length === 1 && !this.isZoomedOut) {
|
|
8632
|
+
// For single-bar (non-grouped) charts in zoom-in view, set bar width to 100 (increased from 80)
|
|
8356
8633
|
xSubgroup.range([0, 100]);
|
|
8357
8634
|
}
|
|
8358
8635
|
else if (this.chartConfiguration.isMultiChartGridLine == undefined) {
|
|
8359
8636
|
xSubgroup.range([0, x.bandwidth()]);
|
|
8360
8637
|
}
|
|
8361
8638
|
else {
|
|
8639
|
+
// used to make grouped bars with lesser width as we are not using padding for width
|
|
8362
8640
|
xSubgroup.range([0, x.bandwidth()]);
|
|
8363
8641
|
}
|
|
8642
|
+
// if (this.chartConfiguration.isDrilldownChart) {
|
|
8643
|
+
// }
|
|
8364
8644
|
var color = d3
|
|
8365
8645
|
.scaleOrdinal()
|
|
8366
8646
|
.domain(subgroups)
|
|
8367
8647
|
.range(Object.values(metaData.colors));
|
|
8648
|
+
// var colorAboveTarget = d3
|
|
8649
|
+
// .scaleOrdinal()
|
|
8650
|
+
// .domain(subgroups)
|
|
8651
|
+
// .range(Object.values(metaData.colorAboveTarget));
|
|
8368
8652
|
var state = svg
|
|
8369
8653
|
.append('g')
|
|
8370
8654
|
.selectAll('.state')
|
|
@@ -8525,7 +8809,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8525
8809
|
d.value >= parseFloat(self.chartData.targetLineData.target) &&
|
|
8526
8810
|
self.chartData.metaData.colorAboveTarget) {
|
|
8527
8811
|
const key = d.key.toLowerCase();
|
|
8528
|
-
const colorAboveTarget = Object.keys(self.chartData.metaData.colorAboveTarget).find(
|
|
8812
|
+
const colorAboveTarget = Object.keys(self.chartData.metaData.colorAboveTarget).find(k => k.toLowerCase() === key);
|
|
8529
8813
|
if (colorAboveTarget) {
|
|
8530
8814
|
return self.chartData.metaData.colorAboveTarget[colorAboveTarget];
|
|
8531
8815
|
}
|
|
@@ -8656,9 +8940,8 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8656
8940
|
.on('mouseover', handleMouseOver);
|
|
8657
8941
|
}
|
|
8658
8942
|
}
|
|
8659
|
-
if (this.chartConfiguration.displayTitleOnTop ||
|
|
8660
|
-
|
|
8661
|
-
this.chartConfiguration.displayTitleOnTop == undefined)) {
|
|
8943
|
+
if (this.chartConfiguration.displayTitleOnTop || (this.chartConfiguration.textsOnBar == undefined &&
|
|
8944
|
+
this.chartConfiguration.displayTitleOnTop == undefined)) {
|
|
8662
8945
|
if (!isria) {
|
|
8663
8946
|
state
|
|
8664
8947
|
.selectAll('rect')
|
|
@@ -8885,8 +9168,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8885
9168
|
const lines = label.split('\n');
|
|
8886
9169
|
text.text(null);
|
|
8887
9170
|
lines.forEach((line, idx) => {
|
|
8888
|
-
text
|
|
8889
|
-
.append('tspan')
|
|
9171
|
+
text.append('tspan')
|
|
8890
9172
|
.text(line)
|
|
8891
9173
|
.attr('x', 0)
|
|
8892
9174
|
.attr('dy', idx === 0 ? '1em' : '1.1em');
|
|
@@ -8910,9 +9192,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8910
9192
|
* used to write y labels based on configuration
|
|
8911
9193
|
*/
|
|
8912
9194
|
if (metaData.yLabel) {
|
|
8913
|
-
const yPosition = isria
|
|
8914
|
-
? 0 - margin.left / 2 - 30
|
|
8915
|
-
: 0 - margin.left / 2 - 40;
|
|
9195
|
+
const yPosition = isria ? 0 - margin.left / 2 - 30 : 0 - margin.left / 2 - 40;
|
|
8916
9196
|
svgYAxisLeft
|
|
8917
9197
|
.append('text')
|
|
8918
9198
|
.attr('class', 'lib-axis-group-label font-size-1')
|
|
@@ -8996,9 +9276,7 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
8996
9276
|
}
|
|
8997
9277
|
const xLabelText = metaData.xLabel;
|
|
8998
9278
|
const isAcr = isAcronym(xLabelText.replace(/[^A-Za-z]/g, ''));
|
|
8999
|
-
const xPosition = isria
|
|
9000
|
-
? height + margin.top + margin.bottom
|
|
9001
|
-
: height + margin.top + margin.bottom + 40;
|
|
9279
|
+
const xPosition = isria ? (height + margin.top + margin.bottom) : (height + margin.top + margin.bottom + 40);
|
|
9002
9280
|
svg
|
|
9003
9281
|
.append('text')
|
|
9004
9282
|
.attr('class', function () {
|
|
@@ -9112,7 +9390,8 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
9112
9390
|
width = dataLength * 120;
|
|
9113
9391
|
}
|
|
9114
9392
|
if (dataLength > 8 && !this.isZoomedOut) {
|
|
9115
|
-
if (this.chartData.dropdownData2 &&
|
|
9393
|
+
if (this.chartData.dropdownData2 &&
|
|
9394
|
+
width < dataLength * 250) {
|
|
9116
9395
|
width = dataLength * 250;
|
|
9117
9396
|
}
|
|
9118
9397
|
else {
|
|
@@ -9194,155 +9473,6 @@ class HorizontalGroupedBarWithScrollZoomComponent extends ComponentUniqueId {
|
|
|
9194
9473
|
.attr('transform', `translate(0,${margin.top})`);
|
|
9195
9474
|
return { outerContainer, svgYAxisLeft, svgYAxisRight, innerContainer, svg };
|
|
9196
9475
|
}
|
|
9197
|
-
renderXAxis(svg, x, height, subgroups, metaData, chartConfig, alternate_text, short_tick_length_bg, long_tick_length_bg, self) {
|
|
9198
|
-
if (chartConfig.isMultiChartGridLine == undefined) {
|
|
9199
|
-
// Normal dashboard charts
|
|
9200
|
-
svg
|
|
9201
|
-
.append('g')
|
|
9202
|
-
.attr('class', 'x1 axis1')
|
|
9203
|
-
.attr('transform', `translate(0,${height})`)
|
|
9204
|
-
.call(d3.axisBottom(x))
|
|
9205
|
-
.call((g) => g.select('.domain').remove());
|
|
9206
|
-
svg.selectAll('g.x1.axis1 g.tick line').remove();
|
|
9207
|
-
if (subgroups.length > 1 && !metaData.xLabel) {
|
|
9208
|
-
svg
|
|
9209
|
-
.selectAll('g.x1.axis1 g.tick text')
|
|
9210
|
-
.attr('class', 'lib-xaxis-labels-texts-drilldown')
|
|
9211
|
-
.style('fill', 'var(--chart-text-color)')
|
|
9212
|
-
.attr('y', 32);
|
|
9213
|
-
}
|
|
9214
|
-
else {
|
|
9215
|
-
svg
|
|
9216
|
-
.selectAll('g.x1.axis1 g.tick text')
|
|
9217
|
-
.attr('class', 'lib-xaxis-labels-texts-drilldown')
|
|
9218
|
-
.style('fill', 'var(--chart-text-color)');
|
|
9219
|
-
}
|
|
9220
|
-
}
|
|
9221
|
-
else {
|
|
9222
|
-
// Weekly charts / multi-chart
|
|
9223
|
-
svg
|
|
9224
|
-
.append('g')
|
|
9225
|
-
.attr('class', 'x1 axis1')
|
|
9226
|
-
.attr('transform', `translate(0,${height})`)
|
|
9227
|
-
.call(d3.axisBottom(x).tickSize(0))
|
|
9228
|
-
.call((g) => g.select('.domain').attr('fill', 'none'));
|
|
9229
|
-
// Tick line size in alternate fashion
|
|
9230
|
-
svg.selectAll('g.x1.axis1 g.tick line').attr('y2', function () {
|
|
9231
|
-
if (alternate_text && chartConfig.isNoAlternateXaxisText == undefined) {
|
|
9232
|
-
alternate_text = false;
|
|
9233
|
-
return long_tick_length_bg - 7;
|
|
9234
|
-
}
|
|
9235
|
-
else {
|
|
9236
|
-
alternate_text = true;
|
|
9237
|
-
return short_tick_length_bg - 4;
|
|
9238
|
-
}
|
|
9239
|
-
});
|
|
9240
|
-
// Reset flag
|
|
9241
|
-
alternate_text = false;
|
|
9242
|
-
// X-axis labels
|
|
9243
|
-
svg
|
|
9244
|
-
.selectAll('g.x1.axis1 g.tick text')
|
|
9245
|
-
.attr('class', 'lib-xaxis-labels-texts-weeklycharts')
|
|
9246
|
-
.attr('y', function () {
|
|
9247
|
-
if (chartConfig.isFullScreen)
|
|
9248
|
-
return short_tick_length_bg;
|
|
9249
|
-
if (alternate_text) {
|
|
9250
|
-
alternate_text = false;
|
|
9251
|
-
return long_tick_length_bg;
|
|
9252
|
-
}
|
|
9253
|
-
else {
|
|
9254
|
-
alternate_text = true;
|
|
9255
|
-
return short_tick_length_bg;
|
|
9256
|
-
}
|
|
9257
|
-
});
|
|
9258
|
-
}
|
|
9259
|
-
}
|
|
9260
|
-
renderXAxisLabels(svg, data, subgroups, metaData, chartConfig, short_tick_length_bg, long_tick_length_bg, isMobile, isria, self) {
|
|
9261
|
-
if (!chartConfig.xLabelsOnSameLine)
|
|
9262
|
-
return;
|
|
9263
|
-
const xAxisLabels = svg.selectAll('g.x1.axis1 g.tick text');
|
|
9264
|
-
this.applyLabelStyles(xAxisLabels, data, subgroups, metaData, chartConfig, short_tick_length_bg, long_tick_length_bg, isMobile, self);
|
|
9265
|
-
this.handleLabelText(xAxisLabels, data, subgroups, metaData, chartConfig, isMobile, self);
|
|
9266
|
-
if (isria && data.length > 8) {
|
|
9267
|
-
this.applyRiaLabelOverride(xAxisLabels);
|
|
9268
|
-
}
|
|
9269
|
-
if (isMobile && !self.isHeaderVisible) {
|
|
9270
|
-
xAxisLabels.classed('mobile-xaxis-override', true);
|
|
9271
|
-
}
|
|
9272
|
-
}
|
|
9273
|
-
applyLabelStyles(labels, data, subgroups, metaData, chartConfig, short_tick_length_bg, long_tick_length_bg, isMobile, self) {
|
|
9274
|
-
labels
|
|
9275
|
-
.attr('class', 'lib-xaxis-labels-texts-drilldown')
|
|
9276
|
-
.style('font-size', self.isHeaderVisible ? '18px' : '14px')
|
|
9277
|
-
.attr('text-anchor', 'middle')
|
|
9278
|
-
.attr('y', (d) => this.calculateLabelY(d, data, subgroups, metaData, chartConfig, short_tick_length_bg, long_tick_length_bg, self))
|
|
9279
|
-
.attr('x', (d) => this.calculateLabelX(d, data, self));
|
|
9280
|
-
}
|
|
9281
|
-
calculateLabelY(d, data, subgroups, metaData, chartConfig, short_tick_length_bg, long_tick_length_bg, self) {
|
|
9282
|
-
// Logic from your original code for y positioning
|
|
9283
|
-
if (subgroups.length > 1 && data.length > 8 && metaData.xLabel) {
|
|
9284
|
-
return short_tick_length_bg + 14;
|
|
9285
|
-
}
|
|
9286
|
-
if (subgroups.length > 1 && data.length > 8 && !metaData.xLabel) {
|
|
9287
|
-
return chartConfig.isFullScreen
|
|
9288
|
-
? short_tick_length_bg + 2
|
|
9289
|
-
: short_tick_length_bg + 10;
|
|
9290
|
-
}
|
|
9291
|
-
let baseY = self.isHeaderVisible
|
|
9292
|
-
? short_tick_length_bg + 25
|
|
9293
|
-
: short_tick_length_bg;
|
|
9294
|
-
return baseY;
|
|
9295
|
-
}
|
|
9296
|
-
calculateLabelX(d, data, self) {
|
|
9297
|
-
if (data.length > 8 && !self.isZoomedOut)
|
|
9298
|
-
return 1;
|
|
9299
|
-
return 0;
|
|
9300
|
-
}
|
|
9301
|
-
handleLabelText(labels, data, subgroups, metaData, chartConfig, isMobile, self) {
|
|
9302
|
-
labels.text((d) => {
|
|
9303
|
-
if (isMobile && !self.isHeaderVisible) {
|
|
9304
|
-
return d
|
|
9305
|
-
.split(/[\s\-]+/)[0]
|
|
9306
|
-
.substring(0, 3)
|
|
9307
|
-
.toLowerCase();
|
|
9308
|
-
}
|
|
9309
|
-
// Split dates or weeks, ignore -1 values, etc.
|
|
9310
|
-
// Keep all your previous text-processing logic here
|
|
9311
|
-
return d.toLowerCase(); // fallback
|
|
9312
|
-
});
|
|
9313
|
-
// Example of handling sideways labels for grouped zoomed-out charts
|
|
9314
|
-
labels.each(function (d) {
|
|
9315
|
-
const isDateLabel = /^(\d{2,4}[-\/])?\d{2,4}[-\/]\d{2,4}$/.test(d.trim());
|
|
9316
|
-
const isWeekLabel = /week|wk|w\d+/i.test(d);
|
|
9317
|
-
if (subgroups.length > 1 &&
|
|
9318
|
-
self.isZoomedOut &&
|
|
9319
|
-
data.length > 8 &&
|
|
9320
|
-
isDateLabel &&
|
|
9321
|
-
!isWeekLabel) {
|
|
9322
|
-
d3.select(this).style('writing-mode', 'sideways-lr');
|
|
9323
|
-
}
|
|
9324
|
-
});
|
|
9325
|
-
}
|
|
9326
|
-
applyRiaLabelOverride(labels) {
|
|
9327
|
-
labels
|
|
9328
|
-
.classed('mobile-xaxis-override', true)
|
|
9329
|
-
.text((d) => d.substring(0, 3))
|
|
9330
|
-
.style('font-size', '12px')
|
|
9331
|
-
.attr('y', 5)
|
|
9332
|
-
.attr('x', 5)
|
|
9333
|
-
.style('text-anchor', 'middle');
|
|
9334
|
-
}
|
|
9335
|
-
calculateMaxValue(maxValue) {
|
|
9336
|
-
if (maxValue === 0) {
|
|
9337
|
-
if (this.chartData.targetLineData) {
|
|
9338
|
-
return this.chartData.targetLineData.target + 20;
|
|
9339
|
-
}
|
|
9340
|
-
else {
|
|
9341
|
-
return 100;
|
|
9342
|
-
}
|
|
9343
|
-
}
|
|
9344
|
-
return maxValue;
|
|
9345
|
-
}
|
|
9346
9476
|
handleClick(d) {
|
|
9347
9477
|
if (this.chartData.metaData.hasDrillDown || d?.toggleFrom)
|
|
9348
9478
|
this.clickEvent.emit(d);
|