@porscheinformatik/clr-addons 21.4.0 → 21.5.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.
@@ -1070,6 +1070,357 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImpo
1070
1070
  args: [{ selector: 'clr-bar-chart', changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, template: "<div class=\"chart-container\" data-testid=\"bar-chart\">\n <div\n class=\"chart-area\"\n data-testid=\"bar-chart-area\"\n #container\n (cngWindowResize)=\"updateChart()\"\n [class.pt-3]=\"alertMessageAndType()\"\n >\n <svg [class.d-none]=\"loading() || !data()?.length || allValuesZero()\" #chart></svg>\n\n @if (tooltipPosition()) {\n <cng-chart-tooltip\n data-testid=\"bar-chart-tooltip\"\n [tooltipPosition]=\"tooltipPosition()\"\n [tooltipOrientation]=\"tooltipOrientation()\"\n [squareColor]=\"!stacks() ? selectedItem()?.color : undefined\"\n (tooltipClosed)=\"resetTooltip()\"\n (cngOutsideClick)=\"resetTooltip()\"\n (tooltipHeaderClicked)=\"valueClicked.emit({ key: tooltipKey(), label: tooltipLabel(), value: tooltipValue() })\"\n >\n <ng-container ngProjectAs=\"cng-title\"> ({{ tooltipValue() }}) {{ tooltipLabel() }}</ng-container>\n\n <p class=\"mt-0\" data-testid=\"bar-chart-tooltip-percentage\">\n {{ (100 * tooltipValue()) / total() | number: '1.0-2' }}%\n {{ tooltipPercentOfTotal() }}\n </p>\n\n @if (stacks()) {\n @for (slice of selectedStackSlices(); track slice.key) {\n <div\n class=\"mt-0-5 d-flex\"\n [attr.data-testid]=\"'bar-chart-tooltip-stack-slice-' + (slice.fullLabel || slice.label)\"\n >\n <div class=\"color-square mr-0-5\" [style.background-color]=\"toChartColor(slice.color)\"></div>\n <strong>{{ slice.fullLabel || slice.label }}:&nbsp;</strong>\n <span\n class=\"has-more-info\"\n [attr.data-testid]=\"'bar-chart-tooltip-stack-value-' + (slice.fullLabel || slice.label)\"\n (click)=\"\n valueClicked.emit({\n key: [slice.key],\n label: slice.fullLabel || slice.label,\n value: slice.value,\n })\n \"\n >\n {{ slice.value }}\n </span>\n </div>\n <p\n class=\"mt-0-25 percentage-info\"\n [attr.data-testid]=\"'bar-chart-tooltip-stack-percentage-' + (slice.fullLabel || slice.label)\"\n >\n {{ (100 * slice.value) / total() | number: '1.0-2' }}%\n {{ tooltipPercentOfTotal() }}\n {{ slice.percentageOfStack | number: '1.0-2' }}% {{ tooltipPercentOf() }} \"{{ tooltipLabel() }}\"\n </p>\n }\n }\n </cng-chart-tooltip>\n }\n @if (loading() || !data()?.length || allValuesZero()) {\n <cng-bar-chart-skeleton\n data-testid=\"bar-chart-skeleton\"\n [orientation]=\"orientation()\"\n [skeletonType]=\"loading() ? 'loading' : 'placeholder'\"\n />\n }\n @if (alertMessageAndType()) {\n <cng-chart-alert-overlay\n data-testid=\"bar-chart-alert-overlay\"\n [alertType]=\"alertMessageAndType()[1]\"\n [alertMessage]=\"alertMessageAndType()[0]\"\n />\n }\n </div>\n\n @if (showLegend() && !loading() && legendItems().length && !allValuesZero()) {\n <cng-chart-legend data-testid=\"bar-chart-legend\" [items]=\"legendItems()\" />\n }\n @if (showExportButton() && !loading() && data()?.length) {\n <cng-chart-export-button\n data-testid=\"bar-chart-export\"\n [svgRef]=\"svgElement()\"\n [filename]=\"exportFilename()\"\n [buttonTitle]=\"exportButtonTitle()\"\n [legendItems]=\"legendItems()\"\n />\n }\n</div>\n", styles: [":host{display:block;width:100%;height:100%}:host ::ng-deep .domain{display:none}.chart-container{display:flex;flex-direction:column;width:100%;height:100%;position:relative}.chart-area{flex:1;min-height:0;position:relative}svg{height:100%;width:100%}cng-bar-chart-skeleton{height:100%}.percentage-info{margin-left:15px}\n"] }]
