@designsystem-se/af 35.3.1 → 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.
- package/components/digi-bar-chart.js +126 -111
- package/components/digi-chart-line.js +1 -1
- package/components/digi-code-block.js +1 -1
- package/components/digi-code-example.js +1 -1
- package/components/digi-info-card.js +1 -1
- package/components/digi-link-button.js +3 -1
- package/components/p-472bc7d3.js +129 -0
- package/custom-elements.json +6 -2
- package/dist/cjs/digi-arbetsformedlingen.cjs.js +1 -1
- package/dist/cjs/{digi-button_24.cjs.entry.js → digi-bar-chart_27.cjs.entry.js} +1611 -47
- package/dist/cjs/digi-calendar-datepicker.cjs.entry.js +2 -2
- package/dist/cjs/digi-chart-line.cjs.entry.js +1 -1
- package/dist/cjs/digi-code-block_3.cjs.entry.js +3 -3
- package/dist/cjs/digi-dialog.cjs.entry.js +2 -2
- package/dist/cjs/digi-footer.cjs.entry.js +2 -2
- package/dist/cjs/digi-form-error-list.cjs.entry.js +2 -2
- package/dist/cjs/digi-form-receipt.cjs.entry.js +2 -2
- package/dist/cjs/digi-form-select-filter.cjs.entry.js +2 -2
- package/dist/cjs/digi-info-card.cjs.entry.js +1 -1
- package/dist/cjs/digi-link-button.cjs.entry.js +2 -1
- package/dist/cjs/digi-navigation-pagination.cjs.entry.js +2 -2
- package/dist/cjs/digi-notification-alert.cjs.entry.js +2 -2
- package/dist/cjs/digi-notification-error-page.cjs.entry.js +2 -2
- package/dist/cjs/digi-tools-feedback.cjs.entry.js +2 -2
- package/dist/cjs/digi-typography-heading-jumbo.cjs.entry.js +38 -0
- package/dist/cjs/digi-typography-preamble.cjs.entry.js +20 -0
- package/dist/cjs/index-7a477838.js +10 -14
- package/dist/cjs/index.cjs.js +20 -20
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/typography-heading-jumbo-variation.enum-8677e099.js +17 -0
- package/dist/cjs/{typography-variation.enum-9f56fd50.js → typography-variation.enum-8fd8bed4.js} +6 -16
- package/dist/collection/components/_chart/bar-chart/bar-chart.css +13 -19
- package/dist/collection/components/_chart/bar-chart/bar-chart.js +125 -110
- package/dist/collection/components/_chart/chart-line/chart-line.css +19 -23
- package/dist/collection/components/_code/code-block/code-block.css +2 -2
- package/dist/collection/components/_info-card/info-card/info-card.js +5 -5
- package/dist/collection/components/_link/link-button/link-button.js +24 -1
- package/dist/digi-arbetsformedlingen/digi-arbetsformedlingen.esm.js +1 -1
- package/dist/digi-arbetsformedlingen/index.esm.js +1 -1
- package/dist/digi-arbetsformedlingen/p-044b32d7.entry.js +1 -0
- package/dist/digi-arbetsformedlingen/{p-e2330d9c.entry.js → p-1241d74a.entry.js} +1 -1
- package/dist/digi-arbetsformedlingen/{p-e54f5b28.entry.js → p-222a2b41.entry.js} +1 -1
- package/dist/digi-arbetsformedlingen/p-37377041.entry.js +1 -0
- package/dist/digi-arbetsformedlingen/p-3ae60edc.entry.js +1 -0
- package/dist/digi-arbetsformedlingen/p-431baa4e.entry.js +1 -0
- package/dist/digi-arbetsformedlingen/{p-0d35dc92.entry.js → p-56ca6c5c.entry.js} +1 -1
- package/dist/digi-arbetsformedlingen/{p-6559910e.entry.js → p-58f76475.entry.js} +1 -1
- package/dist/digi-arbetsformedlingen/{p-092d0e3e.entry.js → p-5a08f170.entry.js} +1 -1
- package/dist/digi-arbetsformedlingen/p-5aae7437.entry.js +1 -0
- package/dist/digi-arbetsformedlingen/{p-c04b06a2.entry.js → p-5ac3d7a9.entry.js} +1 -1
- package/dist/digi-arbetsformedlingen/{p-e0db40e9.entry.js → p-69010d14.entry.js} +1 -1
- package/dist/digi-arbetsformedlingen/{p-f1a6524e.entry.js → p-83b3f053.entry.js} +1 -1
- package/dist/digi-arbetsformedlingen/p-86eddf30.js +1 -0
- package/dist/digi-arbetsformedlingen/p-9f03b573.entry.js +1 -0
- package/dist/digi-arbetsformedlingen/p-a884ccf8.entry.js +1 -0
- package/dist/digi-arbetsformedlingen/{p-01f5f243.entry.js → p-c4cf1215.entry.js} +1 -1
- package/dist/digi-arbetsformedlingen/p-d1886fff.js +1 -0
- package/dist/digi-arbetsformedlingen/{p-5c7acd45.entry.js → p-e3bdf65a.entry.js} +1 -1
- package/dist/esm/digi-arbetsformedlingen.js +1 -1
- package/dist/esm/{digi-button_24.entry.js → digi-bar-chart_27.entry.js} +1608 -47
- package/dist/esm/digi-calendar-datepicker.entry.js +2 -2
- package/dist/esm/digi-chart-line.entry.js +1 -1
- package/dist/esm/digi-code-block_3.entry.js +3 -3
- package/dist/esm/digi-dialog.entry.js +2 -2
- package/dist/esm/digi-footer.entry.js +2 -2
- package/dist/esm/digi-form-error-list.entry.js +2 -2
- package/dist/esm/digi-form-receipt.entry.js +2 -2
- package/dist/esm/digi-form-select-filter.entry.js +2 -2
- package/dist/esm/digi-info-card.entry.js +1 -1
- package/dist/esm/digi-link-button.entry.js +2 -1
- package/dist/esm/digi-navigation-pagination.entry.js +2 -2
- package/dist/esm/digi-notification-alert.entry.js +2 -2
- package/dist/esm/digi-notification-error-page.entry.js +2 -2
- package/dist/esm/digi-tools-feedback.entry.js +2 -2
- package/dist/esm/digi-typography-heading-jumbo.entry.js +34 -0
- package/dist/esm/digi-typography-preamble.entry.js +16 -0
- package/dist/esm/index-148a7577.js +10 -14
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/typography-heading-jumbo-variation.enum-eb737f1b.js +17 -0
- package/dist/esm/{typography-variation.enum-8ba40d15.js → typography-variation.enum-531cdf64.js} +7 -17
- package/dist/types/components/_chart/bar-chart/bar-chart.d.ts +9 -0
- package/dist/types/components/_info-card/info-card/info-card.d.ts +4 -4
- package/dist/types/components/_link/link-button/link-button.d.ts +5 -0
- package/dist/types/components.d.ts +18 -8
- package/hydrate/index.js +132 -115
- package/hydrate/index.mjs +132 -115
- package/package.json +1 -1
- package/components/p-2bc16106.js +0 -129
- package/dist/cjs/bar-chart-variation.enum-a4e866b6.js +0 -7
- package/dist/cjs/digi-bar-chart.cjs.entry.js +0 -1510
- package/dist/cjs/digi-icon-caret-down_2.cjs.entry.js +0 -53
- package/dist/cjs/digi-icon-chart_2.cjs.entry.js +0 -53
- package/dist/digi-arbetsformedlingen/p-0c271457.entry.js +0 -1
- package/dist/digi-arbetsformedlingen/p-2422b0d1.entry.js +0 -1
- package/dist/digi-arbetsformedlingen/p-54a797ed.entry.js +0 -1
- package/dist/digi-arbetsformedlingen/p-a5c6e42e.entry.js +0 -1
- package/dist/digi-arbetsformedlingen/p-b22f09f1.entry.js +0 -1
- package/dist/digi-arbetsformedlingen/p-bd6e0b22.entry.js +0 -1
- package/dist/digi-arbetsformedlingen/p-c1606b8a.entry.js +0 -1
- package/dist/digi-arbetsformedlingen/p-d2d0856f.js +0 -1
- package/dist/digi-arbetsformedlingen/p-d8b9b535.entry.js +0 -1
- package/dist/digi-arbetsformedlingen/p-dcdffb3c.js +0 -1
- package/dist/esm/bar-chart-variation.enum-97c0b47f.js +0 -7
- package/dist/esm/digi-bar-chart.entry.js +0 -1506
- package/dist/esm/digi-icon-caret-down_2.entry.js +0 -48
- package/dist/esm/digi-icon-chart_2.entry.js +0 -48
package/dist/cjs/{typography-variation.enum-9f56fd50.js → typography-variation.enum-8fd8bed4.js}
RENAMED
|
@@ -14,6 +14,12 @@ exports.CalendarDatepickerValidation = void 0;
|
|
|
14
14
|
CalendarDatepickerValidation["NEUTRAL"] = "neutral";
|
|
15
15
|
})(exports.CalendarDatepickerValidation || (exports.CalendarDatepickerValidation = {}));
|
|
16
16
|
|
|
17
|
+
exports.BarChartVariation = void 0;
|
|
18
|
+
(function (BarChartVariation) {
|
|
19
|
+
BarChartVariation["Vertical"] = "vertical";
|
|
20
|
+
BarChartVariation["Horizontal"] = "horizontal";
|
|
21
|
+
})(exports.BarChartVariation || (exports.BarChartVariation = {}));
|
|
22
|
+
|
|
17
23
|
exports.CodeBlockLanguage = void 0;
|
|
18
24
|
(function (CodeBlockLanguage) {
|
|
19
25
|
CodeBlockLanguage["JSON"] = "json";
|
|
@@ -255,22 +261,6 @@ exports.FeedbackVariation = void 0;
|
|
|
255
261
|
FeedbackVariation["SECONDARY"] = "secondary";
|
|
256
262
|
})(exports.FeedbackVariation || (exports.FeedbackVariation = {}));
|
|
257
263
|
|
|
258
|
-
exports.TypographyHeadingJumboLevel = void 0;
|
|
259
|
-
(function (TypographyHeadingJumboLevel) {
|
|
260
|
-
TypographyHeadingJumboLevel["H1"] = "h1";
|
|
261
|
-
TypographyHeadingJumboLevel["H2"] = "h2";
|
|
262
|
-
TypographyHeadingJumboLevel["H3"] = "h3";
|
|
263
|
-
TypographyHeadingJumboLevel["H4"] = "h4";
|
|
264
|
-
TypographyHeadingJumboLevel["H5"] = "h5";
|
|
265
|
-
TypographyHeadingJumboLevel["H6"] = "h6";
|
|
266
|
-
})(exports.TypographyHeadingJumboLevel || (exports.TypographyHeadingJumboLevel = {}));
|
|
267
|
-
|
|
268
|
-
exports.TypographyHeadingJumboVariation = void 0;
|
|
269
|
-
(function (TypographyHeadingJumboVariation) {
|
|
270
|
-
TypographyHeadingJumboVariation["PRIMARY"] = "primary";
|
|
271
|
-
TypographyHeadingJumboVariation["SECONDARY"] = "secondary";
|
|
272
|
-
})(exports.TypographyHeadingJumboVariation || (exports.TypographyHeadingJumboVariation = {}));
|
|
273
|
-
|
|
274
264
|
exports.TypographyVariation = void 0;
|
|
275
265
|
(function (TypographyVariation) {
|
|
276
266
|
TypographyVariation["SMALL"] = "small";
|
|
@@ -3,20 +3,21 @@
|
|
|
3
3
|
:host .digi-bar-chart {
|
|
4
4
|
font-family: var(--digi--global--typography--font-family--default);
|
|
5
5
|
}
|
|
6
|
-
:host .
|
|
7
|
-
|
|
8
|
-
--digi--typography--h3--margin: 0.5rem;
|
|
9
|
-
--digi--typography--h4--margin: 0.5rem;
|
|
10
|
-
--digi--typography--h5--margin: 0.5rem;
|
|
11
|
-
--digi--typography--h6--margin: 0.5rem;
|
|
6
|
+
:host .topWrapper,
|
|
7
|
+
:host .chartTitle .digi-typography {
|
|
12
8
|
display: flex;
|
|
13
|
-
justify-content: flex-start;
|
|
14
9
|
flex-direction: column;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
margin-
|
|
19
|
-
|
|
10
|
+
gap: 0.75rem;
|
|
11
|
+
}
|
|
12
|
+
:host .topWrapper {
|
|
13
|
+
margin-bottom: 0.75rem;
|
|
14
|
+
}
|
|
15
|
+
:host .chartTitle {
|
|
16
|
+
--MARGIN--HEADING-2: 0;
|
|
17
|
+
--MARGIN--HEADING-3: 0;
|
|
18
|
+
--MARGIN--HEADING-4: 0;
|
|
19
|
+
--MARGIN--HEADING-5: 0;
|
|
20
|
+
--MARGIN--HEADING-6: 0;
|
|
20
21
|
}
|
|
21
22
|
:host .buttonWrapper {
|
|
22
23
|
--digi--button--padding--medium: 4px 4px 0.8125rem 0;
|
|
@@ -79,11 +80,4 @@
|
|
|
79
80
|
background-repeat: no-repeat;
|
|
80
81
|
background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
|
|
81
82
|
background-attachment: local, local, scroll, scroll;
|
|
82
|
-
}
|
|
83
|
-
:host .topWrapper {
|
|
84
|
-
display: flex;
|
|
85
|
-
flex-direction: row;
|
|
86
|
-
align-items: flex-end;
|
|
87
|
-
justify-content: space-between;
|
|
88
|
-
flex-wrap: wrap;
|
|
89
83
|
}
|
|
@@ -15,6 +15,9 @@ export class barChart {
|
|
|
15
15
|
// States
|
|
16
16
|
this._loading = false;
|
|
17
17
|
this._placeholderTicks = ['0', '1', '2', '3', '4', '5', '6', '7'];
|
|
18
|
+
// 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;
|
|
19
|
+
this.dataWidth = 1;
|
|
20
|
+
this.barGap = 0;
|
|
18
21
|
this._dims = {};
|
|
19
22
|
this._margin = {
|
|
20
23
|
bottom: 0,
|
|
@@ -32,6 +35,7 @@ export class barChart {
|
|
|
32
35
|
this.defaultDuration = 400;
|
|
33
36
|
// Text and formats
|
|
34
37
|
this.fontSize = '0.875rem';
|
|
38
|
+
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'];
|
|
35
39
|
// Observer for watching size changes when in line chart mode
|
|
36
40
|
this.barChartObserver = new ResizeObserver((entries) => {
|
|
37
41
|
entries.forEach(() => {
|
|
@@ -77,12 +81,8 @@ export class barChart {
|
|
|
77
81
|
this._dims.width - this._margin.right - this._margin.left
|
|
78
82
|
]);
|
|
79
83
|
this._barSelection
|
|
80
|
-
.attr('x',
|
|
81
|
-
|
|
82
|
-
: this._xScale(d.key))
|
|
83
|
-
.attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
|
|
84
|
-
? this._xScale(d.value)
|
|
85
|
-
: this._xScale.bandwidth());
|
|
84
|
+
.attr('x', this.xFunction)
|
|
85
|
+
.attr('width', this.widthFunction);
|
|
86
86
|
this.setValueTicks();
|
|
87
87
|
};
|
|
88
88
|
// Adding click listener for tool tip text
|
|
@@ -175,7 +175,7 @@ export class barChart {
|
|
|
175
175
|
this.updateBars = (fromLoading) => {
|
|
176
176
|
this._barChartContainer
|
|
177
177
|
.selectAll('.barGroup')
|
|
178
|
-
.data(this.
|
|
178
|
+
.data(this.mappedData)
|
|
179
179
|
.join((enter) => {
|
|
180
180
|
var _a, _b;
|
|
181
181
|
const tempSelection = enter
|
|
@@ -206,17 +206,9 @@ export class barChart {
|
|
|
206
206
|
.transition()
|
|
207
207
|
.duration(this.defaultDuration)
|
|
208
208
|
.ease(d3.easePolyInOut)
|
|
209
|
-
.attr('width',
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
.attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
|
|
213
|
-
? this._yScale(d.key)
|
|
214
|
-
: this._yScale(d.value))
|
|
215
|
-
.attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
|
|
216
|
-
? this._yScale.bandwidth()
|
|
217
|
-
: this._dims.height -
|
|
218
|
-
this._margin.bottom -
|
|
219
|
-
this._yScale(d.value))
|
|
209
|
+
.attr('width', this.widthFunction)
|
|
210
|
+
.attr('y', this.yFunction)
|
|
211
|
+
.attr('height', this.heightFunction)
|
|
220
212
|
.attr('fill', '#00005a');
|
|
221
213
|
if (!((_b = (_a = this._chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels))
|
|
222
214
|
return tempSelection;
|
|
@@ -288,15 +280,11 @@ export class barChart {
|
|
|
288
280
|
.on('mouseenter', this.hover)
|
|
289
281
|
.on('mouseleave', this.hoverOut)
|
|
290
282
|
.on('click', this.openTooltip)
|
|
291
|
-
.attr('x',
|
|
292
|
-
? 2
|
|
293
|
-
: this._xScale(d.key))
|
|
283
|
+
.attr('x', this.xFunction)
|
|
294
284
|
.attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
|
|
295
285
|
? this._yScale(d.key)
|
|
296
286
|
: this._dims.height - this._margin.bottom)
|
|
297
|
-
.attr('width',
|
|
298
|
-
? this._xScale(d.value)
|
|
299
|
-
: this._xScale.bandwidth())
|
|
287
|
+
.attr('width', this.widthFunction)
|
|
300
288
|
.attr('height', () => this.afVariation === BarChartVariation.Horizontal
|
|
301
289
|
? this._yScale.bandwidth()
|
|
302
290
|
: 0)
|
|
@@ -304,14 +292,8 @@ export class barChart {
|
|
|
304
292
|
.transition()
|
|
305
293
|
.duration(this.defaultDuration)
|
|
306
294
|
.ease(d3.easePolyInOut)
|
|
307
|
-
.attr('y',
|
|
308
|
-
|
|
309
|
-
: this._yScale(d.value))
|
|
310
|
-
.attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
|
|
311
|
-
? this._yScale.bandwidth()
|
|
312
|
-
: this._dims.height -
|
|
313
|
-
this._margin.bottom -
|
|
314
|
-
this._yScale(d.value))
|
|
295
|
+
.attr('y', this.yFunction)
|
|
296
|
+
.attr('height', this.heightFunction)
|
|
315
297
|
.on('end', () => this.barChartObserver.observe(this._chartDiv)); // Reset barchartObserver
|
|
316
298
|
}
|
|
317
299
|
else {
|
|
@@ -320,20 +302,10 @@ export class barChart {
|
|
|
320
302
|
.transition()
|
|
321
303
|
.duration(this.defaultDuration)
|
|
322
304
|
.ease(d3.easePolyInOut)
|
|
323
|
-
.attr('
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
.attr('
|
|
327
|
-
? 2
|
|
328
|
-
: this._xScale(d.key))
|
|
329
|
-
.attr('width', (d) => this.afVariation === BarChartVariation.Horizontal
|
|
330
|
-
? this._xScale(d.value)
|
|
331
|
-
: this._xScale.bandwidth())
|
|
332
|
-
.attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
|
|
333
|
-
? this._yScale.bandwidth()
|
|
334
|
-
: this._dims.height -
|
|
335
|
-
this._margin.bottom -
|
|
336
|
-
this._yScale(d.value))
|
|
305
|
+
.attr('x', this.xFunction)
|
|
306
|
+
.attr('y', this.yFunction)
|
|
307
|
+
.attr('width', this.widthFunction)
|
|
308
|
+
.attr('height', this.heightFunction)
|
|
337
309
|
.attr('fill', '#00005a');
|
|
338
310
|
}
|
|
339
311
|
return update
|
|
@@ -424,37 +396,67 @@ export class barChart {
|
|
|
424
396
|
const toReturn = [];
|
|
425
397
|
if (this._loading) {
|
|
426
398
|
this._placeholderTicks.forEach((key) => {
|
|
427
|
-
|
|
399
|
+
const tick = { key: key, series: [] };
|
|
400
|
+
tick.series.push({
|
|
428
401
|
key: key,
|
|
402
|
+
serie: '',
|
|
429
403
|
value: Math.floor(Math.random() * (9 - 2 + 1) + 2),
|
|
430
|
-
len:
|
|
404
|
+
len: 0
|
|
431
405
|
});
|
|
406
|
+
toReturn.push(tick);
|
|
432
407
|
});
|
|
433
408
|
return toReturn;
|
|
434
409
|
}
|
|
435
410
|
this._chartData.data.xValueNames.forEach((key, index) => {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
411
|
+
const tick = { key: key, series: [] };
|
|
412
|
+
this._chartData.data.series.forEach((serie) => {
|
|
413
|
+
if (serie.yValues[index]) {
|
|
414
|
+
tick.series.push({
|
|
415
|
+
key: key,
|
|
416
|
+
serie: serie.title,
|
|
417
|
+
value: serie.yValues[index],
|
|
418
|
+
len: serie.yValues[index] ? this.getTextSize(serie.yValues[index].toLocaleString()) : 0
|
|
419
|
+
});
|
|
420
|
+
}
|
|
440
421
|
});
|
|
422
|
+
toReturn.push(tick);
|
|
441
423
|
});
|
|
442
424
|
return toReturn;
|
|
443
425
|
};
|
|
444
426
|
this.adjustBarSize = () => {
|
|
445
|
-
this._barSelection
|
|
446
|
-
.attr('
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
.attr('
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
: this._xScale.
|
|
455
|
-
.
|
|
456
|
-
|
|
457
|
-
|
|
427
|
+
this._barSelection.selectAll('.bar')
|
|
428
|
+
.attr('x', this.xFunction)
|
|
429
|
+
.attr('y', this.yFunction)
|
|
430
|
+
.attr('width', this.widthFunction)
|
|
431
|
+
.attr('height', this.heightFunction);
|
|
432
|
+
};
|
|
433
|
+
// Handling x positioning of bars
|
|
434
|
+
this.xFunction = (d, i) => {
|
|
435
|
+
return this.afVariation === BarChartVariation.Horizontal
|
|
436
|
+
? (d.value > 0 ? this._xScale(0) : this._xScale(d.value))
|
|
437
|
+
: this._xScale(d.key) + ((this._xScale.bandwidth() / this.dataWidth) * i + (this.barGap * i));
|
|
438
|
+
};
|
|
439
|
+
// Handling y positioning of bars
|
|
440
|
+
this.yFunction = (d, i) => {
|
|
441
|
+
if (!d.value)
|
|
442
|
+
return 0;
|
|
443
|
+
return this.afVariation === BarChartVariation.Horizontal
|
|
444
|
+
? this._yScale(d.key) + ((this._yScale.bandwidth() / this.dataWidth) * i + (this.barGap * i))
|
|
445
|
+
: (d.value < 0 ? this._yScale(0) : this._yScale(d.value));
|
|
446
|
+
};
|
|
447
|
+
// Handling height for bars
|
|
448
|
+
this.heightFunction = (d) => {
|
|
449
|
+
if (!d.value)
|
|
450
|
+
return 0;
|
|
451
|
+
return this.afVariation === BarChartVariation.Horizontal
|
|
452
|
+
? this._yScale.bandwidth() / this.dataWidth - (this.barGap)
|
|
453
|
+
: (d.value < 0 ? this._yScale(d.value) - this._yScale(0) : this._yScale(0) - this._yScale(d.value));
|
|
454
|
+
};
|
|
455
|
+
// Handling width for bars
|
|
456
|
+
this.widthFunction = (d) => {
|
|
457
|
+
return this.afVariation === BarChartVariation.Horizontal
|
|
458
|
+
? Math.abs(this._xScale(0) - this._xScale(d.value))
|
|
459
|
+
: this._xScale.bandwidth() / this.dataWidth - (this.barGap);
|
|
458
460
|
};
|
|
459
461
|
// Resize table
|
|
460
462
|
this.resizeTable = () => {
|
|
@@ -694,16 +696,16 @@ export class barChart {
|
|
|
694
696
|
d3.select(event.target)
|
|
695
697
|
.transition('hover')
|
|
696
698
|
.duration(20)
|
|
697
|
-
.attr('fill', event.target.tagName === 'rect'
|
|
698
|
-
?
|
|
699
|
-
: 'var(--digi--color--
|
|
699
|
+
.attr('fill', (d) => event.target.tagName === 'rect'
|
|
700
|
+
? `hsl(from ${this.colorFunction(d.serie)} h s calc(l + 10))`
|
|
701
|
+
: 'var(--digi--color--background--interactive--hover--tertiary)');
|
|
700
702
|
};
|
|
701
703
|
// Removing highlight from bar
|
|
702
704
|
this.hoverOut = (event) => {
|
|
703
705
|
d3.select(event.target)
|
|
704
706
|
.transition('hover')
|
|
705
707
|
.duration(this.defaultDuration)
|
|
706
|
-
.attr('fill', event.target.tagName === 'rect' ?
|
|
708
|
+
.attr('fill', (d) => event.target.tagName === 'rect' ? this.colorFunction(d.serie) : '#333333');
|
|
707
709
|
};
|
|
708
710
|
this.openTooltip = (...[, d]) => {
|
|
709
711
|
// If type is string, the user has clicked on a y-axis tick
|
|
@@ -772,7 +774,7 @@ export class barChart {
|
|
|
772
774
|
if (this.afVariation == BarChartVariation.Horizontal)
|
|
773
775
|
this._tickWidth = this.getLargestText(this._xScale.ticks().map((tick) => tick.toLocaleString()));
|
|
774
776
|
this.tickSizes();
|
|
775
|
-
this._barChartContainer.selectAll('.barGroup').data(this.
|
|
777
|
+
this._barChartContainer.selectAll('.barGroup').data(this.mappedData);
|
|
776
778
|
if ((_b = (_a = this._chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels)
|
|
777
779
|
this._textSelection.remove();
|
|
778
780
|
this.initBarText();
|
|
@@ -843,6 +845,14 @@ export class barChart {
|
|
|
843
845
|
this._chartData = data;
|
|
844
846
|
else
|
|
845
847
|
this._chartData = JSON.parse(data);
|
|
848
|
+
this.mappedData = this.reshapeData();
|
|
849
|
+
// checking for width of each tick
|
|
850
|
+
this.mappedData.forEach((elem) => {
|
|
851
|
+
if (elem.series.length > this.dataWidth)
|
|
852
|
+
this.dataWidth = elem.series.length;
|
|
853
|
+
});
|
|
854
|
+
if (this.dataWidth > 1)
|
|
855
|
+
this.barGap = 1;
|
|
846
856
|
}
|
|
847
857
|
initSvg() {
|
|
848
858
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -966,7 +976,7 @@ export class barChart {
|
|
|
966
976
|
this._barChartContainer.selectAll('.barGroup').remove();
|
|
967
977
|
this._barSelection = this._barChartContainer
|
|
968
978
|
.selectAll('barGroup')
|
|
969
|
-
.data(this.
|
|
979
|
+
.data(this.mappedData)
|
|
970
980
|
.join('g')
|
|
971
981
|
.attr('class', 'barGroup')
|
|
972
982
|
.attr('id', (d) => 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, '_'))
|
|
@@ -977,26 +987,17 @@ export class barChart {
|
|
|
977
987
|
.attr('y', (d) => this.afVariation === BarChartVariation.Horizontal
|
|
978
988
|
? this._yScale(d.key)
|
|
979
989
|
: this._dims.height - this._margin.bottom)
|
|
980
|
-
.attr('x',
|
|
981
|
-
? 2
|
|
982
|
-
: this._xScale(d.key))
|
|
990
|
+
.attr('x', this.xFunction)
|
|
983
991
|
.attr('ry', 4)
|
|
984
992
|
.attr('rx', 4)
|
|
985
|
-
.attr('width',
|
|
986
|
-
? this._xScale(d.value)
|
|
987
|
-
: this._xScale.bandwidth())
|
|
993
|
+
.attr('width', this.widthFunction)
|
|
988
994
|
.attr('height', () => 0)
|
|
989
|
-
//.attr('height', (d: any) => this.afVariation === BarChartVariation.Horizontal ? this._yScale.bandwidth() : (this._dims.height - this._margin.bottom) - this._yScale(d.value))
|
|
990
995
|
.attr('fill', 'gray')
|
|
991
996
|
.transition()
|
|
992
997
|
.duration(400)
|
|
993
998
|
.delay((...[, i]) => i * 150)
|
|
994
|
-
.attr('y',
|
|
995
|
-
|
|
996
|
-
: this._yScale(d.value))
|
|
997
|
-
.attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
|
|
998
|
-
? this._yScale.bandwidth()
|
|
999
|
-
: this._dims.height - this._margin.bottom - this._yScale(d.value));
|
|
999
|
+
.attr('y', this.yFunction)
|
|
1000
|
+
.attr('height', this.heightFunction);
|
|
1000
1001
|
this._barSelection
|
|
1001
1002
|
.transition()
|
|
1002
1003
|
.duration(400)
|
|
@@ -1087,7 +1088,7 @@ export class barChart {
|
|
|
1087
1088
|
if (this.afVariation === BarChartVariation.Horizontal) {
|
|
1088
1089
|
this.setValueTicks();
|
|
1089
1090
|
// Removing first tick, because it aligns with y-axis domain
|
|
1090
|
-
this._xAxisHandle.select('.tick').select('line').remove();
|
|
1091
|
+
//this._xAxisHandle.select('.tick').select('line').remove();
|
|
1091
1092
|
}
|
|
1092
1093
|
else {
|
|
1093
1094
|
if (!empty) {
|
|
@@ -1101,39 +1102,41 @@ export class barChart {
|
|
|
1101
1102
|
initBars() {
|
|
1102
1103
|
this._barSelection = this._barChartContainer
|
|
1103
1104
|
.selectAll('barGroup')
|
|
1104
|
-
.data(this.
|
|
1105
|
+
.data(this.mappedData)
|
|
1105
1106
|
.join('g')
|
|
1106
1107
|
.attr('class', 'barGroup')
|
|
1107
|
-
.attr('id', (d) =>
|
|
1108
|
-
.
|
|
1108
|
+
.attr('id', (d) => {
|
|
1109
|
+
return 'barGroup' + d.key.replace(/[^A-Z0-9]+/gi, '_');
|
|
1110
|
+
});
|
|
1111
|
+
this._barSelection.selectAll('.barGroup')
|
|
1112
|
+
.data((d) => {
|
|
1113
|
+
return d.series;
|
|
1114
|
+
})
|
|
1115
|
+
.join('rect')
|
|
1109
1116
|
.attr('class', 'bar')
|
|
1110
|
-
.style('cursor', 'pointer')
|
|
1111
|
-
|
|
1112
|
-
.attr('y',
|
|
1113
|
-
? this._yScale(d.key)
|
|
1114
|
-
: this._yScale(d.value))
|
|
1115
|
-
.attr('x', (d) => this.afVariation === BarChartVariation.Horizontal
|
|
1116
|
-
? 2
|
|
1117
|
-
: this._xScale(d.key))
|
|
1117
|
+
.style('cursor', 'pointer')
|
|
1118
|
+
.attr('x', this.xFunction)
|
|
1119
|
+
.attr('y', this.yFunction)
|
|
1118
1120
|
.attr('ry', 4)
|
|
1119
1121
|
.attr('rx', 4)
|
|
1120
|
-
.attr('width',
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
.attr('height', (d) => this.afVariation === BarChartVariation.Horizontal
|
|
1124
|
-
? this._yScale.bandwidth()
|
|
1125
|
-
: this._dims.height - this._margin.bottom - this._yScale(d.value))
|
|
1126
|
-
.attr('fill', '#00005a')
|
|
1122
|
+
.attr('width', this.widthFunction)
|
|
1123
|
+
.attr('height', this.heightFunction)
|
|
1124
|
+
.attr('fill', (d) => this.colorFunction(d.serie))
|
|
1127
1125
|
.on('mouseenter', this.hover)
|
|
1128
1126
|
.on('mouseleave', this.hoverOut)
|
|
1129
1127
|
.on('click', this.openTooltip);
|
|
1130
1128
|
}
|
|
1131
1129
|
initBarText() {
|
|
1130
|
+
var _a, _b;
|
|
1131
|
+
if (!((_b = (_a = this._chartData) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.valueLabels))
|
|
1132
|
+
return;
|
|
1132
1133
|
this._textSelection = this._barChartContainer
|
|
1133
1134
|
.selectAll('.barGroup')
|
|
1134
1135
|
.append('text');
|
|
1135
1136
|
this._textSelection
|
|
1136
|
-
.text((d) =>
|
|
1137
|
+
.text((d) => {
|
|
1138
|
+
return d.value ? d.value.toLocaleString(undefined, this._numberFormat) : undefined;
|
|
1139
|
+
})
|
|
1137
1140
|
.attr('class', 'barText')
|
|
1138
1141
|
.attr('font-size', this.fontSize)
|
|
1139
1142
|
.attr('font-weight', '600')
|
|
@@ -1271,6 +1274,18 @@ export class barChart {
|
|
|
1271
1274
|
}
|
|
1272
1275
|
}
|
|
1273
1276
|
}
|
|
1277
|
+
// Getting correct color given index or name of data serie
|
|
1278
|
+
colorFunction(input) {
|
|
1279
|
+
if (typeof input === 'number')
|
|
1280
|
+
return `var(${this.colorPalettes[input]})`;
|
|
1281
|
+
else {
|
|
1282
|
+
const index = this._chartData.data.series.findIndex((serie) => serie.title === input);
|
|
1283
|
+
if (index > 0)
|
|
1284
|
+
return `var(${this.colorPalettes[index]})`;
|
|
1285
|
+
else
|
|
1286
|
+
return `var(${this.colorPalettes[0]})`;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1274
1289
|
// Resizing bar chart
|
|
1275
1290
|
resize() {
|
|
1276
1291
|
var _a;
|
|
@@ -1351,11 +1366,11 @@ export class barChart {
|
|
|
1351
1366
|
}
|
|
1352
1367
|
// Not currently used
|
|
1353
1368
|
/*get cssModifiers() {
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1369
|
+
return {
|
|
1370
|
+
'digi-bar-chart--vertical': this.afVariation == 'vertical',
|
|
1371
|
+
'digi-bar-chart--horizontal': this.afVariation == 'horizontal'
|
|
1372
|
+
};
|
|
1373
|
+
}*/
|
|
1359
1374
|
// Returns pixelwidth of text given the current fontSize (costly function using .each)
|
|
1360
1375
|
getTextSize(text) {
|
|
1361
1376
|
const textWidth = [];
|
|
@@ -1425,7 +1440,7 @@ export class barChart {
|
|
|
1425
1440
|
<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>`;
|
|
1426
1441
|
}
|
|
1427
1442
|
}
|
|
1428
|
-
return (h(Host, { key: '
|
|
1443
|
+
return (h(Host, { key: 'a1e4aaa788766d54c691e95b7e70932b0e7d2b05', ref: (el) => (this._host = el) }, h("div", { key: '2fac926d196acaa20ab5f438968e3c98c08dd104', class: "topWrapper", ref: (el) => (this._titleDiv = el) }, h("digi-typography", { key: '16d8cbd0f03a2a2d24d3366ab1b3eaed797dd361', class: "chartTitle", innerHTML: heading }), h("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() : ''}` }, h("digi-icon-table", { key: '152938d206dc00e2fb88b52d332960cbeda2c045', slot: "icon" }), "Visa tabell"), h("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() : ''}` }, h("digi-icon-chart", { key: 'ac4b8adad6ace97f50591cd39b8b0082d067f069', slot: "icon" }), "Visa diagram"), h("div", { key: 'b28e00a40b5c1a2919146ec4815f23a14fdfac50', class: "scChartStatus", role: "status", ref: (el) => (this._status = el) })), h("div", { key: '63f80744faa1d4b3d7d62bece3b5c446eda3ae7b', class: "chartTooltip", id: this.afId }, h("div", { key: '8c9fa9388b9bfc071c4a594275159eb36a8ec43b', class: "tooltipBody" }), h("digi-icon-x", { key: '252d12a937e5276381fa40ec3bb4e77c259da9c1', class: "close" }), this.afVariation === BarChartVariation.Horizontal ? (h("digi-icon-caret-up", null)) : (h("digi-icon-caret-down", null))), h("div", { key: '9b70433c310882bd0a06784ca1fa21c5b2dd9e52', ref: (el) => (this._chartDiv = el) }, " "), h("div", { key: '459e38448e29eea1fa7a10de7f3f1f06b6404eab', class: "legend", ref: (el) => (this._legendDiv = el) }), h("div", { key: 'cc655054cb3c3688c75060ebbdf6c3f8ea4ad712', class: "table", ref: (el) => (this._tableDiv = el) }, ' ')));
|
|
1429
1444
|
}
|
|
1430
1445
|
static get is() { return "digi-bar-chart"; }
|
|
1431
1446
|
static get encapsulation() { return "scoped"; }
|
|
@@ -13,28 +13,32 @@
|
|
|
13
13
|
min-height: fit-content;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.buttonWrapper {
|
|
17
|
-
--digi--button--padding--medium: 0 0 0.75rem 0;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
16
|
.chart {
|
|
21
17
|
box-sizing: content-box;
|
|
22
18
|
width: auto;
|
|
23
19
|
}
|
|
24
20
|
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
-
--digi--typography--h3--margin: 0.5rem;
|
|
28
|
-
--digi--typography--h4--margin: 0.5rem;
|
|
29
|
-
--digi--typography--h5--margin: 0.5rem;
|
|
30
|
-
--digi--typography--h6--margin: 0.5rem;
|
|
21
|
+
.topWrapper,
|
|
22
|
+
.chartTitle .digi-typography {
|
|
31
23
|
display: flex;
|
|
32
|
-
justify-content: flex-start;
|
|
33
24
|
flex-direction: column;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
gap: 0.75rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.topWrapper {
|
|
29
|
+
margin-bottom: 0.75rem;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.chartTitle {
|
|
33
|
+
--MARGIN--HEADING-2: 0;
|
|
34
|
+
--MARGIN--HEADING-3: 0;
|
|
35
|
+
--MARGIN--HEADING-4: 0;
|
|
36
|
+
--MARGIN--HEADING-5: 0;
|
|
37
|
+
--MARGIN--HEADING-6: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.buttonWrapper {
|
|
41
|
+
--digi--button--padding--medium: 0 0 0.75rem 0;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
.close {
|
|
@@ -150,12 +154,4 @@
|
|
|
150
154
|
overflow-y: auto;
|
|
151
155
|
scrollbar-width: thin;
|
|
152
156
|
scrollbar-color: rgb(245, 245, 245) transparent;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.topWrapper {
|
|
156
|
-
display: flex;
|
|
157
|
-
flex-direction: row;
|
|
158
|
-
align-items: flex-end;
|
|
159
|
-
justify-content: space-between;
|
|
160
|
-
flex-wrap: wrap;
|
|
161
157
|
}
|
|
@@ -30,7 +30,7 @@ digi-code-block .digi-code-block--light pre[class*=language-] {
|
|
|
30
30
|
text-align: left;
|
|
31
31
|
white-space: pre-wrap;
|
|
32
32
|
word-spacing: normal;
|
|
33
|
-
word-break:
|
|
33
|
+
word-break: break-word;
|
|
34
34
|
word-wrap: normal;
|
|
35
35
|
line-height: 1.5;
|
|
36
36
|
-moz-tab-size: 4;
|
|
@@ -174,7 +174,7 @@ digi-code-block .digi-code-block--dark pre[class*=language-] {
|
|
|
174
174
|
text-align: left;
|
|
175
175
|
white-space: pre-wrap;
|
|
176
176
|
word-spacing: normal;
|
|
177
|
-
word-break:
|
|
177
|
+
word-break: break-word;
|
|
178
178
|
word-wrap: normal;
|
|
179
179
|
line-height: 1.5;
|
|
180
180
|
-moz-tab-size: 4;
|
|
@@ -67,7 +67,7 @@ export class InfoCard {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
render() {
|
|
70
|
-
return (h("div", { key: '
|
|
70
|
+
return (h("div", { key: 'b87aaf790c4736075233c8cf0d15e16e757e67f1', class: Object.assign({ 'digi-info-card': true }, this.cssModifiers) }, h("div", { key: '4f645a39d73a782d44ce58d6027805daa07ce6b6', class: "digi-info-card__content" }, h("div", { key: '3c0e7f91e3ac681c051eb24688c88fb28a1cf6bf', class: "digi-info-card__icon" }, this.hasListIcon && (h("span", { key: '53ddc991ebbd95b6a2076f491187a4c8de274b58', class: "digi-info-card__icon" }, h("slot", { key: '182ee887c37e7dea4a4ab98189ea08af15418944', name: "icon" })))), h(this.afHeadingLevel, { key: '8a2b1fbd4cf78cc706daf2fc74157587c16e43b8', class: "digi-info-card__heading" }, this.afHeading), h("digi-typography", { key: '6c0ccbf7115dd68e2f7e6e0b55daac41d9285c2d' }, h("slot", { key: '34f5f0b4526721271edd8095ae78e8812142ea10' })), this.shouldRenderInternalLink && (h("digi-link-internal", { key: 'c4f3442b1b6c22ecc6d0cd12f37af5f4707244b1', class: "digi-info-card__link", afHref: this.afLinkHref, onAfOnClick: (e) => this.clickLinkHandler(e), hideVisitedColor: this.hideVisitedColor }, this.afLinkText)))));
|
|
71
71
|
}
|
|
72
72
|
static get is() { return "digi-info-card"; }
|
|
73
73
|
static get encapsulation() { return "scoped"; }
|
|
@@ -181,9 +181,9 @@ export class InfoCard {
|
|
|
181
181
|
"docs": {
|
|
182
182
|
"tags": [{
|
|
183
183
|
"name": "en",
|
|
184
|
-
"text": "Set info card
|
|
184
|
+
"text": "Set info card size. Can be 'Standard'."
|
|
185
185
|
}],
|
|
186
|
-
"text": "S\u00E4tter storlek p\u00E5 kortet. Kan vara '
|
|
186
|
+
"text": "S\u00E4tter storlek p\u00E5 kortet. Kan vara 'Standard'."
|
|
187
187
|
},
|
|
188
188
|
"getter": false,
|
|
189
189
|
"setter": false,
|
|
@@ -210,9 +210,9 @@ export class InfoCard {
|
|
|
210
210
|
"docs": {
|
|
211
211
|
"tags": [{
|
|
212
212
|
"name": "en",
|
|
213
|
-
"text": "Set
|
|
213
|
+
"text": "Set border position. Can be 'top' or 'left'. This only applies if 'af-type' is 'related'."
|
|
214
214
|
}],
|
|
215
|
-
"text": "S\u00E4tter
|
|
215
|
+
"text": "S\u00E4tter position f\u00F6r kantlinjen. Kan vara 'top' eller 'left'. Detta har endast genomslag om 'af-type' \u00E4r 'related'."
|
|
216
216
|
},
|
|
217
217
|
"getter": false,
|
|
218
218
|
"setter": false,
|