@designsystem-se/af 35.4.0 → 35.4.1-beta.0

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.
Files changed (81) hide show
  1. package/components/digi-bar-chart.js +125 -110
  2. package/dist/cjs/digi-arbetsformedlingen.cjs.js +1 -1
  3. package/dist/cjs/{digi-button_24.cjs.entry.js → digi-bar-chart_27.cjs.entry.js} +1611 -47
  4. package/dist/cjs/digi-calendar-datepicker.cjs.entry.js +2 -2
  5. package/dist/cjs/digi-code-block_3.cjs.entry.js +2 -2
  6. package/dist/cjs/digi-dialog.cjs.entry.js +2 -2
  7. package/dist/cjs/digi-footer.cjs.entry.js +2 -2
  8. package/dist/cjs/digi-form-error-list.cjs.entry.js +2 -2
  9. package/dist/cjs/digi-form-receipt.cjs.entry.js +2 -2
  10. package/dist/cjs/digi-form-select-filter.cjs.entry.js +2 -2
  11. package/dist/cjs/digi-navigation-pagination.cjs.entry.js +2 -2
  12. package/dist/cjs/digi-notification-alert.cjs.entry.js +2 -2
  13. package/dist/cjs/digi-notification-error-page.cjs.entry.js +2 -2
  14. package/dist/cjs/digi-tools-feedback.cjs.entry.js +2 -2
  15. package/dist/cjs/digi-typography-heading-jumbo.cjs.entry.js +38 -0
  16. package/dist/cjs/digi-typography-preamble.cjs.entry.js +20 -0
  17. package/dist/cjs/index-7a477838.js +10 -14
  18. package/dist/cjs/index.cjs.js +20 -20
  19. package/dist/cjs/loader.cjs.js +1 -1
  20. package/dist/cjs/typography-heading-jumbo-variation.enum-8677e099.js +17 -0
  21. package/dist/cjs/{typography-variation.enum-9f56fd50.js → typography-variation.enum-8fd8bed4.js} +6 -16
  22. package/dist/collection/components/_chart/bar-chart/bar-chart.js +125 -110
  23. package/dist/digi-arbetsformedlingen/digi-arbetsformedlingen.esm.js +1 -1
  24. package/dist/digi-arbetsformedlingen/index.esm.js +1 -1
  25. package/dist/digi-arbetsformedlingen/p-044b32d7.entry.js +1 -0
  26. package/dist/digi-arbetsformedlingen/{p-e2330d9c.entry.js → p-1241d74a.entry.js} +1 -1
  27. package/dist/digi-arbetsformedlingen/{p-e54f5b28.entry.js → p-222a2b41.entry.js} +1 -1
  28. package/dist/digi-arbetsformedlingen/p-37377041.entry.js +1 -0
  29. package/dist/digi-arbetsformedlingen/p-3ae60edc.entry.js +1 -0
  30. package/dist/digi-arbetsformedlingen/p-431baa4e.entry.js +1 -0
  31. package/dist/digi-arbetsformedlingen/{p-0d35dc92.entry.js → p-56ca6c5c.entry.js} +1 -1
  32. package/dist/digi-arbetsformedlingen/{p-6559910e.entry.js → p-58f76475.entry.js} +1 -1
  33. package/dist/digi-arbetsformedlingen/{p-092d0e3e.entry.js → p-5a08f170.entry.js} +1 -1
  34. package/dist/digi-arbetsformedlingen/{p-e0db40e9.entry.js → p-69010d14.entry.js} +1 -1
  35. package/dist/digi-arbetsformedlingen/p-86eddf30.js +1 -0
  36. package/dist/digi-arbetsformedlingen/p-9f03b573.entry.js +1 -0
  37. package/dist/digi-arbetsformedlingen/p-a884ccf8.entry.js +1 -0
  38. package/dist/digi-arbetsformedlingen/{p-01f5f243.entry.js → p-c4cf1215.entry.js} +1 -1
  39. package/dist/digi-arbetsformedlingen/p-d1886fff.js +1 -0
  40. package/dist/digi-arbetsformedlingen/{p-5c7acd45.entry.js → p-e3bdf65a.entry.js} +1 -1
  41. package/dist/esm/digi-arbetsformedlingen.js +1 -1
  42. package/dist/esm/{digi-button_24.entry.js → digi-bar-chart_27.entry.js} +1608 -47
  43. package/dist/esm/digi-calendar-datepicker.entry.js +2 -2
  44. package/dist/esm/digi-code-block_3.entry.js +2 -2
  45. package/dist/esm/digi-dialog.entry.js +2 -2
  46. package/dist/esm/digi-footer.entry.js +2 -2
  47. package/dist/esm/digi-form-error-list.entry.js +2 -2
  48. package/dist/esm/digi-form-receipt.entry.js +2 -2
  49. package/dist/esm/digi-form-select-filter.entry.js +2 -2
  50. package/dist/esm/digi-navigation-pagination.entry.js +2 -2
  51. package/dist/esm/digi-notification-alert.entry.js +2 -2
  52. package/dist/esm/digi-notification-error-page.entry.js +2 -2
  53. package/dist/esm/digi-tools-feedback.entry.js +2 -2
  54. package/dist/esm/digi-typography-heading-jumbo.entry.js +34 -0
  55. package/dist/esm/digi-typography-preamble.entry.js +16 -0
  56. package/dist/esm/index-148a7577.js +10 -14
  57. package/dist/esm/index.js +2 -2
  58. package/dist/esm/loader.js +1 -1
  59. package/dist/esm/typography-heading-jumbo-variation.enum-eb737f1b.js +17 -0
  60. package/dist/esm/{typography-variation.enum-8ba40d15.js → typography-variation.enum-531cdf64.js} +7 -17
  61. package/dist/types/components/_chart/bar-chart/bar-chart.d.ts +9 -0
  62. package/hydrate/index.js +125 -110
  63. package/hydrate/index.mjs +125 -110
  64. package/package.json +1 -1
  65. package/dist/cjs/bar-chart-variation.enum-a4e866b6.js +0 -7
  66. package/dist/cjs/digi-bar-chart.cjs.entry.js +0 -1510
  67. package/dist/cjs/digi-icon-caret-down_2.cjs.entry.js +0 -53
  68. package/dist/cjs/digi-icon-chart_2.cjs.entry.js +0 -53
  69. package/dist/digi-arbetsformedlingen/p-07fd5ccf.entry.js +0 -1
  70. package/dist/digi-arbetsformedlingen/p-2422b0d1.entry.js +0 -1
  71. package/dist/digi-arbetsformedlingen/p-54a797ed.entry.js +0 -1
  72. package/dist/digi-arbetsformedlingen/p-a5c6e42e.entry.js +0 -1
  73. package/dist/digi-arbetsformedlingen/p-b22f09f1.entry.js +0 -1
  74. package/dist/digi-arbetsformedlingen/p-c1606b8a.entry.js +0 -1
  75. package/dist/digi-arbetsformedlingen/p-cb8e7e0a.entry.js +0 -1
  76. package/dist/digi-arbetsformedlingen/p-d2d0856f.js +0 -1
  77. package/dist/digi-arbetsformedlingen/p-dcdffb3c.js +0 -1
  78. package/dist/esm/bar-chart-variation.enum-97c0b47f.js +0 -7
  79. package/dist/esm/digi-bar-chart.entry.js +0 -1506
  80. package/dist/esm/digi-icon-caret-down_2.entry.js +0 -48
  81. package/dist/esm/digi-icon-chart_2.entry.js +0 -48