1071
1071
  }], ctorParameters: () => [], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], stacks: [{ type: i0.Input, args: [{ isSignal: true, alias: "stacks", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: true }] }], tooltipOrientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipOrientation", required: false }] }], barSizePx: [{ type: i0.Input, args: [{ isSignal: true, alias: "barSizePx", required: false }] }], barAreaSizePx: [{ type: i0.Input, args: [{ isSignal: true, alias: "barAreaSizePx", required: false }] }], tooltipPercentOfTotal: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipPercentOfTotal", required: false }] }], tooltipPercentOf: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipPercentOf", required: false }] }], noItemsMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "noItemsMessage", required: false }] }], tooManyItemsMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooManyItemsMessage", required: false }] }], tooManyItemsGroupedMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooManyItemsGroupedMessage", required: false }] }], allValuesZeroMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "allValuesZeroMessage", required: false }] }], showLegend: [{ type: i0.Input, args: [{ isSignal: true, alias: "showLegend", required: false }] }], showExportButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "showExportButton", required: false }] }], exportButtonTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportButtonTitle", required: false }] }], exportFilename: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportFilename", required: false }] }], xAxisLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "xAxisLabel", required: false }] }], yAxisLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "yAxisLabel", required: false }] }], valueClicked: [{ type: i0.Output, args: ["valueClicked"] }] } });
1072
1072
 
