@designsystem-se/af 35.4.1-beta.5 → 35.4.1-beta.6

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.
@@ -391,189 +391,33 @@ const barChart = class {
391
391
  return 'barGroup' + key.replace(/[^A-Z0-9]+/gi, '');
392
392
  };
393
393
  this.updateBars = (fromLoading) => {
394
- this.barChartContainer
394
+ this.barSelection = this.barChartContainer.select('.interactiveElements')
395
395
  .selectAll('.barGroup')
396
396
  .data(this.mappedData)
397
- .join((enter) => {
398
- var _a, _b;
399
- const tempSelection = enter
400
- .append('g')
401
- .attr('class', 'barGroup')
402
- .attr('id', (d) => 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, ''));
403
- tempSelection
404
- .append('rect')
405
- .attr('class', 'bar')
406
- .style('cursor', 'pointer')
407
- .attr('ry', 4)
408
- .attr('rx', 4)
409
- .attr('y', (d) => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
410
- ? this.yScale(d.key)
411
- : this.dims.height - this.margin.bottom)
412
- .attr('x', (d) => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
413
- ? 2
414
- : this.xScale(d.key))
415
- .attr('width', () => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
416
- ? 0
417
- : this.xScale.bandwidth())
418
- .attr('height', () => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
419
- ? this.yScale.bandwidth()
420
- : 0)
421
- .on('mouseenter', this.hover)
422
- .on('mouseleave', this.hoverOut)
423
- .on('click', this.openTooltip)
424
- .transition()
425
- .duration(this.defaultDuration)
426
- .ease(linear.polyInOut)
427
- .attr('width', this.widthFunction)
428
- .attr('y', this.yFunction)
429
- .attr('height', this.heightFunction)
430
- .attr('fill', '#00005a');
431
- if (!((_b = (_a = this.chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels))
432
- return tempSelection;
433
- tempSelection
434
- .append('text')
435
- .text((d) => d.value.toLocaleString())
436
- .attr('class', 'barText')
437
- .attr('font-size', this.fontSize)
438
- .attr('font-weight', '600')
439
- .attr('text-anchor', 'end')
440
- .style('pointer-events', 'none')
441
- .attr('y', (d) => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
442
- ? this.yScale(d.key) + this.yScale.bandwidth() / 2
443
- : this.dims.height - this.margin.bottom)
444
- .attr('x', (d) => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
445
- ? 2
446
- : this.xScale(d.key) + this.xScale.bandwidth() / 2)
447
- .transition()
448
- .duration(this.defaultDuration)
449
- .ease(linear.polyInOut)
450
- .attr('font-size', this.fontSize)
451
- .attr('font-weight', '600')
452
- .attr('x', (d) => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
453
- ? this.xScale(d.value)
454
- : this.xScale(d.key) + this.xScale.bandwidth() / 2)
455
- .attr('y', (d) => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
456
- ? this.yScale(d.key) + this.yScale.bandwidth() / 2
457
- : this.yScale(d.value))
458
- .attr('text-anchor', (d) => {
459
- if (this.afVariation === typographyVariation_enum.BarChartVariation.Vertical)
460
- return 'middle';
461
- return this.xScale(d.value) < d.len + this.tickPadding * 2
462
- ? 'start'
463
- : 'end';
464
- })
465
- .attr('dx', (d) => {
466
- if (this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal)
467
- return this.xScale(d.value) < d.len + this.tickPadding * 2
468
- ? this.tickPadding
469
- : -this.tickPadding;
470
- return 0;
471
- })
472
- .attr('fill', (d) => {
473
- if (this.afVariation === typographyVariation_enum.BarChartVariation.Vertical)
474
- return 'black';
475
- return this.xScale(d.value) < d.len + this.tickPadding * 2
476
- ? 'black'
477
- : 'white';
478
- })
479
- .attr('dy', () => this.afVariation == typographyVariation_enum.BarChartVariation.Horizontal
480
- ? '0.35em'
481
- : '-0.25em')
482
- .style('pointer-events', 'none')
483
- .attrTween('text', (d, i, nodelist) => {
484
- const oldnum = parseFloat(nodelist[i].textContent.replace(/\s/g, ''))
485
- ? parseFloat(nodelist[i].textContent.replace(/\s/g, ''))
486
- : 0;
487
- const interpolatedValue = linear.interpolate(oldnum, d.value);
488
- return (t) => (nodelist[i].textContent = parseInt(interpolatedValue(t)).toLocaleString(undefined, this.numberFormat));
489
- });
490
- return tempSelection;
491
- }, (update) => {
492
- // Update ids to bars
493
- update.attr('id', (d) => 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, ''));
494
- // Mouse interaction to updated loading bars
495
- if (fromLoading) {
496
- update
497
- .select('rect')
498
- .on('mouseenter', this.hover)
499
- .on('mouseleave', this.hoverOut)
500
- .on('click', this.openTooltip)
501
- .attr('x', this.xFunction)
502
- .attr('y', (d) => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
503
- ? this.yScale(d.key)
504
- : this.dims.height - this.margin.bottom)
505
- .attr('width', this.widthFunction)
506
- .attr('height', () => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
507
- ? this.yScale.bandwidth()
508
- : 0)
509
- .attr('fill', '#00005a')
510
- .transition()
511
- .duration(this.defaultDuration)
512
- .ease(linear.polyInOut)
513
- .attr('y', this.yFunction)
514
- .attr('height', this.heightFunction)
515
- .on('end', () => this.barChartObserver.observe(this.chartDiv)); // Reset barchartObserver
516
- }
517
- else {
518
- update
519
- .select('rect')
520
- .transition()
521
- .duration(this.defaultDuration)
522
- .ease(linear.polyInOut)
523
- .attr('x', this.xFunction)
524
- .attr('y', this.yFunction)
525
- .attr('width', this.widthFunction)
526
- .attr('height', this.heightFunction)
527
- .attr('fill', '#00005a');
528
- }
529
- return update
530
- .select('text')
531
- .style('display', () => { var _a, _b; return ((_b = (_a = this.chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels) ? null : 'none'; })
532
- .transition()
533
- .duration(this.defaultDuration)
534
- .ease(linear.polyInOut)
535
- .attr('font-size', this.fontSize)
536
- .attr('font-weight', '600')
537
- .attr('y', (d) => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
538
- ? this.yScale(d.key) + this.yScale.bandwidth() / 2
539
- : this.yScale(d.value))
540
- .attr('x', (d) => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
541
- ? this.xScale(d.value)
542
- : this.xScale(d.key) + this.xScale.bandwidth() / 2)
543
- .attr('text-anchor', (d) => {
544
- if (this.afVariation === typographyVariation_enum.BarChartVariation.Vertical)
545
- return 'middle';
546
- return this.xScale(d.value) < d.len + this.tickPadding * 2
547
- ? 'start'
548
- : 'end';
549
- })
550
- .attr('dx', (d) => {
551
- if (this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal)
552
- return this.xScale(d.value) < d.len + this.tickPadding * 2
553
- ? this.tickPadding
554
- : -this.tickPadding;
555
- return 0;
556
- })
557
- .attr('fill', (d) => {
558
- if (this.afVariation === typographyVariation_enum.BarChartVariation.Vertical)
559
- return 'black';
560
- return this.xScale(d.value) < d.len + this.tickPadding * 2
561
- ? 'black'
562
- : 'white';
563
- })
564
- .attr('dy', () => this.afVariation == typographyVariation_enum.BarChartVariation.Horizontal
565
- ? '0.35em'
566
- : '-0.25em')
567
- .style('pointer-events', 'none')
568
- .attrTween('text', (d, i, nodelist) => {
569
- const oldnum = parseFloat(nodelist[i].textContent.replace(/\s/g, ''))
570
- ? parseFloat(nodelist[i].textContent.replace(/\s/g, ''))
571
- : 0;
572
- const interpolatedValue = linear.interpolate(oldnum, d.value);
573
- return (t) => (nodelist[i].textContent = parseInt(interpolatedValue(t)).toLocaleString(undefined, this.numberFormat));
574
- });
575
- }, (exit) => exit.remove());
576
- this.barSelection = this.barChartContainer.selectAll('rect');
397
+ .join('g')
398
+ .attr('class', 'barGroup')
399
+ .attr('id', (d) => this.barGroupID(d.key));
400
+ this.barSelection.selectAll('.bar')
401
+ .data((d) => {
402
+ return d.series;
403
+ })
404
+ .join('rect')
405
+ .attr('class', 'bar')
406
+ .style('cursor', 'pointer')
407
+ .attr('x', this.xFunction)
408
+ .attr('y', this.yFunction)
409
+ .attr('ry', 4)
410
+ .attr('rx', 4)
411
+ .attr('width', this.widthFunction)
412
+ .attr('height', this.heightFunction)
413
+ .attr('fill', (d) => this.colorFunction(d.serie))
414
+ .on('mouseenter', this.hover)
415
+ .on('mouseleave', this.hoverOut)
416
+ .on('click', this.openTooltip);
417
+ if (fromLoading) {
418
+ this.initLegend();
419
+ }
420
+ this.barSelection = this.barChartContainer.selectAll('.barGroup');
577
421
  this.textSelection = this.barChartContainer.selectAll('.barText');
578
422
  };
579
423
  // Setting position of text according to bar size
@@ -612,7 +456,7 @@ const barChart = class {
612
456
  };
613
457
  this.reshapeData = () => {
614
458
  const toReturn = [];
615
- if (this.loading || !this.chartData) {
459
+ if (!this.chartData) {
616
460
  this.placeholderTicks.forEach((key) => {
617
461
  const tick = { key: key, series: [] };
618
462
  tick.series.push({
@@ -1259,6 +1103,7 @@ const barChart = class {
1259
1103
  // Hide unusable components
1260
1104
  linear.select(this.titleDiv)
1261
1105
  .append(this.afHeadingLevel)
1106
+ .attr('class', 'loadingHeader')
1262
1107
  .html(`${text._t.loading}...`);
1263
1108
  this.initYAxis(true);
1264
1109
  this.initXAxis(true);
@@ -1307,14 +1152,17 @@ const barChart = class {
1307
1152
  this.xAxisHandle.attr('transform', `translate(0,${this.dims.height - this.margin.bottom})`);
1308
1153
  }
1309
1154
  const animateBars = () => {
1310
- this.barChartContainer.selectAll('.barGroup').remove();
1155
+ this.barChartContainer.selectAll('.interactiveElements').remove();
1311
1156
  this.barSelection = this.barChartContainer
1157
+ .append('g')
1158
+ .attr('class', 'interactiveElements')
1159
+ .style('isolation', 'isolate')
1312
1160
  .selectAll('barGroup')
1313
1161
  .data(this.mappedData)
1314
1162
  .join('g')
1315
1163
  .attr('class', 'barGroup')
1316
- .attr('id', (d) => 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, ''));
1317
- this.barSelection.selectAll('.barGroup')
1164
+ .attr('id', (d) => this.barGroupID(d.key));
1165
+ this.barSelection.selectAll('bar')
1318
1166
  .data((d) => {
1319
1167
  return d.series;
1320
1168
  })
@@ -1336,7 +1184,7 @@ const barChart = class {
1336
1184
  .attr('y', this.yFunction)
1337
1185
  .attr('height', this.heightFunction);
1338
1186
  this.barChartContainer.selectAll('.bar')
1339
- .transition()
1187
+ .transition('animateBar')
1340
1188
  .duration(400)
1341
1189
  .ease(linear.linear$1)
1342
1190
  .delay((...[, i]) => i * 150 + 400)
@@ -1351,8 +1199,8 @@ const barChart = class {
1351
1199
  };
1352
1200
  const flattenBars = () => {
1353
1201
  this.barChartContainer
1354
- .selectAll('rect')
1355
- .transition()
1202
+ .selectAll('.bar')
1203
+ .transition('animateBar')
1356
1204
  .duration(200)
1357
1205
  .ease(linear.linear$1)
1358
1206
  .attr('y', (d) => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
@@ -1588,10 +1436,11 @@ const barChart = class {
1588
1436
  ]);
1589
1437
  this.setNamedTicks(true);
1590
1438
  // Stop animation
1591
- this.barSelection.selectAll('.barGroup').on('end', null);
1439
+ this.barChartContainer.selectAll('.barGroup').on('end', null);
1440
+ linear.select(this.titleDiv).select('.loadingHeader').remove();
1592
1441
  this.loading = false;
1593
- this.barSelection
1594
- .transition()
1442
+ this.barChartContainer.selectAll('.bar').interrupt('animateBar');
1443
+ this.barChartContainer.selectAll('.bar').transition()
1595
1444
  .duration(this.defaultDuration)
1596
1445
  .attr('y', (d) => this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal
1597
1446
  ? this.yScale(d.key)
@@ -1781,7 +1630,7 @@ const barChart = class {
1781
1630
  <span style="display:block;margin-top:0.25rem;font-size:0.875rem;color:var(--digi--global--color--neutral--grayscale--darkest-3)">${this.chartData.infoText}</span></p>`;
1782
1631
  }
1783
1632
  }
1784
- return (index.h(index.Host, { key: '78d96a495f4d362eb0f599ee48f79465ae6e6f0c', ref: (el) => (this.host = el) }, index.h("svg", { key: '39537403f0811e8090fc1c95a97bfa6b682df1c5', xmlns: "http://www.w3.org/2000/svg", width: "0", height: "0" }, index.h("defs", { key: '29a015c3dd10fe55948ebc41835aa04eae31a9ff' }, index.h("pattern", { key: '0f48268bb9e065e0cf2c7d85a3602a66552b87ce', id: "prognosis", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, index.h("line", { key: 'fc24757af401e96fa228135bbbf17232bff16210', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.evalColorVar(this.colorPalettes[0]), "stroke-width": "8" })), index.h("pattern", { key: 'e779819d8986d0d23dc799bfe208cac5d0f31211', id: "prognosisInactive", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, index.h("line", { key: '767468e01325e2bd2d5847b9e72f70d421f9fd58', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.evalColorVar('--digi--color--background--secondary-accent'), "stroke-width": "8" })), index.h("pattern", { key: '63772f52b5ed106d7cbece41143e932301f87bc5', id: "prognosisHighlight", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, index.h("line", { key: '4b89cfdb16e55f992cf7a9e6bcdf94528c7f4706', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.adjustColor(this.colorFunction(0), 50), "stroke-width": "8" })))), index.h("div", { key: 'd20cc02f768d7a19302b8ed5982f03fff5d82370', class: "topWrapper", ref: (el) => (this.titleDiv = el) }, index.h("digi-typography", { key: '200a0918a84e054e3579cd7d14854c51bb1fb49c', class: "chartTitle", innerHTML: heading }), index.h("digi-button", { key: '0241efd1a7e114a74d08fb2d9dcc3243765e2c67', class: "buttonWrapper tableButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.activateTable, afAriaLabel: `Visa tabell ${((_b = this.chartData) === null || _b === void 0 ? void 0 : _b.title) ? (_c = this.chartData) === null || _c === void 0 ? void 0 : _c.title.toLowerCase() : ''}` }, index.h("digi-icon-table", { key: '8d3cecf7d3abd7f32c24634e11da3608ba6e1aa8', slot: "icon" }), "Visa tabell"), index.h("digi-button", { key: 'da15d792de3403b50828e7b951fdb73e213baa9f', style: { display: 'none' }, class: "buttonWrapper chartButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.reInitChart, afAriaLabel: `Visa diagram ${((_d = this.chartData) === null || _d === void 0 ? void 0 : _d.title) ? (_e = this.chartData) === null || _e === void 0 ? void 0 : _e.title.toLowerCase() : ''}` }, index.h("digi-icon-chart", { key: '05cc0d7e638469f3cd60a4ad0fd93c16aaef1748', slot: "icon" }), "Visa diagram"), index.h("div", { key: 'e83745a86bcb781a970c0caf1177c3b3c7406a13', class: "scChartStatus", role: "status", ref: (el) => (this.status = el) })), index.h("div", { key: '8b99b1365bcacccf51a7352c1385d54781ffb227', class: "svgWrap", ref: (el) => (this.chartDiv = el) }, index.h("div", { key: '9eeb41124c07587a7e9b2cad5fe6597716ec905b', class: "chartTooltip", id: this.afId }, index.h("div", { key: '19f4428ae23fc9861b6743ef4617a2a5a48c3d02', class: "tooltipHead" }, index.h("digi-icon-x", { key: 'abb1b56f8d9449aa0fe16bacbf0b8ef8d10f94b7', class: "tooltipClose" })), index.h("div", { key: '67be9c846f0b0d5fcbae4b49e3a6266a58709c92', class: "tooltipBody" }), this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal ? (index.h("digi-icon-caret-up", { class: "caret" })) : (index.h("digi-icon-caret-down", { class: "caret" })))), index.h("div", { key: 'bd56f13ab74501c24279f66a62e879ec25fc72e9', class: "legendWrap", ref: (el) => (this.legendDiv = el) }, index.h("div", { key: '12089dd98e1e62198ed7a2e054bb454567cc220a', class: "legend" })), index.h("div", { key: '05c1f726446185113b0bf39e7c2e2cf6bbaba376', class: "table", ref: (el) => (this.tableDiv = el) }, ' ')));
1633
+ return (index.h(index.Host, { key: '2e011f2838668e9d58a6b4442e2832b6e1bac21b', ref: (el) => (this.host = el) }, index.h("svg", { key: 'a91c7bc7ed311fd10f0014d382daf46d97524087', xmlns: "http://www.w3.org/2000/svg", width: "0", height: "0" }, index.h("defs", { key: 'b28ad4ff2f0029eecd3a7b220d97ae81c646f6d0' }, index.h("pattern", { key: '2bb838607089932d089c05fdb568e06782cd6ef6', id: "prognosis", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, index.h("line", { key: '4eca3d7dbb9cd2d47bc6367a8f07808ba3767902', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.evalColorVar(this.colorPalettes[0]), "stroke-width": "8" })), index.h("pattern", { key: '87585e674cc45c2496650eb5309f4eee34f89b3a', id: "prognosisInactive", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, index.h("line", { key: '42bfe1a59192f618e60486105e919b2569fef753', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.evalColorVar('--digi--color--background--secondary-accent'), "stroke-width": "8" })), index.h("pattern", { key: '2ab36682ad76783cda635db815fc9f5f542fab21', id: "prognosisHighlight", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, index.h("line", { key: 'd5b93bf96f259cdf093a3e61c38ef61bbfd565ba', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.adjustColor(this.colorFunction(0), 50), "stroke-width": "8" })))), index.h("div", { key: 'f94c18afa372d176500c2d3844212df29c83f16b', class: "topWrapper", ref: (el) => (this.titleDiv = el) }, index.h("digi-typography", { key: '68dca23f7fd92f024f0b3d7eebc7b7214e636090', class: "chartTitle", innerHTML: heading }), index.h("digi-button", { key: '98d6ade579584a998a1d3e246168f42b19bd277f', class: "buttonWrapper tableButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.activateTable, afAriaLabel: `Visa tabell ${((_b = this.chartData) === null || _b === void 0 ? void 0 : _b.title) ? (_c = this.chartData) === null || _c === void 0 ? void 0 : _c.title.toLowerCase() : ''}` }, index.h("digi-icon-table", { key: '36d1e6f12b90215ba6ce00b814573616772820e7', slot: "icon" }), "Visa tabell"), index.h("digi-button", { key: 'c94200814deba4524301e7f2c07ad57e94b6381d', style: { display: 'none' }, class: "buttonWrapper chartButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.reInitChart, afAriaLabel: `Visa diagram ${((_d = this.chartData) === null || _d === void 0 ? void 0 : _d.title) ? (_e = this.chartData) === null || _e === void 0 ? void 0 : _e.title.toLowerCase() : ''}` }, index.h("digi-icon-chart", { key: 'ba94cf5a4ad7e4272d78f1965cd63eee99eb9f8f', slot: "icon" }), "Visa diagram"), index.h("div", { key: 'be79a632683428a30d01a96bf41f1e446b019061', class: "scChartStatus", role: "status", ref: (el) => (this.status = el) })), index.h("div", { key: 'd3644914ab02ae8cb8a054a1d4c90dc854fdaede', class: "svgWrap", ref: (el) => (this.chartDiv = el) }, index.h("div", { key: '6cb1113d71b8cd9ec156d351dc4ea402cdf3f372', class: "chartTooltip", id: this.afId }, index.h("div", { key: '0c601e94970dd3563bec5bfe070a3e02fd339124', class: "tooltipHead" }, index.h("digi-icon-x", { key: 'a478d1013f6630767b03029f4491222bc35dc118', class: "tooltipClose" })), index.h("div", { key: '04de1b3898023ef79ec8c69e501d107d8039351d', class: "tooltipBody" }), this.afVariation === typographyVariation_enum.BarChartVariation.Horizontal ? (index.h("digi-icon-caret-up", { class: "caret" })) : (index.h("digi-icon-caret-down", { class: "caret" })))), index.h("div", { key: '335550b9c1d64cadc9d72b14af008a2cffcfe58e', class: "legendWrap", ref: (el) => (this.legendDiv = el) }, index.h("div", { key: '1bd30ebd1a5c1c6342f102f7adc131c6f85bc8d8', class: "legend" })), index.h("div", { key: '69ddb91b0befa23212d518c27ed018f8c8912c06', class: "table", ref: (el) => (this.tableDiv = el) }, ' ')));
1785
1634
  }
1786
1635
  get hostElement() { return index.getElement(this); }
1787
1636
  static get watchers() { return {
@@ -267,189 +267,33 @@ export class barChart {
267
267
  return 'barGroup' + key.replace(/[^A-Z0-9]+/gi, '');
268
268
  };
269
269
  this.updateBars = (fromLoading) => {
270
- this.barChartContainer
270
+ this.barSelection = this.barChartContainer.select('.interactiveElements')
271
271
  .selectAll('.barGroup')
272
272
  .data(this.mappedData)
273
- .join((enter) => {
274
- var _a, _b;
275
- const tempSelection = enter
276
- .append('g')
277
- .attr('class', 'barGroup')
278
- .attr('id', (d) => 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, ''));
279
- tempSelection
280
- .append('rect')
281
- .attr('class', 'bar')
282
- .style('cursor', 'pointer')
283
- .attr('ry', 4)
284
- .attr('rx', 4)
285
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
286
- ? this.yScale(d.key)
287
- : this.dims.height - this.margin.bottom)
288
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
289
- ? 2
290
- : this.xScale(d.key))
291
- .attr('width', () => this.afVariation === BarChartVariation.Horizontal
292
- ? 0
293
- : this.xScale.bandwidth())
294
- .attr('height', () => this.afVariation === BarChartVariation.Horizontal
295
- ? this.yScale.bandwidth()
296
- : 0)
297
- .on('mouseenter', this.hover)
298
- .on('mouseleave', this.hoverOut)
299
- .on('click', this.openTooltip)
300
- .transition()
301
- .duration(this.defaultDuration)
302
- .ease(d3.easePolyInOut)
303
- .attr('width', this.widthFunction)
304
- .attr('y', this.yFunction)
305
- .attr('height', this.heightFunction)
306
- .attr('fill', '#00005a');
307
- if (!((_b = (_a = this.chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels))
308
- return tempSelection;
309
- tempSelection
310
- .append('text')
311
- .text((d) => d.value.toLocaleString())
312
- .attr('class', 'barText')
313
- .attr('font-size', this.fontSize)
314
- .attr('font-weight', '600')
315
- .attr('text-anchor', 'end')
316
- .style('pointer-events', 'none')
317
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
318
- ? this.yScale(d.key) + this.yScale.bandwidth() / 2
319
- : this.dims.height - this.margin.bottom)
320
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
321
- ? 2
322
- : this.xScale(d.key) + this.xScale.bandwidth() / 2)
323
- .transition()
324
- .duration(this.defaultDuration)
325
- .ease(d3.easePolyInOut)
326
- .attr('font-size', this.fontSize)
327
- .attr('font-weight', '600')
328
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
329
- ? this.xScale(d.value)
330
- : this.xScale(d.key) + this.xScale.bandwidth() / 2)
331
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
332
- ? this.yScale(d.key) + this.yScale.bandwidth() / 2
333
- : this.yScale(d.value))
334
- .attr('text-anchor', (d) => {
335
- if (this.afVariation === BarChartVariation.Vertical)
336
- return 'middle';
337
- return this.xScale(d.value) < d.len + this.tickPadding * 2
338
- ? 'start'
339
- : 'end';
340
- })
341
- .attr('dx', (d) => {
342
- if (this.afVariation === BarChartVariation.Horizontal)
343
- return this.xScale(d.value) < d.len + this.tickPadding * 2
344
- ? this.tickPadding
345
- : -this.tickPadding;
346
- return 0;
347
- })
348
- .attr('fill', (d) => {
349
- if (this.afVariation === BarChartVariation.Vertical)
350
- return 'black';
351
- return this.xScale(d.value) < d.len + this.tickPadding * 2
352
- ? 'black'
353
- : 'white';
354
- })
355
- .attr('dy', () => this.afVariation == BarChartVariation.Horizontal
356
- ? '0.35em'
357
- : '-0.25em')
358
- .style('pointer-events', 'none')
359
- .attrTween('text', (d, i, nodelist) => {
360
- const oldnum = parseFloat(nodelist[i].textContent.replace(/\s/g, ''))
361
- ? parseFloat(nodelist[i].textContent.replace(/\s/g, ''))
362
- : 0;
363
- const interpolatedValue = d3.interpolate(oldnum, d.value);
364
- return (t) => (nodelist[i].textContent = parseInt(interpolatedValue(t)).toLocaleString(undefined, this.numberFormat));
365
- });
366
- return tempSelection;
367
- }, (update) => {
368
- // Update ids to bars
369
- update.attr('id', (d) => 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, ''));
370
- // Mouse interaction to updated loading bars
371
- if (fromLoading) {
372
- update
373
- .select('rect')
374
- .on('mouseenter', this.hover)
375
- .on('mouseleave', this.hoverOut)
376
- .on('click', this.openTooltip)
377
- .attr('x', this.xFunction)
378
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
379
- ? this.yScale(d.key)
380
- : this.dims.height - this.margin.bottom)
381
- .attr('width', this.widthFunction)
382
- .attr('height', () => this.afVariation === BarChartVariation.Horizontal
383
- ? this.yScale.bandwidth()
384
- : 0)
385
- .attr('fill', '#00005a')
386
- .transition()
387
- .duration(this.defaultDuration)
388
- .ease(d3.easePolyInOut)
389
- .attr('y', this.yFunction)
390
- .attr('height', this.heightFunction)
391
- .on('end', () => this.barChartObserver.observe(this.chartDiv)); // Reset barchartObserver
392
- }
393
- else {
394
- update
395
- .select('rect')
396
- .transition()
397
- .duration(this.defaultDuration)
398
- .ease(d3.easePolyInOut)
399
- .attr('x', this.xFunction)
400
- .attr('y', this.yFunction)
401
- .attr('width', this.widthFunction)
402
- .attr('height', this.heightFunction)
403
- .attr('fill', '#00005a');
404
- }
405
- return update
406
- .select('text')
407
- .style('display', () => { var _a, _b; return ((_b = (_a = this.chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels) ? null : 'none'; })
408
- .transition()
409
- .duration(this.defaultDuration)
410
- .ease(d3.easePolyInOut)
411
- .attr('font-size', this.fontSize)
412
- .attr('font-weight', '600')
413
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
414
- ? this.yScale(d.key) + this.yScale.bandwidth() / 2
415
- : this.yScale(d.value))
416
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
417
- ? this.xScale(d.value)
418
- : this.xScale(d.key) + this.xScale.bandwidth() / 2)
419
- .attr('text-anchor', (d) => {
420
- if (this.afVariation === BarChartVariation.Vertical)
421
- return 'middle';
422
- return this.xScale(d.value) < d.len + this.tickPadding * 2
423
- ? 'start'
424
- : 'end';
425
- })
426
- .attr('dx', (d) => {
427
- if (this.afVariation === BarChartVariation.Horizontal)
428
- return this.xScale(d.value) < d.len + this.tickPadding * 2
429
- ? this.tickPadding
430
- : -this.tickPadding;
431
- return 0;
432
- })
433
- .attr('fill', (d) => {
434
- if (this.afVariation === BarChartVariation.Vertical)
435
- return 'black';
436
- return this.xScale(d.value) < d.len + this.tickPadding * 2
437
- ? 'black'
438
- : 'white';
439
- })
440
- .attr('dy', () => this.afVariation == BarChartVariation.Horizontal
441
- ? '0.35em'
442
- : '-0.25em')
443
- .style('pointer-events', 'none')
444
- .attrTween('text', (d, i, nodelist) => {
445
- const oldnum = parseFloat(nodelist[i].textContent.replace(/\s/g, ''))
446
- ? parseFloat(nodelist[i].textContent.replace(/\s/g, ''))
447
- : 0;
448
- const interpolatedValue = d3.interpolate(oldnum, d.value);
449
- return (t) => (nodelist[i].textContent = parseInt(interpolatedValue(t)).toLocaleString(undefined, this.numberFormat));
450
- });
451
- }, (exit) => exit.remove());
452
- this.barSelection = this.barChartContainer.selectAll('rect');
273
+ .join('g')
274
+ .attr('class', 'barGroup')
275
+ .attr('id', (d) => this.barGroupID(d.key));
276
+ this.barSelection.selectAll('.bar')
277
+ .data((d) => {
278
+ return d.series;
279
+ })
280
+ .join('rect')
281
+ .attr('class', 'bar')
282
+ .style('cursor', 'pointer')
283
+ .attr('x', this.xFunction)
284
+ .attr('y', this.yFunction)
285
+ .attr('ry', 4)
286
+ .attr('rx', 4)
287
+ .attr('width', this.widthFunction)
288
+ .attr('height', this.heightFunction)
289
+ .attr('fill', (d) => this.colorFunction(d.serie))
290
+ .on('mouseenter', this.hover)
291
+ .on('mouseleave', this.hoverOut)
292
+ .on('click', this.openTooltip);
293
+ if (fromLoading) {
294
+ this.initLegend();
295
+ }
296
+ this.barSelection = this.barChartContainer.selectAll('.barGroup');
453
297
  this.textSelection = this.barChartContainer.selectAll('.barText');
454
298
  };
455
299
  // Setting position of text according to bar size
@@ -488,7 +332,7 @@ export class barChart {
488
332
  };
489
333
  this.reshapeData = () => {
490
334
  const toReturn = [];
491
- if (this.loading || !this.chartData) {
335
+ if (!this.chartData) {
492
336
  this.placeholderTicks.forEach((key) => {
493
337
  const tick = { key: key, series: [] };
494
338
  tick.series.push({
@@ -1139,6 +983,7 @@ export class barChart {
1139
983
  // Hide unusable components
1140
984
  d3.select(this.titleDiv)
1141
985
  .append(this.afHeadingLevel)
986
+ .attr('class', 'loadingHeader')
1142
987
  .html(`${_t.loading}...`);
1143
988
  this.initYAxis(true);
1144
989
  this.initXAxis(true);
@@ -1187,14 +1032,17 @@ export class barChart {
1187
1032
  this.xAxisHandle.attr('transform', `translate(0,${this.dims.height - this.margin.bottom})`);
1188
1033
  }
1189
1034
  const animateBars = () => {
1190
- this.barChartContainer.selectAll('.barGroup').remove();
1035
+ this.barChartContainer.selectAll('.interactiveElements').remove();
1191
1036
  this.barSelection = this.barChartContainer
1037
+ .append('g')
1038
+ .attr('class', 'interactiveElements')
1039
+ .style('isolation', 'isolate')
1192
1040
  .selectAll('barGroup')
1193
1041
  .data(this.mappedData)
1194
1042
  .join('g')
1195
1043
  .attr('class', 'barGroup')
1196
- .attr('id', (d) => 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, ''));
1197
- this.barSelection.selectAll('.barGroup')
1044
+ .attr('id', (d) => this.barGroupID(d.key));
1045
+ this.barSelection.selectAll('bar')
1198
1046
  .data((d) => {
1199
1047
  return d.series;
1200
1048
  })
@@ -1216,7 +1064,7 @@ export class barChart {
1216
1064
  .attr('y', this.yFunction)
1217
1065
  .attr('height', this.heightFunction);
1218
1066
  this.barChartContainer.selectAll('.bar')
1219
- .transition()
1067
+ .transition('animateBar')
1220
1068
  .duration(400)
1221
1069
  .ease(d3.easeLinear)
1222
1070
  .delay((...[, i]) => i * 150 + 400)
@@ -1231,8 +1079,8 @@ export class barChart {
1231
1079
  };
1232
1080
  const flattenBars = () => {
1233
1081
  this.barChartContainer
1234
- .selectAll('rect')
1235
- .transition()
1082
+ .selectAll('.bar')
1083
+ .transition('animateBar')
1236
1084
  .duration(200)
1237
1085
  .ease(d3.easeLinear)
1238
1086
  .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
@@ -1469,10 +1317,11 @@ export class barChart {
1469
1317
  ]);
1470
1318
  this.setNamedTicks(true);
1471
1319
  // Stop animation
1472
- this.barSelection.selectAll('.barGroup').on('end', null);
1320
+ this.barChartContainer.selectAll('.barGroup').on('end', null);
1321
+ d3.select(this.titleDiv).select('.loadingHeader').remove();
1473
1322
  this.loading = false;
1474
- this.barSelection
1475
- .transition()
1323
+ this.barChartContainer.selectAll('.bar').interrupt('animateBar');
1324
+ this.barChartContainer.selectAll('.bar').transition()
1476
1325
  .duration(this.defaultDuration)
1477
1326
  .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
1478
1327
  ? this.yScale(d.key)
@@ -1662,7 +1511,7 @@ export class barChart {
1662
1511
  <span style="display:block;margin-top:0.25rem;font-size:0.875rem;color:var(--digi--global--color--neutral--grayscale--darkest-3)">${this.chartData.infoText}</span></p>`;
1663
1512
  }
1664
1513
  }
1665
- return (h(Host, { key: '78d96a495f4d362eb0f599ee48f79465ae6e6f0c', ref: (el) => (this.host = el) }, h("svg", { key: '39537403f0811e8090fc1c95a97bfa6b682df1c5', xmlns: "http://www.w3.org/2000/svg", width: "0", height: "0" }, h("defs", { key: '29a015c3dd10fe55948ebc41835aa04eae31a9ff' }, h("pattern", { key: '0f48268bb9e065e0cf2c7d85a3602a66552b87ce', id: "prognosis", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, h("line", { key: 'fc24757af401e96fa228135bbbf17232bff16210', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.evalColorVar(this.colorPalettes[0]), "stroke-width": "8" })), h("pattern", { key: 'e779819d8986d0d23dc799bfe208cac5d0f31211', id: "prognosisInactive", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, h("line", { key: '767468e01325e2bd2d5847b9e72f70d421f9fd58', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.evalColorVar('--digi--color--background--secondary-accent'), "stroke-width": "8" })), h("pattern", { key: '63772f52b5ed106d7cbece41143e932301f87bc5', id: "prognosisHighlight", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, h("line", { key: '4b89cfdb16e55f992cf7a9e6bcdf94528c7f4706', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.adjustColor(this.colorFunction(0), 50), "stroke-width": "8" })))), h("div", { key: 'd20cc02f768d7a19302b8ed5982f03fff5d82370', class: "topWrapper", ref: (el) => (this.titleDiv = el) }, h("digi-typography", { key: '200a0918a84e054e3579cd7d14854c51bb1fb49c', class: "chartTitle", innerHTML: heading }), h("digi-button", { key: '0241efd1a7e114a74d08fb2d9dcc3243765e2c67', class: "buttonWrapper tableButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.activateTable, afAriaLabel: `Visa tabell ${((_b = this.chartData) === null || _b === void 0 ? void 0 : _b.title) ? (_c = this.chartData) === null || _c === void 0 ? void 0 : _c.title.toLowerCase() : ''}` }, h("digi-icon-table", { key: '8d3cecf7d3abd7f32c24634e11da3608ba6e1aa8', slot: "icon" }), "Visa tabell"), h("digi-button", { key: 'da15d792de3403b50828e7b951fdb73e213baa9f', style: { display: 'none' }, class: "buttonWrapper chartButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.reInitChart, afAriaLabel: `Visa diagram ${((_d = this.chartData) === null || _d === void 0 ? void 0 : _d.title) ? (_e = this.chartData) === null || _e === void 0 ? void 0 : _e.title.toLowerCase() : ''}` }, h("digi-icon-chart", { key: '05cc0d7e638469f3cd60a4ad0fd93c16aaef1748', slot: "icon" }), "Visa diagram"), h("div", { key: 'e83745a86bcb781a970c0caf1177c3b3c7406a13', class: "scChartStatus", role: "status", ref: (el) => (this.status = el) })), h("div", { key: '8b99b1365bcacccf51a7352c1385d54781ffb227', class: "svgWrap", ref: (el) => (this.chartDiv = el) }, h("div", { key: '9eeb41124c07587a7e9b2cad5fe6597716ec905b', class: "chartTooltip", id: this.afId }, h("div", { key: '19f4428ae23fc9861b6743ef4617a2a5a48c3d02', class: "tooltipHead" }, h("digi-icon-x", { key: 'abb1b56f8d9449aa0fe16bacbf0b8ef8d10f94b7', class: "tooltipClose" })), h("div", { key: '67be9c846f0b0d5fcbae4b49e3a6266a58709c92', class: "tooltipBody" }), this.afVariation === BarChartVariation.Horizontal ? (h("digi-icon-caret-up", { class: "caret" })) : (h("digi-icon-caret-down", { class: "caret" })))), h("div", { key: 'bd56f13ab74501c24279f66a62e879ec25fc72e9', class: "legendWrap", ref: (el) => (this.legendDiv = el) }, h("div", { key: '12089dd98e1e62198ed7a2e054bb454567cc220a', class: "legend" })), h("div", { key: '05c1f726446185113b0bf39e7c2e2cf6bbaba376', class: "table", ref: (el) => (this.tableDiv = el) }, ' ')));
1514
+ return (h(Host, { key: '2e011f2838668e9d58a6b4442e2832b6e1bac21b', ref: (el) => (this.host = el) }, h("svg", { key: 'a91c7bc7ed311fd10f0014d382daf46d97524087', xmlns: "http://www.w3.org/2000/svg", width: "0", height: "0" }, h("defs", { key: 'b28ad4ff2f0029eecd3a7b220d97ae81c646f6d0' }, h("pattern", { key: '2bb838607089932d089c05fdb568e06782cd6ef6', id: "prognosis", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, h("line", { key: '4eca3d7dbb9cd2d47bc6367a8f07808ba3767902', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.evalColorVar(this.colorPalettes[0]), "stroke-width": "8" })), h("pattern", { key: '87585e674cc45c2496650eb5309f4eee34f89b3a', id: "prognosisInactive", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, h("line", { key: '42bfe1a59192f618e60486105e919b2569fef753', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.evalColorVar('--digi--color--background--secondary-accent'), "stroke-width": "8" })), h("pattern", { key: '2ab36682ad76783cda635db815fc9f5f542fab21', id: "prognosisHighlight", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, h("line", { key: 'd5b93bf96f259cdf093a3e61c38ef61bbfd565ba', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.adjustColor(this.colorFunction(0), 50), "stroke-width": "8" })))), h("div", { key: 'f94c18afa372d176500c2d3844212df29c83f16b', class: "topWrapper", ref: (el) => (this.titleDiv = el) }, h("digi-typography", { key: '68dca23f7fd92f024f0b3d7eebc7b7214e636090', class: "chartTitle", innerHTML: heading }), h("digi-button", { key: '98d6ade579584a998a1d3e246168f42b19bd277f', class: "buttonWrapper tableButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.activateTable, afAriaLabel: `Visa tabell ${((_b = this.chartData) === null || _b === void 0 ? void 0 : _b.title) ? (_c = this.chartData) === null || _c === void 0 ? void 0 : _c.title.toLowerCase() : ''}` }, h("digi-icon-table", { key: '36d1e6f12b90215ba6ce00b814573616772820e7', slot: "icon" }), "Visa tabell"), h("digi-button", { key: 'c94200814deba4524301e7f2c07ad57e94b6381d', style: { display: 'none' }, class: "buttonWrapper chartButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.reInitChart, afAriaLabel: `Visa diagram ${((_d = this.chartData) === null || _d === void 0 ? void 0 : _d.title) ? (_e = this.chartData) === null || _e === void 0 ? void 0 : _e.title.toLowerCase() : ''}` }, h("digi-icon-chart", { key: 'ba94cf5a4ad7e4272d78f1965cd63eee99eb9f8f', slot: "icon" }), "Visa diagram"), h("div", { key: 'be79a632683428a30d01a96bf41f1e446b019061', class: "scChartStatus", role: "status", ref: (el) => (this.status = el) })), h("div", { key: 'd3644914ab02ae8cb8a054a1d4c90dc854fdaede', class: "svgWrap", ref: (el) => (this.chartDiv = el) }, h("div", { key: '6cb1113d71b8cd9ec156d351dc4ea402cdf3f372', class: "chartTooltip", id: this.afId }, h("div", { key: '0c601e94970dd3563bec5bfe070a3e02fd339124', class: "tooltipHead" }, h("digi-icon-x", { key: 'a478d1013f6630767b03029f4491222bc35dc118', class: "tooltipClose" })), h("div", { key: '04de1b3898023ef79ec8c69e501d107d8039351d', class: "tooltipBody" }), this.afVariation === BarChartVariation.Horizontal ? (h("digi-icon-caret-up", { class: "caret" })) : (h("digi-icon-caret-down", { class: "caret" })))), h("div", { key: '335550b9c1d64cadc9d72b14af008a2cffcfe58e', class: "legendWrap", ref: (el) => (this.legendDiv = el) }, h("div", { key: '1bd30ebd1a5c1c6342f102f7adc131c6f85bc8d8', class: "legend" })), h("div", { key: '69ddb91b0befa23212d518c27ed018f8c8912c06', class: "table", ref: (el) => (this.tableDiv = el) }, ' ')));
1666
1515
  }
1667
1516
  static get is() { return "digi-bar-chart"; }
1668
1517
  static get encapsulation() { return "scoped"; }