package/hydrate/index.mjs CHANGED
@@ -35697,6 +35697,9 @@ class barChart {
35697
35697
  // States
35698
35698
  this._loading = false;
35699
35699
  this._placeholderTicks = ['0', '1', '2', '3', '4', '5', '6', '7'];
35700
+ // Width of data at each tick, if we have two data series that have values att same tick, this will be 2 for example. defaults to 1;
35701
+ this.dataWidth = 1;
35702
+ this.barGap = 0;
35700
35703
  this._dims = {};
35701
35704
  this._margin = {
35702
35705
  bottom: 0,
@@ -35714,6 +35717,7 @@ class barChart {
35714
35717
  this.defaultDuration = 400;
35715
35718
  // Text and formats
35716
35719
  this.fontSize = '0.875rem';
35720
+ this.colorPalettes = ['--digi--color--background--brand-primary', '--digi--color--infographic--brand--primary', '--digi--color--background--sentiment--beta--primary', '--digi--color--text--interactive--visited', '--digi--color--icon--validation--error'];
35717
35721
  // Observer for watching size changes when in line chart mode
35718
35722
  this.barChartObserver = new ResizeObserver((entries) => {
35719
35723
  entries.forEach(() => {
@@ -35759,12 +35763,8 @@ class barChart {
35759
35763
  this._dims.width - this._margin.right - this._margin.left
35760
35764
  ]);
35761
35765
  this._barSelection
35762
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
35763
- ? 2
35764
- : this._xScale(d.key))
35765
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
35766
- ? this._xScale(d.value)
35767
- : this._xScale.bandwidth());
35766
+ .attr('x', this.xFunction)
35767
+ .attr('width', this.widthFunction);
35768
35768
  this.setValueTicks();
35769
35769
  };
35770
35770
  // Adding click listener for tool tip text
@@ -35853,7 +35853,7 @@ class barChart {
35853
35853
  this.updateBars = (fromLoading) => {
35854
35854
  this._barChartContainer
35855
35855
  .selectAll('.barGroup')
35856
- .data(this.reshapeData)
35856
+ .data(this.mappedData)
35857
35857
  .join((enter) => {
35858
35858
  var _a, _b;
35859
35859
  const tempSelection = enter
@@ -35884,17 +35884,9 @@ class barChart {
35884
35884
  .transition()
35885
35885
  .duration(this.defaultDuration)
35886
35886
  .ease(polyInOut)
35887
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
35888
- ? this._xScale(d.value)
35889
- : this._xScale.bandwidth())
35890
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
35891
- ? this._yScale(d.key)
35892
- : this._yScale(d.value))
35893
- .attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
35894
- ? this._yScale.bandwidth()
35895
- : this._dims.height -
35896
- this._margin.bottom -
35897
- this._yScale(d.value))
35887
+ .attr('width', this.widthFunction)
35888
+ .attr('y', this.yFunction)
35889
+ .attr('height', this.heightFunction)
35898
35890
  .attr('fill', '#00005a');
35899
35891
  if (!((_b = (_a = this._chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels))
35900
35892
  return tempSelection;
@@ -35966,15 +35958,11 @@ class barChart {
35966
35958
  .on('mouseenter', this.hover)
35967
35959
  .on('mouseleave', this.hoverOut)
35968
35960
  .on('click', this.openTooltip)
35969
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
35970
- ? 2
35971
- : this._xScale(d.key))
35961
+ .attr('x', this.xFunction)
35972
35962
  .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
35973
35963
  ? this._yScale(d.key)
35974
35964
  : this._dims.height - this._margin.bottom)
35975
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
35976
- ? this._xScale(d.value)
35977
- : this._xScale.bandwidth())
35965
+ .attr('width', this.widthFunction)
35978
35966
  .attr('height', () => this.afVariation === BarChartVariation.Horizontal
35979
35967
  ? this._yScale.bandwidth()
35980
35968
  : 0)
@@ -35982,14 +35970,8 @@ class barChart {
35982
35970
  .transition()
35983
35971
  .duration(this.defaultDuration)
35984
35972
  .ease(polyInOut)
35985
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
35986
- ? this._yScale(d.key)
35987
- : this._yScale(d.value))
35988
- .attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
35989
- ? this._yScale.bandwidth()
35990
- : this._dims.height -
35991
- this._margin.bottom -
35992
- this._yScale(d.value))
35973
+ .attr('y', this.yFunction)
35974
+ .attr('height', this.heightFunction)
35993
35975
  .on('end', () => this.barChartObserver.observe(this._chartDiv)); // Reset barchartObserver
35994
35976
  }
35995
35977
  else {
@@ -35998,20 +35980,10 @@ class barChart {
35998
35980
  .transition()
35999
35981
  .duration(this.defaultDuration)
36000
35982
  .ease(polyInOut)
36001
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
36002
- ? this._yScale(d.key)
36003
- : this._yScale(d.value))
36004
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
36005
- ? 2
36006
- : this._xScale(d.key))
36007
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
36008
- ? this._xScale(d.value)
36009
- : this._xScale.bandwidth())
36010
- .attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
36011
- ? this._yScale.bandwidth()
36012
- : this._dims.height -
36013
- this._margin.bottom -
36014
- this._yScale(d.value))
35983
+ .attr('x', this.xFunction)
35984
+ .attr('y', this.yFunction)
35985
+ .attr('width', this.widthFunction)
35986
+ .attr('height', this.heightFunction)
36015
35987
  .attr('fill', '#00005a');
36016
35988
  }