1073
+ class GroupedBarChartComponent extends ChartBase {
1074
+ constructor() {
1075
+ super(...arguments);
1076
+ this.data = input.required(...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
1077
+ this.groups = input(undefined, ...(ngDevMode ? [{ debugName: "groups" }] : /* istanbul ignore next */ []));
1078
+ this.orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
1079
+ this.tooltipOrientation = input('top', ...(ngDevMode ? [{ debugName: "tooltipOrientation" }] : /* istanbul ignore next */ []));
1080
+ this.barSizePx = input(12, ...(ngDevMode ? [{ debugName: "barSizePx" }] : /* istanbul ignore next */ []));
1081
+ this.groupAreaSizePx = input(60, ...(ngDevMode ? [{ debugName: "groupAreaSizePx" }] : /* istanbul ignore next */ []));
1082
+ this.noItemsMessage = input(NO_ITEMS_MESSAGE, ...(ngDevMode ? [{ debugName: "noItemsMessage" }] : /* istanbul ignore next */ []));
1083
+ this.tooManyItemsGroupedMessage = input(TOO_MANY_ITEMS_GROUPED_MESSAGE, ...(ngDevMode ? [{ debugName: "tooManyItemsGroupedMessage" }] : /* istanbul ignore next */ []));
1084
+ this.allValuesZeroMessage = input(ALL_ITEMS_ZERO_MESSAGE, ...(ngDevMode ? [{ debugName: "allValuesZeroMessage" }] : /* istanbul ignore next */ []));
1085
+ this.showLegend = input(true, ...(ngDevMode ? [{ debugName: "showLegend" }] : /* istanbul ignore next */ []));
1086
+ this.showExportButton = input(false, ...(ngDevMode ? [{ debugName: "showExportButton" }] : /* istanbul ignore next */ []));
1087
+ this.exportButtonTitle = input('Export', ...(ngDevMode ? [{ debugName: "exportButtonTitle" }] : /* istanbul ignore next */ []));
1088
+ this.exportFilename = input('grouped-bar-chart', ...(ngDevMode ? [{ debugName: "exportFilename" }] : /* istanbul ignore next */ []));
1089
+ /** Optional label rendered below the X axis. */
1090
+ this.xAxisLabel = input('', ...(ngDevMode ? [{ debugName: "xAxisLabel" }] : /* istanbul ignore next */ []));
1091
+ /** Optional label rendered rotated to the left of the Y axis. */
1092
+ this.yAxisLabel = input('', ...(ngDevMode ? [{ debugName: "yAxisLabel" }] : /* istanbul ignore next */ []));
1093
+ this.valueClicked = output();
1094
+ this.allValuesZero = computed(() => !!this.data()?.length && this.data().every(d => d.value === 0), ...(ngDevMode ? [{ debugName: "allValuesZero" }] : /* istanbul ignore next */ []));
1095
+ this.toChartColor = toChartColor;
1096
+ this.tooltipLabel = computed(() => this.selectedItem()?.fullLabel ?? this.selectedItem()?.label, ...(ngDevMode ? [{ debugName: "tooltipLabel" }] : /* istanbul ignore next */ []));
1097
+ this.legendItems = computed(() => {
1098
+ if (!this.showLegend() || !this.data()?.length) {
1099
+ return [];
1100
+ }
1101
+ const seen = new Set();
1102
+ const items = [];
1103
+ for (const item of this.data()) {
1104
+ const label = item.fullLabel ?? item.label;
1105
+ if (!seen.has(label)) {
1106
+ seen.add(label);
1107
+ items.push({ label, color: item.color });
1108
+ }
1109
+ }
1110
+ return items;
1111
+ }, ...(ngDevMode ? [{ debugName: "legendItems" }] : /* istanbul ignore next */ []));
1112
+ this.alertMessageAndType = computed(() => {
1113
+ if (this.loading()) {
1114
+ return undefined;
1115
+ }
1116
+ if (this.allValuesZero()) {
1117
+ return [this.allValuesZeroMessage(), NO_ITEMS_ALERT_TYPE];
1118
+ }
1119
+ if (!this.showingGroupCount()) {
1120
+ return [this.noItemsMessage(), NO_ITEMS_ALERT_TYPE];
1121
+ }
1122
+ if (this.totalGroupCount() !== this.showingGroupCount()) {
1123
+ const message = this.tooManyItemsGroupedMessage()
1124
+ .replace('{{totalAmount}}', String(this.totalGroupCount()))
1125
+ .replace('{{showingAmount}}', String(this.showingGroupCount()));
1126
+ return [message, TOO_MANY_ITEMS_ALERT_TYPE];
1127
+ }
1128
+ return undefined;
1129
+ }, ...(ngDevMode ? [{ debugName: "alertMessageAndType" }] : /* istanbul ignore next */ []));
1130
+ this.textRenderer = new TextRenderer();
1131
+ this.MARGIN = { top: 10, right: 20, bottom: 30, left: 80 };
1132
+ this.totalGroupCount = signal(0, ...(ngDevMode ? [{ debugName: "totalGroupCount" }] : /* istanbul ignore next */ []));
1133
+ this.showingGroupCount = signal(0, ...(ngDevMode ? [{ debugName: "showingGroupCount" }] : /* istanbul ignore next */ []));
1134
+ this.slicedDataPoints = signal([], ...(ngDevMode ? [{ debugName: "slicedDataPoints" }] : /* istanbul ignore next */ []));
1135
+ this.barSelection = null;
1136
+ this.labelSelection = null;
1137
+ }
1138
+ ngOnChanges(_changes) {
1139
+ if (!this.svg) {
1140
+ return;
1141
+ }
1142
+ requestAnimationFrame(() => this.updateChart());
1143
+ }
1144
+ ngAfterViewInit() {
1145
+ this.createChart();
1146
+ super.ngAfterViewInit();
1147
+ }
1148
+ createChart() {
1149
+ this.svg = select(this.chartRef().nativeElement);
1150
+ }
1151
+ updateChart() {
1152
+ this.svg.selectAll('*').remove();
1153
+ if (this.loading()) {
1154
+ this.resetVisibleState();
1155
+ return;
1156
+ }
1157
+ const normalizedGroups = this.getNormalizedGroups();
1158
+ this.totalGroupCount.set(normalizedGroups.length);
1159
+ if (!this.data()?.length || !normalizedGroups.length) {
1160
+ this.resetVisibleState();
1161
+ return;
1162
+ }
1163
+ const { width: containerWidth, height: containerHeight } = this.getContainerDimensions();
1164
+ const extraBottom = this.xAxisLabel() ? 16 : 0;
1165
+ const extraLeft = this.yAxisLabel() ? 16 : 0;
1166
+ const leftMargin = (this.orientation() === 'horizontal' ? this.MARGIN.left : 30) + extraLeft;
1167
+ const width = containerWidth - leftMargin - this.MARGIN.right;
1168
+ const height = containerHeight - this.MARGIN.top - (this.MARGIN.bottom + extraBottom);
1169
+ if (width <= 0 || height <= 0) {
1170
+ this.resetVisibleState();
1171
+ return;
1172
+ }
1173
+ const visibleGroups = normalizedGroups.slice(0, this.getMaxAmountOfGroups(width, height));
1174
+ const visibleGroupKeys = new Set(visibleGroups.map(group => group.key));
1175
+ const dataPoints = this.data()
1176
+ .filter(item => visibleGroupKeys.has(item.groupKey))
1177
+ .map(item => ({
1178
+ ...item,
1179
+ groupLabel: visibleGroups.find(group => group.key === item.groupKey)?.label ?? item.groupLabel ?? item.groupKey,
1180
+ }));
1181
+ this.showingGroupCount.set(visibleGroups.length);
1182
+ this.slicedDataPoints.set(dataPoints);
1183
+ const g = this.svg
1184
+ .attr('width', width)
1185
+ .attr('height', height)
1186
+ .append('g')
1187
+ .attr('transform', `translate(${leftMargin},${this.MARGIN.top})`);
1188
+ if (this.orientation() === 'vertical') {
1189
+ this.createVerticalChart(g, visibleGroups, width, height, this.xAxisLabel(), this.yAxisLabel(), leftMargin);
1190
+ }
1191
+ else {
1192
+ this.createHorizontalChart(g, visibleGroups, width, height, this.xAxisLabel(), this.yAxisLabel(), leftMargin);
1193
+ }
1194
+ this.styleGridLines(g);
1195
+ }
1196
+ createVerticalChart(g, groups, width, height, xAxisLabel, yAxisLabel, leftMargin) {
1197
+ const x0 = scaleBand()
1198
+ .domain(groups.map(group => group.key))
1199
+ .range([0, width])
1200
+ .paddingInner(0.2);
1201
+ const x1 = scaleBand().domain(this.seriesLabels()).range([0, x0.bandwidth()]).padding(0.05);
1202
+ const y = scaleLinear()
1203
+ .domain([0, max(this.slicedDataPoints(), (d) => d.value) || 0])
1204
+ .nice()
1205
+ .range([height, 0]);
1206
+ const xAxis = g
1207
+ .append('g')
1208
+ .attr('transform', `translate(0,${height})`)
1209
+ .call(axisBottom(x0).tickFormat(groupKey => groups.find(group => group.key === groupKey)?.label ?? groupKey));
1210
+ this.labelSelection = xAxis
1211
+ .selectAll('text')
1212
+ .data(groups)
1213
+ .call(this.addTextCommonInfo)
1214
+ .call(this.addTextAndTitle.bind(this), x0.bandwidth());
1215
+ const tickValues = y.ticks(5).filter((tick) => Number.isInteger(tick));
1216
+ const yAxis = g
1217
+ .append('g')
1218
+ .call(axisLeft(y).tickValues(tickValues).tickSize(-width).tickFormat(format('~s')))
1219
+ .selectAll('text');
1220
+ yAxis.call(this.addTextCommonInfo);
1221
+ this.createBarSelectionGroups(g);
1222
+ this.addVerticalBarRectangle(x0, x1, y, 2)
1223
+ .attr('class', 'bar-highlight')
1224
+ .attr('fill', '#fff')
1225
+ .style('stroke', (d) => toChartColor(d.color))
1226
+ .attr('stroke-width', 2)
1227
+ .style('opacity', 0);
1228
+ this.addVerticalBarRectangle(x0, x1, y)
1229
+ .attr('class', 'bar')
1230
+ .style('fill', (d) => toChartColor(d.color));
1231
+ this.appendAxisLabel(g, xAxisLabel, width / 2, height + 40);
1232
+ this.appendAxisLabel(g, yAxisLabel, -height / 2, -(leftMargin - 10), 'rotate(-90)');
1233
+ }
1234
+ createHorizontalChart(g, groups, width, height, xAxisLabel, yAxisLabel, leftMargin) {
1235
+ const x = scaleLinear()
1236
+ .domain([0, max(this.slicedDataPoints(), (d) => d.value) || 0])
1237
+ .nice()
1238
+ .range([0, width]);
1239
+ const y0 = scaleBand()
1240
+ .domain(groups.map(group => group.key))
1241
+ .range([0, height])
1242
+ .paddingInner(0.2);
1243
+ const y1 = scaleBand().domain(this.seriesLabels()).range([0, y0.bandwidth()]).padding(0.05);
1244
+ const tickValues = x.ticks(5).filter((tick) => Number.isInteger(tick));
1245
+ const xAxis = g
1246
+ .append('g')
1247
+ .attr('transform', `translate(0,${height})`)
1248
+ .call(axisBottom(x).tickValues(tickValues).tickSize(-height).tickFormat(format('~s')))
1249
+ .selectAll('text');
1250
+ xAxis.call(this.addTextCommonInfo);
1251
+ const yAxis = g
1252
+ .append('g')
1253
+ .call(axisLeft(y0).tickFormat(groupKey => groups.find(group => group.key === groupKey)?.label ?? groupKey));
1254
+ this.labelSelection = yAxis
1255
+ .selectAll('text')
1256
+ .data(groups)
1257
+ .call(this.addTextCommonInfo)
1258
+ .call(this.addTextAndTitle.bind(this), this.MARGIN.left - 10);
1259
+ this.createBarSelectionGroups(g);
1260
+ this.addHorizontalBarRectangle(x, y0, y1, 2)
1261
+ .attr('class', 'bar-highlight')
1262
+ .attr('fill', '#fff')
1263
+ .style('stroke', (d) => toChartColor(d.color))
1264
+ .attr('stroke-width', 2)
1265
+ .style('opacity', 0);
1266
+ this.addHorizontalBarRectangle(x, y0, y1)
1267
+ .attr('class', 'bar')
1268
+ .style('fill', (d) => toChartColor(d.color));
1269
+ this.appendAxisLabel(g, xAxisLabel, width / 2, height + 40);
1270
+ this.appendAxisLabel(g, yAxisLabel, -height / 2, -((this.MARGIN.left + leftMargin) / 2), 'rotate(-90)');
1271
+ }
1272
+ createBarSelectionGroups(g) {
1273
+ this.barSelection = g
1274
+ .selectAll('.bar-group')
1275
+ .data(this.slicedDataPoints(), (d) => d.key)
1276
+ .join('g')
1277
+ .attr('class', 'bar-group')
1278
+ .style('cursor', 'pointer')
1279
+ .on('mouseover', (_event, d) => this.setHoverStyles(d, true))
1280
+ .on('mouseout', (_event, d) => this.setHoverStyles(d, false))
1281
+ .call(this.addBarClickHandler.bind(this));
1282
+ }
1283
+ addHorizontalBarRectangle(x, y0, y1, outlineSize = 0) {
1284
+ const barHeight = Math.max(0, Math.min(this.barSizePx(), y1.bandwidth()));
1285
+ const yOffset = (y1.bandwidth() - barHeight) / 2;
1286
+ return this.barSelection
1287
+ .append('rect')
1288
+ .attr('x', -outlineSize)
1289
+ .attr('y', (d) => {
1290
+ return (y0(d.groupKey) || 0) + (y1(d.fullLabel ?? d.label) || 0) + yOffset - outlineSize;
1291
+ })
1292
+ .attr('width', (d) => x(d.value) + 2 * outlineSize)
1293
+ .attr('height', barHeight + 2 * outlineSize)
1294
+ .attr('rx', 1)
1295
+ .attr('ry', 1);
1296
+ }
1297
+ addVerticalBarRectangle(x0, x1, y, outlineSize = 0) {
1298
+ const barWidth = Math.max(0, Math.min(this.barSizePx(), x1.bandwidth()));
1299
+ const xOffset = (x1.bandwidth() - barWidth) / 2;
1300
+ return this.barSelection
1301
+ .append('rect')
1302
+ .attr('x', (d) => {
1303
+ return (x0(d.groupKey) || 0) + (x1(d.fullLabel ?? d.label) || 0) + xOffset - outlineSize;
1304
+ })
1305
+ .attr('y', (d) => y(d.value) - outlineSize)
1306
+ .attr('width', barWidth + 2 * outlineSize)
1307
+ .attr('height', (d) => y(0) - y(d.value) + 2 * outlineSize)
1308
+ .attr('rx', 1)
1309
+ .attr('ry', 1);
1310
+ }
1311
+ emitSelectedValue() {
1312
+ const item = this.selectedItem();
1313
+ if (!item) {
1314
+ return;
1315
+ }
1316
+ this.valueClicked.emit({
1317
+ key: item.key,
1318
+ label: item.fullLabel ?? item.label,
1319
+ groupKey: item.groupKey,
1320
+ groupLabel: item.groupLabel,
1321
+ value: item.value,
1322
+ });
1323
+ }
1324
+ addBarClickHandler(g) {
1325
+ g.on('click', (event, d) => {
1326
+ event.stopPropagation();
1327
+ this.openTooltip(d.key);
1328
+ });
1329
+ }
1330
+ openTooltip(key) {
1331
+ const index = this.slicedDataPoints().findIndex(item => item.key === key);
1332
+ const rect = this.barSelection
1333
+ .filter((_d, i) => i === index)
1334
+ .node()
1335
+ .children[0].getBoundingClientRect();
1336
+ const container = this.chartRef().nativeElement.getBoundingClientRect();
1337
+ this.tooltipPosition.set({
1338
+ x: rect.left - container.left + rect.width / 2,
1339
+ y: (this.tooltipOrientation() === 'top' ? rect.top : rect.bottom) - container.top,
1340
+ });
1341
+ this.selectedItem.set(this.slicedDataPoints()[index]);
1342
+ }
1343
+ setHoverStyles(d, isHover) {
1344
+ const barGroup = this.barSelection.filter((item) => item.key === d.key);
1345
+ barGroup.select('.bar').style('mix-blend-mode', isHover ? 'multiply' : 'unset');
1346
+ barGroup.select('.bar-highlight').style('opacity', isHover ? '1' : '0');
1347
+ this.labelSelection
1348
+ .filter((group) => group.key === d.groupKey)
1349
+ .style('font-weight', isHover ? 'bold' : 'unset');
1350
+ }
1351
+ addTextCommonInfo(g) {
1352
+ g.style('font-size', '11px').style('fill', 'var(--cds-global-color-construction-400, #666)');
1353
+ }
1354
+ addTextAndTitle(g, availableWidth) {
1355
+ g.each((d, index, nodes) => {
1356
+ const target = select(nodes[index]);
1357
+ target.text(this.textRenderer.render(d.label, 15, availableWidth, target.style('font-size'), target.style('font-family')));
1358
+ target.append('title').text(d.label);
1359
+ });
1360
+ }
1361
+ appendAxisLabel(g, text, x, y, transform) {
1362
+ if (!text) {
1363
+ return;
1364
+ }
1365
+ const el = g
1366
+ .append('text')
1367
+ .attr('text-anchor', 'middle')
1368
+ .style('font-size', '12px')
1369
+ .style('fill', 'var(--cds-global-color-construction-400, #666)')
1370
+ .text(text)
1371
+ .attr('x', x)
1372
+ .attr('y', y);
1373
+ if (transform) {
1374
+ el.attr('transform', transform);
1375
+ }
1376
+ }
1377
+ styleGridLines(g) {
1378
+ g.selectAll('.tick line').style('stroke', 'var(--cds-global-color-gray-200, #e8e8e8)');
1379
+ }
1380
+ getNormalizedGroups() {
1381
+ if (this.groups()?.length) {
1382
+ return this.groups();
1383
+ }
1384
+ const seen = new Set();
1385
+ const groups = [];
1386
+ for (const item of this.data() ?? []) {
1387
+ if (!seen.has(item.groupKey)) {
1388
+ seen.add(item.groupKey);
1389
+ groups.push({ key: item.groupKey, label: item.groupLabel ?? item.groupKey });
1390
+ }
1391
+ }
1392
+ return groups;
1393
+ }
1394
+ seriesLabels() {
1395
+ const seen = new Set();
1396
+ const labels = [];
1397
+ for (const item of this.slicedDataPoints()) {
1398
+ const label = item.fullLabel ?? item.label;
1399
+ if (!seen.has(label)) {
1400
+ seen.add(label);
1401
+ labels.push(label);
1402
+ }
1403
+ }
1404
+ return labels;
1405
+ }
1406
+ getMaxAmountOfGroups(width, height) {
1407
+ if (this.orientation() === 'vertical') {
1408
+ return Math.floor(width / this.groupAreaSizePx());
1409
+ }
1410
+ return Math.floor(height / this.groupAreaSizePx());
1411
+ }
1412
+ resetVisibleState() {
1413
+ this.showingGroupCount.set(0);
1414
+ this.slicedDataPoints.set([]);
1415
+ }
1416
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: GroupedBarChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1417
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.19", type: GroupedBarChartComponent, isStandalone: false, selector: "clr-grouped-bar-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, groups: { classPropertyName: "groups", publicName: "groups", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, tooltipOrientation: { classPropertyName: "tooltipOrientation", publicName: "tooltipOrientation", isSignal: true, isRequired: false, transformFunction: null }, barSizePx: { classPropertyName: "barSizePx", publicName: "barSizePx", isSignal: true, isRequired: false, transformFunction: null }, groupAreaSizePx: { classPropertyName: "groupAreaSizePx", publicName: "groupAreaSizePx", isSignal: true, isRequired: false, transformFunction: null }, noItemsMessage: { classPropertyName: "noItemsMessage", publicName: "noItemsMessage", isSignal: true, isRequired: false, transformFunction: null }, tooManyItemsGroupedMessage: { classPropertyName: "tooManyItemsGroupedMessage", publicName: "tooManyItemsGroupedMessage", isSignal: true, isRequired: false, transformFunction: null }, allValuesZeroMessage: { classPropertyName: "allValuesZeroMessage", publicName: "allValuesZeroMessage", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, showExportButton: { classPropertyName: "showExportButton", publicName: "showExportButton", isSignal: true, isRequired: false, transformFunction: null }, exportButtonTitle: { classPropertyName: "exportButtonTitle", publicName: "exportButtonTitle", isSignal: true, isRequired: false, transformFunction: null }, exportFilename: { classPropertyName: "exportFilename", publicName: "exportFilename", isSignal: true, isRequired: false, transformFunction: null }, xAxisLabel: { classPropertyName: "xAxisLabel", publicName: "xAxisLabel", isSignal: true, isRequired: false, transformFunction: null }, yAxisLabel: { classPropertyName: "yAxisLabel", publicName: "yAxisLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueClicked: "valueClicked" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"chart-container\">\n <div class=\"chart-area\" #container (cngWindowResize)=\"updateChart()\" [class.pt-3]=\"alertMessageAndType()\">\n <svg\n [class.d-none]=\"loading() || !data()?.length || allValuesZero()\"\n #chart\n role=\"img\"\n [attr.aria-label]=\"xAxisLabel() || yAxisLabel() ? yAxisLabel() + ' by ' + xAxisLabel() : 'Grouped bar chart'\"\n ></svg>\n\n @if (tooltipPosition()) {\n <cng-chart-tooltip\n [tooltipPosition]=\"tooltipPosition()\"\n [tooltipOrientation]=\"tooltipOrientation()\"\n [squareColor]=\"selectedItem()?.color\"\n (tooltipClosed)=\"resetTooltip()\"\n (cngOutsideClick)=\"resetTooltip()\"\n (tooltipHeaderClicked)=\"emitSelectedValue()\"\n >\n <ng-container ngProjectAs=\"cng-title\">({{ selectedItem()?.value }}) {{ tooltipLabel() }}</ng-container>\n\n <p class=\"mt-0\">\n <strong>{{ selectedItem()?.groupLabel }}</strong>\n </p>\n </cng-chart-tooltip>\n }\n @if (loading() || !data()?.length || allValuesZero()) {\n <cng-bar-chart-skeleton [orientation]=\"orientation()\" [skeletonType]=\"loading() ? 'loading' : 'placeholder'\" />\n }\n @if (alertMessageAndType()) {\n <cng-chart-alert-overlay [alertType]=\"alertMessageAndType()[1]\" [alertMessage]=\"alertMessageAndType()[0]\" />\n }\n </div>\n\n @if (showLegend() && !loading() && legendItems().length && !allValuesZero()) {\n <cng-chart-legend [items]=\"legendItems()\" />\n }\n @if (showExportButton() && !loading() && data()?.length) {\n <cng-chart-export-button\n [svgRef]=\"svgElement()\"\n [filename]=\"exportFilename()\"\n [buttonTitle]=\"exportButtonTitle()\"\n [legendItems]=\"legendItems()\"\n />\n }\n</div>\n", styles: [":host{display:block;width:100%;height:100%}:host ::ng-deep .domain{display:none}.chart-container{display:flex;flex-direction:column;width:100%;height:100%;position:relative}.chart-area{flex:1;min-height:0;position:relative}svg{height:100%;width:100%}cng-bar-chart-skeleton{height:100%}\n"], dependencies: [{ kind: "component", type: ChartAlertOverlayComponent, selector: "cng-chart-alert-overlay", inputs: ["alertMessage", "alertType"] }, { kind: "component", type: ChartExportButtonComponent, selector: "cng-chart-export-button", inputs: ["svgRef", "filename", "buttonTitle", "legendItems"] }, { kind: "component", type: ChartLegendComponent, selector: "cng-chart-legend", inputs: ["items"] }, { kind: "component", type: ChartSkeletonComponent, selector: "cng-bar-chart-skeleton", inputs: ["skeletonType", "orientation"] }, { kind: "component", type: ChartTooltipComponent, selector: "cng-chart-tooltip", inputs: ["tooltipPosition", "tooltipOrientation", "squareColor", "tooltipClickable"], outputs: ["tooltipClosed", "tooltipHeaderClicked"] }, { kind: "directive", type: OutsideClickDirective, selector: "[cngOutsideClick]", outputs: ["cngOutsideClick"] }, { kind: "directive", type: WindowResizeDirective, selector: "[cngWindowResize]", inputs: ["debounce", "includeFirst"], outputs: ["cngWindowResize"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1418
+ }
1419
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: GroupedBarChartComponent, decorators: [{
1420
+ type: Component,
1421
+ args: [{ selector: 'clr-grouped-bar-chart', changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, template: "<div class=\"chart-container\">\n <div class=\"chart-area\" #container (cngWindowResize)=\"updateChart()\" [class.pt-3]=\"alertMessageAndType()\">\n <svg\n [class.d-none]=\"loading() || !data()?.length || allValuesZero()\"\n #chart\n role=\"img\"\n [attr.aria-label]=\"xAxisLabel() || yAxisLabel() ? yAxisLabel() + ' by ' + xAxisLabel() : 'Grouped bar chart'\"\n ></svg>\n\n @if (tooltipPosition()) {\n <cng-chart-tooltip\n [tooltipPosition]=\"tooltipPosition()\"\n [tooltipOrientation]=\"tooltipOrientation()\"\n [squareColor]=\"selectedItem()?.color\"\n (tooltipClosed)=\"resetTooltip()\"\n (cngOutsideClick)=\"resetTooltip()\"\n (tooltipHeaderClicked)=\"emitSelectedValue()\"\n >\n <ng-container ngProjectAs=\"cng-title\">({{ selectedItem()?.value }}) {{ tooltipLabel() }}</ng-container>\n\n <p class=\"mt-0\">\n <strong>{{ selectedItem()?.groupLabel }}</strong>\n </p>\n </cng-chart-tooltip>\n }\n @if (loading() || !data()?.length || allValuesZero()) {\n <cng-bar-chart-skeleton [orientation]=\"orientation()\" [skeletonType]=\"loading() ? 'loading' : 'placeholder'\" />\n }\n @if (alertMessageAndType()) {\n <cng-chart-alert-overlay [alertType]=\"alertMessageAndType()[1]\" [alertMessage]=\"alertMessageAndType()[0]\" />\n }\n </div>\n\n @if (showLegend() && !loading() && legendItems().length && !allValuesZero()) {\n <cng-chart-legend [items]=\"legendItems()\" />\n }\n @if (showExportButton() && !loading() && data()?.length) {\n <cng-chart-export-button\n [svgRef]=\"svgElement()\"\n [filename]=\"exportFilename()\"\n [buttonTitle]=\"exportButtonTitle()\"\n [legendItems]=\"legendItems()\"\n />\n }\n</div>\n", styles: [":host{display:block;width:100%;height:100%}:host ::ng-deep .domain{display:none}.chart-container{display:flex;flex-direction:column;width:100%;height:100%;position:relative}.chart-area{flex:1;min-height:0;position:relative}svg{height:100%;width:100%}cng-bar-chart-skeleton{height:100%}\n"] }]
1422
+ }], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], groups: [{ type: i0.Input, args: [{ isSignal: true, alias: "groups", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], tooltipOrientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipOrientation", required: false }] }], barSizePx: [{ type: i0.Input, args: [{ isSignal: true, alias: "barSizePx", required: false }] }], groupAreaSizePx: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupAreaSizePx", required: false }] }], noItemsMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "noItemsMessage", required: false }] }], tooManyItemsGroupedMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooManyItemsGroupedMessage", required: false }] }], allValuesZeroMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "allValuesZeroMessage", required: false }] }], showLegend: [{ type: i0.Input, args: [{ isSignal: true, alias: "showLegend", required: false }] }], showExportButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "showExportButton", required: false }] }], exportButtonTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportButtonTitle", required: false }] }], exportFilename: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportFilename", required: false }] }], xAxisLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "xAxisLabel", required: false }] }], yAxisLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "yAxisLabel", required: false }] }], valueClicked: [{ type: i0.Output, args: ["valueClicked"] }] } });
1423
+
1073
1424
  /*
1074
1425
  * Copyright (c) 2018-2026 Porsche Informatik. All Rights Reserved.
1075
1426
  * This software is released under MIT license.
@@ -2667,6 +3018,7 @@ const CLR_CHARTS_DECLARATIONS = [
2667
3018
  BarChartComponent,
2668
3019
  ComboChartComponent,
2669
3020
  FunnelChartComponent,
3021
+ GroupedBarChartComponent,
2670
3022
  LineChartComponent,
2671
3023
  PieChartComponent,
2672
3024
  ];
@@ -2676,6 +3028,7 @@ class ClrChartsModule {
2676
3028
  BarChartComponent,
2677
3029
  ComboChartComponent,
2678
3030
  FunnelChartComponent,
3031
+ GroupedBarChartComponent,
2679
3032
  LineChartComponent,
2680
3033
  PieChartComponent], imports: [CommonModule,
2681
3034
  DecimalPipe,
@@ -2693,6 +3046,7 @@ class ClrChartsModule {
2693
3046
  BarChartComponent,
2694
3047
  ComboChartComponent,
2695
3048
  FunnelChartComponent,
3049
+ GroupedBarChartComponent,
2696
3050
  LineChartComponent,
2697
3051
  PieChartComponent] }); }
2698
3052
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ClrChartsModule, imports: [CommonModule,
@@ -2738,5 +3092,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImpo
2738
3092
  * Generated bundle index. Do not edit.
2739
3093
  */
2740
3094
 
2741
- export { AreaChartComponent, BarChartComponent, ClrChartsModule, ComboChartComponent, FunnelChartComponent, LineChartComponent, PieChartComponent };
3095
+ export { AreaChartComponent, BarChartComponent, ClrChartsModule, ComboChartComponent, FunnelChartComponent, GroupedBarChartComponent, LineChartComponent, PieChartComponent };
2742
3096
  //# sourceMappingURL=porscheinformatik-clr-addons-charts.mjs.map