axidio-styleguide-library1-v2 0.2.28 → 0.2.30

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.
@@ -3398,22 +3398,9 @@ class GroupChartComponent extends ComponentUniqueId {
3398
3398
  showLineChartAxis: true,
3399
3399
  showValues: true,
3400
3400
  headerMenuOptions: HeaderConfigHelper.headerConfig.headerMenuOptions,
3401
- xAxisGrid: undefined,
3402
3401
  yAxisGrid: false,
3403
3402
  legendVisible: true,
3404
- isHeaderVisible: undefined,
3405
- isTransparentBackground: undefined,
3406
- isMultiChartGridLine: undefined,
3407
- isFullScreen: undefined,
3408
- customYscale: undefined,
3409
- textsOnBar: undefined,
3410
- isXaxisLabelHidden: undefined,
3411
3403
  isYaxisLabelHidden: false,
3412
- isYaxisHidden: undefined,
3413
- isYaxisDashed: undefined,
3414
- textFormatter: undefined,
3415
- isNoAlternateXaxisText: undefined,
3416
- isXgridBetweenLabels: undefined,
3417
3404
  backgroundColor: '#FFFFFF',
3418
3405
  hideLegendOnTop: true,
3419
3406
  isXaxisColor: '#999999',
@@ -3421,32 +3408,23 @@ class GroupChartComponent extends ComponentUniqueId {
3421
3408
  noHoverEffect: true,
3422
3409
  noHoverDisplayData: true,
3423
3410
  showXaxisTop: true,
3424
- displayYaxisLabels: undefined,
3425
- xLabelsOnSameLine: undefined,
3426
- textAlwaysHorizontal: undefined,
3427
- legendAtTopRight: undefined,
3428
- isDrilldownChart: undefined,
3429
- displayTitleOnTop: undefined,
3430
- isToggleVisible: undefined,
3431
- isTitleHidden: undefined,
3432
- isDisplayBarDetailsAtBottom: undefined,
3433
3411
  howmanyBarDetailsToDisplay: 0,
3434
- barVauleColor: undefined,
3435
3412
  };
3436
3413
  this.uniqueId = this.getUniqueId();
3437
3414
  this.isZoomedOut = false;
3438
3415
  this.isDD1Open = false;
3439
3416
  this.isDD2Open = false;
3440
- this.keepOrder = (a, b) => {
3441
- return a;
3442
- };
3417
+ this.keepOrder = (a, b) => a;
3418
+ }
3419
+ ngOnInit() { }
3420
+ get isAlertEnabled() {
3421
+ return this.chartConfiguration?.headerMenuOptions?.some((option) => option.id === 'editAlert');
3443
3422
  }
3444
3423
  onResized(event) {
3445
- let self = this;
3446
- setTimeout(function () {
3447
- d3.select('#' + self.uniqueId).remove();
3448
- self.initializegroupChart();
3449
- }.bind(self), 10);
3424
+ setTimeout(() => {
3425
+ d3.select('#' + this.uniqueId).remove();
3426
+ this.initializegroupChart();
3427
+ }, 10);
3450
3428
  }