36017
35989
  return update
@@ -36102,37 +36074,67 @@ class barChart {
36102
36074
  const toReturn = [];
36103
36075
  if (this._loading) {
36104
36076
  this._placeholderTicks.forEach((key) => {
36105
- toReturn.push({
36077
+ const tick = { key: key, series: [] };
36078
+ tick.series.push({
36106
36079
  key: key,
36080
+ serie: '',
36107
36081
  value: Math.floor(Math.random() * (9 - 2 + 1) + 2),
36108
- len: '1'
36082
+ len: 0
36109
36083
  });
36084
+ toReturn.push(tick);
36110
36085
  });
36111
36086
  return toReturn;
36112
36087
  }
36113
36088
  this._chartData.data.xValueNames.forEach((key, index) => {
36114
- toReturn.push({
36115
- key: key,
36116
- value: this._chartData.data.series[0].yValues[index],
36117
- len: this.getTextSize(this._chartData.data.series[0].yValues[index].toLocaleString())
36089
+ const tick = { key: key, series: [] };
36090
+ this._chartData.data.series.forEach((serie) => {
36091
+ if (serie.yValues[index]) {
36092
+ tick.series.push({
36093
+ key: key,
36094
+ serie: serie.title,
36095
+ value: serie.yValues[index],
36096
+ len: serie.yValues[index] ? this.getTextSize(serie.yValues[index].toLocaleString()) : 0
36097
+ });
36098
+ }
36118
36099
  });
36100
+ toReturn.push(tick);
36119
36101
  });
36120
36102
  return toReturn;
36121
36103
  };
36122
36104
  this.adjustBarSize = () => {
36123
- this._barSelection
36124
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
36125
- ? this._yScale(d.key)
36126
- : this._yScale(d.value))
36127
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
36128
- ? 2
36129
- : this._xScale(d.key))
36130
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
36131
- ? this._xScale(d.value)
36132
- : this._xScale.bandwidth())
36133
- .attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
36134
- ? this._yScale.bandwidth()
36135
- : this._dims.height - this._margin.bottom - this._yScale(d.value));
36105
+ this._barSelection.selectAll('.bar')
36106
+ .attr('x', this.xFunction)
36107
+ .attr('y', this.yFunction)
36108
+ .attr('width', this.widthFunction)
36109
+ .attr('height', this.heightFunction);
36110
+ };
36111
+ // Handling x positioning of bars
36112
+ this.xFunction = (d, i) => {
36113
+ return this.afVariation === BarChartVariation.Horizontal
36114
+ ? (d.value > 0 ? this._xScale(0) : this._xScale(d.value))
36115
+ : this._xScale(d.key) + ((this._xScale.bandwidth() / this.dataWidth) * i + (this.barGap * i));
36116
+ };
36117
+ // Handling y positioning of bars
36118
+ this.yFunction = (d, i) => {
36119
+ if (!d.value)
36120
+ return 0;
36121
+ return this.afVariation === BarChartVariation.Horizontal
36122
+ ? this._yScale(d.key) + ((this._yScale.bandwidth() / this.dataWidth) * i + (this.barGap * i))
36123
+ : (d.value < 0 ? this._yScale(0) : this._yScale(d.value));
36124
+ };
36125
+ // Handling height for bars
36126
+ this.heightFunction = (d) => {
36127
+ if (!d.value)
36128
+ return 0;
36129
+ return this.afVariation === BarChartVariation.Horizontal
36130
+ ? this._yScale.bandwidth() / this.dataWidth - (this.barGap)
36131
+ : (d.value < 0 ? this._yScale(d.value) - this._yScale(0) : this._yScale(0) - this._yScale(d.value));
36132
+ };
36133
+ // Handling width for bars
36134
+ this.widthFunction = (d) => {
36135
+ return this.afVariation === BarChartVariation.Horizontal
36136
+ ? Math.abs(this._xScale(0) - this._xScale(d.value))
36137
+ : this._xScale.bandwidth() / this.dataWidth - (this.barGap);
36136
36138
  };
