@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
@@ -12,6 +12,12 @@ var CalendarDatepickerValidation;
12
12
  CalendarDatepickerValidation["NEUTRAL"] = "neutral";
13
13
  })(CalendarDatepickerValidation || (CalendarDatepickerValidation = {}));
14
14
 
15
+ var BarChartVariation;
16
+ (function (BarChartVariation) {
17
+ BarChartVariation["Vertical"] = "vertical";
18
+ BarChartVariation["Horizontal"] = "horizontal";
19
+ })(BarChartVariation || (BarChartVariation = {}));
20
+
15
21
  var CodeBlockLanguage;
16
22
  (function (CodeBlockLanguage) {
17
23
  CodeBlockLanguage["JSON"] = "json";
@@ -253,26 +259,10 @@ var FeedbackVariation;
253
259
  FeedbackVariation["SECONDARY"] = "secondary";
254
260
  })(FeedbackVariation || (FeedbackVariation = {}));
255
261
 
256
- var TypographyHeadingJumboLevel;
257
- (function (TypographyHeadingJumboLevel) {
258
- TypographyHeadingJumboLevel["H1"] = "h1";
259
- TypographyHeadingJumboLevel["H2"] = "h2";
260
- TypographyHeadingJumboLevel["H3"] = "h3";
261
- TypographyHeadingJumboLevel["H4"] = "h4";
262
- TypographyHeadingJumboLevel["H5"] = "h5";
263
- TypographyHeadingJumboLevel["H6"] = "h6";
264
- })(TypographyHeadingJumboLevel || (TypographyHeadingJumboLevel = {}));
265
-
266
- var TypographyHeadingJumboVariation;
267
- (function (TypographyHeadingJumboVariation) {
268
- TypographyHeadingJumboVariation["PRIMARY"] = "primary";
269
- TypographyHeadingJumboVariation["SECONDARY"] = "secondary";
270
- })(TypographyHeadingJumboVariation || (TypographyHeadingJumboVariation = {}));
271
-
272
262
  var TypographyVariation;
273
263
  (function (TypographyVariation) {
274
264
  TypographyVariation["SMALL"] = "small";
275
265
  TypographyVariation["LARGE"] = "large";
276
266
  })(TypographyVariation || (TypographyVariation = {}));
277
267
 