3451
3429
  isZoomOutSelected(isZoomOut, event) {
3452
3430
  this.isZoomedOut = isZoomOut;
@@ -3455,165 +3433,191 @@ class GroupChartComponent extends ComponentUniqueId {
3455
3433
  handleZoominZoomoutClick({ isZoomOut, event }) {
3456
3434
  this.isZoomOutSelected(isZoomOut, event);
3457
3435
  }
3458
- ngOnInit() { }
3459
3436
  isLegendVisible() {
3460
- if (this.chartData &&
3461
- this.chartData.metaData.colors &&
3462
- Object.keys(this.chartData.metaData.colors).length > 1) {
3463
- return true;
3464
- }
3465
- return false;
3466
- }
3467
- get isAlertEnabled() {
3468
- return this.chartConfiguration?.headerMenuOptions?.some(option => option.id === 'editAlert');
3437
+ return !!(this.chartData?.metaData?.colors &&
3438
+ Object.keys(this.chartData.metaData.colors).length > 1);
3469
3439
  }
3470
3440
  initializegroupChart() {
3471
- var self = this;
3472
- let data = [];
3473
- let metaData = null;
3474
- let keyList = null;
3475
- let lineData = null;
3476
- let colorMap = {};
3477
- var formatFromBackend;
3478
- var formatForHugeNumbers;
3479
- let isria = this.customChartConfiguration.isRia;
3480
- var x;
3481
- var alternate_text = false;
3482
- var short_tick_length = 4;
3483
- var long_tick_length = 16;
3484
- /**
3485
- * longer tick length needed for weekly charts
3486
- */
3487
- var short_tick_length_bg = 5;
3488
- var long_tick_length_bg = 30;
3489
- var leftAndRightSpaces = 50;
3490
- var rightSvgWidth = 60;
3491
- var tempScale;
3492
- for (var i in this.defaultConfiguration) {
3493
- this.chartConfiguration[i] = ChartHelper.getValueByConfigurationType(i, this.defaultConfiguration, this.customChartConfiguration);
3441
+ this.mergeConfigurations();
3442
+ const chartContext = this.prepareChartData();
3443
+ const dimensions = this.calculateDimensions(chartContext);
3444
+ const scales = this.createScales(chartContext, dimensions);
3445
+ const svgElements = this.createSVGStructure(dimensions);
3446
+ this.renderAxes(svgElements, scales, chartContext, dimensions);
3447
+ this.renderBars(svgElements.svg, chartContext, scales, dimensions);
3448
+ this.renderLabels(svgElements, scales, chartContext, dimensions);
3449
+ this.renderTargetLine(svgElements, scales, chartContext, dimensions);
3450
+ this.renderLineGraph(svgElements.svg, chartContext, scales);
3451
+ }
3452
+ mergeConfigurations() {
3453
+ for (const key in this.defaultConfiguration) {
3454
+ this.chartConfiguration[key] = ChartHelper.getValueByConfigurationType(key, this.defaultConfiguration, this.customChartConfiguration);
3494
3455
  }
3495
- data = this.chartData.data;
3496
- metaData = this.chartData.metaData;
3497
- lineData = this.chartData.lineData;
3498
- // if (lineData || this.chartData.targetLineData) {
3499
- // rightSvgWidth = 60;
3500
- // }
3501
- if (!metaData.colorAboveTarget) {
3502
- metaData['colorAboveTarget'] = metaData.colors;
3456
+ if (this.chartConfiguration.isHeaderVisible !== undefined) {
3457
+ this.isHeaderVisible = this.chartConfiguration.isHeaderVisible;
3503
3458
  }
3504
- colorMap = metaData.colors;
3505
- keyList = metaData.keyList;
3506
- var chartContainer = d3.select(this.containerElt.nativeElement);
3507
- var verticalstackedcontainer = d3.select(this.groupcontainerElt.nativeElement);
3508
- var margin = this.chartConfiguration.margin;
3509
- var width = parseInt(chartContainer.style('width')) - margin.left - margin.right;
3510
- if (this.chartData.data.length > 30 && this.isZoomedOut) {
3511
- width =
3512
- width > this.chartData.data.length * 40
3513
- ? this.chartData.dropdownData1
3514
- ? this.chartData.data.length * 60
3515
- : width
3516
- : this.chartData.dropdownData1
3517
- ? this.chartData.data.length * 60
3518
- : this.chartData.data.length * 40;
3519
- width =
3520
- width > this.chartData.data.length * 40
3521
- ? width
3522
- : this.chartData.data.length * 40;
3459
+ if (this.chartConfiguration.legendVisible !== undefined) {
3460
+ this.legendVisible = this.chartConfiguration.legendVisible;
3523
3461
  }
3524
- if (this.chartData.dropdownData2 &&
3525
- width < this.chartData.data.length * 120 &&
3526
- this.isZoomedOut) {
3527
- width = this.chartData.data.length * 120;
3462
+ if (this.chartConfiguration.isTransparentBackground !== undefined) {
3463
+ this.isTransparentBackground = this.chartConfiguration.isTransparentBackground;
3528
3464
  }
3529
- if (this.chartData.data.length > 8 && !this.isZoomedOut) {
3530
- if (this.chartData.dropdownData2 &&
3531
- width < this.chartData.data.length * 250) {
3532
- width = this.chartData.data.length * 250;
3465
+ }
3466
+ prepareChartData() {
3467
+ const data = this.chartData.data;
3468
+ const metaData = this.chartData.metaData;
3469
+ const lineData = this.chartData.lineData;
3470
+ if (!metaData.colorAboveTarget) {
3471
+ metaData.colorAboveTarget = metaData.colors;
3472
+ }
3473
+ return {
3474
+ data,
3475
+ metaData,
3476
+ lineData,
3477
+ keyList: metaData.keyList,
3478
+ colorMap: metaData.colors,
3479
+ isRia: this.customChartConfiguration?.isRia || false,
3480
+ };
3481
+ }
3482
+ calculateDimensions(chartContext) {
3483
+ const chartContainer = d3.select(this.containerElt.nativeElement);
3484
+ const verticalstackedcontainer = d3.select(this.groupcontainerElt.nativeElement);
3485
+ const margin = this.chartConfiguration.margin;
3486
+ let width = this.calculateWidth(chartContainer, margin);
3487
+ let height = this.calculateHeight(verticalstackedcontainer, margin);
3488
+ return { width, height, margin, chartContainer, verticalstackedcontainer };
3489
+ }
3490
+ calculateWidth(chartContainer, margin) {
3491
+ const baseWidth = parseInt(chartContainer.style('width')) - margin.left - margin.right;
3492
+ const dataLength = this.chartData.data.length;
3493
+ let width = baseWidth;
3494
+ if (dataLength > 30 && this.isZoomedOut) {
3495
+ const multiplier = this.chartData.dropdownData1 ? 60 : 40;
3496
+ width = Math.max(width, dataLength * multiplier);
3497
+ }
3498
+ if (this.chartData.dropdownData2 && width < dataLength * 120 && this.isZoomedOut) {
3499
+ width = dataLength * 120;
3500
+ }
3501
+ if (dataLength > 8 && !this.isZoomedOut) {
3502
+ if (this.chartData.dropdownData2 && width < dataLength * 250) {
3503
+ width = dataLength * 250;
3504
+ }
3505
+ else {
3506
+ width = dataLength * 160;
3533
3507
  }
3534
- else
3535
- width = this.chartData.data.length * 160;
3536
3508
  }
3537
- // if (this.chartData.data.length > 8) {
3538
- // width = this.chartData.data.length * 140;
3539
- // }
3540
- var height = parseInt(verticalstackedcontainer.style('height')) *
3541
- (self.chartConfiguration.svgHeight / 100) -
3509
+ return width;
3510
+ }
3511
+ calculateHeight(verticalstackedcontainer, margin) {
3512
+ let height = parseInt(verticalstackedcontainer.style('height')) *
3513
+ (this.chartConfiguration.svgHeight / 100) -
3542
3514
  margin.top -
3543
3515
  margin.bottom;
3544
- /**
3545
- * entire height used in weekly charts as x axis needed to be displayed at the bottom of the chart
3546
- */
3547
- if (this.chartConfiguration.isFullScreen != undefined &&
3548
- this.chartConfiguration.isFullScreen) {
3549
- height =
3550
- this.chartConfiguration.svgHeight != 70
3551
- ? this.chartConfiguration.svgHeight
3552
- : parseInt(verticalstackedcontainer.style('height'));
3516
+ if (this.chartConfiguration.isFullScreen && this.chartConfiguration.svgHeight !== 70) {
3517
+ height = this.chartConfiguration.svgHeight;
3518
+ }
3519
+ else if (this.chartConfiguration.isFullScreen) {
3520
+ height = parseInt(verticalstackedcontainer.style('height'));
3553
3521
  }
3554
3522
  if (this.chartConfiguration.isDrilldownChart && !this.isHeaderVisible) {
3555
- height =
3556
- parseInt(verticalstackedcontainer.style('height')) -
3557
- margin.top -
3558
- margin.bottom -
3559
- 130;
3523
+ height = parseInt(verticalstackedcontainer.style('height')) - margin.top - margin.bottom - 130;
3560
3524
  }
3561
3525
  if (this.chartConfiguration.isHeaderVisible) {
3562
- height =
3563
- parseInt(verticalstackedcontainer.style('height')) -
3564
- margin.top -
3565
- margin.bottom -
3566
- 100;
3526
+ height = parseInt(verticalstackedcontainer.style('height')) - margin.top - margin.bottom - 100;
3567
3527
  }
3568
- /**
3569
- * for hiding header
3570
- * used by weekly charts
3571
- */
3572
- if (this.chartConfiguration.isHeaderVisible != undefined)
3573
- this.isHeaderVisible = this.chartConfiguration.isHeaderVisible;
3574
- /**
3575
- * for hiding legends
3576
- * used by weekly charts
3577
- */
3578
- if (this.chartConfiguration.legendVisible != undefined) {
3579
- this.legendVisible = this.chartConfiguration.legendVisible;
3528
+ return height;
3529
+ }
3530
+ createScales(chartContext, dimensions) {
3531
+ const { data, metaData, lineData, keyList } = chartContext;
3532
+ const { width, height, margin } = dimensions;
3533
+ const leftAndRightSpaces = 50;
3534
+ const rightSvgWidth = 60;
3535
+ const groups = d3.map(data, (d) => d.name).keys();
3536
+ let x;
3537
+ if (this.chartConfiguration.isMultiChartGridLine !== undefined) {
3538
+ x = d3
3539
+ .scaleBand()
3540
+ .rangeRound([width, 0])
3541
+ .align(0.5)
3542
+ .padding(0.5)
3543
+ .domain(data.map((d) => d.name.toLowerCase()));
3580
3544
  }
3581
- /**
3582
- * for removing background color so that it can take parents color
3583
- *
3584
- */
3585
- if (this.chartConfiguration.isTransparentBackground != undefined) {
3586
- this.isTransparentBackground =
3587
- this.chartConfiguration.isTransparentBackground;
3545
+ else {
3546
+ x = d3
3547
+ .scaleBand()
3548
+ .domain(groups)
3549
+ .range([leftAndRightSpaces, width - rightSvgWidth - leftAndRightSpaces])
3550
+ .padding(0.3);
3588
3551
  }
3589
- /**
3590
- * format data values based on configuration received
3591
- */
3592
- if (this.chartConfiguration.textFormatter != undefined) {
3593
- formatFromBackend = ChartHelper.dataValueFormatter(this.chartConfiguration.textFormatter);
3594
- formatForHugeNumbers = ChartHelper.dataValueFormatter('.2s');
3552
+ const xScaleFromOrigin = d3.scaleBand().domain(groups).range([0, width - rightSvgWidth]);
3553
+ const xSubgroup = d3.scaleBand().domain(keyList).range([0, x.bandwidth()]);
3554
+ const maxValue = this.calculateMaxValue(data, keyList);
3555
+ const y = d3.scaleLinear().domain([0, maxValue]).nice().rangeRound([height, 0]);
3556
+ let lineYscale = null;
3557
+ if (lineData) {
3558
+ lineYscale = this.createLineYScale(lineData, height);
3559
+ }
3560
+ const color = d3.scaleOrdinal().domain(keyList).range(Object.values(metaData.colors));
3561
+ return {
3562
+ x,
3563
+ xScaleFromOrigin,
3564
+ xSubgroup,
3565
+ y,
3566
+ lineYscale,
3567
+ color,
3568
+ leftAndRightSpaces,
3569
+ rightSvgWidth,
3570
+ };
3571
+ }
3572
+ calculateMaxValue(data, keyList) {
3573
+ let maxValue = d3.max(data, (d) => d3.max(keyList, (key) => +d[key])) || 0;
3574
+ if (maxValue === 0) {
3575
+ maxValue = this.chartData.targetLineData
3576
+ ? this.chartData.targetLineData.target + 20
3577
+ : 100;
3578
+ }
3579
+ if (this.chartConfiguration.customYscale) {
3580
+ maxValue *= this.chartConfiguration.customYscale;
3581
+ }
3582
+ if (this.chartData.targetLineData && maxValue < this.chartData.targetLineData.target) {
3583
+ const target = this.chartData.targetLineData.target;
3584
+ maxValue = maxValue < 10 && target < 10 ? target + 3 : target + 20;
3595
3585
  }
3596
- var outerContainer = chartContainer
3586
+ return maxValue;
3587
+ }
3588
+ createLineYScale(lineData, height) {
3589
+ let maxLineValue = d3.max(lineData, (d) => +d.value) || 0;
3590
+ maxLineValue *= this.chartConfiguration.customYscale || 1;
3591
+ let minLineValue = d3.min(lineData, (d) => +d.value) || 0;
3592
+ if (maxLineValue > 0)
3593
+ minLineValue -= 3;
3594
+ if (minLineValue > 0)
3595
+ minLineValue = 0;
3596
+ return d3.scaleLinear().domain([minLineValue, maxLineValue]).range([height, minLineValue]);
3597
+ }
3598
+ createSVGStructure(dimensions) {
3599
+ const { chartContainer, height, margin } = dimensions;
3600
+ const rightSvgWidth = 60;
3601
+ const outerContainer = chartContainer
3597
3602
  .append('div')
3598
- .attr('id', self.uniqueId)
3603
+ .attr('id', this.uniqueId)
3599
3604
  .attr('class', 'outer-container')
3600
3605
  .style('width', '100%')
3601
3606
  .style('height', height)
3602
3607
  .style('overflow-x', 'hidden')
3603
3608
  .style('padding-left', `${margin.left}px`)
3604
- // .call(ChartHelper.responsivefy)
3605
3609
  .style('padding-right', `${rightSvgWidth}px`)
3606
3610
  .style('margin-left', '15px');
3607
- var svgYAxisLeft = outerContainer
3611
+ const svgYAxisLeft = outerContainer
3608
3612
  .append('svg')
3609
- .attr('width', '100')
3613
+ .attr('width', 100)
3610
3614
  .attr('height', height + margin.top + margin.bottom + 10)
3611
3615
  .style('position', 'absolute')
3612
3616
  .style('left', '0')
3613
3617
  .style('z-index', 1)
3614
3618
  .append('g')
3615
- .attr('transform', 'translate(' + (margin.left + 15) + ',' + margin.top + ')');
3616
- var svgYAxisRight = outerContainer
3619
+ .attr('transform', `translate(${margin.left + 15},${margin.top})`);
3620
+ const svgYAxisRight = outerContainer
3617
3621
  .append('svg')
3618
3622
  .attr('width', rightSvgWidth)
3619
3623
  .attr('height', height + margin.top + margin.bottom + 10)
@@ -3621,962 +3625,591 @@ class GroupChartComponent extends ComponentUniqueId {
3621
3625
  .style('right', '12px')
3622
3626
  .style('z-index', 1)
3623
3627
  .append('g')
3624
- .attr('transform', 'translate(' + 0 + ',' + margin.top + ')');
3625
- var innerContainer = outerContainer
3628
+ .attr('transform', `translate(0,${margin.top})`);
3629
+ const innerContainer = outerContainer
3626
3630
  .append('div')
3627
3631
  .attr('class', 'inner-container')
3628
3632
  .style('width', '100%')
3629
3633
  .style('overflow-x', 'auto');
3630
- var svg = innerContainer
3634
+ const svg = innerContainer
3631
3635
  .append('svg')
3632
- // .attr('id', self.uniqueId)
3633
- .attr('width', width - rightSvgWidth)
3636
+ .attr('width', dimensions.width - rightSvgWidth)
3634
3637
  .attr('height', height + margin.top + margin.bottom + 30)
3635
- // .call(ChartHelper.responsivefy)
3636
3638
  .append('g')
3637
- .attr('transform', 'translate(' + 0 + ',' + margin.top + ')');
3638
- var subgroups = keyList;
3639
- var groups = d3
3640
- .map(data, function (d) {
3641
- return d.name;
3642
- })
3643
- .keys();
3644
- /**
3645
- * x axis range made similar to line chart or vertical stack so that all the charts will get aligned with each other.
3646
- */
3647
- if (this.chartConfiguration.isMultiChartGridLine != undefined) {
3648
- x = d3
3649
- .scaleBand()
3650
- .rangeRound([width, 0])
3651
- .align(0.5)
3652
- .padding([0.5])
3653
- .domain(data.map(function (d) {
3654
- return d.name.toLowerCase();
3655
- }));
3639
+ .attr('transform', `translate(0,${margin.top})`);
3640
+ return { outerContainer, svgYAxisLeft, svgYAxisRight, svg };
3641
+ }
3642
+ renderAxes(svgElements, scales, chartContext, dimensions) {
3643
+ const { svg, svgYAxisLeft, svgYAxisRight } = svgElements;
3644
+ const { x, xScaleFromOrigin, y, lineYscale } = scales;
3645
+ const { height } = dimensions;
3646
+ const { metaData, lineData, keyList } = chartContext;
3647
+ this.renderXAxis(svg, x, xScaleFromOrigin, height, chartContext, keyList);
3648
+ this.renderYAxis(svg, svgYAxisLeft, svgYAxisRight, y, dimensions);
3649
+ if (this.chartConfiguration.yAxisGrid) {
3650
+ this.renderYAxisGrid(svg, y, dimensions.width);
3656
3651
  }
3657
- else {
3658
- x = d3
3659
- .scaleBand()
3660
- .domain(groups)
3661
- .range([leftAndRightSpaces, width - rightSvgWidth - leftAndRightSpaces])
3662
- .padding([0.3]);
3652
+ if (this.chartConfiguration.isXgridBetweenLabels) {
3653
+ this.renderXAxisGrid(svg, x, height);
3663
3654
  }
3664
- // x.bandwidth(96);
3665
- var xScaleFromOrigin = d3
3666
- .scaleBand()
3667
- .domain(groups)
3668
- .range([0, width - rightSvgWidth]);
3669
- // .padding([0.2]);
3670
- /**
3671
- * draw second x axis on top
3672
- */
3673
- // if (self.chartConfiguration.showXaxisTop) {
3674
- // svg
3675
- // .append('g')
3676
- // .attr('class', 'lib-line-axis-text lib-line-x-axis-text x-axis')
3677
- // .attr('style', self.chartConfiguration.xAxisCustomTextStyles)
3678
- // .call(d3.axisBottom(x).tickSize(0));
3679
- // }
3680
- // d3.svg.axis().scale(x).orient('bottom').ticks(1).innerTickSize(-height);
3681
- if (this.chartConfiguration.isMultiChartGridLine == undefined) {
3682
- /**
3683
- * normal ticks for all dashboard charts
3684
- */
3655
+ if (lineData && this.chartConfiguration.showLineChartAxis && lineYscale) {
3656
+ this.renderLineYAxis(svgYAxisRight, lineYscale);
3657
+ }
3658
+ }
3659
+ renderXAxis(svg, x, xScaleFromOrigin, height, chartContext, keyList) {
3660
+ const { data, metaData } = chartContext;
3661
+ if (this.chartConfiguration.isMultiChartGridLine === undefined) {
3685
3662
  svg
3686
3663
  .append('g')
3687
3664
  .attr('class', 'x1 axis1')
3688
- .attr('transform', 'translate(0,' + height + ')')
3665
+ .attr('transform', `translate(0,${height})`)
3689
3666
  .call(d3.axisBottom(x))
3690
3667
  .call((g) => g.select('.domain').remove());
3691
3668
  svg.selectAll('g.x1.axis1 g.tick line').remove();
3692
- if (subgroups.length > 1 && !metaData.xLabel) {
3693
- svg
3694
- .selectAll('g.x1.axis1 g.tick text')
3695
- .attr('class', 'lib-xaxis-labels-texts-drilldown')
3696
- .style('fill', 'var(--chart-text-color)')
3697
- .attr('y', 32); // Increase distance from bars (default is ~9)
3698
- }
3699
- else {
3700
- svg
3701
- .selectAll('g.x1.axis1 g.tick text')
3702
- .attr('class', 'lib-xaxis-labels-texts-drilldown')
3703
- .style('fill', 'var(--chart-text-color)');
3669
+ const textClass = 'lib-xaxis-labels-texts-drilldown';
3670
+ const textSelection = svg.selectAll('g.x1.axis1 g.tick text').attr('class', textClass).style('fill', 'var(--chart-text-color)');
3671
+ if (keyList.length > 1 && !metaData.xLabel) {
3672
+ textSelection.attr('y', 32);
3704
3673
  }
3705
- // .attr('y', function () {
3706
- // if (alternate_text) {
3707
- // alternate_text = false;
3708
- // return long_tick_length + 1;
3709
- // } else {
3710
- // alternate_text = true;
3711
- // return short_tick_length + 1;
3712
- // }
3713
- // });
3714
3674
  }
3715
3675
  else {
3716
- /**
3717
- * bigger ticks for weekly charts and more space from x axis to labels
3718
- */
3719
- /**
3720
- * draw x axis
3721
- */
3722
- svg
3723
- .append('g')
3724
- .attr('class', 'x1 axis1')
3725
- .attr('transform', 'translate(0,' + height + ')')
3726
- .call(d3.axisBottom(x).tickSize(0))
3727
- .call((g) => g.select('.domain').attr('fill', 'none'));
3728
- /**
3729
- * tick line size in alternate fashion
3730
- */
3731
- svg.selectAll('g.x1.axis1 g.tick line').attr('y2', function () {
3732
- if (alternate_text &&
3733
- self.chartConfiguration.isNoAlternateXaxisText == undefined) {
3734
- alternate_text = false;
3735
- return long_tick_length_bg - 7;
3736
- }
3737
- else {
3738
- alternate_text = true;
3739
- return short_tick_length_bg - 4;
3740
- }
3741
- });
3742
- /**
3743
- * reset the flag so that values can be shown in same alternate fashion
3744
- */
3745
- alternate_text = false;
3746
- /**
3747
- * print x-axis label texts
3748
- * used by weekly charts
3749
- */
3750
- svg
3751
- .selectAll('g.x1.axis1 g.tick text')
3752
- .attr('class', 'lib-xaxis-labels-texts-weeklycharts')
3753
- .attr('y', function () {
3754
- if (alternate_text) {
3755
- alternate_text = false;
3756
- return long_tick_length_bg;
3757
- }
3758
- else {
3759
- alternate_text = true;
3760
- return short_tick_length_bg;
3761
- }
3762
- });
3676
+ this.renderMultiChartXAxis(svg, x, height, data, metaData);
3763
3677
  }
3764
- if (self.chartConfiguration.xLabelsOnSameLine) {
3765
- svg
3766
- .selectAll('g.x1.axis1 g.tick text')
3767
- .attr('class', 'lib-xaxis-labels-texts-drilldown')
3768
- .attr('y', short_tick_length_bg)
3769
- .text(function (d) {
3770
- var isValueToBeIgnored = false;
3771
- data.map((indiv) => {
3772
- if (indiv.name.toLowerCase() == d.trim().toLowerCase() &&
3773
- indiv[metaData.keyList[0]] == -1) {
3774
- isValueToBeIgnored = true;
3775
- }
3776
- });
3777
- if (isValueToBeIgnored) {
3778
- return '';
3779
- }
3780
- if (d.trim().indexOf(' ') > -1) {
3781
- return d.trim().substring(0, d.indexOf(' ')).toLowerCase();
3782
- }
3783
- return d.toLowerCase();
3784
- });
3785
- svg
3786
- .selectAll('g.x1.axis1 g.tick')
3787
- .append('text')
3788
- .attr('class', 'lib-xaxis-labels-texts-drilldown')
3789
- .attr('y', long_tick_length_bg)
3790
- .attr('fill', 'currentColor')
3791
- .text(function (d) {
3792
- if (d.trim().indexOf(' ') > -1) {
3793
- return d.trim().substring(d.indexOf(' '), d.length).toLowerCase();
3794
- }
3795
- return '';
3796
- });
3678
+ if (this.chartConfiguration.xLabelsOnSameLine) {
3679
+ this.renderXLabelsOnSameLine(svg, data, metaData);
3797
3680
  }
3798
- /**y scale for left y axis */
3799
- var y = d3.scaleLinear().rangeRound([height, 0]);
3800
- var maxValue = d3.max(data, (d) => d3.max(keyList, (key) => +d[key]));
3801
- if (maxValue == 0) {
3802
- if (this.chartData.targetLineData) {
3803
- maxValue = this.chartData.targetLineData.target + 20;
3681
+ // Render bottom x-axis
3682
+ svg
3683
+ .append('g')
3684
+ .attr('class', 'x2 axis2')
3685
+ .attr('transform', `translate(0,${height})`)
3686
+ .style('color', '#000')
3687
+ .call(d3.axisBottom(xScaleFromOrigin).tickSize(0))
3688
+ .call((g) => g.select('.domain').attr('fill', 'none'));
3689
+ svg.selectAll('g.x2.axis2 g.tick text').style('display', 'none');
3690
+ if (this.isZoomedOut) {
3691
+ svg.selectAll('.lib-xaxis-labels-texts-drilldown').attr('class', 'lib-display-hidden');
3692
+ }
3693
+ }
3694
+ renderMultiChartXAxis(svg, x, height, data, metaData) {
3695
+ let alternate_text = false;
3696
+ const short_tick_length_bg = 5;
3697
+ const long_tick_length_bg = 30;
3698
+ svg
3699
+ .append('g')
3700
+ .attr('class', 'x1 axis1')
3701
+ .attr('transform', `translate(0,${height})`)
3702
+ .call(d3.axisBottom(x).tickSize(0))
3703
+ .call((g) => g.select('.domain').attr('fill', 'none'));
3704
+ svg.selectAll('g.x1.axis1 g.tick line').attr('y2', () => {
3705
+ if (alternate_text && !this.chartConfiguration.isNoAlternateXaxisText) {
3706
+ alternate_text = false;
3707
+ return long_tick_length_bg - 7;
3804
3708
  }
3805
3709
  else {
3806
- maxValue = 100;
3710
+ alternate_text = true;
3711
+ return short_tick_length_bg - 4;
3807
3712
  }
3808
- }
3809
- if (self.chartConfiguration.yAxisGrid) {
3810
- // svg
3811
- // .append('g')
3812
- // .attr('class', 'grid')
3813
- // .call(
3814
- // d3
3815
- // .axisLeft(y)
3816
- // .ticks(self.chartConfiguration.numberOfYTicks)
3817
- // .tickSize(-width)
3818
- // .tickFormat('')
3819
- // )
3820
- // // .style('stroke-dasharray', '5 5')
3821
- // .style('color', '#B9B9B9')
3822
- // .style('opacity', '0.5')
3823
- // .call((g) => g.select('.domain').remove());
3824
- }
3825
- if (this.chartConfiguration.customYscale) {
3826
- /**
3827
- * increase y-scale so that values wont cross or exceed out of range
3828
- * used in weekly charts
3829
- */
3830
- maxValue = maxValue * this.chartConfiguration.customYscale;
3831
- }
3832
- if (this.chartData.targetLineData &&
3833
- maxValue < this.chartData.targetLineData.target) {
3834
- maxValue =
3835
- maxValue < 10 && this.chartData.targetLineData.target < 10
3836
- ? this.chartData.targetLineData.target + 3
3837
- : this.chartData.targetLineData.target + 20;
3838
- }
3839
- y.domain([0, maxValue]).nice();
3840
- let lineYscale;
3841
- if (lineData != null) {
3842
- let maxLineValue = d3.max(lineData, function (d) {
3843
- return +d.value;
3844
- });
3845
- maxLineValue = maxLineValue * this.chartConfiguration.customYscale;
3846
- let minLineValue = d3.min(lineData, function (d) {
3847
- return +d.value;
3848
- });
3849
- if (maxLineValue > 0)
3850
- minLineValue = minLineValue - 3;
3851
- if (minLineValue > 0) {
3852
- minLineValue = 0;
3713
+ });
3714
+ alternate_text = false;
3715
+ svg.selectAll('g.x1.axis1 g.tick text').attr('class', 'lib-xaxis-labels-texts-weeklycharts').attr('y', () => {
3716
+ if (alternate_text) {
3717
+ alternate_text = false;
3718
+ return long_tick_length_bg;
3853
3719
  }
3854
- lineYscale = d3
3855
- .scaleLinear()
3856
- .domain([minLineValue, maxLineValue])
3857
- .range([height, minLineValue]);
3858
- }
3859
- let yLineAxis;
3860
- if (lineYscale != null) {
3861
- yLineAxis = d3
3862
- .axisRight(lineYscale)
3863
- .ticks(self.chartConfiguration.numberOfYTicks)
3864
- .tickSize(0)
3865
- .tickFormat(self.chartConfiguration.yLineAxisLabelFomatter);
3866
- }
3867
- /**
3868
- * show x-axis grid between labels
3869
- * used by weekly charts
3870
- */
3871
- if (self.chartConfiguration.isXgridBetweenLabels) {
3872
- svg
3873
- .append('g')
3874
- .attr('class', 'grid')
3875
- .attr('transform', 'translate(' + x.bandwidth() / 2 + ',' + height + ')')
3876
- .call(d3.axisBottom(x).tickSize(-height).tickFormat(''))
3877
- .style('stroke-dasharray', '5 5')
3878
- .style('color', 'var(--chart-grid-color, #999999)')
3879
- .call((g) => g.select('.domain').remove());
3880
- }
3881
- if (this.chartConfiguration.yAxisGrid) {
3882
- /**
3883
- * draw y axis
3884
- */
3885
- svg
3886
- .append('g')
3887
- .call(d3
3888
- .axisLeft(y)
3889
- .ticks(self.chartConfiguration.numberOfYTicks)
3890
- .tickSize(-width))
3891
- .style('color', 'var(--chart-axis-color, #B9B9B9)')
3892
- .style('opacity', '0.5')
3893
- .call((g) => g.select('.domain').remove());
3720
+ else {
3721
+ alternate_text = true;
3722
+ return short_tick_length_bg;
3723
+ }
3724
+ });
3725
+ }
3726
+ renderXLabelsOnSameLine(svg, data, metaData) {
3727
+ const short_tick_length_bg = 5;
3728
+ const long_tick_length_bg = 30;
3729
+ svg
3730
+ .selectAll('g.x1.axis1 g.tick text')
3731
+ .attr('class', 'lib-xaxis-labels-texts-drilldown')
3732
+ .attr('y', short_tick_length_bg)
3733
+ .text((d) => {
3734
+ const isValueToBeIgnored = data.some((indiv) => indiv.name.toLowerCase() === d.trim().toLowerCase() &&
3735
+ indiv[metaData.keyList[0]] === -1);
3736
+ if (isValueToBeIgnored)
3737
+ return '';
3738
+ if (d.trim().indexOf(' ') > -1) {
3739
+ return d.trim().substring(0, d.indexOf(' ')).toLowerCase();
3740
+ }
3741
+ return d.toLowerCase();
3742
+ });
3743
+ svg
3744
+ .selectAll('g.x1.axis1 g.tick')
3745
+ .append('text')
3746
+ .attr('class', 'lib-xaxis-labels-texts-drilldown')
3747
+ .attr('y', long_tick_length_bg)
3748
+ .attr('fill', 'currentColor')
3749
+ .text((d) => {
3750
+ if (d.trim().indexOf(' ') > -1) {
3751
+ return d.trim().substring(d.indexOf(' ')).toLowerCase();
3752
+ }
3753
+ return '';
3754
+ });
3755
+ }
3756
+ renderYAxis(svg, svgYAxisLeft, svgYAxisRight, y, dimensions) {
3757
+ svg
3758
+ .append('g')
3759
+ .attr('class', 'lib-stacked-y-axis-text yaxis-dashed')
3760
+ .attr('style', this.chartConfiguration.yAxisCustomTextStyles)
3761
+ .attr('transform', 'translate(0,0)')
3762
+ .call(y)
3763
+ .style('display', 'none');
3764
+ svgYAxisLeft
3765
+ .append('g')
3766
+ .append('g')
3767
+ .attr('class', 'lib-yaxis-labels-texts-drilldown yaxis-dashed')
3768
+ .attr('style', this.chartConfiguration.yAxisCustomTextStyles)
3769
+ .attr('transform', 'translate(0,0)')
3770
+ .call(d3
3771
+ .axisLeft(y)
3772
+ .tickSize(0)
3773
+ .ticks(this.chartConfiguration.numberOfYTicks)
3774
+ .tickFormat(this.chartConfiguration.yAxisLabelFomatter))
3775
+ .selectAll('text')
3776
+ .style('fill', 'var(--chart-text-color)');
3777
+ svgYAxisRight
3778
+ .append('g')
3779
+ .attr('class', 'lib-yaxis-labels-texts-drilldown yaxis-dashed')
3780
+ .attr('style', this.chartConfiguration.yAxisCustomTextStyles)
3781
+ .attr('transform', 'translate(0,0)')
3782
+ .call(y)
3783
+ .style('display', 'none');
3784
+ this.applyAxisVisibilitySettings();
3785
+ }
3786
+ applyAxisVisibilitySettings() {
3787
+ if (this.chartConfiguration.isXaxisLabelHidden) {
3788
+ d3.selectAll('g.lib-line-x-axis-text > g > text').attr('class', 'lib-display-hidden');
3894
3789
  }
3895
- else {
3896
- svg
3897
- .append('g')
3898
- .call(d3.axisLeft(y).ticks(self.chartConfiguration.numberOfYTicks))
3899
- .style('color', '#B9B9B9')
3900
- .style('opacity', '0.5')
3901
- .call((g) => g.select('.domain').remove());
3790
+ if (this.chartConfiguration.isYaxisLabelHidden) {
3791
+ d3.selectAll('.yaxis-dashed > g > text').attr('class', 'lib-display-hidden');
3902
3792
  }
3903
- var xSubgroup = d3.scaleBand().domain(subgroups);
3904
- if (this.chartConfiguration.isMultiChartGridLine == undefined) {
3905
- xSubgroup.range([0, x.bandwidth()]);
3793
+ if (this.chartConfiguration.isYaxisHidden) {
3794
+ d3.selectAll('.yaxis-dashed').attr('class', 'lib-display-hidden');
3906
3795
  }
3907
- else {
3908
- /**
3909
- * used to make grouped bars with lesser width as we are not using padding for width
3910
- * used by weekly charts
3911
- */
3912
- xSubgroup.range([0, x.bandwidth()]);
3796
+ if (this.chartConfiguration.isYaxisDashed) {
3797
+ d3.selectAll('.yaxis-dashed').style('stroke-dasharray', '5 5').style('color', '#999999');
3913
3798
  }
3914
- // if (this.chartConfiguration.isDrilldownChart) {
3915
- // }
3916
- var color = d3
3917
- .scaleOrdinal()
3918
- .domain(subgroups)
3919
- .range(Object.values(metaData.colors));
3920
- // var colorAboveTarget = d3
3921
- // .scaleOrdinal()
3922
- // .domain(subgroups)
3923
- // .range(Object.values(metaData.colorAboveTarget));
3924
- var state = svg
3799
+ }
3800
+ renderYAxisGrid(svg, y, width) {
3801
+ svg
3802
+ .append('g')
3803
+ .call(d3.axisLeft(y).ticks(this.chartConfiguration.numberOfYTicks).tickSize(-width))
3804
+ .style('color', 'var(--chart-axis-color, #B9B9B9)')
3805
+ .style('opacity', '0.5')
3806
+ .call((g) => g.select('.domain').remove());
3807
+ }
3808
+ renderXAxisGrid(svg, x, height) {
3809
+ svg
3810
+ .append('g')
3811
+ .attr('class', 'grid')
3812
+ .attr('transform', `translate(${x.bandwidth() / 2},${height})`)
3813
+ .call(d3.axisBottom(x).tickSize(-height).tickFormat(''))
3814
+ .style('stroke-dasharray', '5 5')
3815
+ .style('color', 'var(--chart-grid-color, #999999)')
3816
+ .call((g) => g.select('.domain').remove());
3817
+ }
3818
+ renderLineYAxis(svgYAxisRight, lineYscale) {
3819
+ const yLineAxis = d3
3820
+ .axisRight(lineYscale)
3821
+ .ticks(this.chartConfiguration.numberOfYTicks)
3822
+ .tickSize(0)
3823
+ .tickFormat(this.chartConfiguration.yLineAxisLabelFomatter);
3824
+ svgYAxisRight
3825
+ .append('g')
3826
+ .attr('class', 'lib-stacked-y-axis-text1')
3827
+ .attr('style', this.chartConfiguration.yAxisCustomTextStyles)
3828
+ .attr('transform', 'translate(0,0)')
3829
+ .call(yLineAxis);
3830
+ }
3831
+ renderBars(svg, chartContext, scales, dimensions) {
3832
+ const { data, metaData, keyList, isRia } = chartContext;
3833
+ const { x, xSubgroup, y } = scales;
3834
+ const { height } = dimensions;
3835
+ const state = svg
3925
3836
  .append('g')
3926
3837
  .selectAll('.state')
3927
3838
  .data(data)
3928
3839
  .enter()
3929
3840
  .append('g')
3930
- .attr('transform', function (d) {
3931
- return 'translate(' + x(d.name) + ',0)';
3932
- });
3841
+ .attr('transform', (d) => `translate(${x(d.name)},0)`);
3933
3842
  state
3934
3843
  .selectAll('rect')
3935
- .data(function (d) {
3936
- let newList = [];
3937
- subgroups.map(function (key) {
3938
- // if (key !== "group") {
3939
- let obj = { key: key, value: d[key], name: d.name };
3940
- newList.push(obj);
3941
- // }
3942
- });
3943
- return newList;
3944
- })
3844
+ .data((d) => this.prepareBarData(d, keyList))
3945
3845
  .enter()
3946
3846
  .append('rect')
3947
3847
  .attr('class', 'bars')
3948
- .on('click', function (d) {
3949
- if (d.key != 'Target') {
3950
- if (!metaData.barWithoutClick ||
3951
- !metaData.barWithoutClick.length ||
3952
- (!metaData.barWithoutClick.includes(d?.name) &&
3953
- !metaData.barWithoutClick.includes(d?.key)))
3954
- // self.handleClick(d.data.name);
3955
- self.handleClick(d);
3956
- }
3957
- })
3958
- .attr('x', function (d) {
3959
- if (self.chartConfiguration.isDrilldownChart) {
3960
- data.map((indiv) => {
3961
- if (indiv.name == d.name) {
3962
- let keys = Object.keys(indiv).filter((temp, i) => i != 0);
3963
- tempScale = d3.scaleBand().domain(keys).range([0, x.bandwidth()]);
3964
- if (x.bandwidth() > 100) {
3965
- if (self.chartData.data.length == 1) {
3966
- if (Object.keys(self.chartData.data[0]).length == 2) {
3967
- tempScale.range([
3968
- 0 + (x.bandwidth() - 200) / 2,
3969
- x.bandwidth() - (x.bandwidth() - 200) / 2,
3970
- ]);
3971
- // .padding(0.05);
3972
- }
3973
- else
3974
- tempScale.range([
3975
- 0 + (x.bandwidth() - 300) / 2,
3976
- x.bandwidth() - (x.bandwidth() - 300) / 2,
3977
- ]);
3978
- // .padding(0.05);
3979
- }
3980
- else
3981
- tempScale.range([
3982
- 0 + (x.bandwidth() - 125) / 2,
3983
- x.bandwidth() - (x.bandwidth() - 125) / 2,
3984
- ]);
3985
- }
3986
- }
3987
- });
3988
- return tempScale(d.key);
3848
+ .on('click', (d) => this.handleBarClick(d, metaData))
3849
+ .attr('x', (d) => this.getBarX(d, data, x, xSubgroup))
3850
+ .attr('y', (d) => y(d.value))
3851
+ .attr('width', (d) => this.getBarWidth(d, data, x, xSubgroup))
3852
+ .attr('height', (d) => this.getBarHeight(d, y, height))
3853
+ .style('cursor', (d) => (metaData.hasDrillDown && !isRia ? 'pointer' : 'default'))
3854
+ .attr('fill', (d) => this.getBarColor(d, metaData));
3855
+ if (!isRia && (this.chartConfiguration.displayTitleOnTop || (!this.chartConfiguration.textsOnBar && !this.chartConfiguration.displayTitleOnTop))) {
3856
+ state.selectAll('rect').on('mouseout', (d, i) => this.handleMouseOut(svg)).on('mouseover', (d, i) => this.handleMouseOver(svg, d, data, metaData, x, y, scales.leftAndRightSpaces));
3857
+ }
3858
+ if (this.chartConfiguration.textsOnBar && !this.isZoomedOut) {
3859
+ this.renderBarTexts(state, data, metaData, keyList, x, xSubgroup, y, isRia, svg);
3860
+ }
3861
+ if (this.chartConfiguration.isDrilldownChart) {
3862
+ svg.selectAll('g.x1.axis1 g.tick line').style('display', 'none');
3863
+ }
3864
+ }
3865
+ prepareBarData(d, keyList) {
3866
+ return keyList.map((key) => ({ key, value: d[key], name: d.name }));
3867
+ }
3868
+ handleBarClick(d, metaData) {
3869
+ if (d.key === 'Target')
3870
+ return;
3871
+ if (!metaData.barWithoutClick?.length ||
3872
+ (!metaData.barWithoutClick.includes(d?.name) && !metaData.barWithoutClick.includes(d?.key))) {
3873
+ this.handleClick(d);
3874
+ }
3875
+ }
3876
+ getBarX(d, data, x, xSubgroup) {
3877
+ if (this.chartConfiguration.isDrilldownChart) {
3878
+ return this.calculateDrilldownBarX(d, data, x);
3879
+ }
3880
+ return xSubgroup(d.key);
3881
+ }
3882
+ calculateDrilldownBarX(d, data, x) {
3883
+ let tempScale;
3884
+ data.forEach((indiv) => {
3885
+ if (indiv.name === d.name) {
3886
+ const keys = Object.keys(indiv).filter((temp, i) => i !== 0);
3887
+ tempScale = d3.scaleBand().domain(keys).range([0, x.bandwidth()]);
3888
+ if (x.bandwidth() > 100) {
3889
+ tempScale = this.adjustDrilldownScale(tempScale, data, x);
3890
+ }
3989
3891
  }
3990
- return xSubgroup(d.key);
3991
- })
3992
- .attr('y', function (d) {
3993
- return y(d.value);
3994
- })
3995
- .attr('width', function (d) {
3996
- if (self.chartConfiguration.isDrilldownChart) {
3997
- // var tempScale;
3998
- data.map((indiv) => {
3999
- if (indiv.name == d.name) {
4000
- let keys = Object.keys(indiv).filter((temp, i) => i != 0);
4001
- var temp;
4002
- tempScale = d3.scaleBand().domain(keys).range([0, x.bandwidth()]);
4003
- if (x.bandwidth() > 100) {
4004
- if (self.chartData.data.length == 1) {
4005
- if (Object.keys(self.chartData.data[0]).length == 2) {
4006
- tempScale.range([
4007
- 0 + (x.bandwidth() - 200) / 2,
4008
- x.bandwidth() - (x.bandwidth() - 200) / 2,
4009
- ]);
4010
- // .padding(0.05);
4011
- }
4012
- else
4013
- tempScale.range([
4014
- 0 + (x.bandwidth() - 300) / 2,
4015
- x.bandwidth() - (x.bandwidth() - 300) / 2,
4016
- ]);
4017
- // .padding(0.05);
4018
- }
4019
- else
4020
- tempScale.range([
4021
- 0 + (x.bandwidth() - 125) / 2,
4022
- x.bandwidth() - (x.bandwidth() - 125) / 2,
4023
- ]);
4024
- }
3892
+ });
3893
+ return tempScale ? tempScale(d.key) : 0;
3894
+ }
3895
+ adjustDrilldownScale(tempScale, data, x) {
3896
+ if (this.chartData.data.length === 1) {
3897
+ const keysLength = Object.keys(this.chartData.data[0]).length;
3898
+ const offset = keysLength === 2 ? 200 : 300;
3899
+ tempScale.range([
3900
+ 0 + (x.bandwidth() - offset) / 2,
3901
+ x.bandwidth() - (x.bandwidth() - offset) / 2,
3902
+ ]);
3903
+ }
3904
+ else {
3905
+ tempScale.range([
3906
+ 0 + (x.bandwidth() - 125) / 2,
3907
+ x.bandwidth() - (x.bandwidth() - 125) / 2,
3908
+ ]);
3909
+ }
3910
+ return tempScale;
3911
+ }
3912
+ getBarWidth(d, data, x, xSubgroup) {
3913
+ if (this.chartConfiguration.isDrilldownChart) {
3914
+ let tempScale;
3915
+ data.forEach((indiv) => {
3916
+ if (indiv.name === d.name) {
3917
+ const keys = Object.keys(indiv).filter((temp, i) => i !== 0);
3918
+ tempScale = d3.scaleBand().domain(keys).range([0, x.bandwidth()]);
3919
+ if (x.bandwidth() > 100) {
3920
+ tempScale = this.adjustDrilldownScale(tempScale, data, x);
4025
3921
  }
4026
- });
4027
- return tempScale.bandwidth();
4028
- }
4029
- return xSubgroup.bandwidth();
4030
- })
4031
- .attr('height', function (d) {
4032
- if (d.value == -1) {
4033
- return height - y(0);
4034
- }
4035
- if (d.value)
4036
- return height - y(d.value);
3922
+ }
3923
+ });
3924
+ return tempScale ? tempScale.bandwidth() : 0;
3925
+ }
3926
+ return xSubgroup.bandwidth();
3927
+ }
3928
+ getBarHeight(d, y, height) {
3929
+ if (d.value === -1)
4037
3930
  return height - y(0);
4038
- })
4039
- // .style('cursor', 'pointer')
4040
- .style('cursor', function (d) {
4041
- if (metaData.hasDrillDown && !isria)
4042
- return 'pointer';
4043
- else
4044
- return 'default';
4045
- })
4046
- .attr('fill', function (d) {
4047
- if (d.value &&
4048
- self.chartData.targetLineData &&
4049
- d.value >= parseInt(self.chartData.targetLineData.target) &&
4050
- self.chartData.metaData.colorAboveTarget)
4051
- return self.chartData.metaData.colorAboveTarget[d.key];
4052
- return self.chartData.metaData.colors[d.key];
4053
- });
4054
- /**
4055
- * display angled texts on the bars
4056
- */
4057
- if (this.chartConfiguration.textsOnBar != undefined && !this.isZoomedOut) {
3931
+ if (d.value)
3932
+ return height - y(d.value);
3933
+ return height - y(0);
3934
+ }
3935
+ getBarColor(d, metaData) {
3936
+ if (d.value &&
3937
+ this.chartData.targetLineData &&
3938
+ d.value >= parseInt(this.chartData.targetLineData.target) &&
3939
+ this.chartData.metaData.colorAboveTarget) {
3940
+ return this.chartData.metaData.colorAboveTarget[d.key];
3941
+ }
3942
+ return this.chartData.metaData.colors[d.key];
3943
+ }
3944
+ renderBarTexts(state, data, metaData, keyList, x, xSubgroup, y, isRia, svg) {
3945
+ state
3946
+ .selectAll('text')
3947
+ .data((d) => this.prepareBarData(d, keyList))
3948
+ .enter()
3949
+ .append('text')
3950
+ .attr('x', 0)
3951
+ .attr('y', 0)
3952
+ .attr('class', 'lib-data-labels-weeklycharts')
3953
+ .text((d) => this.getBarTextLabel(d))
3954
+ .style('fill', '#000')
3955
+ .style('font-weight', 'bold')
3956
+ .style('font-size', () => this.getBarTextFontSize())
3957
+ .attr('transform', (d) => this.getBarTextTransform(d, data, x, xSubgroup, y))
3958
+ .on('click', (d) => this.handleBarClick(d, metaData));
3959
+ if (!isRia) {
4058
3960
  state
4059
- .selectAll('text')
4060
- .data(function (d) {
4061
- let newList = [];
4062
- subgroups.map(function (key) {
4063
- let obj = { key: key, value: d[key], name: d.name };
4064
- newList.push(obj);
4065
- });
4066
- return newList;
4067
- })
4068
- .enter()
4069
- .append('text')
4070
- .attr('x', function (d) {
4071
- return 0;
4072
- })
4073
- .attr('y', function (d) {
4074
- return 0;
4075
- })
4076
- .attr('class', 'lib-data-labels-weeklycharts')
4077
- .text(function (d) {
4078
- return d.key && d.value
4079
- ? d.key.length > 20
4080
- ? d.key.substring(0, 17) + '...'
4081
- : d.key
4082
- : '';
4083
- })
4084
- .style('fill', function (d) {
4085
- return '#000';
4086
- })
4087
- .style('font-weight', 'bold')
4088
- .style('font-size', function (d) {
4089
- if (self.chartConfiguration.isDrilldownChart) {
4090
- if (window.innerWidth > 1900) {
4091
- return '18px';
4092
- }
4093
- else if (window.innerWidth < 1400) {
4094
- return '10px';
4095
- }
4096
- else {
4097
- return '14px';
4098
- }
4099
- }
4100
- else {
4101
- return '14px';
4102
- }
4103
- })
4104
- .attr('transform', function (d) {
4105
- data.map((indiv) => {
4106
- if (indiv.name == d.name) {
4107
- let keys = Object.keys(indiv).filter((temp, i) => i != 0);
4108
- var temp;
4109
- tempScale = d3.scaleBand().domain(keys).range([0, x.bandwidth()]);
4110
- if (x.bandwidth() > 100) {
4111
- if (self.chartData.data.length == 1) {
4112
- if (Object.keys(self.chartData.data[0]).length == 2) {
4113
- tempScale.range([
4114
- 0 + (x.bandwidth() - 200) / 2,
4115
- x.bandwidth() - (x.bandwidth() - 200) / 2,
4116
- ]);
4117
- // .padding(0.05);
4118
- }
4119
- else
4120
- tempScale.range([
4121
- 0 + (x.bandwidth() - 300) / 2,
4122
- x.bandwidth() - (x.bandwidth() - 300) / 2,
4123
- ]);
4124
- // .padding(0.05);
4125
- }
4126
- else
4127
- tempScale.range([
4128
- 0 + (x.bandwidth() - 125) / 2,
4129
- x.bandwidth() - (x.bandwidth() - 125) / 2,
4130
- ]);
4131
- }
4132
- }
4133
- });
4134
- /**
4135
- * if set, then all texts ll be horizontal
4136
- */
4137
- if (self.chartConfiguration.textAlwaysHorizontal) {
4138
- return ('translate(' + xSubgroup(d.key) + ',' + (y(d.value) - 3) + ')');
3961
+ .selectAll('.lib-data-labels-weeklycharts')
3962
+ .on('mouseout', (d, i) => this.handleMouseOut(svg))
3963
+ .on('mouseover', (d, i) => this.handleMouseOver(svg, d, data, metaData, x, y, x.bandwidth()));
3964
+ }
3965
+ }
3966
+ getBarTextLabel(d) {
3967
+ if (!d.key || !d.value)
3968
+ return '';
3969
+ return d.key.length > 20 ? d.key.substring(0, 17) + '...' : d.key;
3970
+ }
3971
+ getBarTextFontSize() {
3972
+ if (this.chartConfiguration.isDrilldownChart) {
3973
+ if (window.innerWidth > 1900)
3974
+ return '18px';
3975
+ if (window.innerWidth < 1400)
3976
+ return '10px';
3977
+ return '14px';
3978
+ }
3979
+ return '14px';
3980
+ }
3981
+ getBarTextTransform(d, data, x, xSubgroup, y) {
3982
+ let tempScale;
3983
+ data.forEach((indiv) => {
3984
+ if (indiv.name === d.name) {
3985
+ const keys = Object.keys(indiv).filter((temp, i) => i !== 0);
3986
+ tempScale = d3.scaleBand().domain(keys).range([0, x.bandwidth()]);
3987
+ if (x.bandwidth() > 100) {
3988
+ tempScale = this.adjustDrilldownScale(tempScale, data, x);
4139
3989
  }
4140
- /**
4141
- * rotate texts having more than one digits
4142
- */
4143
- // if (d.value > 9)
4144
- if (!isNaN(tempScale(d.key)))
4145
- return ('translate(' +
4146
- (tempScale(d.key) + tempScale.bandwidth() * 0.55) +
4147
- ',' +
4148
- (y(0) - 10) +
4149
- ') rotate(270)');
4150
- return 'translate(0,0)';
4151
- // else
4152
- // return (
4153
- // 'translate(' +
4154
- // (tempScale(d.key) + tempScale.bandwidth() / 2) +
4155
- // ',' +
4156
- // y(0) +
4157
- // ')'
4158
- // );
4159
- })
4160
- .on('click', function (d) {
4161
- if (!metaData.barWithoutClick ||
4162
- !metaData.barWithoutClick.length ||
4163
- (!metaData.barWithoutClick.includes(d?.name) &&
4164
- !metaData.barWithoutClick.includes(d?.key)))
4165
- self.handleClick(d);
4166
- });
4167
- if (!isria) {
4168
- state.selectAll('.lib-data-labels-weeklycharts')
4169
- .on('mouseout', handleMouseOut)
4170
- .on('mouseover', handleMouseOver);
4171
3990
  }
3991
+ });
3992
+ if (this.chartConfiguration.textAlwaysHorizontal) {
3993
+ return `translate(${xSubgroup(d.key)},${y(d.value) - 3})`;
4172
3994
  }
4173
- if (this.chartConfiguration.displayTitleOnTop || (this.chartConfiguration.textsOnBar == undefined &&
4174
- this.chartConfiguration.displayTitleOnTop == undefined)) {
4175
- if (!isria) {
4176
- state
4177
- .selectAll('rect')
4178
- .on('mouseout', handleMouseOut)
4179
- .on('mouseover', handleMouseOver);
4180
- }
3995
+ if (tempScale && !isNaN(tempScale(d.key))) {
3996
+ return `translate(${tempScale(d.key) + tempScale.bandwidth() * 0.55},${y(0) - 10}) rotate(270)`;
4181
3997
  }
4182
- function handleMouseOver(d, i) {
4183
- svg.selectAll('.lib-verticalstack-title-ontop').remove();
4184
- svg
4185
- .append('foreignObject')
4186
- .attr('x', function () {
4187
- // var tempScale;
4188
- var elementsCounter;
4189
- data.map((indiv) => {
4190
- if (indiv.name == d.name) {
4191
- let keys = Object.keys(indiv).filter((temp, i) => i != 0);
4192
- elementsCounter = keys.length;
4193
- tempScale = d3.scaleBand().domain(keys).range([0, x.bandwidth()]);
4194
- if (x.bandwidth() > 100) {
4195
- if (self.chartData.data.length == 1) {
4196
- if (Object.keys(self.chartData.data[0]).length == 2) {
4197
- tempScale.range([
4198
- 0 + (x.bandwidth() - 200) / 2,
4199
- x.bandwidth() - (x.bandwidth() - 200) / 2,
4200
- ]);
4201
- // .padding(0.05);
4202
- }
4203
- else
4204
- tempScale.range([
4205
- 0 + (x.bandwidth() - 300) / 2,
4206
- x.bandwidth() - (x.bandwidth() - 300) / 2,
4207
- ]);
4208
- // .padding(0.05);
4209
- }
4210
- else
4211
- tempScale.range([
4212
- 0 + (x.bandwidth() - 125) / 2,
4213
- x.bandwidth() - (x.bandwidth() - 125) / 2,
4214
- ]);
4215
- }
4216
- }
4217
- });
4218
- if (metaData.hasDrillDown) {
4219
- if (tempScale.bandwidth() + leftAndRightSpaces * 2 > 180) {
4220
- return (x(d.name) + tempScale(d.key) + tempScale.bandwidth() / 2 - 90);
4221
- }
4222
- return (x(d.name) +
4223
- tempScale(d.key) -
4224
- (tempScale.bandwidth() + leftAndRightSpaces * 2) / 2 +
4225
- tempScale.bandwidth() / 2);
4226
- }
4227
- else
4228
- return x(d.name) + tempScale(d.key) - (tempScale.bandwidth() + leftAndRightSpaces * 2) / 2 + tempScale.bandwidth() / 2;
4229
- })
4230
- .attr('class', 'lib-verticalstack-title-ontop')
4231
- .attr('y', function () {
4232
- return y(d.value) - 3 - 40;
4233
- })
4234
- .attr('dy', function () {
4235
- return d.class;
4236
- })
4237
- .attr('width', function () {
4238
- // var tempScale;
4239
- data.map((indiv) => {
4240
- if (indiv.name == d.name) {
4241
- let keys = Object.keys(indiv).filter((temp, i) => i != 0);
4242
- tempScale = d3.scaleBand().domain(keys).range([0, x.bandwidth()]);
4243
- if (x.bandwidth() > 100) {
4244
- if (self.chartData.data.length == 1) {
4245
- if (Object.keys(self.chartData.data[0]).length == 2) {
4246
- tempScale.range([
4247
- 0 + (x.bandwidth() - 200) / 2,
4248
- x.bandwidth() - (x.bandwidth() - 200) / 2,
4249
- ]);
4250
- // .padding(0.05);
4251
- }
4252
- else
4253
- tempScale.range([
4254
- 0 + (x.bandwidth() - 300) / 2,
4255
- x.bandwidth() - (x.bandwidth() - 300) / 2,
4256
- ]);
4257
- // .padding(0.05);
4258
- }
4259
- else
4260
- tempScale.range([
4261
- 0 + (x.bandwidth() - 125) / 2,
4262
- x.bandwidth() - (x.bandwidth() - 125) / 2,
4263
- ]);
4264
- }
4265
- }
4266
- });
4267
- if (metaData.hasDrillDown) {
4268
- if (tempScale.bandwidth() + leftAndRightSpaces * 2 > 180) {
4269
- return '180px';
4270
- }
4271
- return tempScale.bandwidth() + leftAndRightSpaces * 2;
4272
- }
4273
- else
4274
- return tempScale.bandwidth() + leftAndRightSpaces * 2;
4275
- })
4276
- .attr('height', 40)
4277
- .append('xhtml:div')
4278
- .attr('class', 'title')
4279
- .style('z-index', 99)
4280
- .html(function () {
4281
- let dataType = metaData.dataType ? metaData.dataType : '';
4282
- if (!self.isZoomedOut) {
4283
- let desiredText = '<span class="title-bar-name">' + d.name + '</span>';
4284
- desiredText +=
4285
- '<span class="title-bar-value"><span>' +
4286
- d.value +
4287
- '</span>' +
4288
- dataType +
4289
- '</span>';
4290
- return desiredText;
4291
- }
4292
- else {
4293
- let tempKey = d.name.length <= 8 ? d.name : d.name.substring(0, 5) + '...';
4294
- let desiredText = '<span class="title-bar-name">' +
4295
- tempKey +
4296
- ':' +
4297
- d.value +
4298
- dataType +
4299
- '</span>';
4300
- desiredText +=
4301
- '<span class="title-bar-value">' + d.name + '</span>';
4302
- return desiredText;
3998
+ return 'translate(0,0)';
3999
+ }
4000
+ handleMouseOver(svg, d, data, metaData, x, y, leftAndRightSpaces) {
4001
+ svg.selectAll('.lib-verticalstack-title-ontop').remove();
4002
+ let tempScale;
4003
+ data.forEach((indiv) => {
4004
+ if (indiv.name === d.name) {
4005
+ const keys = Object.keys(indiv).filter((temp, i) => i !== 0);
4006
+ tempScale = d3.scaleBand().domain(keys).range([0, x.bandwidth()]);
4007
+ if (x.bandwidth() > 100) {
4008
+ tempScale = this.adjustDrilldownScale(tempScale, data, x);
4303
4009
  }
4304
- });
4010
+ }
4011
+ });
4012
+ const foreignObject = svg
4013
+ .append('foreignObject')
4014
+ .attr('x', () => this.calculateTooltipX(d, x, tempScale, metaData, leftAndRightSpaces))
4015
+ .attr('y', () => y(d.value) - 43)
4016
+ .attr('class', 'lib-verticalstack-title-ontop')
4017
+ .attr('width', () => this.calculateTooltipWidth(tempScale, metaData, leftAndRightSpaces))
4018
+ .attr('height', 40);
4019
+ foreignObject
4020
+ .append('xhtml:div')
4021
+ .attr('class', 'title')
4022
+ .style('z-index', 99)
4023
+ .html(() => this.getTooltipHTML(d, metaData));
4024
+ }
4025
+ calculateTooltipX(d, x, tempScale, metaData, leftAndRightSpaces) {
4026
+ if (metaData.hasDrillDown) {
4027
+ if (tempScale.bandwidth() + leftAndRightSpaces * 2 > 180) {
4028
+ return x(d.name) + tempScale(d.key) + tempScale.bandwidth() / 2 - 90;
4029
+ }
4030
+ return (x(d.name) +
4031
+ tempScale(d.key) -
4032
+ (tempScale.bandwidth() + leftAndRightSpaces * 2) / 2 +
4033
+ tempScale.bandwidth() / 2);
4305
4034
  }
4306
- function handleMouseOut(d, i) {
4307
- svg.selectAll('.lib-verticalstack-title-ontop').remove();
4035
+ return (x(d.name) +
4036
+ tempScale(d.key) -
4037
+ (tempScale.bandwidth() + leftAndRightSpaces * 2) / 2 +
4038
+ tempScale.bandwidth() / 2);
4039
+ }
4040
+ calculateTooltipWidth(tempScale, metaData, leftAndRightSpaces) {
4041
+ if (metaData.hasDrillDown) {
4042
+ if (tempScale.bandwidth() + leftAndRightSpaces * 2 > 180) {
4043
+ return '180px';
4044
+ }
4045
+ return tempScale.bandwidth() + leftAndRightSpaces * 2;
4308
4046
  }
4309
- svg
4310
- .append('g')
4311
- .attr('class', 'x2 axis2')
4312
- .attr('transform', 'translate(0,' + height + ')')
4313
- .style('color', '#000')
4314
- .call(d3.axisBottom(xScaleFromOrigin).tickSize(0))
4315
- .call((g) => g.select('.domain').attr('fill', 'none'));
4316
- svg.selectAll('g.x2.axis2 g.tick text').style('display', 'none');
4317
- svg
4318
- .append('g')
4319
- .attr('class', 'lib-stacked-y-axis-text yaxis-dashed')
4320
- .attr('style', self.chartConfiguration.yAxisCustomTextStyles)
4321
- .attr('transform', 'translate(0,0)')
4322
- .call(y)
4323
- .style('display', 'none');
4324
- svgYAxisLeft
4325
- .append('g')
4326
- .append('g')
4327
- .attr('class', 'lib-yaxis-labels-texts-drilldown yaxis-dashed')
4328
- .attr('style', self.chartConfiguration.yAxisCustomTextStyles)
4329
- .attr('transform', 'translate(0,0)')
4330
- .call(d3
4331
- .axisLeft(y)
4332
- .tickSize(0)
4333
- .ticks(self.chartConfiguration.numberOfYTicks)
4334
- .tickFormat(self.chartConfiguration.yAxisLabelFomatter))
4335
- .selectAll('text')
4336
- .style('fill', 'var(--chart-text-color)');
4337
- svgYAxisRight
4338
- .append('g')
4339
- .attr('class', 'lib-yaxis-labels-texts-drilldown yaxis-dashed')
4340
- .attr('style', self.chartConfiguration.yAxisCustomTextStyles)
4341
- .attr('transform', 'translate(0,0)')
4342
- .call(y)
4343
- .style('display', 'none');
4344
- /**
4345
- * hide x axis labels
4346
- * config is there for future use
4347
- * used by weekly charts
4348
- */
4349
- if (this.chartConfiguration.isXaxisLabelHidden != undefined &&
4350
- this.chartConfiguration.isXaxisLabelHidden) {
4351
- d3.selectAll('g.lib-line-x-axis-text > g > text').attr('class', 'lib-display-hidden');
4047
+ return tempScale.bandwidth() + leftAndRightSpaces * 2;
4048
+ }
4049
+ getTooltipHTML(d, metaData) {
4050
+ const dataType = metaData.dataType || '';
4051
+ if (!this.isZoomedOut) {
4052
+ return `<span class="title-bar-name">${d.name}</span><span class="title-bar-value"><span>${d.value}</span>${dataType}</span>`;
4352
4053
  }
4353
- /**
4354
- * hide y axis labels
4355
- * used by weekly charts
4356
- */
4357
- if (this.chartConfiguration.isYaxisLabelHidden != undefined &&
4358
- this.chartConfiguration.isYaxisLabelHidden) {
4359
- d3.selectAll('.yaxis-dashed > g > text').attr('class', 'lib-display-hidden');
4054
+ else {
4055
+ const tempKey = d.name.length <= 8 ? d.name : d.name.substring(0, 5) + '...';
4056
+ return `<span class="title-bar-name">${tempKey}:${d.value}${dataType}</span><span class="title-bar-value">${d.name}</span>`;
4360
4057
  }
4361
- /**
4362
- * hide y axis labels
4363
- * config is there for future use
4364
- */
4365
- if (this.chartConfiguration.isYaxisHidden != undefined &&
4366
- this.chartConfiguration.isYaxisHidden) {
4367
- d3.selectAll('.yaxis-dashed').attr('class', 'lib-display-hidden');
4058
+ }
4059
+ handleMouseOut(svg) {
4060
+ svg.selectAll('.lib-verticalstack-title-ontop').remove();
4061
+ }
4062
+ renderLabels(svgElements, scales, chartContext, dimensions) {
4063
+ const { svg, svgYAxisLeft, svgYAxisRight } = svgElements;
4064
+ const { metaData } = chartContext;
4065
+ const { width, height, margin } = dimensions;
4066
+ if (metaData.yLabel) {
4067
+ this.renderYAxisLabel(svgYAxisLeft, metaData.yLabel, height, margin);
4368
4068
  }
4369
- /**
4370
- * dashed y axis
4371
- * used by weekly charts
4372
- */
4373
- if (this.chartConfiguration.isYaxisDashed != undefined &&
4374
- this.chartConfiguration.isYaxisDashed) {
4375
- d3.selectAll('.yaxis-dashed')
4376
- .style('stroke-dasharray', '5 5')
4377
- .style('color', '#999999');
4069
+ if (metaData.xLabel) {
4070
+ this.renderXAxisLabel(svg, metaData.xLabel, width, height, margin);
4378
4071
  }
4379
- if (lineData != null) {
4380
- if (lineData && self.chartConfiguration.showLineChartAxis) {
4381
- svgYAxisRight
4382
- .append('g')
4383
- .attr('class', 'lib-stacked-y-axis-text1')
4384
- .attr('style', self.chartConfiguration.yAxisCustomTextStyles)
4385
- .attr('transform', 'translate(' + 0 + ',0)')
4386
- .call(yLineAxis);
4387
- }
4072
+ if (metaData.lineyLabel) {
4073
+ this.renderLineYAxisLabel(svgYAxisRight, metaData.lineyLabel);
4388
4074
  }
4389
- /**
4390
- * used to display y label
4391
- */
4392
- if (this.isZoomedOut) {
4393
- svg
4394
- .selectAll('.lib-xaxis-labels-texts-drilldown')
4395
- .attr('class', 'lib-display-hidden');
4075
+ }
4076
+ renderYAxisLabel(svgYAxisLeft, yLabel, height, margin) {
4077
+ svgYAxisLeft
4078
+ .append('text')
4079
+ .attr('class', 'lib-axis-group-label font-size-1')
4080
+ .attr('style', this.chartConfiguration.yAxisCustomlabelStyles)
4081
+ .attr('transform', 'rotate(-90)')
4082
+ .attr('y', 0 - margin.left / 2 - 30)
4083
+ .attr('x', 0 - height / 2)
4084
+ .attr('dy', '1em')
4085
+ .style('text-anchor', 'middle')
4086
+ .attr('fill', 'var(--chart-text-color)');
4087
+ if (this.chartConfiguration.isMultiChartGridLine === undefined) {
4088
+ svgYAxisLeft.selectAll('.lib-axis-group-label').style('font-size', 'smaller').text(yLabel);
4396
4089
  }
4397
- /**
4398
- * used to write y labels based on configuration
4399
- */
4400
- if (metaData.yLabel) {
4090
+ else {
4401
4091
  svgYAxisLeft
4402
- .append('text')
4403
- .attr('class', 'lib-axis-group-label font-size-1')
4404
- .attr('style', self.chartConfiguration.yAxisCustomlabelStyles)
4405
- .attr('transform', 'rotate(-90)')
4406
- .attr('y', 0 - margin.left / 2 - 30)
4407
- .attr('x', 0 - height / 2)
4408
- .attr('dy', '1em')
4409
- .style('text-anchor', 'middle')
4410
- .attr('fill', 'var(--chart-text-color)');
4411
- if (this.chartConfiguration.isMultiChartGridLine == undefined) {
4412
- svgYAxisLeft
4413
- .selectAll('.lib-axis-group-label')
4414
- .style('font-size', 'smaller')
4415
- .text(metaData.yLabel);
4416
- }
4417
- else {
4418
- /**
4419
- * used by weekly charts
4420
- */
4421
- svg
4422
- .selectAll('.lib-axis-group-label')
4423
- .attr('class', 'lib-ylabel-weeklyCharts')
4424
- .text(metaData.yLabel.toLowerCase());
4425
- }
4426
- }
4427
- if (metaData.xLabel) {
4428
- function isAcronym(label) {
4429
- return ((label.length <= 4 && /^[A-Z]+$/.test(label)) ||
4430
- (label === label.toUpperCase() && /[A-Z]/.test(label)));
4431
- }
4432
- const xLabelText = metaData.xLabel;
4433
- const isAcr = isAcronym(xLabelText.replace(/[^A-Za-z]/g, ''));
4434
- svg
4435
- .append('text')
4436
- .attr('class', function () {
4437
- let baseClass = 'lib-axis-group-label font-size-1';
4438
- if (self.chartConfiguration.isDrilldownChart)
4439
- return baseClass + ' lib-xlabel-drilldowncharts';
4440
- if (self.chartConfiguration.isMultiChartGridLine != undefined)
4441
- return baseClass + ' lib-xlabel-weeklyCharts';
4442
- return baseClass + ' lib-axis-waterfall-label';
4443
- })
4444
- .attr('style', self.chartConfiguration.xAxisCustomlabelStyles)
4445
- .attr('transform', 'translate(' + width / 2 + ' ,' + (height + margin.top + 20) + ')')
4446
- .style('text-anchor', 'middle')
4447
- .style('fill', 'var(--chart-text-color)')
4448
- .text(isAcr ? xLabelText.toUpperCase() : xLabelText.toLowerCase())
4449
- .style('text-transform', isAcr ? 'none' : 'capitalize');
4450
- }
4451
- if (this.chartData.targetLineData) {
4452
- const yZero = y(this.chartData.targetLineData.target);
4453
- svg
4454
- .append('line')
4455
- .attr('x1', 0)
4456
- .attr('x2', width)
4457
- .attr('y1', yZero)
4458
- .attr('y2', yZero)
4459
- .style('stroke-dasharray', '5 5')
4460
- .style('stroke', this.chartData.targetLineData.color);
4461
- // svgYAxisRight
4462
- // .append('line')
4463
- // .attr('x1', 0)
4464
- // .attr('x2', rightSvgWidth)
4465
- // .attr('y1', yZero)
4466
- // .attr('y2', yZero)
4467
- // .style('stroke', this.chartData.targetLineData.color);
4468
- svgYAxisRight
4469
- .append('foreignObject')
4470
- .attr('transform', 'translate(' + 0 + ',' + (yZero - 30) + ')')
4471
- .attr('width', rightSvgWidth)
4472
- .attr('height', 50)
4473
- .append('xhtml:div')
4474
- .attr('class', 'target-display')
4475
- .style('color', 'var(--chart-text-color)')
4476
- .html(function () {
4477
- let dataTypeTemp = '';
4478
- let targetLineName = 'target';
4479
- if (metaData.dataType) {
4480
- dataTypeTemp = metaData.dataType;
4481
- }
4482
- if (self.chartData.targetLineData &&
4483
- self.chartData.targetLineData.targetName) {
4484
- targetLineName = self.chartData.targetLineData.targetName;
4485
- }
4486
- return (`<div>${targetLineName}</div>` +
4487
- '<div>' +
4488
- self.chartData.targetLineData.target +
4489
- '' +
4490
- dataTypeTemp +
4491
- '</div>');
4492
- });
4092
+ .selectAll('.lib-axis-group-label')
4093
+ .attr('class', 'lib-ylabel-weeklyCharts')
4094
+ .text(yLabel.toLowerCase());
4493
4095
  }
4096
+ }
4097
+ renderXAxisLabel(svg, xLabel, width, height, margin) {
4098
+ const isAcronym = this.isAcronym(xLabel.replace(/[^A-Za-z]/g, ''));
4099
+ let baseClass = 'lib-axis-group-label font-size-1';
4494
4100
  if (this.chartConfiguration.isDrilldownChart) {
4495
- /**
4496
- * used by drilldown charts
4497
- */
4498
- // svg
4499
- // .selectAll('.lib-axis-group-label')
4500
- // .attr('class', 'lib-ylabel-drilldowncharts')
4501
- // .text(metaData.yLabel.toLowerCase());
4502
- svg.selectAll('g.x1.axis1 g.tick line').style('display', 'none');
4101
+ baseClass += ' lib-xlabel-drilldowncharts';
4503
4102
  }
4504
- if (metaData.lineyLabel) {
4505
- svgYAxisRight
4506
- .append('text')
4507
- .attr('class', 'lib-axis-group-label lib-line-axis')
4508
- .attr('style', self.chartConfiguration.yAxisCustomlabelStyles)
4509
- .attr('transform', 'translate(0,0) rotate(90)')
4510
- .attr('y', 0 - 100)
4511
- .attr('x', 0 + 100)
4512
- .attr('dy', '5em')
4513
- .style('text-anchor', 'middle')
4514
- .style('font-size', 'smaller')
4515
- .text(metaData.lineyLabel);
4103
+ else if (this.chartConfiguration.isMultiChartGridLine !== undefined) {
4104
+ baseClass += ' lib-xlabel-weeklyCharts';
4516
4105
  }
4517
- if (lineData) {
4518
- svg
4519
- .append('path')
4520
- .datum(lineData)
4521
- .attr('fill', 'none')
4522
- .attr('stroke', self.chartConfiguration.lineGraphColor)
4523
- .attr('stroke-width', 1.5)
4524
- .attr('d', d3
4525
- .line()
4526
- .x(function (d) {
4527
- return x(d.name) + x.bandwidth() / 2;
4528
- })
4529
- .y(function (d) {
4530
- return lineYscale(d.value);
4531
- }));
4532
- var dot = svg
4533
- .selectAll('myCircles')
4534
- .data(lineData)
4535
- .enter()
4536
- .append('g')
4537
- .on('click', function (d) {
4538
- if (!metaData.barWithoutClick ||
4539
- !metaData.barWithoutClick.length ||
4540
- (!metaData.barWithoutClick.includes(d?.name) &&
4541
- !metaData.barWithoutClick.includes(d?.key)))
4542
- self.handleClick(d);
4543
- });
4106
+ else {
4107
+ baseClass += ' lib-axis-waterfall-label';
4108
+ }
4109
+ svg
4110
+ .append('text')
4111
+ .attr('class', baseClass)
4112
+ .attr('style', this.chartConfiguration.xAxisCustomlabelStyles)
4113
+ .attr('transform', `translate(${width / 2},${height + margin.top + 20})`)
4114
+ .style('text-anchor', 'middle')
4115
+ .style('fill', 'var(--chart-text-color)')
4116
+ .text(isAcronym ? xLabel.toUpperCase() : xLabel.toLowerCase())
4117
+ .style('text-transform', isAcronym ? 'none' : 'capitalize');
4118
+ }
4119
+ isAcronym(label) {
4120
+ return ((label.length <= 4 && /^[A-Z]+$/.test(label)) ||
4121
+ (label === label.toUpperCase() && /[A-Z]/.test(label)));
4122
+ }
4123
+ renderLineYAxisLabel(svgYAxisRight, lineyLabel) {
4124
+ svgYAxisRight
4125
+ .append('text')
4126
+ .attr('class', 'lib-axis-group-label lib-line-axis')
4127
+ .attr('style', this.chartConfiguration.yAxisCustomlabelStyles)
4128
+ .attr('transform', 'translate(0,0) rotate(90)')
4129
+ .attr('y', -100)
4130
+ .attr('x', 100)
4131
+ .attr('dy', '5em')
4132
+ .style('text-anchor', 'middle')
4133
+ .style('font-size', 'smaller')
4134
+ .text(lineyLabel);
4135
+ }
4136
+ renderTargetLine(svgElements, scales, chartContext, dimensions) {
4137
+ if (!this.chartData.targetLineData)
4138
+ return;
4139
+ const { svg, svgYAxisRight } = svgElements;
4140
+ const { y } = scales;
4141
+ const { width } = dimensions;
4142
+ const { metaData } = chartContext;
4143
+ const targetData = this.chartData.targetLineData;
4144
+ const yZero = y(targetData.target);
4145
+ svg
4146
+ .append('line')
4147
+ .attr('x1', 0)
4148
+ .attr('x2', width)
4149
+ .attr('y1', yZero)
4150
+ .attr('y2', yZero)
4151
+ .style('stroke-dasharray', '5 5')
4152
+ .style('stroke', targetData.color);
4153
+ const rightSvgWidth = 60;
4154
+ svgYAxisRight
4155
+ .append('foreignObject')
4156
+ .attr('transform', `translate(0,${yZero - 30})`)
4157
+ .attr('width', rightSvgWidth)
4158
+ .attr('height', 50)
4159
+ .append('xhtml:div')
4160
+ .attr('class', 'target-display')
4161
+ .style('color', 'var(--chart-text-color)')
4162
+ .html(() => {
4163
+ const dataType = metaData.dataType || '';
4164
+ const targetName = targetData.targetName || 'target';
4165
+ return `<div>${targetName}</div><div>${targetData.target}${dataType}</div>`;
4166
+ });
4167
+ }
4168
+ renderLineGraph(svg, chartContext, scales) {
4169
+ const { lineData, metaData } = chartContext;
4170
+ if (!lineData)
4171
+ return;
4172
+ const { x, lineYscale } = scales;
4173
+ svg
4174
+ .append('path')
4175
+ .datum(lineData)
4176
+ .attr('fill', 'none')
4177
+ .attr('stroke', this.chartConfiguration.lineGraphColor)
4178
+ .attr('stroke-width', 1.5)
4179
+ .attr('d', d3
4180
+ .line()
4181
+ .x((d) => x(d.name) + x.bandwidth() / 2)
4182
+ .y((d) => lineYscale(d.value)));
4183
+ const dot = svg
4184
+ .selectAll('myCircles')
4185
+ .data(lineData)
4186
+ .enter()
4187
+ .append('g')
4188
+ .on('click', (d) => this.handleBarClick(d, metaData));
4189
+ dot
4190
+ .append('circle')
4191
+ .attr('fill', this.chartConfiguration.lineGraphColor)
4192
+ .attr('stroke', 'none')
4193
+ .attr('cx', (d) => x(d.name) + x.bandwidth() / 2)
4194
+ .attr('cy', (d) => lineYscale(d.value))
4195
+ .style('cursor', 'pointer')
4196
+ .attr('r', 3);
4197
+ if (this.chartConfiguration.lineGraphColor) {
4544
4198
  dot
4545
- .append('circle')
4546
- .attr('fill', function (d) {
4547
- return self.chartConfiguration.lineGraphColor;
4548
- })
4549
- .attr('stroke', 'none')
4550
- .attr('cx', function (d) {
4551
- return x(d.name) + x.bandwidth() / 2;
4552
- })
4553
- .attr('cy', function (d) {
4554
- return lineYscale(d.value);
4555
- })
4556
- .style('cursor', 'pointer')
4557
- .attr('r', 3);
4558
- if (self.chartConfiguration.lineGraphColor) {
4559
- dot
4560
- .append('text')
4561
- .attr('class', 'dot')
4562
- .attr('color', self.chartConfiguration.lineGraphColor)
4563
- .attr('style', 'font-size: ' + '.85em')
4564
- .attr('x', function (d, i) {
4565
- return x(d.name) + x.bandwidth() / 2;
4566
- })
4567
- .attr('y', function (d) {
4568
- return lineYscale(d.value);
4569
- })
4570
- .attr('dy', '-1em')
4571
- .text(function (d) {
4572
- return self.chartConfiguration.labelFormatter(d.value);
4573
- });
4574
- }
4199
+ .append('text')
4200
+ .attr('class', 'dot')
4201
+ .attr('color', this.chartConfiguration.lineGraphColor)
4202
+ .attr('style', 'font-size: .85em')
4203
+ .attr('x', (d) => x(d.name) + x.bandwidth() / 2)
4204
+ .attr('y', (d) => lineYscale(d.value))
4205
+ .attr('dy', '-1em')
4206
+ .text((d) => this.chartConfiguration.labelFormatter(d.value));
4575
4207
  }
4576
4208
  }
4577
4209
  handleClick(d) {
4578
- if (this.chartData.metaData.hasDrillDown || d?.toggleFrom)
4210
+ if (this.chartData.metaData.hasDrillDown || d?.toggleFrom) {
4579
4211
  this.clickEvent.emit(d);
4212
+ }
4580
4213
  }
4581
4214
  handleHeaderMenuClick(id) {
4582
4215
  this.headerMenuclickEvent.emit(id);
@@ -6825,6 +6458,21 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6825
6458
  this.isTopCaptionVisible = true;
6826
6459
  this.uniqueId = this.getUniqueId();
6827
6460
  this.isTransparentBackground = false;
6461
+ this.isCC = false;
6462
+ this.isZoomedOut = true;
6463
+ this.CONSTANTS = {
6464
+ RIGHT_SVG_WIDTH: 60,
6465
+ LEFT_RIGHT_SPACES: 50,
6466
+ SHORT_TICK_LENGTH: 4,
6467
+ LONG_TICK_LENGTH: 16,
6468
+ SHORT_TICK_LENGTH_BG: 5,
6469
+ LONG_TICK_LENGTH_BG: 30,
6470
+ MIN_MOBILE_BAR_WIDTH: 32,
6471
+ DESKTOP_MIN_BAR_WIDTH: 40,
6472
+ MOBILE_BAR_PADDING: 12,
6473
+ ZOOM_THRESHOLD: 30,
6474
+ ZOOM_IN_THRESHOLD: 8,
6475
+ };
6828
6476
  this.defaultConfiguration = {
6829
6477
  margin: { top: 20, right: 20, bottom: 20, left: 40 },
6830
6478
  svgHeight: 70,
@@ -6840,6 +6488,7 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6840
6488
  forComparison: true,
6841
6489
  headerMenuOptions: HeaderConfigHelper.headerConfig.headerMenuOptions,
6842
6490
  yAxisGrid: false,
6491
+ // Optional configs with undefined defaults
6843
6492
  isHeaderVisible: undefined,
6844
6493
  isTransparentBackground: undefined,
6845
6494
  isTopCaptionVisible: undefined,
@@ -6867,56 +6516,40 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6867
6516
  isToggleVisible: undefined,
6868
6517
  isTitleHidden: undefined,
6869
6518
  };
6870
- this.isCC = false;
6871
- this.isZoomedOut = true;
6872
- }
6873
- isZoomOutSelected(isZoomOut) {
6874
- this.isZoomedOut = isZoomOut;
6875
- this.ngOnChanges();
6876
6519
  }
6520
+ ngOnInit() { }
6877
6521
  ngOnChanges() {
6878
- let self = this;
6879
- d3.select('#' + self.uniqueId).remove();
6522
+ this.removeExistingChart();
6880
6523
  this.initializeStackedChart();
6881
6524
  }
6882
6525
  onResized(event) {
6883
- let self = this;
6884
- setTimeout(function () {
6885
- d3.select('#' + self.uniqueId).remove();
6886
- self.initializeStackedChart();
6887
- }.bind(self), 10);
6526
+ setTimeout(() => {
6527
+ this.removeExistingChart();
6528
+ this.initializeStackedChart();
6529
+ }, 10);
6888
6530
  }
6889
- ngOnInit() { }
6890
- initializeStackedChart() {
6891
- var self = this;
6892
- let data = [];
6893
- let metaData = null;
6894
- let keyList = null;
6895
- let lineData = null;
6896
- let colors = null;
6897
- var alternate_text = false;
6898
- var alternate_label = false;
6899
- var short_tick_length = 4;
6900
- var long_tick_length = 16;
6901
- var short_tick_length_bg = 5;
6902
- var long_tick_length_bg = 30;
6903
- var formatFromBackend;
6904
- var formatForHugeNumbers;
6905
- var tempObjectHolder = {};
6906
- var rightSvgWidth = 60;
6907
- var leftAndRightSpaces = 50;
6908
- let isria = this.customChartConfiguration.isRia;
6909
- // Responsive breakpoints
6910
- const isMobile = window.innerWidth < 576;
6911
- const isTablet = window.innerWidth >= 576 && window.innerWidth < 992;
6912
- const isDesktop = window.innerWidth >= 992;
6913
- // Adjust margins and font sizes based on device
6914
- if (isMobile) {
6531
+ isZoomOutSelected(isZoomOut) {
6532
+ this.isZoomedOut = isZoomOut;
6533
+ this.ngOnChanges();
6534
+ }
6535
+ removeExistingChart() {
6536
+ d3.select('#' + this.uniqueId).remove();
6537
+ }
6538
+ getDeviceConfig() {
6539
+ const width = window.innerWidth;
6540
+ return {
6541
+ isMobile: width < 576,
6542
+ isTablet: width >= 576 && width < 992,
6543
+ isDesktop: width >= 992,
6544
+ };
6545
+ }
6546
+ configureResponsiveSettings(device) {
6547
+ if (device.isMobile) {
6915
6548
  this.chartConfiguration.margin = { top: 20, right: 10, bottom: 40, left: 30 };
6916
6549
  this.chartConfiguration.numberOfYTicks = 4;
6917
6550
  this.chartConfiguration.svgHeight = 60;
6918
6551
  }
6919
- else if (isTablet) {
6552
+ else if (device.isTablet) {
6920
6553
  this.chartConfiguration.margin = { top: 25, right: 20, bottom: 45, left: 40 };
6921
6554
  this.chartConfiguration.numberOfYTicks = 6;
6922
6555
  this.chartConfiguration.svgHeight = 70;
@@ -6926,922 +6559,605 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
6926
6559
  this.chartConfiguration.numberOfYTicks = 7;
6927
6560
  this.chartConfiguration.svgHeight = 80;
6928
6561
  }
6929
- for (var i in this.defaultConfiguration) {
6930
- this.chartConfiguration[i] = ChartHelper.getValueByConfigurationType(i, this.defaultConfiguration, this.customChartConfiguration);
6562
+ }
6563
+ mergeConfigurations() {
6564
+ for (const key in this.defaultConfiguration) {
6565
+ this.chartConfiguration[key] = ChartHelper.getValueByConfigurationType(key, this.defaultConfiguration, this.customChartConfiguration);
6931
6566
  }
6932
- data = this.chartData.data;
6933
- metaData = this.chartData.metaData;
6934
- if (metaData.unit == undefined)
6567
+ }
6568
+ prepareMetaData(metaData) {
6569
+ if (!metaData.unit)
6935
6570
  metaData.unit = '';
6936
- if (metaData.isCC) {
6571
+ if (metaData.isCC)
6937
6572
  this.isCC = metaData.isCC;
6938
- }
6939
- if (metaData.barWithoutClick && metaData.barWithoutClick.length) {
6940
- metaData.barWithoutClick = metaData.barWithoutClick.map((ele) => ele.toLowerCase());
6573
+ if (metaData.barWithoutClick?.length) {
6574
+ metaData.barWithoutClick = metaData.barWithoutClick.map(el => el.toLowerCase());
6941
6575
  }
6942
6576
  else {
6943
6577
  metaData.barWithoutClick = [];
6944
6578
  }
6945
- lineData = this.chartData.lineData;
6946
- colors = metaData.colors;
6947
- keyList = metaData.keyList;
6948
- var chartContainer = d3.select(this.containerElt.nativeElement);
6949
- var verticalstackedcontainer = d3.select(this.verticalstackedcontainerElt.nativeElement);
6950
- let parsedNum = parseFloat(this.chartData?.targetLineData?.target);
6951
- if (!isNaN(parsedNum)) {
6952
- if (Number.isInteger(parsedNum)) {
6953
- parsedNum = parseInt(this.chartData.targetLineData.target);
6954
- }
6955
- else {
6956
- parsedNum = parseFloat(this.chartData.targetLineData.target);
6957
- }
6579
+ return metaData;
6580
+ }
6581
+ calculateDimensions(chartContainer, verticalContainer, margin, device, dataLength) {
6582
+ const containerWidth = chartContainer.node().getBoundingClientRect().width;
6583
+ const containerHeight = verticalContainer.node().getBoundingClientRect().height;
6584
+ let width = containerWidth - margin.left - margin.right;
6585
+ let height = containerHeight * (this.chartConfiguration.svgHeight / 100) - margin.top - margin.bottom;
6586
+ if (dataLength > this.CONSTANTS.ZOOM_THRESHOLD && this.isZoomedOut) {
6587
+ const minWidth = dataLength * (device.isMobile ? 15 : 25);
6588
+ width = Math.max(width, minWidth);
6958
6589
  }
6959
- var margin = this.chartConfiguration.margin;
6960
- // Responsive width and height
6961
- var containerWidth = chartContainer.node().getBoundingClientRect().width;
6962
- var containerHeight = verticalstackedcontainer.node().getBoundingClientRect().height;
6963
- var width = containerWidth - margin.left - margin.right;
6964
- var height = containerHeight * (self.chartConfiguration.svgHeight / 100) - margin.top - margin.bottom;
6965
- // Adjust width for large datasets and zoom
6966
- if (this.chartData.data.length > 30 && this.isZoomedOut) {
6967
- width = width > this.chartData.data.length * (isMobile ? 15 : 25)
6968
- ? width
6969
- : this.chartData.data.length * (isMobile ? 15 : 25);
6970
- }
6971
- if (this.chartData.data.length > 8 && !this.isZoomedOut) {
6972
- width = this.chartData.data.length * (isMobile ? 60 : 130);
6973
- }
6974
- // Fullscreen and drilldown adjustments
6975
- if (this.chartConfiguration.isFullScreen != undefined && this.chartConfiguration.isFullScreen) {
6976
- height = this.chartConfiguration.svgHeight != 80
6590
+ if (dataLength > this.CONSTANTS.ZOOM_IN_THRESHOLD && !this.isZoomedOut) {
6591
+ width = dataLength * (device.isMobile ? 60 : 130);
6592
+ }
6593
+ if (this.chartConfiguration.isFullScreen) {
6594
+ height = this.chartConfiguration.svgHeight !== 80
6977
6595
  ? this.chartConfiguration.svgHeight
6978
6596
  : containerHeight;
6979
6597
  }
6980
6598
  if (this.chartConfiguration.isDrilldownChart) {
6981
- height = containerHeight - margin.top - margin.bottom - (isMobile ? 60 : 130);
6982
- }
6983
- // ...existing code...
6984
- /**
6985
- * for hiding header
6986
- * used by weekly charts
6987
- */
6988
- if (this.chartConfiguration.isHeaderVisible != undefined) {
6989
- this.isHeaderVisible = this.chartConfiguration.isHeaderVisible;
6990
- }
6991
- /**
6992
- * for hiding legends
6993
- * used by weekly charts
6994
- */
6995
- if (this.chartConfiguration.isTopCaptionVisible != undefined) {
6996
- //UPDATENAME
6997
- this.isTopCaptionVisible = this.chartConfiguration.isTopCaptionVisible;
6998
- }
6999
- /**
7000
- * for removing background color so that it can take parents color
7001
- *
7002
- */
7003
- if (this.chartConfiguration.isTransparentBackground != undefined) {
7004
- this.isTransparentBackground =
7005
- this.chartConfiguration.isTransparentBackground;
6599
+ height = containerHeight - margin.top - margin.bottom - (device.isMobile ? 60 : 130);
7006
6600
  }
7007
- /**
7008
- * format data values based on configuration received
7009
- */
7010
- if (this.chartConfiguration.textFormatter != undefined) {
7011
- formatFromBackend = ChartHelper.dataValueFormatter(this.chartConfiguration.textFormatter);
7012
- formatForHugeNumbers = ChartHelper.dataValueFormatter('.2s');
6601
+ let barWidth;
6602
+ let barPadding;
6603
+ let requiredSvgWidth;
6604
+ if (device.isMobile) {
6605
+ barWidth = this.CONSTANTS.MIN_MOBILE_BAR_WIDTH;
6606
+ barPadding = this.CONSTANTS.MOBILE_BAR_PADDING;
6607
+ requiredSvgWidth = Math.max(width - this.CONSTANTS.RIGHT_SVG_WIDTH, (barWidth + barPadding) * dataLength + this.CONSTANTS.LEFT_RIGHT_SPACES * 2 +
6608
+ this.CONSTANTS.RIGHT_SVG_WIDTH - barPadding);
7013
6609
  }
7014
- var outerContainer = chartContainer
6610
+ else {
6611
+ barWidth = Math.max(this.CONSTANTS.DESKTOP_MIN_BAR_WIDTH, (width - this.CONSTANTS.RIGHT_SVG_WIDTH - this.CONSTANTS.LEFT_RIGHT_SPACES * 2) / dataLength);
6612
+ barPadding = 0;
6613
+ requiredSvgWidth = width - this.CONSTANTS.RIGHT_SVG_WIDTH;
6614
+ }
6615
+ return {
6616
+ width,
6617
+ height,
6618
+ containerWidth,
6619
+ containerHeight,
6620
+ barWidth,
6621
+ barPadding,
6622
+ requiredSvgWidth,
6623
+ };
6624
+ }
6625
+ createSvgContainers(chartContainer, dimensions, margin) {
6626
+ const outerContainer = chartContainer
7015
6627
  .append('div')
7016
- .attr('id', self.uniqueId)
6628
+ .attr('id', this.uniqueId)
7017
6629
  .attr('class', 'outer-container')
7018
6630
  .style('width', '100%')
7019
- .style('height', height)
6631
+ .style('height', dimensions.height)
7020
6632
  .style('overflow-x', 'hidden')
7021
6633
  .style('padding-left', `${margin.left}px`)
7022
6634
  .style('margin-left', '10px')
7023
- .style('padding-right', `${rightSvgWidth}px`);
7024
- var svgYAxisLeft = outerContainer
6635
+ .style('padding-right', `${this.CONSTANTS.RIGHT_SVG_WIDTH}px`);
6636
+ const svgYAxisLeft = outerContainer
7025
6637
  .append('svg')
7026
6638
  .attr('width', '80')
7027
- .attr('height', height + margin.top + margin.bottom)
6639
+ .attr('height', dimensions.height + margin.top + margin.bottom)
7028
6640
  .style('position', 'absolute')
7029
6641
  .style('left', '0')
7030
6642
  .style('z-index', 1)
7031
6643
  .append('g')
7032
- .attr('transform', 'translate(' + (margin.left + 10) + ',' + margin.top + ')');
7033
- var svgYAxisRight = outerContainer
6644
+ .attr('transform', `translate(${margin.left + 10},${margin.top})`);
6645
+ const svgYAxisRight = outerContainer
7034
6646
  .append('svg')
7035
- .attr('width', rightSvgWidth)
7036
- .attr('height', height + margin.top + margin.bottom)
6647
+ .attr('width', this.CONSTANTS.RIGHT_SVG_WIDTH)
6648
+ .attr('height', dimensions.height + margin.top + margin.bottom)
7037
6649
  .style('position', 'absolute')
7038
6650
  .style('right', '2px')
7039
6651
  .style('z-index', 1)
7040
6652
  .append('g')
7041
- .attr('transform', 'translate(' + 0 + ',' + margin.top + ')');
7042
- var innerContainer = outerContainer
6653
+ .attr('transform', `translate(0,${margin.top})`);
6654
+ const innerContainer = outerContainer
7043
6655
  .append('div')
7044
6656
  .attr('class', 'inner-container')
7045
6657
  .style('width', '100%')
7046
6658
  .style('overflow-x', 'auto');
7047
- // Calculate bar width and padding for mobile to avoid overlap and add space between bars
7048
- let barWidth;
7049
- let barPadding = 12; // px, space between bars on mobile
7050
- let requiredSvgWidth;
7051
- if (isMobile) {
7052
- // Use a minimum width per bar and add padding between bars
7053
- const minBarWidth = 32; // px, can adjust as needed
7054
- barWidth = minBarWidth;
7055
- requiredSvgWidth = Math.max(width - rightSvgWidth, (barWidth + barPadding) * data.length + leftAndRightSpaces * 2 + rightSvgWidth - barPadding // no padding after last bar
7056
- );
7057
- innerContainer.style('overflow-x', 'auto');
7058
- }
7059
- else {
7060
- barWidth = Math.max(40, (width - rightSvgWidth - leftAndRightSpaces * 2) / data.length);
7061
- barPadding = 0;
7062
- requiredSvgWidth = width - rightSvgWidth;
7063
- }
7064
- var svg = innerContainer
6659
+ const svg = innerContainer
7065
6660
  .append('svg')
7066
- .attr('width', requiredSvgWidth)
7067
- .attr('height', height + margin.top + margin.bottom + 30)
6661
+ .attr('width', dimensions.requiredSvgWidth)
6662
+ .attr('height', dimensions.height + margin.top + margin.bottom + 30)
7068
6663
  .append('g')
7069
- .attr('transform', 'translate(' + 0 + ',' + margin.top + ')');
7070
- let stackKey = keyList;
7071
- var stack = d3
7072
- .stack()
7073
- .keys(stackKey)
7074
- /*.order(d3.stackOrder)*/
7075
- .offset(d3.stackOffsetNone);
7076
- var layers = stack(data);
7077
- data.sort(function (a, b) {
7078
- return b.total - a.total;
7079
- });
7080
- let lineYscale;
7081
- if (lineData != null) {
7082
- lineYscale = d3
7083
- .scaleLinear()
7084
- .domain([
7085
- 0,
7086
- d3.max(lineData, function (d) {
7087
- return +d.value;
7088
- }),
7089
- ])
7090
- .range([height, 0]);
7091
- }
7092
- // Calculate bar width for mobile to avoid overlap
7093
- // ...barWidth is now calculated above, remove duplicate...
7094
- var xScale = d3
6664
+ .attr('transform', `translate(0,${margin.top})`);
6665
+ return { svg, svgYAxisLeft, svgYAxisRight, innerContainer };
6666
+ }
6667
+ createScales(data, layers, lineData, dimensions, device) {
6668
+ const { width, height, barWidth, barPadding } = dimensions;
6669
+ const xScale = d3
7095
6670
  .scaleBand()
7096
6671
  .rangeRound([
7097
- leftAndRightSpaces,
7098
- width - rightSvgWidth - leftAndRightSpaces
6672
+ this.CONSTANTS.LEFT_RIGHT_SPACES,
6673
+ width - this.CONSTANTS.RIGHT_SVG_WIDTH - this.CONSTANTS.LEFT_RIGHT_SPACES
7099
6674
  ])
7100
- .domain(data.map(function (d) {
7101
- return d.name;
7102
- }).reverse())
7103
- .padding(isMobile ? 0.2 : 0.5);
7104
- var xScaleFromOrigin = d3
6675
+ .domain(data.map(d => d.name).reverse())
6676
+ .padding(device.isMobile ? 0.2 : 0.5);
6677
+ const xScaleFromOrigin = d3
7105
6678
  .scaleBand()
7106
- .rangeRound([width - rightSvgWidth, 0])
7107
- .domain(data.map(function (d) {
7108
- return d.name;
7109
- }).reverse());
7110
- // ...existing code...
7111
- /**
7112
- * draw second x axis on top
7113
- */
7114
- if (self.chartConfiguration.showXaxisTop) {
7115
- svg
7116
- .append('g')
7117
- .attr('class', 'lib-line-axis-text lib-line-x-axis-text x-axis')
7118
- .attr('style', self.chartConfiguration.xAxisCustomTextStyles)
7119
- .call(d3.axisBottom(xScale).tickSize(0));
7120
- svg.selectAll('.x-axis > g > text').attr('class', 'lib-display-hidden');
7121
- }
7122
- /**
7123
- * draw second x axis on top
7124
- */
7125
- // if (self.chartConfiguration.showXaxisAtTarget) {
7126
- // svg
7127
- // .append('g')
7128
- // .attr('class', 'lib-line-axis-text lib-line-x-axis-text x-axis')
7129
- // .attr('style', self.chartConfiguration.xAxisCustomTextStyles)
7130
- // .call(d3.axisBottom(xScale).tickSize(0));
7131
- // svg.selectAll('.x-axis > g > text').attr('class', 'lib-display-hidden');
7132
- // }
7133
- if (this.chartConfiguration.xAxisGrid) {
7134
- for (var j = 0; j < this.chartConfiguration.xAxisGrid.length; j++) {
7135
- svg
7136
- .append('g')
7137
- .attr('class', `x${j + 2} axis${j + 2}`)
7138
- .style('color', 'var(--chart-grid-color)') // Use CSS variable instead of hardcoded
7139
- .attr('transform', 'translate(0,' + height * this.chartConfiguration.xAxisGrid[j] + ')')
7140
- .call(d3.axisBottom(xScale).tickSize(0).ticks(5).tickFormat(''))
7141
- .style('fill', 'var(--chart-text-color)');
7142
- }
7143
- }
7144
- let yScale = d3.scaleLinear().rangeRound([height, 0]);
7145
- /**
7146
- * update max vakues so that the vakue wont exceed the max limit
7147
- * used by weekly charts
7148
- */
7149
- var maxValue = d3.max(layers, (d) => d3.max(d, (d) => d[1]));
7150
- if (maxValue == 0) {
7151
- if (this.chartData.targetLineData) {
7152
- maxValue = this.chartData.targetLineData.target + 20;
7153
- }
7154
- else {
7155
- maxValue = 100;
7156
- }
6679
+ .rangeRound([width - this.CONSTANTS.RIGHT_SVG_WIDTH, 0])
6680
+ .domain(data.map(d => d.name).reverse());
6681
+ const yScale = d3.scaleLinear().rangeRound([height, 0]);
6682
+ let maxValue = d3.max(layers, (d) => d3.max(d, (d) => d[1]));
6683
+ if (maxValue === 0) {
6684
+ maxValue = this.chartData.targetLineData
6685
+ ? Number(this.chartData.targetLineData.target) + 20
6686
+ : 100;
7157
6687
  }
7158
6688
  if (this.chartConfiguration.customYscale) {
7159
- maxValue = maxValue * this.chartConfiguration.customYscale;
6689
+ maxValue *= this.chartConfiguration.customYscale;
7160
6690
  }
7161
- if (this.chartData.targetLineData &&
7162
- maxValue < this.chartData.targetLineData.target) {
7163
- maxValue =
7164
- maxValue < 10 && this.chartData.targetLineData.target < 10
7165
- ? this.chartData.targetLineData.target + 3
7166
- : this.chartData.targetLineData.target + 20;
6691
+ if (this.chartData.targetLineData && maxValue < Number(this.chartData.targetLineData.target)) {
6692
+ const target = Number(this.chartData.targetLineData.target);
6693
+ maxValue = maxValue < 10 && target < 10 ? target + 3 : target + 20;
7167
6694
  }
7168
6695
  yScale.domain([0, maxValue]).nice();
7169
- let xAxis = d3
7170
- .axisBottom(xScale)
7171
- .tickSize(0)
7172
- .tickFormat(self.chartConfiguration.xAxisLabelFomatter);
7173
- let yAxis = d3
7174
- .axisLeft(yScale)
7175
- .ticks(self.chartConfiguration.numberOfYTicks)
7176
- .tickSize(0)
7177
- .tickFormat(self.chartConfiguration.yAxisLabelFomatter);
7178
- let yLineAxis;
7179
- if (lineYscale != null) {
7180
- yLineAxis = d3
7181
- .axisRight(lineYscale)
7182
- .ticks(self.chartConfiguration.numberOfYTicks)
7183
- .tickSize(0)
7184
- .tickFormat(self.chartConfiguration.yLineAxisLabelFomatter);
7185
- }
7186
- /**
7187
- * between x-axis label used by weekly charts
7188
- * isXgridBetweenLabels will be undefined for dashboard charts
7189
- */
7190
- if (self.chartConfiguration.isXgridBetweenLabels) {
7191
- svg
7192
- .append('g')
7193
- .attr('class', 'grid')
7194
- .attr('transform', 'translate(' + xScale.bandwidth() / 2 + ',' + height + ')')
7195
- .call(d3.axisBottom(xScale).tickSize(-height).tickFormat(''))
7196
- .style('stroke-dasharray', '5 5')
7197
- .style('color', '#999999')
7198
- // .style("opacity", "0.5")
7199
- .call((g) => g.select('.domain').remove());
6696
+ let lineYscale = null;
6697
+ if (lineData) {
6698
+ lineYscale = d3
6699
+ .scaleLinear()
6700
+ .domain([0, d3.max(lineData, d => +d.value)])
6701
+ .range([height, 0]);
7200
6702
  }
7201
- /**
7202
- * used to draw y-axis grid
7203
- */
7204
- if (self.chartConfiguration.yAxisGrid) {
7205
- svg
7206
- .append('g')
7207
- .attr('class', 'grid')
7208
- .call(d3
7209
- .axisLeft(yScale)
7210
- .ticks(self.chartConfiguration.numberOfYTicks)
7211
- .tickSize(-width)
7212
- .tickFormat(''))
7213
- // Remove hardcoded colors and use CSS variables
7214
- .style('color', 'var(--chart-grid-color)')
7215
- .style('opacity', '1');
7216
- // .call((g) => g.select('.domain').remove());
6703
+ return { xScale, xScaleFromOrigin, yScale, lineYscale };
6704
+ }
6705
+ createAxes(scales) {
6706
+ const xAxis = d3
6707
+ .axisBottom(scales.xScale)
6708
+ .tickSize(0)
6709
+ .tickFormat(this.chartConfiguration.xAxisLabelFomatter);
6710
+ const yAxis = d3
6711
+ .axisLeft(scales.yScale)
6712
+ .ticks(this.chartConfiguration.numberOfYTicks)
6713
+ .tickSize(0)
6714
+ .tickFormat(this.chartConfiguration.yAxisLabelFomatter);
6715
+ let yLineAxis = null;
6716
+ if (scales.lineYscale) {
6717
+ yLineAxis = d3
6718
+ .axisRight(scales.lineYscale)
6719
+ .ticks(this.chartConfiguration.numberOfYTicks)
6720
+ .tickSize(0)
6721
+ .tickFormat(this.chartConfiguration.yLineAxisLabelFomatter);
7217
6722
  }
7218
- var layer = svg
6723
+ return { xAxis, yAxis, yLineAxis };
6724
+ }
6725
+ renderBars(svg, layers, scales, metaData, dimensions, device) {
6726
+ const layer = svg
7219
6727
  .selectAll('.layer')
7220
6728
  .data(layers)
7221
6729
  .enter()
7222
6730
  .append('g')
7223
6731
  .attr('class', 'layer')
7224
- .style('fill', function (d, i) {
7225
- return metaData.colors[d.key];
7226
- });
7227
- var rect = layer
6732
+ .style('fill', (d) => metaData.colors[d.key]);
6733
+ const rect = layer
7228
6734
  .selectAll('rect')
7229
- .data(function (d) {
7230
- return d;
7231
- })
6735
+ .data((d) => d)
7232
6736
  .enter();
6737
+ this.appendRectangles(rect, scales, metaData, dimensions, device);
6738
+ this.addInteractions(rect, svg, metaData, scales);
6739
+ return rect;
6740
+ }
6741
+ appendRectangles(rect, scales, metaData, dimensions, device) {
6742
+ const { barWidth, barPadding } = dimensions;
6743
+ const { xScale, yScale } = scales;
7233
6744
  rect
7234
6745
  .append('rect')
7235
- .on('click', function (d) {
7236
- if (!lineData || self.chartConfiguration.forComparison) {
7237
- if (!metaData.barWithoutClick ||
7238
- !metaData.barWithoutClick.length ||
7239
- !metaData.barWithoutClick.includes(d.data.name.toLowerCase()))
7240
- self.handleClick(d.data.name);
6746
+ .on('click', (d) => {
6747
+ if (!this.chartData.lineData || this.chartConfiguration.forComparison) {
6748
+ if (!metaData.barWithoutClick?.includes(d.data.name.toLowerCase())) {
6749
+ this.handleClick(d.data.name);
6750
+ }
7241
6751
  }
7242
6752
  })
7243
- .attr('y', function (d) {
6753
+ .attr('y', (d) => {
7244
6754
  if (!isNaN(d[0]) && !isNaN(d[1])) {
7245
6755
  const actualHeight = yScale(d[0]) - yScale(d[1]);
7246
6756
  return actualHeight < 3 ? yScale(d[0]) - 3 : yScale(d[1]);
7247
6757
  }
7248
6758
  return 0;
7249
6759
  })
7250
- .attr('x', function (d, i) {
7251
- if (isMobile) {
7252
- // On mobile, position bars with padding
7253
- return leftAndRightSpaces + i * (barWidth + barPadding);
6760
+ .attr('x', (d, i) => {
6761
+ if (device.isMobile) {
6762
+ return this.CONSTANTS.LEFT_RIGHT_SPACES + i * (barWidth + barPadding);
7254
6763
  }
7255
- if (self.chartConfiguration.isMultiChartGridLine == undefined) {
6764
+ if (!this.chartConfiguration.isMultiChartGridLine) {
7256
6765
  return xScale(d.data.name);
7257
6766
  }
7258
- else {
7259
- if (self.chartConfiguration.isDrilldownChart &&
7260
- self.chartData.data.length <= 3) {
7261
- return xScale(d.data.name) + xScale.bandwidth() / 2 - 35;
7262
- }
7263
- return xScale(d.data.name) + xScale.bandwidth() * 0.1;
6767
+ if (this.chartConfiguration.isDrilldownChart && this.chartData.data.length <= 3) {
6768
+ return xScale(d.data.name) + xScale.bandwidth() / 2 - 35;
7264
6769
  }
6770
+ return xScale(d.data.name) + xScale.bandwidth() * 0.1;
7265
6771
  })
7266
- .attr('height', function (d) {
6772
+ .attr('height', (d) => {
7267
6773
  if (!isNaN(d[0]) && !isNaN(d[1])) {
7268
6774
  const actualHeight = yScale(d[0]) - yScale(d[1]);
7269
6775
  return actualHeight < 3 ? 3 : actualHeight;
7270
6776
  }
7271
- return 0;
7272
- })
7273
- .attr('width', function (d) {
7274
- // Use calculated barWidth for mobile, otherwise scale
7275
- if (isMobile) {
7276
- return barWidth;
7277
- }
7278
- return self.chartConfiguration.isMultiChartGridLine == undefined
7279
- ? xScale.bandwidth()
7280
- : self.chartConfiguration.isDrilldownChart &&
7281
- self.chartData.data.length <= 3
7282
- ? 70
7283
- : xScale.bandwidth() * 0.8;
7284
- })
7285
- // .style('cursor', 'pointer');
7286
- .style('cursor', function (d) {
7287
- if (metaData.hasDrillDown) {
7288
- if (metaData.barWithoutClick.length > 0 &&
7289
- metaData.barWithoutClick.includes(d.data.name.toLowerCase())) {
7290
- return 'default';
7291
- }
7292
- return 'pointer';
7293
- }
7294
- else
7295
- return 'default';
7296
- })
7297
- .style('fill', function (d) {
7298
- if (!isNaN(d[0]) &&
7299
- !isNaN(d[1]) &&
7300
- self.chartData.targetLineData &&
7301
- parseFloat(d[1]) - parseFloat(d[0]) >=
7302
- parseFloat(self.chartData.targetLineData.target))
7303
- return self.chartData?.targetLineData?.barAboveTargetColor;
7304
- return metaData.colors[d.key];
7305
- });
7306
- /**
7307
- * do not show valus on hover as its alreay dislayed
7308
- */
7309
- if (!this.isCC && !self.chartConfiguration.isMultiChartGridLine) {
7310
- rect
7311
- .append('svg:title') // TITLE APPENDED HERE
7312
- .text(function (d) {
7313
- return d[1] - d[0];
7314
- });
7315
- }
7316
- if (this.isCC) {
7317
- rect
7318
- .append('text')
7319
- .attr('x', function (d) {
7320
- return xScale(d.data.name);
7321
- })
7322
- .attr('text-anchor', function (d) {
7323
- if (!d[0]) {
7324
- return 'end';
7325
- }
7326
- else {
7327
- return 'start';
7328
- }
7329
- })
7330
- .attr('class', 'verticalbar__text')
7331
- .attr('y', function (d) {
7332
- if (!d[0]) {
7333
- return yScale(d[1]);
7334
- }
7335
- else {
7336
- return yScale(d[1]) - 7;
7337
- }
7338
- })
7339
- // .attr("y", function (d) { return yScale(d[0]) - yScale(d[1]); })
7340
- .attr('dy', function (d) {
7341
- return d.class;
7342
- })
7343
- .text(function (d) {
7344
- if (!d[0]) {
7345
- if (!isNaN(d[1] - d[0])) {
7346
- return Math.round((d[1] - d[0]) * 100) / 100;
7347
- }
7348
- else
7349
- return;
7350
- }
7351
- else {
7352
- if (!isNaN(d[1])) {
7353
- return Math.round(d[1] * 100) / 100;
7354
- }
7355
- else
7356
- return;
7357
- }
7358
- });
7359
- }
7360
- /**
7361
- svg
7362
- .append('foreignObject')
7363
- .attr('transform', 'translate(' + 0 + ',' + (yZero - 25) + ')')
7364
- .attr('width', width)
7365
- .attr('height', 30)
7366
- .append('xhtml:div')
7367
- .attr('class', 'target-display')
7368
- .style('color', this.chartData.targetLineData.color)
7369
- */
7370
- /**
7371
- * on hover, display title on top
7372
- */
7373
- function handleMouseOver(d, i) {
7374
- if (!self.chartConfiguration.displayTitleOnTop) {
7375
- return;
7376
- }
7377
- svg
7378
- .selectAll('rect')
7379
- .filter(function (data) {
7380
- return data == d;
7381
- })
7382
- .style('fill', function (d) {
7383
- if (!isNaN(d[0]) &&
7384
- !isNaN(d[1]) &&
7385
- self.chartData.targetLineData &&
7386
- parseFloat(d[1]) - parseFloat(d[0]) >=
7387
- parseFloat(self.chartData.targetLineData.target))
7388
- return self.chartData.targetLineData.barAboveTargetHoverColor
7389
- ? self.chartData.targetLineData.barAboveTargetHoverColor
7390
- : self.chartData?.targetLineData?.barAboveTargetColor
7391
- ? self.chartData?.targetLineData?.barAboveTargetColor
7392
- : '';
7393
- return metaData.hoverColor ? metaData.hoverColor : '';
7394
- });
7395
- svg
7396
- .append('foreignObject')
7397
- .attr('x', function () {
7398
- if (xScale.bandwidth() + leftAndRightSpaces * 2 > 180) {
7399
- return (xScale(d.data.name) -
7400
- leftAndRightSpaces +
7401
- (xScale.bandwidth() + leftAndRightSpaces * 2 - 180) / 2);
7402
- }
7403
- return xScale(d.data.name) - leftAndRightSpaces;
7404
- })
7405
- .attr('class', 'lib-verticalstack-title-ontop')
7406
- .attr('y', function () {
7407
- // Increase the gap between the bar and the tooltip (was -1 - 40)
7408
- return yScale(d[1]) - 1 - 50; // 10px more gap
7409
- })
7410
- .attr('dy', function () {
7411
- return d.class;
7412
- })
7413
- .attr('width', function () {
7414
- if (d.data.name && /week/i.test(d.data.name) && /\d{4}-\d{2}-\d{2}/.test(d.data.name)) {
7415
- return '250px'; // increase for week + date
7416
- }
7417
- if (xScale.bandwidth() + leftAndRightSpaces * 2 > 180) {
7418
- return '180px';
7419
- }
7420
- return xScale.bandwidth() + leftAndRightSpaces * 2;
7421
- })
7422
- .attr('height', 40)
7423
- .append('xhtml:div')
7424
- .attr('class', 'title')
7425
- .style('z-index', 99)
7426
- .html(function () {
7427
- // Tooltip content without any arrow mark
7428
- if (!isNaN(d[1] - d[0])) {
7429
- if (d[1] - d[0] === 0) {
7430
- return '<span class="title-top-text">0</span>';
7431
- }
7432
- var dataType = metaData.dataType ? metaData.dataType : '';
7433
- var desiredText = '';
7434
- // Always show the full x-axis label (category name) in the tooltip
7435
- desiredText =
7436
- '<span class="title-bar-name">' +
7437
- (d.data.name ? d.data.name : '') +
7438
- '</span>';
7439
- desiredText += metaData.unit
7440
- ? '<span class="title-top-text">' +
7441
- metaData.unit +
7442
- (d[1] - d[0]) + ' ' +
7443
- dataType +
7444
- '</span>'
7445
- : '<span class="title-top-text">' +
7446
- (d[1] - d[0]) + ' ' +
7447
- dataType +
7448
- '</span>';
7449
- // No arrow mark or arrow HTML/CSS in tooltip
7450
- return desiredText;
7451
- }
7452
- else
7453
- return;
7454
- });
7455
- }
7456
- function handleMouseOut(d, i) {
7457
- if (!self.chartConfiguration.displayTitleOnTop) {
7458
- return;
7459
- }
7460
- // svg.selectAll('rect').style('fill', metaData.colors[d.key]);
7461
- svg.selectAll('rect').style('fill', function (d) {
7462
- if (!isNaN(d[0]) &&
7463
- !isNaN(d[1]) &&
7464
- self.chartData.targetLineData &&
7465
- parseFloat(d[1]) - parseFloat(d[0]) >=
7466
- parseFloat(self.chartData.targetLineData.target))
7467
- return self.chartData?.targetLineData?.barAboveTargetColor;
7468
- return metaData.colors[d.key];
7469
- });
7470
- svg.selectAll('.lib-verticalstack-title-ontop').remove();
7471
- }
7472
- /**
7473
- * used to show value on top of the bars
7474
- * need to be used by bar charts only(one bar should contain one value)
7475
- * used by weekly charts
7476
- */
7477
- if (this.chartConfiguration.showTotalOnTop != undefined) {
7478
- rect
7479
- .append('text')
7480
- .attr('x', function (d) {
7481
- return xScale(d.data.name) + xScale.bandwidth() / 2;
7482
- })
7483
- .attr('class', 'lib-verticalstack-labels-ontop-weklycharts')
7484
- .attr('y', function (d) {
7485
- return yScale(d[1]) - 3;
7486
- })
7487
- .attr('dy', function (d) {
7488
- return d.class;
7489
- })
7490
- .text(function (d) {
7491
- if (!isNaN(d[1] - d[0])) {
7492
- if (d[1] - d[0] == 0) {
7493
- return;
7494
- }
7495
- if (d[1] - d[0] <= 999)
7496
- return metaData.unit
7497
- ? metaData.unit + formatFromBackend(d[1] - d[0])
7498
- : formatFromBackend(d[1] - d[0]);
7499
- else
7500
- return metaData.unit
7501
- ? metaData.unit + formatForHugeNumbers(d[1] - d[0])
7502
- : formatForHugeNumbers(d[1] - d[0]);
7503
- }
7504
- else
7505
- return;
7506
- });
7507
- }
7508
- /**
7509
- * used to show angled values on top of the bars
7510
- * used by weekly charts
7511
- */
7512
- if (this.chartConfiguration.showAngledLabels != undefined) {
7513
- rect
7514
- .append('text')
7515
- .attr('x', 0)
7516
- .attr('fill', function (d, i) {
7517
- return metaData.colors[d.key];
7518
- })
7519
- .attr('class', 'lib-data-labels-angled-weeklycharts')
7520
- .attr('y', 0)
7521
- .attr('dy', function (d) {
7522
- return d.class;
7523
- })
7524
- .text(function (d) {
7525
- if (!isNaN(d[1] - d[0]) && d[1] - d[0] > 0) {
7526
- if (d[1] - d[0] <= 999)
7527
- return metaData.unit
7528
- ? metaData.unit + formatFromBackend(d[1] - d[0])
7529
- : formatFromBackend(d[1] - d[0]);
7530
- else
7531
- return metaData.unit + formatForHugeNumbers(d[1] - d[0]);
7532
- }
7533
- else
7534
- return;
7535
- })
7536
- .attr('transform', function (d) {
7537
- if (!isNaN(d[1] - d[0]) && d[1] - d[0] > 0) {
7538
- var total = 0;
7539
- var incrementer = 1;
7540
- metaData.keyList.forEach((key) => {
7541
- if (d.data[key])
7542
- total = total + d.data[key];
7543
- else
7544
- incrementer = 2;
7545
- });
7546
- if (tempObjectHolder[d.data.name] == undefined) {
7547
- tempObjectHolder[d.data.name] = 1;
7548
- }
7549
- else {
7550
- tempObjectHolder[d.data.name] =
7551
- tempObjectHolder[d.data.name] + incrementer;
7552
- }
7553
- switch (tempObjectHolder[d.data.name]) {
7554
- case 1:
7555
- return ('translate(' +
7556
- (xScale(d.data.name) + xScale.bandwidth() / 3) +
7557
- ',' +
7558
- (yScale(total) - 3) +
7559
- ') rotate(270)');
7560
- case 2:
7561
- return ('translate(' +
7562
- (xScale(d.data.name) + xScale.bandwidth() / 2 + 2) +
7563
- ',' +
7564
- (yScale(total) - 3) +
7565
- ') rotate(270)');
7566
- default:
7567
- return ('translate(' +
7568
- (xScale(d.data.name) + (xScale.bandwidth() * 3) / 4) +
7569
- ',' +
7570
- (yScale(total) - 3) +
7571
- ') rotate(270)');
7572
- }
7573
- }
7574
- return 'rotate(0)';
7575
- });
7576
- }
7577
- if (this.chartConfiguration.isMultiChartGridLine == undefined) {
7578
- if (isMobile) {
7579
- // Custom x-axis label rendering for mobile: evenly distribute under each bar
7580
- svg.selectAll('.custom-x-label').remove();
7581
- data.forEach(function (d, i) {
7582
- const xVal = leftAndRightSpaces + i * (barWidth + barPadding) + barWidth / 2;
7583
- svg.append('text')
7584
- .attr('class', 'custom-x-label')
7585
- .attr('x', 0)
7586
- .attr('y', height + 18)
7587
- .attr('text-anchor', 'middle')
7588
- .attr('transform', 'translate(' + (xVal + 20) + ',0)') // current value + 20
7589
- .style('font-size', '10px')
7590
- .style('fill', 'var(--chart-text-color)')
7591
- .style('writing-mode', 'sideways-lr') // writing mode for mobile
7592
- .text(d.name.substring(0, 3));
7593
- });
7594
- }
7595
- else {
7596
- svg
7597
- .append('g')
7598
- .attr('transform', 'translate(0,' + height + ')')
7599
- .attr('class', 'lib-stacked-x-axis-text')
7600
- .call(xAxis)
7601
- .selectAll('text')
7602
- .style('fill', 'var(--chart-text-color)')
7603
- .style('font-size', '12px')
7604
- .attr('text-anchor', 'middle')
7605
- .attr('dx', '0')
7606
- .attr('dy', '0.71em')
7607
- .attr('transform', null)
7608
- .text(function (d) {
7609
- return d;
7610
- });
6777
+ return 0;
6778
+ })
6779
+ .attr('width', (d) => {
6780
+ if (device.isMobile)
6781
+ return barWidth;
6782
+ if (!this.chartConfiguration.isMultiChartGridLine)
6783
+ return xScale.bandwidth();
6784
+ if (this.chartConfiguration.isDrilldownChart && this.chartData.data.length <= 3) {
6785
+ return 70;
7611
6786
  }
7612
- svg
7613
- .append('g')
7614
- .attr('class', 'lib-stacked-y-axis-text')
7615
- .attr('style', self.chartConfiguration.yAxisCustomTextStyles)
7616
- .attr('transform', 'translate(0,0)')
7617
- .call(yAxis)
7618
- .selectAll('text')
7619
- .style('fill', 'var(--chart-text-color)');
6787
+ return xScale.bandwidth() * 0.8;
6788
+ })
6789
+ .style('cursor', (d) => {
6790
+ if (metaData.hasDrillDown) {
6791
+ if (metaData.barWithoutClick?.includes(d.data.name.toLowerCase())) {
6792
+ return 'default';
6793
+ }
6794
+ return 'pointer';
6795
+ }
6796
+ return 'default';
6797
+ })
6798
+ .style('fill', (d) => this.getBarColor(d, metaData));
6799
+ }
6800
+ getBarColor(d, metaData) {
6801
+ if (!isNaN(d[0]) &&
6802
+ !isNaN(d[1]) &&
6803
+ this.chartData.targetLineData &&
6804
+ parseFloat(d[1]) - parseFloat(d[0]) >= parseFloat(String(this.chartData.targetLineData.target))) {
6805
+ return this.chartData.targetLineData.barAboveTargetColor || metaData.colors[d.key];
7620
6806
  }
7621
- else if (this.chartConfiguration.isDrilldownChart) {
6807
+ return metaData.colors[d.key];
6808
+ }
6809
+ addInteractions(rect, svg, metaData, scales) {
6810
+ rect
6811
+ .selectAll('rect')
6812
+ .on('mouseenter', (d) => this.handleMouseOver(d, svg, metaData, scales))
6813
+ .on('mouseout', (d) => this.handleMouseOut(svg, metaData));
6814
+ }
6815
+ handleMouseOver(d, svg, metaData, scales) {
6816
+ if (!this.chartConfiguration.displayTitleOnTop)
6817
+ return;
6818
+ svg.selectAll('rect')
6819
+ .filter((data) => data === d)
6820
+ .style('fill', (d) => this.getHoverColor(d, metaData));
6821
+ this.displayTooltip(d, svg, metaData, scales);
6822
+ }
6823
+ getHoverColor(d, metaData) {
6824
+ if (!isNaN(d[0]) &&
6825
+ !isNaN(d[1]) &&
6826
+ this.chartData.targetLineData &&
6827
+ parseFloat(d[1]) - parseFloat(d[0]) >= parseFloat(String(this.chartData.targetLineData.target))) {
6828
+ return this.chartData.targetLineData.barAboveTargetHoverColor ||
6829
+ this.chartData.targetLineData.barAboveTargetColor ||
6830
+ metaData.colors[d.key];
6831
+ }
6832
+ return metaData.hoverColor || metaData.colors[d.key];
6833
+ }
6834
+ displayTooltip(d, svg, metaData, scales) {
6835
+ const { xScale, yScale } = scales;
6836
+ const value = d[1] - d[0];
6837
+ if (isNaN(value))
6838
+ return;
6839
+ const width = /week/i.test(d.data.name) && /\d{4}-\d{2}-\d{2}/.test(d.data.name)
6840
+ ? '250px'
6841
+ : xScale.bandwidth() + this.CONSTANTS.LEFT_RIGHT_SPACES * 2 > 180
6842
+ ? '180px'
6843
+ : xScale.bandwidth() + this.CONSTANTS.LEFT_RIGHT_SPACES * 2;
6844
+ svg
6845
+ .append('foreignObject')
6846
+ .attr('x', this.calculateTooltipX(d, xScale, width))
6847
+ .attr('class', 'lib-verticalstack-title-ontop')
6848
+ .attr('y', yScale(d[1]) - 51)
6849
+ .attr('width', width)
6850
+ .attr('height', 40)
6851
+ .append('xhtml:div')
6852
+ .attr('class', 'title')
6853
+ .style('z-index', 99)
6854
+ .html(this.generateTooltipHtml(d, metaData, value));
6855
+ }
6856
+ calculateTooltipX(d, xScale, width) {
6857
+ const bandwidth = xScale.bandwidth();
6858
+ const numericWidth = typeof width === 'string' ? parseInt(width) : width;
6859
+ if (bandwidth + this.CONSTANTS.LEFT_RIGHT_SPACES * 2 > 180) {
6860
+ return xScale(d.data.name) - this.CONSTANTS.LEFT_RIGHT_SPACES +
6861
+ (bandwidth + this.CONSTANTS.LEFT_RIGHT_SPACES * 2 - 180) / 2;
6862
+ }
6863
+ return xScale(d.data.name) - this.CONSTANTS.LEFT_RIGHT_SPACES;
6864
+ }
6865
+ generateTooltipHtml(d, metaData, value) {
6866
+ if (value === 0)
6867
+ return '<span class="title-top-text">0</span>';
6868
+ const dataType = metaData.dataType || '';
6869
+ const name = d.data.name ? `<span class="title-bar-name">${d.data.name}</span>` : '';
6870
+ const valueText = metaData.unit
6871
+ ? `${metaData.unit}${value} ${dataType}`
6872
+ : `${value} ${dataType}`;
6873
+ return `${name}<span class="title-top-text">${valueText}</span>`;
6874
+ }
6875
+ handleMouseOut(svg, metaData) {
6876
+ if (!this.chartConfiguration.displayTitleOnTop)
6877
+ return;
6878
+ svg.selectAll('rect')
6879
+ .style('fill', (d) => this.getBarColor(d, metaData));
6880
+ svg.selectAll('.lib-verticalstack-title-ontop').remove();
6881
+ }
6882
+ renderAxisLabels(svg, svgYAxisLeft, metaData, dimensions, margin) {
6883
+ if (metaData.yLabel) {
6884
+ this.addYAxisLabel(svgYAxisLeft, metaData.yLabel, dimensions.height, margin);
6885
+ }
6886
+ if (metaData.xLabel) {
6887
+ this.addXAxisLabel(svg, metaData.xLabel, dimensions.width, dimensions.height, margin);
6888
+ }
6889
+ }
6890
+ addYAxisLabel(svgYAxisLeft, label, height, margin) {
6891
+ const isria = this.customChartConfiguration?.isRia;
6892
+ const isAcronym = this.isAcronymLabel(label);
6893
+ const yPosition = isria ? -margin.left / 2 - 30 : -margin.left / 2 - 40;
6894
+ svgYAxisLeft.selectAll('.lib-axis-group-label, .lib-ylabel-drilldowncharts, .lib-ylabel-weeklyCharts').remove();
6895
+ svgYAxisLeft
6896
+ .append('text')
6897
+ .attr('class', this.getYAxisLabelClass())
6898
+ .attr('style', this.chartConfiguration.yAxisCustomlabelStyles)
6899
+ .attr('transform', 'rotate(-90)')
6900
+ .attr('y', yPosition)
6901
+ .attr('x', -height / 2)
6902
+ .attr('dy', '1em')
6903
+ .style('text-anchor', 'middle')
6904
+ .style('fill', 'var(--chart-text-color)')
6905
+ .text(isAcronym ? label.toUpperCase() : label.toLowerCase())
6906
+ .style('text-transform', isAcronym ? 'none' : 'capitalize');
6907
+ }
6908
+ addXAxisLabel(svg, label, width, height, margin) {
6909
+ const isria = this.customChartConfiguration?.isRia;
6910
+ const isAcronym = this.isAcronymLabel(label);
6911
+ const xPosition = isria
6912
+ ? height + margin.top + margin.bottom
6913
+ : height + margin.top + margin.bottom + 10;
6914
+ svg
6915
+ .append('text')
6916
+ .attr('class', this.getXAxisLabelClass())
6917
+ .attr('style', this.chartConfiguration.xAxisCustomlabelStyles)
6918
+ .attr('transform', `translate(${width / 2},${xPosition})`)
6919
+ .style('text-anchor', 'middle')
6920
+ .style('fill', 'var(--chart-text-color)')
6921
+ .text(isAcronym ? label.toUpperCase() : label.toLowerCase())
6922
+ .style('text-transform', isAcronym ? 'none' : 'capitalize');
6923
+ }
6924
+ isAcronymLabel(label) {
6925
+ const cleanLabel = label.replace(/[^A-Za-z]/g, '');
6926
+ return (label.length <= 4 && /^[A-Z]+$/.test(label)) ||
6927
+ (label === label.toUpperCase() && /[A-Z]/.test(label));
6928
+ }
6929
+ getYAxisLabelClass() {
6930
+ let baseClass = 'lib-axis-group-label font-size-1';
6931
+ if (this.chartConfiguration.isDrilldownChart) {
6932
+ return `${baseClass} lib-ylabel-drilldowncharts`;
6933
+ }
6934
+ if (this.chartConfiguration.isMultiChartGridLine !== undefined) {
6935
+ return `${baseClass} lib-ylabel-weeklyCharts`;
6936
+ }
6937
+ return `${baseClass} lib-axis-waterfall-label`;
6938
+ }
6939
+ getXAxisLabelClass() {
6940
+ let baseClass = 'lib-axis-group-label font-size-1';
6941
+ if (this.chartConfiguration.isDrilldownChart) {
6942
+ return `${baseClass} lib-xlabel-drilldowncharts`;
6943
+ }
6944
+ if (this.chartConfiguration.isMultiChartGridLine !== undefined) {
6945
+ return `${baseClass} lib-xlabel-weeklyCharts`;
6946
+ }
6947
+ return `${baseClass} lib-axis-waterfall-label`;
6948
+ }
6949
+ applyConfigurationFlags() {
6950
+ if (this.chartConfiguration.isHeaderVisible !== undefined) {
6951
+ this.isHeaderVisible = this.chartConfiguration.isHeaderVisible;
6952
+ }
6953
+ if (this.chartConfiguration.isTopCaptionVisible !== undefined) {
6954
+ this.isTopCaptionVisible = this.chartConfiguration.isTopCaptionVisible;
6955
+ }
6956
+ if (this.chartConfiguration.isTransparentBackground !== undefined) {
6957
+ this.isTransparentBackground = this.chartConfiguration.isTransparentBackground;
6958
+ }
6959
+ }
6960
+ initializeStackedChart() {
6961
+ const device = this.getDeviceConfig();
6962
+ this.configureResponsiveSettings(device);
6963
+ this.mergeConfigurations();
6964
+ this.applyConfigurationFlags();
6965
+ const data = this.chartData.data;
6966
+ const metaData = this.prepareMetaData(this.chartData.metaData);
6967
+ const lineData = this.chartData.lineData;
6968
+ const colors = metaData.colors;
6969
+ const keyList = metaData.keyList;
6970
+ const chartContainer = d3.select(this.containerElt.nativeElement);
6971
+ const verticalstackedcontainer = d3.select(this.verticalstackedcontainerElt.nativeElement);
6972
+ const margin = this.chartConfiguration.margin;
6973
+ const dimensions = this.calculateDimensions(chartContainer, verticalstackedcontainer, margin, device, data.length);
6974
+ const { svg, svgYAxisLeft, svgYAxisRight } = this.createSvgContainers(chartContainer, dimensions, margin);
6975
+ const stack = d3.stack().keys(keyList).offset(d3.stackOffsetNone);
6976
+ const layers = stack(data);
6977
+ data.sort((a, b) => b.total - a.total);
6978
+ const scales = this.createScales(data, layers, lineData, dimensions, device);
6979
+ const axes = this.createAxes(scales);
6980
+ this.renderGrids(svg, scales, dimensions);
6981
+ const rect = this.renderBars(svg, layers, scales, metaData, dimensions, device);
6982
+ this.renderAxes(svg, svgYAxisLeft, svgYAxisRight, axes, scales, dimensions, device, data);
6983
+ this.renderAxisLabels(svg, svgYAxisLeft, metaData, dimensions, margin);
6984
+ this.renderTargetLine(svg, svgYAxisRight, scales, dimensions, metaData);
6985
+ this.renderDataLabels(rect, scales, metaData, dimensions);
6986
+ this.renderLineChart(svg, lineData, scales, colors, metaData);
6987
+ }
6988
+ renderGrids(svg, scales, dimensions) {
6989
+ if (this.chartConfiguration.isXgridBetweenLabels) {
7622
6990
  svg
7623
6991
  .append('g')
7624
- .attr('transform', 'translate(0,' + height + ')')
7625
- .attr('class', 'lib-stacked-x-axis-text multichart1')
7626
- .call(xAxis)
7627
- .style('display', 'none');
7628
- svgYAxisLeft
7629
- .append('g')
7630
- .attr('class', 'lib-yaxis-labels-texts-drilldown yaxis-dashed')
7631
- .attr('style', self.chartConfiguration.yAxisCustomTextStyles)
7632
- .attr('transform', 'translate(0,0)')
7633
- .call(yAxis)
7634
- .selectAll('text')
7635
- .style('fill', 'var(--chart-text-color)');
7636
- svgYAxisRight
7637
- .append('g')
7638
- .attr('class', 'lib-yaxis-labels-texts-drilldown yaxis-dashed')
7639
- .attr('style', self.chartConfiguration.yAxisCustomTextStyles)
7640
- .attr('transform', 'translate(0,0)')
7641
- .call(yAxis)
7642
- .style('display', 'none');
6992
+ .attr('class', 'grid')
6993
+ .attr('transform', `translate(${scales.xScale.bandwidth() / 2},${dimensions.height})`)
6994
+ .call(d3.axisBottom(scales.xScale).tickSize(-dimensions.height).tickFormat(''))
6995
+ .style('stroke-dasharray', '5 5')
6996
+ .style('color', '#999999')
6997
+ .call((g) => g.select('.domain').remove());
7643
6998
  }
7644
- else {
6999
+ if (this.chartConfiguration.yAxisGrid) {
7645
7000
  svg
7646
7001
  .append('g')
7647
- .attr('transform', 'translate(0,' + height + ')')
7648
- .attr('class', 'lib-stacked-x-axis-text multichart')
7649
- .attr('transform', 'translate(0,' + height + ')')
7650
- .call(xAxis)
7651
- .selectAll('text')
7652
- .style('fill', 'var(--chart-text-color)');
7002
+ .attr('class', 'grid')
7003
+ .call(d3
7004
+ .axisLeft(scales.yScale)
7005
+ .ticks(this.chartConfiguration.numberOfYTicks)
7006
+ .tickSize(-dimensions.width)
7007
+ .tickFormat(''))
7008
+ .style('color', 'var(--chart-grid-color)')
7009
+ .style('opacity', '1');
7010
+ }
7011
+ if (this.chartConfiguration.xAxisGrid) {
7012
+ for (let j = 0; j < this.chartConfiguration.xAxisGrid.length; j++) {
7013
+ svg
7014
+ .append('g')
7015
+ .attr('class', `x${j + 2} axis${j + 2}`)
7016
+ .style('color', 'var(--chart-grid-color)')
7017
+ .attr('transform', `translate(0,${dimensions.height * this.chartConfiguration.xAxisGrid[j]})`)
7018
+ .call(d3.axisBottom(scales.xScale).tickSize(0).ticks(5).tickFormat(''))
7019
+ .style('fill', 'var(--chart-text-color)');
7020
+ }
7021
+ }
7022
+ }
7023
+ renderAxes(svg, svgYAxisLeft, svgYAxisRight, axes, scales, dimensions, device, data) {
7024
+ if (this.chartConfiguration.showXaxisTop) {
7653
7025
  svg
7654
7026
  .append('g')
7655
- .attr('class', 'lib-stacked-y-axis-text yaxis-dashed')
7656
- .attr('style', self.chartConfiguration.yAxisCustomTextStyles)
7657
- .attr('transform', 'translate(0,0)')
7658
- .call(yAxis)
7659
- .selectAll('text')
7660
- .style('fill', 'var(--chart-text-color)');
7027
+ .attr('class', 'lib-line-axis-text lib-line-x-axis-text x-axis')
7028
+ .attr('style', this.chartConfiguration.xAxisCustomTextStyles)
7029
+ .call(d3.axisBottom(scales.xScale).tickSize(0));
7030
+ svg.selectAll('.x-axis > g > text').attr('class', 'lib-display-hidden');
7661
7031
  }
7662
- /**
7663
- * for existing charts, place xaxis labels nearer to xaxis
7664
- * used by existing charts
7665
- */
7666
- if (this.chartConfiguration.isMultiChartGridLine == undefined) {
7667
- d3.selectAll('g.lib-stacked-x-axis-text g.tick text').attr('y', function () {
7668
- if (alternate_text) {
7669
- alternate_text = false;
7670
- return long_tick_length + 1;
7671
- }
7672
- else {
7673
- alternate_text = true;
7674
- return short_tick_length + 1;
7675
- }
7676
- });
7032
+ if (!this.chartConfiguration.isMultiChartGridLine) {
7033
+ this.renderStandardAxes(svg, axes, scales, dimensions, device, data);
7034
+ }
7035
+ else if (this.chartConfiguration.isDrilldownChart) {
7036
+ this.renderDrilldownAxes(svg, svgYAxisLeft, svgYAxisRight, axes, scales, dimensions);
7677
7037
  }
7678
7038
  else {
7679
- d3.selectAll('.multichart > g > text').attr('class', 'lib-display-hidden');
7039
+ this.renderMultiChartAxes(svg, axes, scales, dimensions);
7680
7040
  }
7681
- /**
7682
- * based of the flag, hide or show xaxis texts
7683
- * used by weekly charts
7684
- */
7685
- if (this.chartConfiguration.isXaxisLabelHidden != undefined &&
7686
- this.chartConfiguration.isXaxisLabelHidden) {
7687
- d3.selectAll('.multichart > g > text').attr('class', 'lib-display-hidden');
7041
+ this.applyAxisStyling(svg, svgYAxisLeft, svgYAxisRight);
7042
+ this.applyAxisConfigurations(svg, scales, dimensions, data);
7043
+ }
7044
+ renderStandardAxes(svg, axes, scales, dimensions, device, data) {
7045
+ if (device.isMobile) {
7046
+ this.renderMobileXAxis(svg, data, dimensions);
7688
7047
  }
7689
- else if (this.chartConfiguration.isXaxisLabelHidden != undefined) {
7690
- svg
7691
- .append('g')
7692
- .attr('class', 'x1 axis1')
7693
- .attr('transform', 'translate(0,' + height + ')')
7694
- .style('color', '#000')
7695
- .call(d3.axisBottom(xScale).tickSize(0))
7696
- .call((g) => g.select('.domain').attr('fill', 'none'));
7048
+ else {
7697
7049
  svg
7698
7050
  .append('g')
7699
- .attr('class', 'x2 axis2')
7700
- .attr('transform', 'translate(0,' + height + ')')
7701
- .style('color', '#000')
7702
- .call(d3.axisBottom(xScaleFromOrigin).tickSize(0))
7703
- .call((g) => g.select('.domain').attr('fill', 'none'));
7704
- svg.selectAll('.axis2 > g > text').attr('class', 'lib-display-hidden');
7705
- // svg.selectAll('g.x2.axis2 g.tick text').style('display', 'none');
7706
- svg.selectAll('.x1.axis1 .tick line').attr('y2', function () {
7707
- if (self.chartConfiguration.hideXaxisTick) {
7708
- return 0;
7709
- }
7710
- /**
7711
- * isNoAlternateXaxisText is used to prevent x-axis label to be displayed in alternate fashion
7712
- * for future use
7713
- */
7714
- if (alternate_text &&
7715
- self.chartConfiguration.isNoAlternateXaxisText == undefined) {
7716
- alternate_text = false;
7717
- return long_tick_length_bg - 7;
7718
- }
7719
- else {
7720
- alternate_text = true;
7721
- return short_tick_length_bg - 4;
7722
- }
7723
- });
7724
- /**
7725
- * reset the flag so that texts also follow the pattern of ticks
7726
- * used by weekly charts
7727
- */
7728
- alternate_text = false;
7729
- svg
7730
- .selectAll('g.x1.axis1 g.tick text')
7731
- // .attr('class', 'lib-xaxis-labels-texts-weeklycharts')
7732
- .attr('class', function () {
7733
- if (self.chartConfiguration.isDrilldownChart) {
7734
- if (data && data.length > 8) {
7735
- return 'lib-xaxis-labels-texts-drilldown-alt';
7736
- }
7737
- return 'lib-xaxis-labels-texts-drilldown';
7738
- }
7739
- else
7740
- return 'lib-xaxis-labels-texts-weeklycharts';
7741
- })
7742
- .attr('y', function () {
7743
- if (alternate_text) {
7744
- alternate_text = false;
7745
- return long_tick_length_bg;
7746
- }
7747
- else {
7748
- alternate_text = true;
7749
- return short_tick_length_bg;
7750
- }
7751
- });
7051
+ .attr('transform', `translate(0,${dimensions.height})`)
7052
+ .attr('class', 'lib-stacked-x-axis-text')
7053
+ .call(axes.xAxis)
7054
+ .selectAll('text')
7055
+ .style('fill', 'var(--chart-text-color)')
7056
+ .style('font-size', '12px')
7057
+ .attr('text-anchor', 'middle')
7058
+ .attr('dx', '0')
7059
+ .attr('dy', '0.71em')
7060
+ .attr('transform', null);
7752
7061
  }
7753
- if (self.chartConfiguration.xLabelsOnSameLine) {
7754
- svg
7755
- .selectAll('g.x1.axis1 g.tick text')
7756
- .attr('class', 'lib-xaxis-labels-texts-drilldown')
7757
- .attr('y', short_tick_length_bg)
7758
- .text(function (d, i) {
7759
- if (isMobile) {
7760
- // If label has more than one word, show only first 3 letters of first word
7761
- var firstWord = d.split(' ')[0];
7762
- return firstWord.substring(0, 3);
7763
- }
7764
- if (d.trim().indexOf(' ') > -1) {
7765
- return d.trim().substring(0, d.indexOf(' ')).toLowerCase();
7766
- }
7767
- return d.toLowerCase();
7768
- })
7769
- .attr('transform', function (d, i) {
7770
- if (isMobile) {
7771
- var totalBars = 0;
7772
- if (this.parentNode && this.parentNode.parentNode) {
7773
- totalBars = d3.select(this.parentNode.parentNode).selectAll('g.tick').size();
7774
- }
7775
- if (totalBars === 2) {
7776
- return 'translate(0,0)';
7777
- }
7778
- else {
7779
- return 'translate(' + (i * 30) + ',0)';
7780
- }
7781
- }
7782
- return null;
7783
- });
7062
+ svg
7063
+ .append('g')
7064
+ .attr('class', 'lib-stacked-y-axis-text')
7065
+ .attr('style', this.chartConfiguration.yAxisCustomTextStyles)
7066
+ .call(axes.yAxis)
7067
+ .selectAll('text')
7068
+ .style('fill', 'var(--chart-text-color)');
7069
+ }
7070
+ renderMobileXAxis(svg, data, dimensions) {
7071
+ svg.selectAll('.custom-x-label').remove();
7072
+ data.forEach((d, i) => {
7073
+ const xVal = this.CONSTANTS.LEFT_RIGHT_SPACES +
7074
+ i * (dimensions.barWidth + dimensions.barPadding) +
7075
+ dimensions.barWidth / 2;
7784
7076
  svg
7785
- .selectAll('g.x1.axis1 g.tick')
7786
7077
  .append('text')
7787
- .attr('class', 'lib-xaxis-labels-texts-drilldown')
7788
- .attr('y', long_tick_length_bg)
7789
- .attr('fill', 'currentColor')
7790
- .text(function (d) {
7791
- // For mobile, do not print the second word at all
7792
- if (isMobile) {
7793
- return '';
7794
- }
7795
- if (d.trim().indexOf(' ') > -1) {
7796
- return d.trim().substring(d.indexOf(' '), d.length).toLowerCase();
7797
- }
7798
- return '';
7799
- })
7800
- .attr('transform', function (d, i) {
7801
- if (isMobile && i === 0) {
7802
- return 'translate(20,0)';
7803
- }
7804
- return null;
7805
- });
7806
- }
7807
- /**
7808
- * hide yaxis values
7809
- * used by weekly charts
7810
- */
7811
- if (this.chartConfiguration.isYaxisLabelHidden != undefined &&
7812
- this.chartConfiguration.isYaxisLabelHidden) {
7813
- svg
7814
- .selectAll('.yaxis-dashed > g > text')
7815
- .attr('class', 'lib-display-hidden');
7816
- }
7817
- /** hide y axis labels
7818
- * config is there for future use
7819
- */
7820
- if (this.chartConfiguration.isYaxisHidden != undefined &&
7821
- this.chartConfiguration.isYaxisHidden) {
7822
- d3.selectAll('.yaxis-dashed').attr('class', 'lib-display-hidden');
7823
- }
7824
- /**
7825
- * dashed y axis
7826
- * used by weekly charts
7827
- */
7828
- if (this.chartConfiguration.isYaxisDashed != undefined &&
7829
- this.chartConfiguration.isYaxisDashed) {
7078
+ .attr('class', 'custom-x-label')
7079
+ .attr('x', 0)
7080
+ .attr('y', dimensions.height + 18)
7081
+ .attr('text-anchor', 'middle')
7082
+ .attr('transform', `translate(${xVal + 20},0)`)
7083
+ .style('font-size', '10px')
7084
+ .style('fill', 'var(--chart-text-color)')
7085
+ .style('writing-mode', 'sideways-lr')
7086
+ .text(d.name.substring(0, 3));
7087
+ });
7088
+ }
7089
+ renderDrilldownAxes(svg, svgYAxisLeft, svgYAxisRight, axes, scales, dimensions) {
7090
+ svg
7091
+ .append('g')
7092
+ .attr('transform', `translate(0,${dimensions.height})`)
7093
+ .attr('class', 'lib-stacked-x-axis-text multichart1')
7094
+ .call(axes.xAxis)
7095
+ .style('display', 'none');
7096
+ svgYAxisLeft
7097
+ .append('g')
7098
+ .attr('class', 'lib-yaxis-labels-texts-drilldown yaxis-dashed')
7099
+ .attr('style', this.chartConfiguration.yAxisCustomTextStyles)
7100
+ .call(axes.yAxis)
7101
+ .selectAll('text')
7102
+ .style('fill', 'var(--chart-text-color)');
7103
+ svgYAxisRight
7104
+ .append('g')
7105
+ .attr('class', 'lib-yaxis-labels-texts-drilldown yaxis-dashed')
7106
+ .attr('style', this.chartConfiguration.yAxisCustomTextStyles)
7107
+ .call(axes.yAxis)
7108
+ .style('display', 'none');
7109
+ }
7110
+ renderMultiChartAxes(svg, axes, scales, dimensions) {
7111
+ svg
7112
+ .append('g')
7113
+ .attr('transform', `translate(0,${dimensions.height})`)
7114
+ .attr('class', 'lib-stacked-x-axis-text multichart')
7115
+ .call(axes.xAxis)
7116
+ .selectAll('text')
7117
+ .style('fill', 'var(--chart-text-color)');
7118
+ svg
7119
+ .append('g')
7120
+ .attr('class', 'lib-stacked-y-axis-text yaxis-dashed')
7121
+ .attr('style', this.chartConfiguration.yAxisCustomTextStyles)
7122
+ .call(axes.yAxis)
7123
+ .selectAll('text')
7124
+ .style('fill', 'var(--chart-text-color)');
7125
+ }
7126
+ applyAxisStyling(svg, svgYAxisLeft, svgYAxisRight) {
7127
+ const styleAxisDomain = (container) => {
7128
+ container.selectAll('.domain')
7129
+ .style('stroke', 'var(--chart-axis-color)')
7130
+ .style('stroke-width', '1px');
7131
+ };
7132
+ styleAxisDomain(svg);
7133
+ styleAxisDomain(svgYAxisLeft);
7134
+ styleAxisDomain(svgYAxisRight);
7135
+ if (this.chartConfiguration.isYaxisDashed) {
7830
7136
  d3.selectAll('.yaxis-dashed')
7831
7137
  .style('stroke-dasharray', '5 5')
7832
- .style('color', 'var(--chart-grid-color)'); // Use CSS variable
7138
+ .style('color', 'var(--chart-grid-color)');
7833
7139
  }
7834
- /**
7835
- * x axis color
7836
- * used by weekly charts
7837
- */
7838
- if (this.chartConfiguration.isXaxisColor != undefined) {
7140
+ if (this.chartConfiguration.isXaxisColor) {
7839
7141
  d3.selectAll('.multichart').style('color', this.chartConfiguration.isXaxisColor || 'var(--chart-text-color)');
7840
7142
  }
7841
- /**
7842
- * used to display y label
7843
- */
7844
- if (this.isZoomedOut && this.chartData.data.length > 9) {
7143
+ }
7144
+ applyAxisConfigurations(svg, scales, dimensions, data) {
7145
+ if (this.chartConfiguration.isMultiChartGridLine !== undefined) {
7146
+ d3.selectAll('.multichart > g > text').attr('class', 'lib-display-hidden');
7147
+ }
7148
+ if (this.chartConfiguration.isXaxisLabelHidden) {
7149
+ d3.selectAll('.multichart > g > text').attr('class', 'lib-display-hidden');
7150
+ }
7151
+ else if (this.chartConfiguration.isXaxisLabelHidden !== undefined) {
7152
+ this.renderCustomXAxis(svg, scales, dimensions, data);
7153
+ }
7154
+ if (this.chartConfiguration.isYaxisLabelHidden) {
7155
+ svg.selectAll('.yaxis-dashed > g > text').attr('class', 'lib-display-hidden');
7156
+ }
7157
+ if (this.chartConfiguration.isYaxisHidden) {
7158
+ d3.selectAll('.yaxis-dashed').attr('class', 'lib-display-hidden');
7159
+ }
7160
+ if (this.isZoomedOut && data.length > 9) {
7845
7161
  svg
7846
7162
  .selectAll('.lib-xaxis-labels-texts-drilldown')
7847
7163
  .attr('transform', 'rotate(-90)')
@@ -7849,219 +7165,272 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
7849
7165
  .attr('x', '-5')
7850
7166
  .attr('dy', null);
7851
7167
  }
7852
- function styleAxisDomain() {
7853
- svg.selectAll('.domain')
7854
- .style('stroke', 'var(--chart-axis-color)')
7855
- .style('stroke-width', '1px');
7856
- svgYAxisLeft.selectAll('.domain')
7857
- .style('stroke', 'var(--chart-axis-color)')
7858
- .style('stroke-width', '1px');
7859
- svgYAxisRight.selectAll('.domain')
7860
- .style('stroke', 'var(--chart-axis-color)')
7861
- .style('stroke-width', '1px');
7168
+ }
7169
+ renderCustomXAxis(svg, scales, dimensions, data) {
7170
+ const device = this.getDeviceConfig();
7171
+ svg
7172
+ .append('g')
7173
+ .attr('class', 'x1 axis1')
7174
+ .attr('transform', `translate(0,${dimensions.height})`)
7175
+ .style('color', '#000')
7176
+ .call(d3.axisBottom(scales.xScale).tickSize(0))
7177
+ .call((g) => g.select('.domain').attr('fill', 'none'));
7178
+ this.styleCustomXAxisTicks(svg, data, device);
7179
+ if (this.chartConfiguration.xLabelsOnSameLine) {
7180
+ this.applyXLabelsOnSameLine(svg, device);
7862
7181
  }
7863
- styleAxisDomain();
7864
- if (metaData.yLabel) {
7865
- svgYAxisLeft.selectAll('.lib-axis-group-label, .lib-ylabel-drilldowncharts, .lib-ylabel-weeklyCharts').remove();
7866
- function isAcronym(label) {
7867
- return (label.length <= 4 && /^[A-Z]+$/.test(label)) || (label === label.toUpperCase() && /[A-Z]/.test(label));
7182
+ }
7183
+ styleCustomXAxisTicks(svg, data, device) {
7184
+ let alternateText = false;
7185
+ svg.selectAll('.x1.axis1 .tick line').attr('y2', () => {
7186
+ if (this.chartConfiguration.hideXaxisTick)
7187
+ return 0;
7188
+ if (alternateText && !this.chartConfiguration.isNoAlternateXaxisText) {
7189
+ alternateText = false;
7190
+ return this.CONSTANTS.LONG_TICK_LENGTH_BG - 7;
7868
7191
  }
7869
- const yLabelText = metaData.yLabel;
7870
- const isAcr = isAcronym(yLabelText.replace(/[^A-Za-z]/g, ''));
7871
- const yPosition = isria ? 0 - margin.left / 2 - 30 : 0 - margin.left / 2 - 40;
7872
- svgYAxisLeft
7873
- .append('text')
7874
- .attr('class', function () {
7875
- let baseClass = 'lib-axis-group-label font-size-1';
7876
- if (self.chartConfiguration.isDrilldownChart)
7877
- return baseClass + ' lib-ylabel-drilldowncharts';
7878
- if (self.chartConfiguration.isMultiChartGridLine != undefined)
7879
- return baseClass + ' lib-ylabel-weeklyCharts';
7880
- return baseClass + ' lib-axis-waterfall-label';
7881
- })
7882
- .attr('style', self.chartConfiguration.yAxisCustomlabelStyles)
7883
- .attr('transform', 'rotate(-90)')
7884
- .attr('y', yPosition)
7885
- .attr('x', 0 - height / 2)
7886
- .attr('dy', '1em')
7887
- .style('text-anchor', 'middle')
7888
- .style('fill', 'var(--chart-text-color)')
7889
- .style('color', 'var(--chart-text-color)')
7890
- .text(isAcr ? yLabelText.toUpperCase() : yLabelText.toLowerCase())
7891
- .style('text-transform', isAcr ? 'none' : 'capitalize');
7192
+ alternateText = true;
7193
+ return this.CONSTANTS.SHORT_TICK_LENGTH_BG - 4;
7194
+ });
7195
+ alternateText = false;
7196
+ svg
7197
+ .selectAll('g.x1.axis1 g.tick text')
7198
+ .attr('class', () => {
7199
+ if (this.chartConfiguration.isDrilldownChart) {
7200
+ return data.length > 8
7201
+ ? 'lib-xaxis-labels-texts-drilldown-alt'
7202
+ : 'lib-xaxis-labels-texts-drilldown';
7203
+ }
7204
+ return 'lib-xaxis-labels-texts-weeklycharts';
7205
+ })
7206
+ .attr('y', () => {
7207
+ if (alternateText) {
7208
+ alternateText = false;
7209
+ return this.CONSTANTS.LONG_TICK_LENGTH_BG;
7210
+ }
7211
+ alternateText = true;
7212
+ return this.CONSTANTS.SHORT_TICK_LENGTH_BG;
7213
+ });
7214
+ }
7215
+ applyXLabelsOnSameLine(svg, device) {
7216
+ svg
7217
+ .selectAll('g.x1.axis1 g.tick text')
7218
+ .attr('class', 'lib-xaxis-labels-texts-drilldown')
7219
+ .attr('y', this.CONSTANTS.SHORT_TICK_LENGTH_BG)
7220
+ .text((d) => {
7221
+ if (device.isMobile) {
7222
+ return d.split(' ')[0].substring(0, 3);
7223
+ }
7224
+ const trimmed = d.trim();
7225
+ const spaceIndex = trimmed.indexOf(' ');
7226
+ return spaceIndex > -1
7227
+ ? trimmed.substring(0, spaceIndex).toLowerCase()
7228
+ : trimmed.toLowerCase();
7229
+ })
7230
+ .attr('transform', function (d, i) {
7231
+ if (device.isMobile) {
7232
+ const parent = this.parentNode?.parentNode;
7233
+ const totalBars = parent ? d3.select(parent).selectAll('g.tick').size() : 0;
7234
+ return totalBars === 2 ? 'translate(0,0)' : `translate(${i * 30},0)`;
7235
+ }
7236
+ return null;
7237
+ });
7238
+ svg
7239
+ .selectAll('g.x1.axis1 g.tick')
7240
+ .append('text')
7241
+ .attr('class', 'lib-xaxis-labels-texts-drilldown')
7242
+ .attr('y', this.CONSTANTS.LONG_TICK_LENGTH_BG)
7243
+ .attr('fill', 'currentColor')
7244
+ .text((d) => {
7245
+ if (device.isMobile)
7246
+ return '';
7247
+ const trimmed = d.trim();
7248
+ const spaceIndex = trimmed.indexOf(' ');
7249
+ return spaceIndex > -1
7250
+ ? trimmed.substring(spaceIndex).toLowerCase()
7251
+ : '';
7252
+ })
7253
+ .attr('transform', (d, i) => {
7254
+ return device.isMobile && i === 0 ? 'translate(20,0)' : null;
7255
+ });
7256
+ }
7257
+ renderDataLabels(rect, scales, metaData, dimensions) {
7258
+ if (!this.isCC && !this.chartConfiguration.isMultiChartGridLine) {
7259
+ rect.append('svg:title').text((d) => d[1] - d[0]);
7892
7260
  }
7893
- if (this.chartData.targetLineData) {
7894
- const yZero = yScale(parsedNum);
7895
- svg
7896
- .append('line')
7897
- .attr('x1', 0)
7898
- .attr('x2', width)
7899
- .attr('y1', yZero)
7900
- .attr('y2', yZero)
7901
- .style('stroke-dasharray', '5 5')
7902
- .style('stroke', this.chartData.targetLineData.color);
7903
- // svgYAxisRight
7904
- // .append('line')
7905
- // .attr('x1', 0)
7906
- // .attr('x2', rightSvgWidth)
7907
- // .attr('y1', yZero)
7908
- // .attr('y2', yZero)
7909
- // .style('stroke', this.chartData.targetLineData.color);
7910
- svgYAxisRight
7911
- .append('foreignObject')
7912
- // .attr('transform', 'translate(' + 0 + ',' + (yZero - 30) + ')')
7913
- .attr('transform', 'translate(' + 0 + ',' + (yZero - 13) + ')')
7914
- .attr('width', rightSvgWidth)
7915
- .attr('height', 50)
7916
- .append('xhtml:div')
7917
- .attr('class', 'target-display')
7918
- .style('color', 'var(--chart-text-color)')
7919
- .html(function (d, i) {
7920
- let dataTypeTemp = '';
7921
- let targetLineName = 'target';
7922
- if (metaData.dataType) {
7923
- dataTypeTemp = metaData.dataType;
7261
+ if (this.chartConfiguration.showTotalOnTop) {
7262
+ this.renderTopLabels(rect, scales, metaData);
7263
+ }
7264
+ if (this.chartConfiguration.showAngledLabels) {
7265
+ this.renderAngledLabels(rect, scales, metaData);
7266
+ }
7267
+ }
7268
+ renderTopLabels(rect, scales, metaData) {
7269
+ const formatFromBackend = this.chartConfiguration.textFormatter
7270
+ ? ChartHelper.dataValueFormatter(this.chartConfiguration.textFormatter)
7271
+ : (d) => d;
7272
+ const formatForHugeNumbers = ChartHelper.dataValueFormatter('.2s');
7273
+ rect
7274
+ .append('text')
7275
+ .attr('x', (d) => scales.xScale(d.data.name) + scales.xScale.bandwidth() / 2)
7276
+ .attr('class', 'lib-verticalstack-labels-ontop-weklycharts')
7277
+ .attr('y', (d) => scales.yScale(d[1]) - 3)
7278
+ .text((d) => {
7279
+ const value = d[1] - d[0];
7280
+ if (isNaN(value) || value === 0)
7281
+ return;
7282
+ const formattedValue = value <= 999
7283
+ ? formatFromBackend(value)
7284
+ : formatForHugeNumbers(value);
7285
+ return metaData.unit ? metaData.unit + formattedValue : formattedValue;
7286
+ });
7287
+ }
7288
+ renderAngledLabels(rect, scales, metaData) {
7289
+ const formatFromBackend = this.chartConfiguration.textFormatter
7290
+ ? ChartHelper.dataValueFormatter(this.chartConfiguration.textFormatter)
7291
+ : (d) => d;
7292
+ const formatForHugeNumbers = ChartHelper.dataValueFormatter('.2s');
7293
+ const tempObjectHolder = {};
7294
+ rect
7295
+ .append('text')
7296
+ .attr('x', 0)
7297
+ .attr('y', 0)
7298
+ .attr('fill', (d) => metaData.colors[d.key])
7299
+ .attr('class', 'lib-data-labels-angled-weeklycharts')
7300
+ .text((d) => {
7301
+ const value = d[1] - d[0];
7302
+ if (isNaN(value) || value <= 0)
7303
+ return;
7304
+ const formattedValue = value <= 999
7305
+ ? formatFromBackend(value)
7306
+ : formatForHugeNumbers(value);
7307
+ return metaData.unit ? metaData.unit + formattedValue : formattedValue;
7308
+ })
7309
+ .attr('transform', (d) => {
7310
+ const value = d[1] - d[0];
7311
+ if (isNaN(value) || value <= 0)
7312
+ return 'rotate(0)';
7313
+ let total = 0;
7314
+ let incrementer = 1;
7315
+ metaData.keyList.forEach(key => {
7316
+ if (d.data[key]) {
7317
+ total += d.data[key];
7924
7318
  }
7925
- if (self.chartData.targetLineData &&
7926
- self.chartData.targetLineData.targetName) {
7927
- targetLineName = self.chartData.targetLineData.targetName;
7319
+ else {
7320
+ incrementer = 2;
7928
7321
  }
7929
- return (`<div>${targetLineName}</div>` +
7930
- '<div>' +
7931
- self.chartData.targetLineData.target +
7932
- '' +
7933
- dataTypeTemp +
7934
- '</div>');
7935
7322
  });
7936
- }
7937
- rect
7938
- .selectAll('rect')
7939
- .on('mouseenter', handleMouseOver)
7940
- .on('mouseout', handleMouseOut);
7941
- if (metaData.lineyLabel) {
7942
- svg
7943
- .append('text')
7944
- .attr('class', 'lib-axis-group-label lib-line-axis')
7945
- .attr('style', self.chartConfiguration.yAxisCustomlabelStyles)
7946
- .attr('transform', 'translate(' + (width - 20) + ',0) rotate(90)')
7947
- .attr('y', 0 - margin.right * 3)
7948
- .attr('x', height / 2)
7949
- .attr('dy', '5em')
7950
- .style('text-anchor', 'middle')
7951
- .text(metaData.lineyLabel);
7952
- }
7953
- if (metaData.xLabel) {
7954
- function isAcronym(label) {
7955
- return ((label.length <= 4 && /^[A-Z]+$/.test(label)) ||
7956
- (label === label.toUpperCase() && /[A-Z]/.test(label)));
7323
+ tempObjectHolder[d.data.name] = (tempObjectHolder[d.data.name] || 0) + incrementer;
7324
+ const position = tempObjectHolder[d.data.name];
7325
+ const xPos = scales.xScale(d.data.name);
7326
+ const bandwidth = scales.xScale.bandwidth();
7327
+ const yPos = scales.yScale(total) - 3;
7328
+ switch (position) {
7329
+ case 1:
7330
+ return `translate(${xPos + bandwidth / 3},${yPos}) rotate(270)`;
7331
+ case 2:
7332
+ return `translate(${xPos + bandwidth / 2 + 2},${yPos}) rotate(270)`;
7333
+ default:
7334
+ return `translate(${xPos + (bandwidth * 3) / 4},${yPos}) rotate(270)`;
7957
7335
  }
7958
- const xLabelText = metaData.xLabel;
7959
- const isAcr = isAcronym(xLabelText.replace(/[^A-Za-z]/g, ''));
7960
- const xPosition = isria ? (height + margin.top + margin.bottom) : (height + margin.top + margin.bottom + 10);
7336
+ });
7337
+ }
7338
+ renderTargetLine(svg, svgYAxisRight, scales, dimensions, metaData) {
7339
+ if (!this.chartData.targetLineData)
7340
+ return;
7341
+ const parsedTarget = this.parseTargetValue(this.chartData.targetLineData.target);
7342
+ const yZero = scales.yScale(parsedTarget);
7343
+ svg
7344
+ .append('line')
7345
+ .attr('x1', 0)
7346
+ .attr('x2', dimensions.width)
7347
+ .attr('y1', yZero)
7348
+ .attr('y2', yZero)
7349
+ .style('stroke-dasharray', '5 5')
7350
+ .style('stroke', this.chartData.targetLineData.color);
7351
+ this.renderTargetLabel(svgYAxisRight, yZero, metaData);
7352
+ }
7353
+ parseTargetValue(target) {
7354
+ const parsed = parseFloat(String(target));
7355
+ if (isNaN(parsed))
7356
+ return 0;
7357
+ return Number.isInteger(parsed) ? parseInt(String(target)) : parsed;
7358
+ }
7359
+ renderTargetLabel(svgYAxisRight, yZero, metaData) {
7360
+ const dataType = metaData.dataType || '';
7361
+ const targetName = this.chartData.targetLineData.targetName || 'target';
7362
+ svgYAxisRight
7363
+ .append('foreignObject')
7364
+ .attr('transform', `translate(0,${yZero - 13})`)
7365
+ .attr('width', this.CONSTANTS.RIGHT_SVG_WIDTH)
7366
+ .attr('height', 50)
7367
+ .append('xhtml:div')
7368
+ .attr('class', 'target-display')
7369
+ .style('color', 'var(--chart-text-color)')
7370
+ .html(`<div>${targetName}</div><div>${this.chartData.targetLineData.target}${dataType}</div>`);
7371
+ }
7372
+ renderLineChart(svg, lineData, scales, colors, metaData) {
7373
+ if (!lineData || !colors)
7374
+ return;
7375
+ const dataGroup = d3
7376
+ .nest()
7377
+ .key((d) => d.category)
7378
+ .entries(lineData);
7379
+ const lineGen = d3
7380
+ .line()
7381
+ .x((d) => scales.xScale(d.name) + scales.xScale.bandwidth() / 2)
7382
+ .y((d) => scales.lineYscale(d.value));
7383
+ dataGroup.forEach((group) => {
7961
7384
  svg
7962
- .append('text')
7963
- .attr('class', function () {
7964
- let baseClass = 'lib-axis-group-label font-size-1';
7965
- if (self.chartConfiguration.isDrilldownChart)
7966
- return baseClass + ' lib-xlabel-drilldowncharts';
7967
- if (self.chartConfiguration.isMultiChartGridLine != undefined)
7968
- return baseClass + ' lib-xlabel-weeklyCharts';
7969
- return baseClass + ' lib-axis-waterfall-label';
7970
- })
7971
- .attr('style', self.chartConfiguration.xAxisCustomlabelStyles)
7972
- .attr('transform', 'translate(' + width / 2 + ' ,' + xPosition + ')')
7973
- .style('text-anchor', 'middle')
7974
- .style('fill', 'var(--chart-text-color)')
7975
- .text(isAcr ? xLabelText.toUpperCase() : xLabelText.toLowerCase())
7976
- .style('text-transform', isAcr ? 'none' : 'capitalize');
7977
- }
7978
- if (lineData && colors) {
7979
- var dataGroup = d3
7980
- .nest()
7981
- .key(function (d) {
7982
- return d.category;
7983
- })
7984
- .entries(lineData);
7985
- var lineGen = d3
7986
- .line()
7987
- .x(function (d) {
7988
- return xScale(d.name) + xScale.bandwidth() / 2;
7385
+ .append('path')
7386
+ .datum(group.values)
7387
+ .attr('fill', 'none')
7388
+ .attr('stroke', (d) => {
7389
+ return d[0]?.category
7390
+ ? colors[d[0].category]
7391
+ : this.chartConfiguration.lineGraphColor;
7989
7392
  })
7990
- .y(function (d) {
7991
- return lineYscale(d.value);
7992
- });
7993
- var calculateCX = (d) => {
7994
- return xScale(d.name) + xScale.bandwidth() / 2;
7995
- };
7996
- var calculateCY = (d) => {
7997
- return lineYscale(d.value);
7998
- };
7999
- dataGroup.forEach(function (d, i) {
8000
- svg
8001
- .append('path')
8002
- .datum(d.values)
8003
- .attr('fill', 'none')
8004
- .attr('stroke', function (d) {
8005
- if ('category' in d[0]) {
8006
- return colors[d[0].category];
8007
- }
8008
- else {
8009
- return self.chartConfiguration.lineGraphColor;
8010
- }
8011
- })
8012
- .attr('stroke-width', 2.5) /**line thinkness */
8013
- .attr('d', lineGen(d.values));
8014
- var dot = svg
8015
- .selectAll('myCircles')
8016
- .data(d.values)
8017
- .enter()
8018
- .append('g')
8019
- .on('click', function (d) {
8020
- self.handleClick(d);
8021
- });
8022
- dot
8023
- .append('circle')
8024
- .attr('fill', function (d) {
8025
- if ('category' in d) {
8026
- return colors[d.category];
8027
- }
8028
- else {
8029
- return self.chartConfiguration.lineGraphColor;
8030
- }
8031
- })
8032
- .attr('stroke', 'none')
8033
- .attr('cx', function (d, i) {
8034
- return xScale(d.name) + xScale.bandwidth() / 2;
8035
- })
8036
- .attr('cy', function (d, i) {
8037
- return lineYscale(d.value);
8038
- })
8039
- .attr('r', 3) /**radius of circle=5 */
8040
- .style('cursor', 'pointer');
8041
- if (self.chartConfiguration.lineGraphColor) {
8042
- dot
8043
- .append('text')
8044
- .attr('class', 'dots')
8045
- .attr('fill', self.chartConfiguration.lineGraphColor)
8046
- .attr('style', 'font-size: ' + '.85em;' + 'font-weight:' + 'bold')
8047
- .attr('x', function (d, i) {
8048
- return xScale(d.name) + xScale.bandwidth() / 2;
8049
- })
8050
- .attr('y', function (d, i) {
8051
- return lineYscale(d.value);
8052
- })
8053
- .attr('dy', '-1em')
8054
- .text(function (d, i) {
8055
- return self.chartConfiguration.labelFormatter(d.value);
8056
- });
8057
- }
8058
- });
7393
+ .attr('stroke-width', 2.5)
7394
+ .attr('d', lineGen);
7395
+ this.renderLineDots(svg, group.values, scales, colors);
7396
+ });
7397
+ }
7398
+ renderLineDots(svg, values, scales, colors) {
7399
+ const dot = svg
7400
+ .selectAll('.line-dots')
7401
+ .data(values)
7402
+ .enter()
7403
+ .append('g')
7404
+ .on('click', (d) => this.handleClick(d));
7405
+ dot
7406
+ .append('circle')
7407
+ .attr('fill', (d) => {
7408
+ return d.category
7409
+ ? colors[d.category]
7410
+ : this.chartConfiguration.lineGraphColor;
7411
+ })
7412
+ .attr('stroke', 'none')
7413
+ .attr('cx', (d) => scales.xScale(d.name) + scales.xScale.bandwidth() / 2)
7414
+ .attr('cy', (d) => scales.lineYscale(d.value))
7415
+ .attr('r', 3)
7416
+ .style('cursor', 'pointer');
7417
+ if (this.chartConfiguration.lineGraphColor) {
7418
+ dot
7419
+ .append('text')
7420
+ .attr('class', 'dots')
7421
+ .attr('fill', this.chartConfiguration.lineGraphColor)
7422
+ .style('font-size', '.85em')
7423
+ .style('font-weight', 'bold')
7424
+ .attr('x', (d) => scales.xScale(d.name) + scales.xScale.bandwidth() / 2)
7425
+ .attr('y', (d) => scales.lineYscale(d.value))
7426
+ .attr('dy', '-1em')
7427
+ .text((d) => this.chartConfiguration.labelFormatter(d.value));
8059
7428
  }
8060
- // svg.attr('width', 150).style('max-width', 150).style('overflow-x', 'auto');
8061
7429
  }
8062
7430
  handleClick(d) {
8063
- if (this.chartData?.metaData?.hasDrillDown || d?.toggleFrom)
7431
+ if (this.chartData?.metaData?.hasDrillDown || d?.toggleFrom) {
8064
7432
  this.clickEvent.emit(d);
7433
+ }
8065
7434
  }
8066
7435
  handleHeaderMenuClick(id) {
8067
7436
  this.headerMenuclickEvent.emit(id);
@@ -8070,15 +7439,14 @@ class HorizontalBarsWithScrollZoomComponent extends ComponentUniqueId {
8070
7439
  this.clickEvent.emit(event);
8071
7440
  }
8072
7441
  handleZoominZoomoutClick({ isZoomOut, event }) {
8073
- // this.isZoomOutSelected(isZoomOut, event);
8074
7442
  this.isZoomOutSelected(isZoomOut);
8075
7443
  }
8076
7444
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: HorizontalBarsWithScrollZoomComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
8077
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: HorizontalBarsWithScrollZoomComponent, selector: "lib-horizontal-bars-with-scroll-zoom", inputs: { chartData: "chartData", customChartConfiguration: "customChartConfiguration" }, outputs: { clickEvent: "clickEvent", headerMenuclickEvent: "headerMenuclickEvent" }, viewQueries: [{ propertyName: "containerElt", first: true, predicate: ["verticalstackedchartcontainer"], descendants: true, static: true }, { propertyName: "verticalstackedcontainerElt", first: true, predicate: ["verticalstackedcontainer"], descendants: true, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<meta http-equiv=\"CACHE-CONTROL\" content=\"NO-CACHE\" />\r\n<meta http-equiv=\"EXPIRES\" content=\"Sat, 01 Jun 2004 11:12:01 GMT\" />\r\n<div\r\n #verticalstackedcontainer\r\n class=\"lib-chart-wrapper\"\r\n [ngClass]=\"{ 'lib-no-background': isTransparentBackground }\"\r\n style=\"background-color: var(--card-bg);\"\r\n\r\n (resized)=\"onResized($event)\"\r\n>\r\n <div class=\"header-alt\" *ngIf=\"!isHeaderVisible\">\r\n <lib-chart-header-v2\r\n [chartData]=\"chartData\"\r\n [chartConfiguration]=\"chartConfiguration\"\r\n (clickEvent)=\"handleClick($event)\"\r\n ></lib-chart-header-v2>\r\n\r\n <!-- <span *ngIf=\"chartConfiguration.isComparebyDropdownVisible\">\r\n <lib-dropdown></lib-dropdown>\r\n </span> -->\r\n <lib-chart-header-v3\r\n [chartData]=\"chartData\"\r\n [chartConfiguration]=\"chartConfiguration\"\r\n (compareByFilterSelection)=\"handleCompareByFilterSelection($event)\"\r\n (zoomInZoomOutClick)=\"handleZoominZoomoutClick($event)\"\r\n ></lib-chart-header-v3>\r\n </div>\r\n <div\r\n [style.height]=\"chartConfiguration.svgHeight\"\r\n id=\"verticalstackedchartcontainer\"\r\n #verticalstackedchartcontainer\r\n class=\"lib-chart-svg\"\r\n ></div>\r\n</div>\r\n", styles: [".lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-weight:400;letter-spacing:0px;color:#000;opacity:1;font-size:1.2em}.lib-axis-group-label{font-size:.85em;font-weight:600;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:0px;color:#000;opacity:1}.dots{font-size:10px}.inline__display{display:flex;justify-content:space-around;padding-top:2%}.verticalbar__text{font-style:normal;font-variant:normal;font-weight:400;font-size:13px;line-height:20px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:0px;opacity:1}.lib-line-label-item{display:inline-block!important;font-size:.85em;margin-right:10px;font-weight:600}.lib-line-label-wrapper-vertical{display:flex;justify-content:center}.target-display{font-size:12px;line-height:14.52px;font-weight:700;text-transform:uppercase;float:right}.title{background-color:#d9d9d9;height:40px;display:flex;flex-direction:column;justify-content:center;align-items:center;border-radius:3px;line-height:1}.title-top-text{color:var(--font-color)!important;font-size:14px;font-weight:600}.title-bar-name{color:var(--font-color)!important;font-size:17px;font-weight:700;text-transform:capitalize}.title-bottom-text{color:var(--font-color)!important;font-size:12px}.zoomIcons-holder{display:flex;align-items:center;margin-right:15px}.zoomIcons{border:.5px solid #b6b6b6;cursor:pointer;display:flex;justify-content:center;align-items:center;width:30px;height:30px;color:var(--color)!important}.zoom-active{background-color:#2d5ca0;opacity:1}.zoom-inactive{background-color:#d9d9d9;opacity:.5}@media (max-width: 575px){.lib-xaxis-labels-texts-drilldown{writing-mode:sideways-lr}}@media screen and (min-width: 1024px) and (min-height: 400px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:10px!important}.dots{font-size:10px!important}}@media screen and (min-width: 1024px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:10px!important}.dots{font-size:10px!important}}@media screen and (min-width: 1024px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:10px!important}.dots{font-size:10px!important}}@media screen and (min-width: 1366px) and (min-height: 400px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:12px!important}.dots{font-size:12px!important}}@media screen and (min-width: 1366px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:12px!important}.dots{font-size:12px!important}}@media screen and (min-width: 1366px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:12px!important}.dots{font-size:12px!important}}@media screen and (min-width: 1920px) and (min-height: 400px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:14px!important}.dots{font-size:14px!important}}@media screen and (min-width: 1920px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:14px!important}.dots{font-size:14px!important}}@media screen and (min-width: 1920px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:14px!important}.dots{font-size:14px!important}}@media screen and (min-width: 2560px) and (min-height: 500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:16px!important}.dots{font-size:16px!important}}@media screen and (min-width: 2560px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:16px!important}.dots{font-size:16px!important}}@media screen and (min-width: 2560px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:16px!important}}.bottom__text{position:absolute!important;bottom:0!important;display:flex!important;justify-content:center!important;align-items:center!important;width:100%!important}.box__heightwidth{opacity:1;height:10px;width:10px;border:none!important;border-radius:50%}.label__text{margin-right:10px;display:flex;justify-content:center;align-items:center;font-style:normal;font-variant:normal;font-weight:400;font-size:10px;line-height:13px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif;letter-spacing:.2px;color:#707070!important}.lib-verticalstack-labels-ontop-weklycharts{font-style:normal;font-variant:normal;font-weight:700;font-size:10px;line-height:11px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.05px;text-anchor:middle;fill:#000}.lib-verticalstack-title-ontop{font-style:normal;font-variant:normal;font-size:14px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.05px;text-anchor:middle;fill:#000}.marginLeft-20{margin-left:20px}.flex-inline{display:flex;justify-content:center;align-items:center;font-size:14px}\n", ".lib-chart-wrapper{width:100%;height:100%;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;background:#fff 0% 0% no-repeat padding-box;position:relative}.lib-chart-wrapper-wo-shadow{width:100%;height:100%;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto}.lib-chart-wrapper:hover .chart-header-v1:not(.header-no-background){background-color:#2e3640}.lib-chart-wrapper:hover .chart-header-v1:not(.header-no-background) .chart-title{color:#fff}.lib-chart-svg{width:100%}.lib-chart-header{text-align:center;background-color:#052340;color:#fff;width:100%;height:17%;word-spacing:.5px;line-height:1.8;font-weight:700;padding-top:2%;letter-spacing:0;font-size:1.2em}.lib-donut-chart-footer{width:100%;text-align:right}.lib-donut-label-text{font-size:.9em;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-weight:400;letter-spacing:0px;color:#000;opacity:1}.lib-donut-label-icon{display:inline-block;width:10px;height:10px;margin-right:20px;border-radius:3px}.lib-donut-label-item{font-weight:400;font-size:.85em;color:#2f2f2f}.lib-donut-justified-label-wrapper{width:100%;display:inline-block;text-align:center;list-style-type:none}.lib-donut-justified-label-item{font-weight:400;font-size:.85em;color:#2f2f2f;display:inline-block;text-align:left;padding:0 10px}.lib-donut-justified-label-icon{display:inline-block;width:10px;height:10px;margin-right:5px;border-radius:3px}.lib-no-background{background:none!important}.lib-display-hidden{display:none}.lib-ylabel-weeklyCharts{font-style:normal;font-variant:normal;font-weight:800;font-size:10px;line-height:12px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.07px;text-transform:capitalize;color:#000}.lib-data-labels-weeklycharts{font-style:normal;font-variant:normal;font-weight:400;font-size:12px;line-height:14px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.06px;color:#000}.lib-data-labels-angled-weeklycharts{font-style:normal;font-variant:normal;font-weight:800;font-size:9.5px;line-height:11px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:.4px;text-anchor:start}.lib-xaxis-labels-texts-weeklycharts{font-style:normal;font-variant:normal;font-weight:800;font-size:10px;line-height:11px;letter-spacing:-.05px;fill:#000}.lib-xaxis-labels-texts-drilldown{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:14px;letter-spacing:-1px;color:#000;opacity:1;text-transform:capitalize}.lib-white-space-nowrap{white-space:nowrap}.lib-xaxis-labels-texts-drilldown-alt{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:10px;letter-spacing:0px;color:#000;opacity:1;text-transform:capitalize}.lib-yaxis-labels-texts-drilldown{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:14px;letter-spacing:0px;color:#000!important;opacity:1}.lib-ylabel-drilldowncharts,.lib-xlabel-drilldowncharts{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:16px;letter-spacing:-.1px;color:#000!important;opacity:1}.lib-donut-justified-label-icon-drilldown{display:inline-block;width:14px;height:14px;margin-right:10px;border-radius:50%}.marginright-2{margin-right:2%}.margintop-5{margin-top:5%}.width-100{width:100%}.float-right{float:right}.marginBottom-10{margin-bottom:10px}.header-alt{align-items:center;margin-bottom:10px}input::placeholder{font-size:20px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:0px;color:#000;opacity:1}.padding-5{padding:5px}.hidden{visibility:hidden}.font-weight-bold{font-weight:900}.textalign-center{text-align:center}.cursor-pointer{cursor:pointer}.cursor-default{cursor:default}.font-weight-600{font-weight:600}.marginRight-15{margin-right:15px}.marginRight-20{margin-right:20px}.switch{position:relative;display:inline-block;width:46px;height:24px;margin-left:5px;margin-right:5px}.switch input{opacity:0;width:0;height:0}.slider{position:absolute;cursor:pointer;inset:0;background-color:#2d5ca0;-webkit-transition:.4s;transition:.4s}.slider:before{position:absolute;content:\"\";height:18px;width:18px;right:3px;bottom:3px;background-color:#fff;-webkit-transition:.4s;transition:.4s}.slider.round{border-radius:18px}.slider.round:before{border-radius:50%}.slider1{position:absolute;cursor:pointer;inset:0;background-color:#015ba2cf;-webkit-transition:.4s;transition:.4s}.slider1:before{position:absolute;content:\"\";height:18px;width:18px;left:3px;bottom:3px;background-color:#fff;-webkit-transition:.4s;transition:.4s}.slider1.round1{border-radius:18px}.slider1.round1:before{border-radius:50%}.lib-display-flex{display:flex}.lib-align-items-center{align-items:center}.lib-flex-direction-column{flex-direction:column}.lib-justify-content-space-between{justify-content:space-between}.lib-justify-content-space-around{justify-content:space-around}.lib-justify-content-center{justify-content:center}.lib-justify-content-start{justify-content:start}.lib-justify-content-end{justify-content:end}.lib-ml-20{margin-left:20px}.lib-position-absolute{position:absolute}.lib-z-index-9{z-index:9}.marginright-3{margin-right:3px}@media (min-height: 900px){.lib-chart-wrapper{border-radius:8px}.header-font-size-1{font-size:18px!important}.font-size-1{font-size:14px!important}.font-size-2{font-size:16px!important}.font-size-3{font-size:14px!important}.font-size-4{font-size:22px!important}.font-size-5{font-size:24px!important}}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.ResizedDirective, selector: "[resized]", outputs: ["resized"] }, { kind: "component", type: ChartHeaderV2Component, selector: "lib-chart-header-v2", inputs: ["chartData", "chartConfiguration"], outputs: ["clickEvent", "zoomInZoomOutClick"] }, { kind: "component", type: ChartHeaderV3Component, selector: "lib-chart-header-v3", inputs: ["chartData", "chartConfiguration"], outputs: ["compareByFilterSelection", "zoomInZoomOutClick"] }], encapsulation: i0.ViewEncapsulation.None }); }
7445
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: HorizontalBarsWithScrollZoomComponent, selector: "lib-horizontal-bars-with-scroll-zoom", inputs: { chartData: "chartData", customChartConfiguration: "customChartConfiguration" }, outputs: { clickEvent: "clickEvent", headerMenuclickEvent: "headerMenuclickEvent" }, viewQueries: [{ propertyName: "containerElt", first: true, predicate: ["verticalstackedchartcontainer"], descendants: true, static: true }, { propertyName: "verticalstackedcontainerElt", first: true, predicate: ["verticalstackedcontainer"], descendants: true, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<meta http-equiv=\"CACHE-CONTROL\" content=\"NO-CACHE\" />\r\n<meta http-equiv=\"EXPIRES\" content=\"Sat, 01 Jun 2004 11:12:01 GMT\" />\r\n<div\r\n #verticalstackedcontainer\r\n class=\"lib-chart-wrapper\"\r\n [ngClass]=\"{ 'lib-no-background': isTransparentBackground }\"\r\n style=\"background-color: var(--card-bg);\"\r\n\r\n (resized)=\"onResized($event)\"\r\n>\r\n <div class=\"header-alt\" *ngIf=\"!isHeaderVisible\">\r\n <lib-chart-header-v2\r\n [chartData]=\"chartData\"\r\n [chartConfiguration]=\"chartConfiguration\"\r\n (clickEvent)=\"handleClick($event)\"\r\n ></lib-chart-header-v2>\r\n\r\n <lib-chart-header-v3\r\n [chartData]=\"chartData\"\r\n [chartConfiguration]=\"chartConfiguration\"\r\n (compareByFilterSelection)=\"handleCompareByFilterSelection($event)\"\r\n (zoomInZoomOutClick)=\"handleZoominZoomoutClick($event)\"\r\n ></lib-chart-header-v3>\r\n </div>\r\n <div\r\n [style.height]=\"chartConfiguration.svgHeight\"\r\n id=\"verticalstackedchartcontainer\"\r\n #verticalstackedchartcontainer\r\n class=\"lib-chart-svg\"\r\n ></div>\r\n</div>\r\n", styles: [".lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-weight:400;letter-spacing:0px;color:#000;opacity:1;font-size:1.2em}.lib-axis-group-label{font-size:.85em;font-weight:600;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:0px;color:#000;opacity:1}.dots{font-size:10px}.inline__display{display:flex;justify-content:space-around;padding-top:2%}.verticalbar__text{font-style:normal;font-variant:normal;font-weight:400;font-size:13px;line-height:20px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:0px;opacity:1}.lib-line-label-item{display:inline-block!important;font-size:.85em;margin-right:10px;font-weight:600}.lib-line-label-wrapper-vertical{display:flex;justify-content:center}.target-display{font-size:12px;line-height:14.52px;font-weight:700;text-transform:uppercase;float:right}.title{background-color:#d9d9d9;height:40px;display:flex;flex-direction:column;justify-content:center;align-items:center;border-radius:3px;line-height:1}.title-top-text{color:var(--font-color)!important;font-size:14px;font-weight:600}.title-bar-name{color:var(--font-color)!important;font-size:17px;font-weight:700;text-transform:capitalize}.title-bottom-text{color:var(--font-color)!important;font-size:12px}.zoomIcons-holder{display:flex;align-items:center;margin-right:15px}.zoomIcons{border:.5px solid #b6b6b6;cursor:pointer;display:flex;justify-content:center;align-items:center;width:30px;height:30px;color:var(--color)!important}.zoom-active{background-color:#2d5ca0;opacity:1}.zoom-inactive{background-color:#d9d9d9;opacity:.5}@media (max-width: 575px){.lib-xaxis-labels-texts-drilldown{writing-mode:sideways-lr}}@media screen and (min-width: 1024px) and (min-height: 400px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:10px!important}.dots{font-size:10px!important}}@media screen and (min-width: 1024px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:10px!important}.dots{font-size:10px!important}}@media screen and (min-width: 1024px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:10px!important}.dots{font-size:10px!important}}@media screen and (min-width: 1366px) and (min-height: 400px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:12px!important}.dots{font-size:12px!important}}@media screen and (min-width: 1366px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:12px!important}.dots{font-size:12px!important}}@media screen and (min-width: 1366px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:12px!important}.dots{font-size:12px!important}}@media screen and (min-width: 1920px) and (min-height: 400px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:14px!important}.dots{font-size:14px!important}}@media screen and (min-width: 1920px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:14px!important}.dots{font-size:14px!important}}@media screen and (min-width: 1920px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:14px!important}.dots{font-size:14px!important}}@media screen and (min-width: 2560px) and (min-height: 500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:16px!important}.dots{font-size:16px!important}}@media screen and (min-width: 2560px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:16px!important}.dots{font-size:16px!important}}@media screen and (min-width: 2560px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:16px!important}}.bottom__text{position:absolute!important;bottom:0!important;display:flex!important;justify-content:center!important;align-items:center!important;width:100%!important}.box__heightwidth{opacity:1;height:10px;width:10px;border:none!important;border-radius:50%}.label__text{margin-right:10px;display:flex;justify-content:center;align-items:center;font-style:normal;font-variant:normal;font-weight:400;font-size:10px;line-height:13px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif;letter-spacing:.2px;color:#707070!important}.lib-verticalstack-labels-ontop-weklycharts{font-style:normal;font-variant:normal;font-weight:700;font-size:10px;line-height:11px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.05px;text-anchor:middle;fill:#000}.lib-verticalstack-title-ontop{font-style:normal;font-variant:normal;font-size:14px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.05px;text-anchor:middle;fill:#000}.marginLeft-20{margin-left:20px}.flex-inline{display:flex;justify-content:center;align-items:center;font-size:14px}\n", ".lib-chart-wrapper{width:100%;height:100%;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;background:#fff 0% 0% no-repeat padding-box;position:relative}.lib-chart-wrapper-wo-shadow{width:100%;height:100%;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto}.lib-chart-wrapper:hover .chart-header-v1:not(.header-no-background){background-color:#2e3640}.lib-chart-wrapper:hover .chart-header-v1:not(.header-no-background) .chart-title{color:#fff}.lib-chart-svg{width:100%}.lib-chart-header{text-align:center;background-color:#052340;color:#fff;width:100%;height:17%;word-spacing:.5px;line-height:1.8;font-weight:700;padding-top:2%;letter-spacing:0;font-size:1.2em}.lib-donut-chart-footer{width:100%;text-align:right}.lib-donut-label-text{font-size:.9em;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-weight:400;letter-spacing:0px;color:#000;opacity:1}.lib-donut-label-icon{display:inline-block;width:10px;height:10px;margin-right:20px;border-radius:3px}.lib-donut-label-item{font-weight:400;font-size:.85em;color:#2f2f2f}.lib-donut-justified-label-wrapper{width:100%;display:inline-block;text-align:center;list-style-type:none}.lib-donut-justified-label-item{font-weight:400;font-size:.85em;color:#2f2f2f;display:inline-block;text-align:left;padding:0 10px}.lib-donut-justified-label-icon{display:inline-block;width:10px;height:10px;margin-right:5px;border-radius:3px}.lib-no-background{background:none!important}.lib-display-hidden{display:none}.lib-ylabel-weeklyCharts{font-style:normal;font-variant:normal;font-weight:800;font-size:10px;line-height:12px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.07px;text-transform:capitalize;color:#000}.lib-data-labels-weeklycharts{font-style:normal;font-variant:normal;font-weight:400;font-size:12px;line-height:14px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.06px;color:#000}.lib-data-labels-angled-weeklycharts{font-style:normal;font-variant:normal;font-weight:800;font-size:9.5px;line-height:11px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:.4px;text-anchor:start}.lib-xaxis-labels-texts-weeklycharts{font-style:normal;font-variant:normal;font-weight:800;font-size:10px;line-height:11px;letter-spacing:-.05px;fill:#000}.lib-xaxis-labels-texts-drilldown{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:14px;letter-spacing:-1px;color:#000;opacity:1;text-transform:capitalize}.lib-white-space-nowrap{white-space:nowrap}.lib-xaxis-labels-texts-drilldown-alt{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:10px;letter-spacing:0px;color:#000;opacity:1;text-transform:capitalize}.lib-yaxis-labels-texts-drilldown{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:14px;letter-spacing:0px;color:#000!important;opacity:1}.lib-ylabel-drilldowncharts,.lib-xlabel-drilldowncharts{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:16px;letter-spacing:-.1px;color:#000!important;opacity:1}.lib-donut-justified-label-icon-drilldown{display:inline-block;width:14px;height:14px;margin-right:10px;border-radius:50%}.marginright-2{margin-right:2%}.margintop-5{margin-top:5%}.width-100{width:100%}.float-right{float:right}.marginBottom-10{margin-bottom:10px}.header-alt{align-items:center;margin-bottom:10px}input::placeholder{font-size:20px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:0px;color:#000;opacity:1}.padding-5{padding:5px}.hidden{visibility:hidden}.font-weight-bold{font-weight:900}.textalign-center{text-align:center}.cursor-pointer{cursor:pointer}.cursor-default{cursor:default}.font-weight-600{font-weight:600}.marginRight-15{margin-right:15px}.marginRight-20{margin-right:20px}.switch{position:relative;display:inline-block;width:46px;height:24px;margin-left:5px;margin-right:5px}.switch input{opacity:0;width:0;height:0}.slider{position:absolute;cursor:pointer;inset:0;background-color:#2d5ca0;-webkit-transition:.4s;transition:.4s}.slider:before{position:absolute;content:\"\";height:18px;width:18px;right:3px;bottom:3px;background-color:#fff;-webkit-transition:.4s;transition:.4s}.slider.round{border-radius:18px}.slider.round:before{border-radius:50%}.slider1{position:absolute;cursor:pointer;inset:0;background-color:#015ba2cf;-webkit-transition:.4s;transition:.4s}.slider1:before{position:absolute;content:\"\";height:18px;width:18px;left:3px;bottom:3px;background-color:#fff;-webkit-transition:.4s;transition:.4s}.slider1.round1{border-radius:18px}.slider1.round1:before{border-radius:50%}.lib-display-flex{display:flex}.lib-align-items-center{align-items:center}.lib-flex-direction-column{flex-direction:column}.lib-justify-content-space-between{justify-content:space-between}.lib-justify-content-space-around{justify-content:space-around}.lib-justify-content-center{justify-content:center}.lib-justify-content-start{justify-content:start}.lib-justify-content-end{justify-content:end}.lib-ml-20{margin-left:20px}.lib-position-absolute{position:absolute}.lib-z-index-9{z-index:9}.marginright-3{margin-right:3px}@media (min-height: 900px){.lib-chart-wrapper{border-radius:8px}.header-font-size-1{font-size:18px!important}.font-size-1{font-size:14px!important}.font-size-2{font-size:16px!important}.font-size-3{font-size:14px!important}.font-size-4{font-size:22px!important}.font-size-5{font-size:24px!important}}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.ResizedDirective, selector: "[resized]", outputs: ["resized"] }, { kind: "component", type: ChartHeaderV2Component, selector: "lib-chart-header-v2", inputs: ["chartData", "chartConfiguration"], outputs: ["clickEvent", "zoomInZoomOutClick"] }, { kind: "component", type: ChartHeaderV3Component, selector: "lib-chart-header-v3", inputs: ["chartData", "chartConfiguration"], outputs: ["compareByFilterSelection", "zoomInZoomOutClick"] }], encapsulation: i0.ViewEncapsulation.None }); }
8078
7446
  }
8079
7447
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: HorizontalBarsWithScrollZoomComponent, decorators: [{
8080
7448
  type: Component,
8081
- args: [{ selector: 'lib-horizontal-bars-with-scroll-zoom', encapsulation: ViewEncapsulation.None, template: "<meta http-equiv=\"CACHE-CONTROL\" content=\"NO-CACHE\" />\r\n<meta http-equiv=\"EXPIRES\" content=\"Sat, 01 Jun 2004 11:12:01 GMT\" />\r\n<div\r\n #verticalstackedcontainer\r\n class=\"lib-chart-wrapper\"\r\n [ngClass]=\"{ 'lib-no-background': isTransparentBackground }\"\r\n style=\"background-color: var(--card-bg);\"\r\n\r\n (resized)=\"onResized($event)\"\r\n>\r\n <div class=\"header-alt\" *ngIf=\"!isHeaderVisible\">\r\n <lib-chart-header-v2\r\n [chartData]=\"chartData\"\r\n [chartConfiguration]=\"chartConfiguration\"\r\n (clickEvent)=\"handleClick($event)\"\r\n ></lib-chart-header-v2>\r\n\r\n <!-- <span *ngIf=\"chartConfiguration.isComparebyDropdownVisible\">\r\n <lib-dropdown></lib-dropdown>\r\n </span> -->\r\n <lib-chart-header-v3\r\n [chartData]=\"chartData\"\r\n [chartConfiguration]=\"chartConfiguration\"\r\n (compareByFilterSelection)=\"handleCompareByFilterSelection($event)\"\r\n (zoomInZoomOutClick)=\"handleZoominZoomoutClick($event)\"\r\n ></lib-chart-header-v3>\r\n </div>\r\n <div\r\n [style.height]=\"chartConfiguration.svgHeight\"\r\n id=\"verticalstackedchartcontainer\"\r\n #verticalstackedchartcontainer\r\n class=\"lib-chart-svg\"\r\n ></div>\r\n</div>\r\n", styles: [".lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-weight:400;letter-spacing:0px;color:#000;opacity:1;font-size:1.2em}.lib-axis-group-label{font-size:.85em;font-weight:600;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:0px;color:#000;opacity:1}.dots{font-size:10px}.inline__display{display:flex;justify-content:space-around;padding-top:2%}.verticalbar__text{font-style:normal;font-variant:normal;font-weight:400;font-size:13px;line-height:20px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:0px;opacity:1}.lib-line-label-item{display:inline-block!important;font-size:.85em;margin-right:10px;font-weight:600}.lib-line-label-wrapper-vertical{display:flex;justify-content:center}.target-display{font-size:12px;line-height:14.52px;font-weight:700;text-transform:uppercase;float:right}.title{background-color:#d9d9d9;height:40px;display:flex;flex-direction:column;justify-content:center;align-items:center;border-radius:3px;line-height:1}.title-top-text{color:var(--font-color)!important;font-size:14px;font-weight:600}.title-bar-name{color:var(--font-color)!important;font-size:17px;font-weight:700;text-transform:capitalize}.title-bottom-text{color:var(--font-color)!important;font-size:12px}.zoomIcons-holder{display:flex;align-items:center;margin-right:15px}.zoomIcons{border:.5px solid #b6b6b6;cursor:pointer;display:flex;justify-content:center;align-items:center;width:30px;height:30px;color:var(--color)!important}.zoom-active{background-color:#2d5ca0;opacity:1}.zoom-inactive{background-color:#d9d9d9;opacity:.5}@media (max-width: 575px){.lib-xaxis-labels-texts-drilldown{writing-mode:sideways-lr}}@media screen and (min-width: 1024px) and (min-height: 400px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:10px!important}.dots{font-size:10px!important}}@media screen and (min-width: 1024px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:10px!important}.dots{font-size:10px!important}}@media screen and (min-width: 1024px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:10px!important}.dots{font-size:10px!important}}@media screen and (min-width: 1366px) and (min-height: 400px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:12px!important}.dots{font-size:12px!important}}@media screen and (min-width: 1366px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:12px!important}.dots{font-size:12px!important}}@media screen and (min-width: 1366px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:12px!important}.dots{font-size:12px!important}}@media screen and (min-width: 1920px) and (min-height: 400px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:14px!important}.dots{font-size:14px!important}}@media screen and (min-width: 1920px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:14px!important}.dots{font-size:14px!important}}@media screen and (min-width: 1920px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:14px!important}.dots{font-size:14px!important}}@media screen and (min-width: 2560px) and (min-height: 500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:16px!important}.dots{font-size:16px!important}}@media screen and (min-width: 2560px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:16px!important}.dots{font-size:16px!important}}@media screen and (min-width: 2560px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:16px!important}}.bottom__text{position:absolute!important;bottom:0!important;display:flex!important;justify-content:center!important;align-items:center!important;width:100%!important}.box__heightwidth{opacity:1;height:10px;width:10px;border:none!important;border-radius:50%}.label__text{margin-right:10px;display:flex;justify-content:center;align-items:center;font-style:normal;font-variant:normal;font-weight:400;font-size:10px;line-height:13px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif;letter-spacing:.2px;color:#707070!important}.lib-verticalstack-labels-ontop-weklycharts{font-style:normal;font-variant:normal;font-weight:700;font-size:10px;line-height:11px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.05px;text-anchor:middle;fill:#000}.lib-verticalstack-title-ontop{font-style:normal;font-variant:normal;font-size:14px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.05px;text-anchor:middle;fill:#000}.marginLeft-20{margin-left:20px}.flex-inline{display:flex;justify-content:center;align-items:center;font-size:14px}\n", ".lib-chart-wrapper{width:100%;height:100%;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;background:#fff 0% 0% no-repeat padding-box;position:relative}.lib-chart-wrapper-wo-shadow{width:100%;height:100%;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto}.lib-chart-wrapper:hover .chart-header-v1:not(.header-no-background){background-color:#2e3640}.lib-chart-wrapper:hover .chart-header-v1:not(.header-no-background) .chart-title{color:#fff}.lib-chart-svg{width:100%}.lib-chart-header{text-align:center;background-color:#052340;color:#fff;width:100%;height:17%;word-spacing:.5px;line-height:1.8;font-weight:700;padding-top:2%;letter-spacing:0;font-size:1.2em}.lib-donut-chart-footer{width:100%;text-align:right}.lib-donut-label-text{font-size:.9em;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-weight:400;letter-spacing:0px;color:#000;opacity:1}.lib-donut-label-icon{display:inline-block;width:10px;height:10px;margin-right:20px;border-radius:3px}.lib-donut-label-item{font-weight:400;font-size:.85em;color:#2f2f2f}.lib-donut-justified-label-wrapper{width:100%;display:inline-block;text-align:center;list-style-type:none}.lib-donut-justified-label-item{font-weight:400;font-size:.85em;color:#2f2f2f;display:inline-block;text-align:left;padding:0 10px}.lib-donut-justified-label-icon{display:inline-block;width:10px;height:10px;margin-right:5px;border-radius:3px}.lib-no-background{background:none!important}.lib-display-hidden{display:none}.lib-ylabel-weeklyCharts{font-style:normal;font-variant:normal;font-weight:800;font-size:10px;line-height:12px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.07px;text-transform:capitalize;color:#000}.lib-data-labels-weeklycharts{font-style:normal;font-variant:normal;font-weight:400;font-size:12px;line-height:14px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.06px;color:#000}.lib-data-labels-angled-weeklycharts{font-style:normal;font-variant:normal;font-weight:800;font-size:9.5px;line-height:11px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:.4px;text-anchor:start}.lib-xaxis-labels-texts-weeklycharts{font-style:normal;font-variant:normal;font-weight:800;font-size:10px;line-height:11px;letter-spacing:-.05px;fill:#000}.lib-xaxis-labels-texts-drilldown{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:14px;letter-spacing:-1px;color:#000;opacity:1;text-transform:capitalize}.lib-white-space-nowrap{white-space:nowrap}.lib-xaxis-labels-texts-drilldown-alt{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:10px;letter-spacing:0px;color:#000;opacity:1;text-transform:capitalize}.lib-yaxis-labels-texts-drilldown{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:14px;letter-spacing:0px;color:#000!important;opacity:1}.lib-ylabel-drilldowncharts,.lib-xlabel-drilldowncharts{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:16px;letter-spacing:-.1px;color:#000!important;opacity:1}.lib-donut-justified-label-icon-drilldown{display:inline-block;width:14px;height:14px;margin-right:10px;border-radius:50%}.marginright-2{margin-right:2%}.margintop-5{margin-top:5%}.width-100{width:100%}.float-right{float:right}.marginBottom-10{margin-bottom:10px}.header-alt{align-items:center;margin-bottom:10px}input::placeholder{font-size:20px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:0px;color:#000;opacity:1}.padding-5{padding:5px}.hidden{visibility:hidden}.font-weight-bold{font-weight:900}.textalign-center{text-align:center}.cursor-pointer{cursor:pointer}.cursor-default{cursor:default}.font-weight-600{font-weight:600}.marginRight-15{margin-right:15px}.marginRight-20{margin-right:20px}.switch{position:relative;display:inline-block;width:46px;height:24px;margin-left:5px;margin-right:5px}.switch input{opacity:0;width:0;height:0}.slider{position:absolute;cursor:pointer;inset:0;background-color:#2d5ca0;-webkit-transition:.4s;transition:.4s}.slider:before{position:absolute;content:\"\";height:18px;width:18px;right:3px;bottom:3px;background-color:#fff;-webkit-transition:.4s;transition:.4s}.slider.round{border-radius:18px}.slider.round:before{border-radius:50%}.slider1{position:absolute;cursor:pointer;inset:0;background-color:#015ba2cf;-webkit-transition:.4s;transition:.4s}.slider1:before{position:absolute;content:\"\";height:18px;width:18px;left:3px;bottom:3px;background-color:#fff;-webkit-transition:.4s;transition:.4s}.slider1.round1{border-radius:18px}.slider1.round1:before{border-radius:50%}.lib-display-flex{display:flex}.lib-align-items-center{align-items:center}.lib-flex-direction-column{flex-direction:column}.lib-justify-content-space-between{justify-content:space-between}.lib-justify-content-space-around{justify-content:space-around}.lib-justify-content-center{justify-content:center}.lib-justify-content-start{justify-content:start}.lib-justify-content-end{justify-content:end}.lib-ml-20{margin-left:20px}.lib-position-absolute{position:absolute}.lib-z-index-9{z-index:9}.marginright-3{margin-right:3px}@media (min-height: 900px){.lib-chart-wrapper{border-radius:8px}.header-font-size-1{font-size:18px!important}.font-size-1{font-size:14px!important}.font-size-2{font-size:16px!important}.font-size-3{font-size:14px!important}.font-size-4{font-size:22px!important}.font-size-5{font-size:24px!important}}\n"] }]
7449
+ args: [{ selector: 'lib-horizontal-bars-with-scroll-zoom', encapsulation: ViewEncapsulation.None, template: "<meta http-equiv=\"CACHE-CONTROL\" content=\"NO-CACHE\" />\r\n<meta http-equiv=\"EXPIRES\" content=\"Sat, 01 Jun 2004 11:12:01 GMT\" />\r\n<div\r\n #verticalstackedcontainer\r\n class=\"lib-chart-wrapper\"\r\n [ngClass]=\"{ 'lib-no-background': isTransparentBackground }\"\r\n style=\"background-color: var(--card-bg);\"\r\n\r\n (resized)=\"onResized($event)\"\r\n>\r\n <div class=\"header-alt\" *ngIf=\"!isHeaderVisible\">\r\n <lib-chart-header-v2\r\n [chartData]=\"chartData\"\r\n [chartConfiguration]=\"chartConfiguration\"\r\n (clickEvent)=\"handleClick($event)\"\r\n ></lib-chart-header-v2>\r\n\r\n <lib-chart-header-v3\r\n [chartData]=\"chartData\"\r\n [chartConfiguration]=\"chartConfiguration\"\r\n (compareByFilterSelection)=\"handleCompareByFilterSelection($event)\"\r\n (zoomInZoomOutClick)=\"handleZoominZoomoutClick($event)\"\r\n ></lib-chart-header-v3>\r\n </div>\r\n <div\r\n [style.height]=\"chartConfiguration.svgHeight\"\r\n id=\"verticalstackedchartcontainer\"\r\n #verticalstackedchartcontainer\r\n class=\"lib-chart-svg\"\r\n ></div>\r\n</div>\r\n", styles: [".lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-weight:400;letter-spacing:0px;color:#000;opacity:1;font-size:1.2em}.lib-axis-group-label{font-size:.85em;font-weight:600;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:0px;color:#000;opacity:1}.dots{font-size:10px}.inline__display{display:flex;justify-content:space-around;padding-top:2%}.verticalbar__text{font-style:normal;font-variant:normal;font-weight:400;font-size:13px;line-height:20px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:0px;opacity:1}.lib-line-label-item{display:inline-block!important;font-size:.85em;margin-right:10px;font-weight:600}.lib-line-label-wrapper-vertical{display:flex;justify-content:center}.target-display{font-size:12px;line-height:14.52px;font-weight:700;text-transform:uppercase;float:right}.title{background-color:#d9d9d9;height:40px;display:flex;flex-direction:column;justify-content:center;align-items:center;border-radius:3px;line-height:1}.title-top-text{color:var(--font-color)!important;font-size:14px;font-weight:600}.title-bar-name{color:var(--font-color)!important;font-size:17px;font-weight:700;text-transform:capitalize}.title-bottom-text{color:var(--font-color)!important;font-size:12px}.zoomIcons-holder{display:flex;align-items:center;margin-right:15px}.zoomIcons{border:.5px solid #b6b6b6;cursor:pointer;display:flex;justify-content:center;align-items:center;width:30px;height:30px;color:var(--color)!important}.zoom-active{background-color:#2d5ca0;opacity:1}.zoom-inactive{background-color:#d9d9d9;opacity:.5}@media (max-width: 575px){.lib-xaxis-labels-texts-drilldown{writing-mode:sideways-lr}}@media screen and (min-width: 1024px) and (min-height: 400px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:10px!important}.dots{font-size:10px!important}}@media screen and (min-width: 1024px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:10px!important}.dots{font-size:10px!important}}@media screen and (min-width: 1024px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:10px!important}.dots{font-size:10px!important}}@media screen and (min-width: 1366px) and (min-height: 400px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:12px!important}.dots{font-size:12px!important}}@media screen and (min-width: 1366px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:12px!important}.dots{font-size:12px!important}}@media screen and (min-width: 1366px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:12px!important}.dots{font-size:12px!important}}@media screen and (min-width: 1920px) and (min-height: 400px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:14px!important}.dots{font-size:14px!important}}@media screen and (min-width: 1920px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:14px!important}.dots{font-size:14px!important}}@media screen and (min-width: 1920px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:14px!important}.dots{font-size:14px!important}}@media screen and (min-width: 2560px) and (min-height: 500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:16px!important}.dots{font-size:16px!important}}@media screen and (min-width: 2560px) and (min-height: 1000px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:16px!important}.dots{font-size:16px!important}}@media screen and (min-width: 2560px) and (min-height: 1500px){.lib-stacked-y-axis-text text,.lib-stacked-x-axis-text text{font-size:16px!important}}.bottom__text{position:absolute!important;bottom:0!important;display:flex!important;justify-content:center!important;align-items:center!important;width:100%!important}.box__heightwidth{opacity:1;height:10px;width:10px;border:none!important;border-radius:50%}.label__text{margin-right:10px;display:flex;justify-content:center;align-items:center;font-style:normal;font-variant:normal;font-weight:400;font-size:10px;line-height:13px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif;letter-spacing:.2px;color:#707070!important}.lib-verticalstack-labels-ontop-weklycharts{font-style:normal;font-variant:normal;font-weight:700;font-size:10px;line-height:11px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.05px;text-anchor:middle;fill:#000}.lib-verticalstack-title-ontop{font-style:normal;font-variant:normal;font-size:14px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.05px;text-anchor:middle;fill:#000}.marginLeft-20{margin-left:20px}.flex-inline{display:flex;justify-content:center;align-items:center;font-size:14px}\n", ".lib-chart-wrapper{width:100%;height:100%;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;background:#fff 0% 0% no-repeat padding-box;position:relative}.lib-chart-wrapper-wo-shadow{width:100%;height:100%;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto}.lib-chart-wrapper:hover .chart-header-v1:not(.header-no-background){background-color:#2e3640}.lib-chart-wrapper:hover .chart-header-v1:not(.header-no-background) .chart-title{color:#fff}.lib-chart-svg{width:100%}.lib-chart-header{text-align:center;background-color:#052340;color:#fff;width:100%;height:17%;word-spacing:.5px;line-height:1.8;font-weight:700;padding-top:2%;letter-spacing:0;font-size:1.2em}.lib-donut-chart-footer{width:100%;text-align:right}.lib-donut-label-text{font-size:.9em;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-weight:400;letter-spacing:0px;color:#000;opacity:1}.lib-donut-label-icon{display:inline-block;width:10px;height:10px;margin-right:20px;border-radius:3px}.lib-donut-label-item{font-weight:400;font-size:.85em;color:#2f2f2f}.lib-donut-justified-label-wrapper{width:100%;display:inline-block;text-align:center;list-style-type:none}.lib-donut-justified-label-item{font-weight:400;font-size:.85em;color:#2f2f2f;display:inline-block;text-align:left;padding:0 10px}.lib-donut-justified-label-icon{display:inline-block;width:10px;height:10px;margin-right:5px;border-radius:3px}.lib-no-background{background:none!important}.lib-display-hidden{display:none}.lib-ylabel-weeklyCharts{font-style:normal;font-variant:normal;font-weight:800;font-size:10px;line-height:12px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.07px;text-transform:capitalize;color:#000}.lib-data-labels-weeklycharts{font-style:normal;font-variant:normal;font-weight:400;font-size:12px;line-height:14px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:-.06px;color:#000}.lib-data-labels-angled-weeklycharts{font-style:normal;font-variant:normal;font-weight:800;font-size:9.5px;line-height:11px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:.4px;text-anchor:start}.lib-xaxis-labels-texts-weeklycharts{font-style:normal;font-variant:normal;font-weight:800;font-size:10px;line-height:11px;letter-spacing:-.05px;fill:#000}.lib-xaxis-labels-texts-drilldown{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:14px;letter-spacing:-1px;color:#000;opacity:1;text-transform:capitalize}.lib-white-space-nowrap{white-space:nowrap}.lib-xaxis-labels-texts-drilldown-alt{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:10px;letter-spacing:0px;color:#000;opacity:1;text-transform:capitalize}.lib-yaxis-labels-texts-drilldown{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:14px;letter-spacing:0px;color:#000!important;opacity:1}.lib-ylabel-drilldowncharts,.lib-xlabel-drilldowncharts{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;font-size:16px;letter-spacing:-.1px;color:#000!important;opacity:1}.lib-donut-justified-label-icon-drilldown{display:inline-block;width:14px;height:14px;margin-right:10px;border-radius:50%}.marginright-2{margin-right:2%}.margintop-5{margin-top:5%}.width-100{width:100%}.float-right{float:right}.marginBottom-10{margin-bottom:10px}.header-alt{align-items:center;margin-bottom:10px}input::placeholder{font-size:20px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto;letter-spacing:0px;color:#000;opacity:1}.padding-5{padding:5px}.hidden{visibility:hidden}.font-weight-bold{font-weight:900}.textalign-center{text-align:center}.cursor-pointer{cursor:pointer}.cursor-default{cursor:default}.font-weight-600{font-weight:600}.marginRight-15{margin-right:15px}.marginRight-20{margin-right:20px}.switch{position:relative;display:inline-block;width:46px;height:24px;margin-left:5px;margin-right:5px}.switch input{opacity:0;width:0;height:0}.slider{position:absolute;cursor:pointer;inset:0;background-color:#2d5ca0;-webkit-transition:.4s;transition:.4s}.slider:before{position:absolute;content:\"\";height:18px;width:18px;right:3px;bottom:3px;background-color:#fff;-webkit-transition:.4s;transition:.4s}.slider.round{border-radius:18px}.slider.round:before{border-radius:50%}.slider1{position:absolute;cursor:pointer;inset:0;background-color:#015ba2cf;-webkit-transition:.4s;transition:.4s}.slider1:before{position:absolute;content:\"\";height:18px;width:18px;left:3px;bottom:3px;background-color:#fff;-webkit-transition:.4s;transition:.4s}.slider1.round1{border-radius:18px}.slider1.round1:before{border-radius:50%}.lib-display-flex{display:flex}.lib-align-items-center{align-items:center}.lib-flex-direction-column{flex-direction:column}.lib-justify-content-space-between{justify-content:space-between}.lib-justify-content-space-around{justify-content:space-around}.lib-justify-content-center{justify-content:center}.lib-justify-content-start{justify-content:start}.lib-justify-content-end{justify-content:end}.lib-ml-20{margin-left:20px}.lib-position-absolute{position:absolute}.lib-z-index-9{z-index:9}.marginright-3{margin-right:3px}@media (min-height: 900px){.lib-chart-wrapper{border-radius:8px}.header-font-size-1{font-size:18px!important}.font-size-1{font-size:14px!important}.font-size-2{font-size:16px!important}.font-size-3{font-size:14px!important}.font-size-4{font-size:22px!important}.font-size-5{font-size:24px!important}}\n"] }]
8082
7450
  }], ctorParameters: () => [], propDecorators: { containerElt: [{
8083
7451
  type: ViewChild,
8084
7452
  args: ['verticalstackedchartcontainer', { static: true }]