36137
36139
  // Resize table
36138
36140
  this.resizeTable = () => {
@@ -36372,16 +36374,16 @@ class barChart {
36372
36374
  select(event.target)
36373
36375
  .transition('hover')
36374
36376
  .duration(20)
36375
- .attr('fill', event.target.tagName === 'rect'
36376
- ? '#4C4C8B'
36377
- : 'var(--digi--color--text--link-hover)');
36377
+ .attr('fill', (d) => event.target.tagName === 'rect'
36378
+ ? `hsl(from ${this.colorFunction(d.serie)} h s calc(l + 10))`
36379
+ : 'var(--digi--color--background--interactive--hover--tertiary)');
36378
36380
  };
36379
36381
  // Removing highlight from bar
36380
36382
  this.hoverOut = (event) => {
36381
36383
  select(event.target)
36382
36384
  .transition('hover')
36383
36385
  .duration(this.defaultDuration)
36384
- .attr('fill', event.target.tagName === 'rect' ? '#00005a' : '#333333');
36386
+ .attr('fill', (d) => event.target.tagName === 'rect' ? this.colorFunction(d.serie) : '#333333');
36385
36387
  };
36386
36388
  this.openTooltip = (...[, d]) => {
36387
36389
  // If type is string, the user has clicked on a y-axis tick
@@ -36450,7 +36452,7 @@ class barChart {
36450
36452
  if (this.afVariation == BarChartVariation.Horizontal)
36451
36453
  this._tickWidth = this.getLargestText(this._xScale.ticks().map((tick) => tick.toLocaleString()));
36452
36454
  this.tickSizes();
36453
- this._barChartContainer.selectAll('.barGroup').data(this.reshapeData);
36455
+ this._barChartContainer.selectAll('.barGroup').data(this.mappedData);
36454
36456
  if ((_b = (_a = this._chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels)
36455
36457
  this._textSelection.remove();
36456
36458
  this.initBarText();
@@ -36521,6 +36523,14 @@ class barChart {
36521
36523
  this._chartData = data;
36522
36524
  else
36523
36525
  this._chartData = JSON.parse(data);
36526
+ this.mappedData = this.reshapeData();
36527
+ // checking for width of each tick
36528
+ this.mappedData.forEach((elem) => {
36529
+ if (elem.series.length > this.dataWidth)
36530
+ this.dataWidth = elem.series.length;
36531
+ });
36532
+ if (this.dataWidth > 1)
36533
+ this.barGap = 1;
36524
36534
  }
36525
36535
  initSvg() {
36526
36536
  var _a, _b, _c, _d, _e, _f, _g;
@@ -36640,7 +36650,7 @@ class barChart {
36640
36650
  this._barChartContainer.selectAll('.barGroup').remove();
36641
36651
  this._barSelection = this._barChartContainer
36642
36652
  .selectAll('barGroup')
36643
- .data(this.reshapeData)
36653
+ .data(this.mappedData)
36644
36654
  .join('g')
36645
36655
  .attr('class', 'barGroup')
36646
36656
  .attr('id', (d) => 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, '_'))
@@ -36651,26 +36661,17 @@ class barChart {
36651
36661
  .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
36652
36662
  ? this._yScale(d.key)
36653
36663
  : this._dims.height - this._margin.bottom)
36654
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
36655
- ? 2
36656
- : this._xScale(d.key))
36664
+ .attr('x', this.xFunction)
36657
36665
  .attr('ry', 4)
36658
36666
  .attr('rx', 4)
36659
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
36660
- ? this._xScale(d.value)
36661
- : this._xScale.bandwidth())
36667
+ .attr('width', this.widthFunction)
36662
36668
  .attr('height', () => 0)
36663
- //.attr('height', (d: any) => this.afVariation === BarChartVariation.Horizontal ? this._yScale.bandwidth() : (this._dims.height - this._margin.bottom) - this._yScale(d.value))
36664
36669
  .attr('fill', 'gray')
36665
36670
  .transition()
36666
36671
  .duration(400)
36667
36672
  .delay((...[, i]) => i * 150)
36668
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
36669
- ? this._yScale(d.key)
36670
- : this._yScale(d.value))
36671
- .attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
36672
- ? this._yScale.bandwidth()
36673
- : this._dims.height - this._margin.bottom - this._yScale(d.value));
36673
+ .attr('y', this.yFunction)
36674
+ .attr('height', this.heightFunction);
36674
36675
  this._barSelection
36675
36676
  .transition()
36676
36677
  .duration(400)
@@ -36760,7 +36761,7 @@ class barChart {
36760
36761
  if (this.afVariation === BarChartVariation.Horizontal) {
36761
36762
  this.setValueTicks();
36762
36763
  // Removing first tick, because it aligns with y-axis domain
36763
- this._xAxisHandle.select('.tick').select('line').remove();
36764
+ //this._xAxisHandle.select('.tick').select('line').remove();
36764
36765
  }
36765
36766
  else {
36766
36767
  if (!empty) {
@@ -36774,39 +36775,41 @@ class barChart {
36774
36775
  initBars() {
36775
36776
  this._barSelection = this._barChartContainer
36776
36777
  .selectAll('barGroup')
36777
- .data(this.reshapeData)
36778
+ .data(this.mappedData)
36778
36779
  .join('g')
36779
36780
  .attr('class', 'barGroup')
36780
- .attr('id', (d) => 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, '_'))
36781
- .append('rect')
36781
+ .attr('id', (d) => {
36782
+ return 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, '_');
36783
+ });
36784
+ this._barSelection.selectAll('.barGroup')
36785
+ .data((d) => {
36786
+ return d.series;
36787
+ })
36788
+ .join('rect')
36782
36789
  .attr('class', 'bar')
36783
- .style('cursor', 'pointer');
36784
- this._barSelection
36785
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
36786
- ? this._yScale(d.key)
36787
- : this._yScale(d.value))
36788
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
36789
- ? 2
36790
- : this._xScale(d.key))
36790
+ .style('cursor', 'pointer')
36791
+ .attr('x', this.xFunction)
36792
+ .attr('y', this.yFunction)
36791
36793
  .attr('ry', 4)
36792
36794
  .attr('rx', 4)
36793
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
36794
- ? this._xScale(d.value)
36795
- : this._xScale.bandwidth())
36796
- .attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
36797
- ? this._yScale.bandwidth()
36798
- : this._dims.height - this._margin.bottom - this._yScale(d.value))
36799
- .attr('fill', '#00005a')
36795
+ .attr('width', this.widthFunction)
36796
+ .attr('height', this.heightFunction)
36797
+ .attr('fill', (d) => this.colorFunction(d.serie))
36800
36798
  .on('mouseenter', this.hover)
36801
36799
  .on('mouseleave', this.hoverOut)
36802
36800
  .on('click', this.openTooltip);
36803
36801
  }