278
- export { BadgeNotificationType as B, CalendarDatepickerValidation as C, DialogHeadingLevel as D, ErrorPageStatusCodes as E, FooterVariation as F, HeaderCenterContentWidth as H, InfoCardMultiContainerHeadingLevel as I, LayoutBlockContainer as L, NavigationVerticalMenuActiveIndicatorSize as N, TitleLogoVariation as T, CodeBlockLanguage as a, DialogSize as b, DialogVariation as c, FormErrorListHeadingLevel as d, FormRadiobuttonLayout as e, FormRadiobuttonValidation as f, FormRadiobuttonVariation as g, FormReceiptHeadingLevel as h, FormReceiptType as i, FormReceiptVariation as j, FormSelectFilterValidation as k, InfoCardMultiHeadingLevel as l, InfoCardMultiVariation as m, InfoCardHeadingLevel as n, LayoutContainerVariation as o, LayoutContainerMaxWidth as p, NavigationVerticalMenuVariation as q, NotificationAlertHeadingLevel as r, NotificationAlertSize as s, NotificationAlertVariation as t, ToolsFeedbackHeadingLevel as u, ToolsFeedbackType as v, FeedbackVariation as w, TypographyHeadingJumboLevel as x, TypographyHeadingJumboVariation as y, TypographyVariation as z };
268
+ export { BadgeNotificationType as B, CalendarDatepickerValidation as C, DialogHeadingLevel as D, ErrorPageStatusCodes as E, FooterVariation as F, HeaderCenterContentWidth as H, InfoCardMultiContainerHeadingLevel as I, LayoutBlockContainer as L, NavigationVerticalMenuActiveIndicatorSize as N, TitleLogoVariation as T, BarChartVariation as a, CodeBlockLanguage as b, DialogSize as c, DialogVariation as d, FormErrorListHeadingLevel as e, FormRadiobuttonLayout as f, FormRadiobuttonValidation as g, FormRadiobuttonVariation as h, FormReceiptHeadingLevel as i, FormReceiptType as j, FormReceiptVariation as k, FormSelectFilterValidation as l, InfoCardMultiHeadingLevel as m, InfoCardMultiVariation as n, InfoCardHeadingLevel as o, LayoutContainerVariation as p, LayoutContainerMaxWidth as q, NavigationVerticalMenuVariation as r, NotificationAlertHeadingLevel as s, NotificationAlertSize as t, NotificationAlertVariation as u, ToolsFeedbackHeadingLevel as v, ToolsFeedbackType as w, FeedbackVariation as x, TypographyVariation as y };
@@ -43,6 +43,9 @@ export declare class barChart {
43
43
  private _placeholderTicks;
44
44
  private _prevHeight;
45
45
  private _tempScale;
46
+ private mappedData;
47
+ private dataWidth;
48
+ private barGap;
46
49
  afChartDataUpdate(data: ChartLineData | string): void;
47
50
  private _chartDiv;
48
51
  private _host;
@@ -66,6 +69,7 @@ export declare class barChart {
66
69
  private defaultDuration;
67
70
  fontSize: string;
68
71
  private _numberFormat;
72
+ private colorPalettes;
69
73
  barChartObserver: ResizeObserver;
70
74
  tableObserver: ResizeObserver;
71
75
  initSvg(): void;
@@ -89,6 +93,11 @@ export declare class barChart {
89
93
  private adjustBarText;
90
94
  private reshapeData;
91
95
  private adjustBarSize;
96
+ colorFunction(input: number | string): string;
97
+ xFunction: (d: any, i: number) => any;
98
+ yFunction: (d: any, i: number) => any;
99
+ heightFunction: (d: any) => number;
100
+ widthFunction: (d: any) => number;
92
101
  resize(): void;
93
102
  private resizeTable;
94
103
  private getLargestText;
package/hydrate/index.js CHANGED
@@ -35701,6 +35701,9 @@ class barChart {
35701
35701
  // States
35702
35702
  this._loading = false;
35703
35703
  this._placeholderTicks = ['0', '1', '2', '3', '4', '5', '6', '7'];
35704
+ // 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;
35705
+ this.dataWidth = 1;
35706
+ this.barGap = 0;
35704
35707
  this._dims = {};
35705
35708
  this._margin = {
35706
35709
  bottom: 0,
@@ -35718,6 +35721,7 @@ class barChart {
35718
35721
  this.defaultDuration = 400;
35719
35722
  // Text and formats
35720
35723
  this.fontSize = '0.875rem';
35724
+ 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'];
35721
35725
  // Observer for watching size changes when in line chart mode
35722
35726
  this.barChartObserver = new ResizeObserver((entries) => {
35723
35727
  entries.forEach(() => {
@@ -35763,12 +35767,8 @@ class barChart {
35763
35767
  this._dims.width - this._margin.right - this._margin.left
35764
35768
  ]);
35765
35769
  this._barSelection
35766
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
35767
- ? 2
35768
- : this._xScale(d.key))
35769
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
35770
- ? this._xScale(d.value)
35771
- : this._xScale.bandwidth());
35770
+ .attr('x', this.xFunction)
35771
+ .attr('width', this.widthFunction);
35772
35772
  this.setValueTicks();
35773
35773
  };
35774
35774
  // Adding click listener for tool tip text
@@ -35857,7 +35857,7 @@ class barChart {
35857
35857
  this.updateBars = (fromLoading) => {
35858
35858
  this._barChartContainer
35859
35859
  .selectAll('.barGroup')
35860
- .data(this.reshapeData)
35860
+ .data(this.mappedData)
35861
35861
  .join((enter) => {
35862
35862
  var _a, _b;
35863
35863
  const tempSelection = enter
@@ -35888,17 +35888,9 @@ class barChart {
35888
35888
  .transition()
35889
35889
  .duration(this.defaultDuration)
35890
35890
  .ease(polyInOut)
35891
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
35892
- ? this._xScale(d.value)
35893
- : this._xScale.bandwidth())
35894
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
35895
- ? this._yScale(d.key)
35896
- : this._yScale(d.value))
35897
- .attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
35898
- ? this._yScale.bandwidth()
35899
- : this._dims.height -
35900
- this._margin.bottom -
35901
- this._yScale(d.value))
35891
+ .attr('width', this.widthFunction)
35892
+ .attr('y', this.yFunction)
35893
+ .attr('height', this.heightFunction)
35902
35894
  .attr('fill', '#00005a');
35903
35895
  if (!((_b = (_a = this._chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels))
35904
35896
  return tempSelection;
@@ -35970,15 +35962,11 @@ class barChart {
35970
35962
  .on('mouseenter', this.hover)
35971
35963
  .on('mouseleave', this.hoverOut)
35972
35964
  .on('click', this.openTooltip)
35973
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
35974
- ? 2
35975
- : this._xScale(d.key))
35965
+ .attr('x', this.xFunction)
35976
35966
  .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
35977
35967
  ? this._yScale(d.key)
35978
35968
  : this._dims.height - this._margin.bottom)
35979
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
35980
- ? this._xScale(d.value)
35981
- : this._xScale.bandwidth())
35969
+ .attr('width', this.widthFunction)
35982
35970
  .attr('height', () => this.afVariation === BarChartVariation.Horizontal
35983
35971
  ? this._yScale.bandwidth()
35984
35972
  : 0)
@@ -35986,14 +35974,8 @@ class barChart {
35986
35974
  .transition()
35987
35975
  .duration(this.defaultDuration)
35988
35976
  .ease(polyInOut)
35989
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
35990
- ? this._yScale(d.key)
35991
- : this._yScale(d.value))
35992
- .attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
35993
- ? this._yScale.bandwidth()
35994
- : this._dims.height -
35995
- this._margin.bottom -
35996
- this._yScale(d.value))
35977
+ .attr('y', this.yFunction)
35978
+ .attr('height', this.heightFunction)
35997
35979
  .on('end', () => this.barChartObserver.observe(this._chartDiv)); // Reset barchartObserver
35998
35980
  }
35999
35981
  else {
@@ -36002,20 +35984,10 @@ class barChart {
36002
35984
  .transition()
36003
35985
  .duration(this.defaultDuration)
36004
35986
  .ease(polyInOut)
36005
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
36006
- ? this._yScale(d.key)
36007
- : this._yScale(d.value))
36008
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
36009
- ? 2
36010
- : this._xScale(d.key))
36011
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
36012
- ? this._xScale(d.value)
36013
- : this._xScale.bandwidth())
36014
- .attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
36015
- ? this._yScale.bandwidth()
36016
- : this._dims.height -
36017
- this._margin.bottom -
36018
- this._yScale(d.value))
35987
+ .attr('x', this.xFunction)
35988
+ .attr('y', this.yFunction)
35989
+ .attr('width', this.widthFunction)
35990
+ .attr('height', this.heightFunction)
36019
35991
  .attr('fill', '#00005a');
36020
35992
  }
36021
35993
  return update
@@ -36106,37 +36078,67 @@ class barChart {
36106
36078
  const toReturn = [];
36107
36079
  if (this._loading) {
36108
36080
  this._placeholderTicks.forEach((key) => {
36109
- toReturn.push({
36081
+ const tick = { key: key, series: [] };
36082
+ tick.series.push({
36110
36083
  key: key,
36084
+ serie: '',
36111
36085
  value: Math.floor(Math.random() * (9 - 2 + 1) + 2),
36112
- len: '1'
36086
+ len: 0
36113
36087
  });
36088
+ toReturn.push(tick);
36114
36089
  });
36115
36090
  return toReturn;
36116
36091
  }
36117
36092
  this._chartData.data.xValueNames.forEach((key, index) => {
36118
- toReturn.push({
36119
- key: key,
36120
- value: this._chartData.data.series[0].yValues[index],
36121
- len: this.getTextSize(this._chartData.data.series[0].yValues[index].toLocaleString())
36093
+ const tick = { key: key, series: [] };
36094
+ this._chartData.data.series.forEach((serie) => {
36095
+ if (serie.yValues[index]) {
36096
+ tick.series.push({
36097
+ key: key,
36098
+ serie: serie.title,
36099
+ value: serie.yValues[index],
36100
+ len: serie.yValues[index] ? this.getTextSize(serie.yValues[index].toLocaleString()) : 0
36101
+ });
36102
+ }
36122
36103
  });
36104
+ toReturn.push(tick);
36123
36105
  });
36124
36106
  return toReturn;
36125
36107
  };
36126
36108
  this.adjustBarSize = () => {
36127
- this._barSelection
36128
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
36129
- ? this._yScale(d.key)
36130
- : this._yScale(d.value))
36131
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
36132
- ? 2
36133
- : this._xScale(d.key))
36134
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
36135
- ? this._xScale(d.value)
36136
- : this._xScale.bandwidth())
36137
- .attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
36138
- ? this._yScale.bandwidth()
36139
- : this._dims.height - this._margin.bottom - this._yScale(d.value));
36109
+ this._barSelection.selectAll('.bar')
36110
+ .attr('x', this.xFunction)
36111
+ .attr('y', this.yFunction)
36112
+ .attr('width', this.widthFunction)
36113
+ .attr('height', this.heightFunction);
36114
+ };
36115
+ // Handling x positioning of bars
36116
+ this.xFunction = (d, i) => {
36117
+ return this.afVariation === BarChartVariation.Horizontal
36118
+ ? (d.value > 0 ? this._xScale(0) : this._xScale(d.value))
36119
+ : this._xScale(d.key) + ((this._xScale.bandwidth() / this.dataWidth) * i + (this.barGap * i));
36120
+ };
36121
+ // Handling y positioning of bars
36122
+ this.yFunction = (d, i) => {
36123
+ if (!d.value)
36124
+ return 0;
36125
+ return this.afVariation === BarChartVariation.Horizontal
36126
+ ? this._yScale(d.key) + ((this._yScale.bandwidth() / this.dataWidth) * i + (this.barGap * i))
36127
+ : (d.value < 0 ? this._yScale(0) : this._yScale(d.value));
36128
+ };
36129
+ // Handling height for bars
36130
+ this.heightFunction = (d) => {
36131
+ if (!d.value)
36132
+ return 0;
36133
+ return this.afVariation === BarChartVariation.Horizontal
36134
+ ? this._yScale.bandwidth() / this.dataWidth - (this.barGap)
36135
+ : (d.value < 0 ? this._yScale(d.value) - this._yScale(0) : this._yScale(0) - this._yScale(d.value));
36136
+ };
36137
+ // Handling width for bars
36138
+ this.widthFunction = (d) => {
36139
+ return this.afVariation === BarChartVariation.Horizontal
36140
+ ? Math.abs(this._xScale(0) - this._xScale(d.value))
36141
+ : this._xScale.bandwidth() / this.dataWidth - (this.barGap);
36140
36142
  };
36141
36143
  // Resize table
36142
36144
  this.resizeTable = () => {
@@ -36376,16 +36378,16 @@ class barChart {
36376
36378
  select(event.target)
36377
36379
  .transition('hover')
36378
36380
  .duration(20)
36379
- .attr('fill', event.target.tagName === 'rect'
36380
- ? '#4C4C8B'
36381
- : 'var(--digi--color--text--link-hover)');
36381
+ .attr('fill', (d) => event.target.tagName === 'rect'
36382
+ ? `hsl(from ${this.colorFunction(d.serie)} h s calc(l + 10))`
36383
+ : 'var(--digi--color--background--interactive--hover--tertiary)');
36382
36384
  };
36383
36385
  // Removing highlight from bar
36384
36386
  this.hoverOut = (event) => {
36385
36387
  select(event.target)
36386
36388
  .transition('hover')
36387
36389
  .duration(this.defaultDuration)
36388
- .attr('fill', event.target.tagName === 'rect' ? '#00005a' : '#333333');
36390
+ .attr('fill', (d) => event.target.tagName === 'rect' ? this.colorFunction(d.serie) : '#333333');
36389
36391
  };
36390
36392
  this.openTooltip = (...[, d]) => {
36391
36393
  // If type is string, the user has clicked on a y-axis tick
@@ -36454,7 +36456,7 @@ class barChart {
36454
36456
  if (this.afVariation == BarChartVariation.Horizontal)
36455
36457
  this._tickWidth = this.getLargestText(this._xScale.ticks().map((tick) => tick.toLocaleString()));
36456
36458
  this.tickSizes();
36457
- this._barChartContainer.selectAll('.barGroup').data(this.reshapeData);
36459
+ this._barChartContainer.selectAll('.barGroup').data(this.mappedData);
36458
36460
  if ((_b = (_a = this._chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels)
36459
36461
  this._textSelection.remove();
36460
36462
  this.initBarText();
@@ -36525,6 +36527,14 @@ class barChart {
36525
36527
  this._chartData = data;
36526
36528
  else
36527
36529
  this._chartData = JSON.parse(data);
36530
+ this.mappedData = this.reshapeData();
36531
+ // checking for width of each tick
36532
+ this.mappedData.forEach((elem) => {
36533
+ if (elem.series.length > this.dataWidth)
36534
+ this.dataWidth = elem.series.length;
36535
+ });
36536
+ if (this.dataWidth > 1)
36537
+ this.barGap = 1;
36528
36538
  }
36529
36539
  initSvg() {
36530
36540
  var _a, _b, _c, _d, _e, _f, _g;
@@ -36644,7 +36654,7 @@ class barChart {
36644
36654
  this._barChartContainer.selectAll('.barGroup').remove();
36645
36655
  this._barSelection = this._barChartContainer
36646
36656
  .selectAll('barGroup')
36647
- .data(this.reshapeData)
36657
+ .data(this.mappedData)
36648
36658
  .join('g')
36649
36659
  .attr('class', 'barGroup')
36650
36660
  .attr('id', (d) => 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, '_'))
@@ -36655,26 +36665,17 @@ class barChart {
36655
36665
  .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
36656
36666
  ? this._yScale(d.key)
36657
36667
  : this._dims.height - this._margin.bottom)
36658
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
36659
- ? 2
36660
- : this._xScale(d.key))
36668
+ .attr('x', this.xFunction)
36661
36669
  .attr('ry', 4)
36662
36670
  .attr('rx', 4)
36663
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
36664
- ? this._xScale(d.value)
36665
- : this._xScale.bandwidth())
36671
+ .attr('width', this.widthFunction)
36666
36672
  .attr('height', () => 0)
36667
- //.attr('height', (d: any) => this.afVariation === BarChartVariation.Horizontal ? this._yScale.bandwidth() : (this._dims.height - this._margin.bottom) - this._yScale(d.value))
36668
36673
  .attr('fill', 'gray')
36669
36674
  .transition()
36670
36675
  .duration(400)
36671
36676
  .delay((...[, i]) => i * 150)
36672
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
36673
- ? this._yScale(d.key)
36674
- : this._yScale(d.value))
36675
- .attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
36676
- ? this._yScale.bandwidth()
36677
- : this._dims.height - this._margin.bottom - this._yScale(d.value));
36677
+ .attr('y', this.yFunction)
36678
+ .attr('height', this.heightFunction);
36678
36679
  this._barSelection
36679
36680
  .transition()
36680
36681
  .duration(400)
@@ -36764,7 +36765,7 @@ class barChart {
36764
36765
  if (this.afVariation === BarChartVariation.Horizontal) {
36765
36766
  this.setValueTicks();
36766
36767
  // Removing first tick, because it aligns with y-axis domain
36767
- this._xAxisHandle.select('.tick').select('line').remove();
36768
+ //this._xAxisHandle.select('.tick').select('line').remove();
36768
36769
  }
36769
36770
  else {
36770
36771
  if (!empty) {
@@ -36778,39 +36779,41 @@ class barChart {
36778
36779
  initBars() {
36779
36780
  this._barSelection = this._barChartContainer
36780
36781
  .selectAll('barGroup')
36781
- .data(this.reshapeData)
36782
+ .data(this.mappedData)
36782
36783
  .join('g')
36783
36784
  .attr('class', 'barGroup')
36784
- .attr('id', (d) => 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, '_'))
36785
- .append('rect')
36785
+ .attr('id', (d) => {
36786
+ return 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, '_');
36787
+ });
36788
+ this._barSelection.selectAll('.barGroup')
36789
+ .data((d) => {
36790
+ return d.series;
36791
+ })
36792
+ .join('rect')
36786
36793
  .attr('class', 'bar')
36787
- .style('cursor', 'pointer');
36788
- this._barSelection
36789
- .attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
36790
- ? this._yScale(d.key)
36791
- : this._yScale(d.value))
36792
- .attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
36793
- ? 2
36794
- : this._xScale(d.key))
36794
+ .style('cursor', 'pointer')
36795
+ .attr('x', this.xFunction)
36796
+ .attr('y', this.yFunction)
36795
36797
  .attr('ry', 4)
36796
36798
  .attr('rx', 4)
36797
- .attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
36798
- ? this._xScale(d.value)
36799
- : this._xScale.bandwidth())
36800
- .attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
36801
- ? this._yScale.bandwidth()
36802
- : this._dims.height - this._margin.bottom - this._yScale(d.value))
36803
- .attr('fill', '#00005a')
36799
+ .attr('width', this.widthFunction)
36800
+ .attr('height', this.heightFunction)
36801
+ .attr('fill', (d) => this.colorFunction(d.serie))
36804
36802
  .on('mouseenter', this.hover)
36805
36803
  .on('mouseleave', this.hoverOut)
36806
36804
  .on('click', this.openTooltip);
36807
36805
  }
36808
36806
  initBarText() {
36807
+ var _a, _b;
36808
+ if (!((_b = (_a = this._chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels))
36809
+ return;
36809
36810
  this._textSelection = this._barChartContainer
36810
36811
  .selectAll('.barGroup')
36811
36812
  .append('text');
36812
36813
  this._textSelection
36813
- .text((d) => d.value.toLocaleString(undefined, this._numberFormat))
36814
+ .text((d) => {
36815
+ return d.value ? d.value.toLocaleString(undefined, this._numberFormat) : undefined;
36816
+ })
36814
36817
  .attr('class', 'barText')
36815
36818
  .attr('font-size', this.fontSize)
36816
36819
  .attr('font-weight', '600')
@@ -36948,6 +36951,18 @@ class barChart {
36948
36951
  }
36949
36952
  }
36950
36953
  }
36954
+ // Getting correct color given index or name of data serie
36955
+ colorFunction(input) {
36956
+ if (typeof input === 'number')
36957
+ return `var(${this.colorPalettes[input]})`;
36958
+ else {
36959
+ const index = this._chartData.data.series.findIndex((serie) => serie.title === input);
36960
+ if (index > 0)
36961
+ return `var(${this.colorPalettes[index]})`;
36962
+ else
36963
+ return `var(${this.colorPalettes[0]})`;
36964
+ }
36965
+ }
36951
36966
  // Resizing bar chart
36952
36967
  resize() {
36953
36968
  var _a;
@@ -37028,11 +37043,11 @@ class barChart {
37028
37043
  }
37029
37044
  // Not currently used
37030
37045
  /*get cssModifiers() {
37031
- return {
37032
- 'digi-bar-chart--vertical': this.afVariation == 'vertical',
37033
- 'digi-bar-chart--horizontal': this.afVariation == 'horizontal'
37034
- };
37035
- }*/
37046
+ return {
37047
+ 'digi-bar-chart--vertical': this.afVariation == 'vertical',
37048
+ 'digi-bar-chart--horizontal': this.afVariation == 'horizontal'
37049
+ };
37050
+ }*/
37036
37051
  // Returns pixelwidth of text given the current fontSize (costly function using .each)
37037
37052
  getTextSize(text) {
37038
37053
  const textWidth = [];
@@ -37102,7 +37117,7 @@ class barChart {
37102
37117
  <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>`;
37103
37118
  }
37104
37119
  }
37105
- 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) }, ' ')));
37120
+ 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) }, ' ')));
37106
37121
  }
37107
37122
  get hostElement() { return getElement(this); }
37108
37123
  static get watchers() { return {