36804
36802
  initBarText() {
36803
+ var _a, _b;
36804
+ if (!((_b = (_a = this._chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels))
36805
+ return;
36805
36806
  this._textSelection = this._barChartContainer
36806
36807
  .selectAll('.barGroup')
36807
36808
  .append('text');
36808
36809
  this._textSelection
36809
- .text((d) => d.value.toLocaleString(undefined, this._numberFormat))
36810
+ .text((d) => {
36811
+ return d.value ? d.value.toLocaleString(undefined, this._numberFormat) : undefined;
36812
+ })
36810
36813
  .attr('class', 'barText')
36811
36814
  .attr('font-size', this.fontSize)
36812
36815
  .attr('font-weight', '600')
@@ -36944,6 +36947,18 @@ class barChart {
36944
36947
  }
36945
36948
  }
36946
36949
  }
36950
+ // Getting correct color given index or name of data serie
36951
+ colorFunction(input) {
36952
+ if (typeof input === 'number')
36953
+ return `var(${this.colorPalettes[input]})`;
36954
+ else {
36955
+ const index = this._chartData.data.series.findIndex((serie) => serie.title === input);
36956
+ if (index > 0)
36957
+ return `var(${this.colorPalettes[index]})`;
36958
+ else
36959
+ return `var(${this.colorPalettes[0]})`;
36960
+ }
36961
+ }
36947
36962
  // Resizing bar chart
36948
36963
  resize() {
36949
36964
  var _a;
@@ -37024,11 +37039,11 @@ class barChart {
37024
37039
  }
37025
37040
  // Not currently used
37026
37041
  /*get cssModifiers() {
37027
- return {
37028
- 'digi-bar-chart--vertical': this.afVariation == 'vertical',
37029
- 'digi-bar-chart--horizontal': this.afVariation == 'horizontal'
37030
- };
37031
- }*/
37042
+ return {
37043
+ 'digi-bar-chart--vertical': this.afVariation == 'vertical',
37044
+ 'digi-bar-chart--horizontal': this.afVariation == 'horizontal'
37045
+ };
37046
+ }*/
37032
37047
  // Returns pixelwidth of text given the current fontSize (costly function using .each)
37033
37048
  getTextSize(text) {
37034
37049
  const textWidth = [];
@@ -37098,7 +37113,7 @@ class barChart {
37098
37113
  <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>`;
37099
37114
  }
37100
37115
  }
37101
- return (hAsync(Host, { key: '7659fcc4817cdfb3f19f2bd11a41464c13b5e19e', ref: (el) => (this._host = el) }, hAsync("div", { key: '063611cf8dbb2554904d972ed3fc1f89d714772e', class: "topWrapper", ref: (el) => (this._titleDiv = el) }, hAsync("digi-typography", { key: 'ad58c43c2629e7b2b97e3ad1658646e5171b1531', class: "chartTitle", innerHTML: heading }), hAsync("digi-button", { key: '2234460c0ffab8e7d251f099f4f2d38e1e5ebede', 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() : ''}` }, hAsync("digi-icon-table", { key: 'b82a89d578d997ab878d44a2928e5e31773bd34f', slot: "icon" }), "Visa tabell"), hAsync("digi-button", { key: 'b5dc532f7655bd383d0dcf42f8851edbc81b448c', 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() : ''}` }, hAsync("digi-icon-chart", { key: 'f868d9fd2c37c247e8abdd59cf2b9342ad120fef', slot: "icon" }), "Visa diagram"), hAsync("div", { key: '6a0f7838d86a43b46d9a036ad935f50ebb2b523f', class: "scChartStatus", role: "status", ref: (el) => (this._status = el) })), hAsync("div", { key: '5f37b9eaf1030cd1d5b1b0360cdaaa61f953b624', class: "chartTooltip", id: this.afId }, hAsync("div", { key: 'a89608cb64620456a165ba4fb57db823870d2231', class: "tooltipBody" }), hAsync("digi-icon-x", { key: 'e842c2b42f6bc7d6dfdad1d1b8a7acb9f8df5a1a', class: "close" }), this.afVariation === BarChartVariation.Horizontal ? (hAsync("digi-icon-caret-up", null)) : (hAsync("digi-icon-caret-down", null))), hAsync("div", { key: 'f07154ab370a948016aa30a2547c4c9b25fae03b', ref: (el) => (this._chartDiv = el) }, " "), hAsync("div", { key: '385151df18d373779257040d298bf8c108184500', class: "legend", ref: (el) => (this._legendDiv = el) }), hAsync("div", { key: 'd5f07fc01a628aa2035a96d86621b6bab1e73f01', class: "table", ref: (el) => (this._tableDiv = el) }, ' ')));
37116
+ return (hAsync(Host, { key: 'a1e4aaa788766d54c691e95b7e70932b0e7d2b05', ref: (el) => (this._host = el) }, hAsync("div", { key: '2fac926d196acaa20ab5f438968e3c98c08dd104', class: "topWrapper", ref: (el) => (this._titleDiv = el) }, hAsync("digi-typography", { key: '16d8cbd0f03a2a2d24d3366ab1b3eaed797dd361', class: "chartTitle", innerHTML: heading }), hAsync("digi-button", { key: '22a93add4a7f1ea3965ce496f2b5cbf488b01314', 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() : ''}` }, hAsync("digi-icon-table", { key: '152938d206dc00e2fb88b52d332960cbeda2c045', slot: "icon" }), "Visa tabell"), hAsync("digi-button", { key: '66db213ee1c4cb169c7c257853a15a468bf2a83e', 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() : ''}` }, hAsync("digi-icon-chart", { key: 'ac4b8adad6ace97f50591cd39b8b0082d067f069', slot: "icon" }), "Visa diagram"), hAsync("div", { key: 'b28e00a40b5c1a2919146ec4815f23a14fdfac50', class: "scChartStatus", role: "status", ref: (el) => (this._status = el) })), hAsync("div", { key: '63f80744faa1d4b3d7d62bece3b5c446eda3ae7b', class: "chartTooltip", id: this.afId }, hAsync("div", { key: '8c9fa9388b9bfc071c4a594275159eb36a8ec43b', class: "tooltipBody" }), hAsync("digi-icon-x", { key: '252d12a937e5276381fa40ec3bb4e77c259da9c1', class: "close" }), this.afVariation === BarChartVariation.Horizontal ? (hAsync("digi-icon-caret-up", null)) : (hAsync("digi-icon-caret-down", null))), hAsync("div", { key: '9b70433c310882bd0a06784ca1fa21c5b2dd9e52', ref: (el) => (this._chartDiv = el) }, " "), hAsync("div", { key: '459e38448e29eea1fa7a10de7f3f1f06b6404eab', class: "legend", ref: (el) => (this._legendDiv = el) }), hAsync("div", { key: 'cc655054cb3c3688c75060ebbdf6c3f8ea4ad712', class: "table", ref: (el) => (this._tableDiv = el) }, ' ')));
37102
37117
  }
37103
37118
  get hostElement() { return getElement(this); }
37104
37119
  static get watchers() { return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@designsystem-se/af",
3
3
  "author": "Arbetsförmedlingen",
4
- "version": "35.4.0",
4
+ "version": "35.4.1-beta.0",
5
5
  "description": "Web Components for Digi Designsystem",
6
6
  "license": "Apache-2.0",
7
7
  "main": "./dist/index.cjs.js",
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- exports.BarChartVariation = void 0;
4
- (function (BarChartVariation) {
5
- BarChartVariation["Vertical"] = "vertical";
6
- BarChartVariation["Horizontal"] = "horizontal";
7
- })(exports.BarChartVariation || (exports.BarChartVariation = {}));