@siemens/native-charts-ng 47.9.0 → 48.0.0-next.2

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 (31) hide show
  1. package/fesm2022/siemens-native-charts-ng-gauge.mjs +299 -0
  2. package/fesm2022/siemens-native-charts-ng-gauge.mjs.map +1 -0
  3. package/fesm2022/siemens-native-charts-ng-micro-bar.mjs +46 -0
  4. package/fesm2022/siemens-native-charts-ng-micro-bar.mjs.map +1 -0
  5. package/fesm2022/siemens-native-charts-ng-micro-donut.mjs +100 -0
  6. package/fesm2022/siemens-native-charts-ng-micro-donut.mjs.map +1 -0
  7. package/fesm2022/siemens-native-charts-ng-micro-line.mjs +60 -0
  8. package/fesm2022/siemens-native-charts-ng-micro-line.mjs.map +1 -0
  9. package/fesm2022/siemens-native-charts-ng-micro-progress.mjs +40 -0
  10. package/fesm2022/siemens-native-charts-ng-micro-progress.mjs.map +1 -0
  11. package/fesm2022/siemens-native-charts-ng-utils.mjs +82 -0
  12. package/fesm2022/siemens-native-charts-ng-utils.mjs.map +1 -0
  13. package/fesm2022/siemens-native-charts-ng.mjs +8 -358
  14. package/fesm2022/siemens-native-charts-ng.mjs.map +1 -1
  15. package/{components/si-nchart-gauge/si-nchart-gauge.component.d.ts → gauge/index.d.ts} +27 -28
  16. package/gauge/package.json +3 -0
  17. package/index.d.ts +11 -5
  18. package/micro-bar/index.d.ts +34 -0
  19. package/micro-bar/package.json +3 -0
  20. package/micro-donut/index.d.ts +57 -0
  21. package/micro-donut/package.json +3 -0
  22. package/micro-line/index.d.ts +35 -0
  23. package/micro-line/package.json +3 -0
  24. package/micro-progress/index.d.ts +32 -0
  25. package/micro-progress/package.json +3 -0
  26. package/package.json +27 -3
  27. package/utils/{svg-math.d.ts → index.d.ts} +14 -5
  28. package/utils/package.json +3 -0
  29. package/components/index.d.ts +0 -5
  30. package/public-api.d.ts +0 -6
  31. package/public-api.module.d.ts +0 -8
@@ -0,0 +1,299 @@
1
+ import * as i0 from '@angular/core';
2
+ import { input, numberAttribute, booleanAttribute, inject, LOCALE_ID, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { makeArc, polarToCartesian, valueToRelativeAngle, makeLine } from '@siemens/native-charts-ng/utils';
4
+
5
+ /**
6
+ * Copyright (c) Siemens 2016 - 2025
7
+ * SPDX-License-Identifier: MIT
8
+ */
9
+ class SiNChartGaugeComponent {
10
+ /**
11
+ * Start angle in degrees
12
+ *
13
+ * @defaultValue -90
14
+ */
15
+ startAngle = input(-90, { transform: numberAttribute });
16
+ /**
17
+ * End angle in degrees
18
+ *
19
+ * @defaultValue 90
20
+ */
21
+ endAngle = input(90, { transform: numberAttribute });
22
+ /**
23
+ * Min value, can be negative
24
+ *
25
+ * @defaultValue -100
26
+ */
27
+ min = input(-100, { transform: numberAttribute });
28
+ /**
29
+ * Max value, can be negative
30
+ *
31
+ * @defaultValue 100
32
+ */
33
+ max = input(100, { transform: numberAttribute });
34
+ /**
35
+ * Display mode: `sum` to sum up multiple series or `single` for a single value with optional
36
+ * segmented display.
37
+ *
38
+ * @defaultValue 'sum'
39
+ */
40
+ mode = input('sum');
41
+ /**
42
+ * Series
43
+ *
44
+ * @defaultValue []
45
+ */
46
+ series = input([]);
47
+ /**
48
+ * Colored segments.
49
+ *
50
+ * @defaultValue []
51
+ */
52
+ segments = input([]);
53
+ /**
54
+ * Unit
55
+ *
56
+ * @defaultValue ''
57
+ */
58
+ unit = input('');
59
+ /**
60
+ * Min number of decimals.
61
+ * @defaultValue 0
62
+ */
63
+ minNumberOfDecimals = input(0);
64
+ /**
65
+ * Max number of decimals.
66
+ * @defaultValue 2
67
+ */
68
+ maxNumberOfDecimals = input(2);
69
+ /**
70
+ * Number of decimals on the axis.
71
+ * @defaultValue 0
72
+ */
73
+ axisNumberOfDecimals = input(0);
74
+ /**
75
+ * Whether to show ticks
76
+ *
77
+ * @defaultValue true
78
+ */
79
+ showTicks = input(true, { transform: booleanAttribute });
80
+ /**
81
+ * Whether to show the legend
82
+ *
83
+ * @defaultValue true
84
+ */
85
+ showLegend = input(true, { transform: booleanAttribute });
86
+ /**
87
+ * Legend position:
88
+ * - `column`: chart and legend form a column, i.e. the legend is below the chart.
89
+ * The chart size is driven by the available width.
90
+ * - `row`: chart and legend form a row, i.e. the legend is besides the chart. The
91
+ * The chart size is driven by the available height.
92
+ *
93
+ * @defaultValue 'row'
94
+ */
95
+ legendPosition = input('row');
96
+ /**
97
+ * Whether to show range start/end labels on the outside of the ring
98
+ *
99
+ * @defaultValue false
100
+ */
101
+ showRangeLabelsOutside = input(false, { transform: booleanAttribute });
102
+ dim = { width: 100, height: 60 };
103
+ center = { x: 50, y: 50 };
104
+ radius = 40;
105
+ additionalHeight = 10;
106
+ backgroundPath = '';
107
+ internalSeries = [];
108
+ ticks = [];
109
+ totalSum = 0;
110
+ totalSumString = '0';
111
+ valignMiddle = false;
112
+ internalSegments = [];
113
+ locale = inject(LOCALE_ID).toString();
114
+ numberFormat = new Intl.NumberFormat(this.locale, { maximumFractionDigits: 2 });
115
+ axisNumberFormat = new Intl.NumberFormat(this.locale, {
116
+ minimumFractionDigits: this.axisNumberOfDecimals(),
117
+ maximumFractionDigits: this.axisNumberOfDecimals()
118
+ });
119
+ ngOnChanges(changes) {
120
+ let calc = false;
121
+ if (changes.minNumberOfDecimals || changes.maxNumberOfDecimals) {
122
+ this.numberFormat = new Intl.NumberFormat(this.locale, {
123
+ minimumFractionDigits: this.minNumberOfDecimals(),
124
+ maximumFractionDigits: Math.max(this.minNumberOfDecimals(), this.maxNumberOfDecimals())
125
+ });
126
+ calc = true;
127
+ }
128
+ if (changes.axisNumberOfDecimals) {
129
+ this.axisNumberFormat = new Intl.NumberFormat(this.locale, {
130
+ minimumFractionDigits: this.axisNumberOfDecimals(),
131
+ maximumFractionDigits: this.axisNumberOfDecimals()
132
+ });
133
+ calc = true;
134
+ }
135
+ if (changes.startAngle || changes.endAngle) {
136
+ this.init();
137
+ calc = true;
138
+ }
139
+ if (changes.series ||
140
+ changes.min ||
141
+ changes.max ||
142
+ changes.showTicks ||
143
+ changes.showRangeLabelsOutside ||
144
+ changes.segments) {
145
+ calc = true;
146
+ }
147
+ if (calc) {
148
+ this.calc();
149
+ }
150
+ }
151
+ ngOnInit() {
152
+ this.init();
153
+ this.calc();
154
+ }
155
+ init() {
156
+ this.backgroundPath = makeArc(this.center, this.radius, this.startAngle(), this.endAngle());
157
+ // auto adjust height
158
+ const maxAngle = Math.max(Math.abs(this.startAngle()), Math.abs(this.endAngle()));
159
+ const height = Math.max(50, polarToCartesian(this.center, this.radius, maxAngle).y);
160
+ this.dim.height = height + this.additionalHeight;
161
+ this.valignMiddle = height > 50;
162
+ }
163
+ calc() {
164
+ if (this.mode() === 'sum') {
165
+ this.calcSeriesSum();
166
+ }
167
+ else {
168
+ this.calcSeriesSingle();
169
+ }
170
+ }
171
+ reset() {
172
+ this.totalSum = 0;
173
+ this.internalSeries = [];
174
+ this.internalSegments = [];
175
+ this.ticks = [];
176
+ }
177
+ calcSeriesSum() {
178
+ this.reset();
179
+ const zeroValueAngle = this.startAngle() +
180
+ valueToRelativeAngle(this.startAngle(), this.endAngle(), this.min(), this.max(), -this.min());
181
+ this.addTick(this.startAngle(), this.min(), true);
182
+ if (this.min() !== 0) {
183
+ this.addTick(zeroValueAngle, 0, false);
184
+ }
185
+ this.addTick(this.endAngle(), this.max(), true);
186
+ let nextPosAngle = zeroValueAngle;
187
+ let nextNegAngle = zeroValueAngle;
188
+ for (const series of this.series()) {
189
+ if (series.value >= 0) {
190
+ nextPosAngle = this.addInternalSeries(nextPosAngle, series);
191
+ }
192
+ else if (series.value < 0) {
193
+ nextNegAngle = this.addInternalSeries(nextNegAngle, series, true);
194
+ }
195
+ }
196
+ this.totalSumString = this.numberFormat.format(this.totalSum);
197
+ }
198
+ calcSeriesSingle() {
199
+ this.reset();
200
+ let angle = this.startAngle();
201
+ let value = this.min();
202
+ for (const segment of this.segments()) {
203
+ const nextAngle = valueToRelativeAngle(this.startAngle(), this.endAngle(), this.min(), this.max(), segment.endValue - value) + angle;
204
+ this.internalSegments.push({
205
+ segment,
206
+ colorVar: `var(--${segment.colorToken})`,
207
+ path: makeArc(this.center, this.radius - 3.5, angle, nextAngle)
208
+ });
209
+ if (segment.endValue !== this.max()) {
210
+ this.addTick(nextAngle, segment.endValue, false);
211
+ }
212
+ angle = nextAngle;
213
+ value = segment.endValue;
214
+ }
215
+ this.addTick(this.startAngle(), this.min(), true);
216
+ this.addTick(this.endAngle(), this.max(), true);
217
+ const series = this.series()[0];
218
+ if (!series) {
219
+ this.totalSumString = '-';
220
+ return;
221
+ }
222
+ const activeSegment = this.segments().find((s, i) => series.value < s.endValue || i == this.segments().length - 1);
223
+ this.addInternalSeries(this.startAngle(), series, false, activeSegment?.colorToken);
224
+ this.totalSumString = this.numberFormat.format(this.totalSum);
225
+ }
226
+ addTick(angle, title, boundary) {
227
+ const segmentOffset = this.mode() === 'single' && this.segments().length ? 1.25 : 0;
228
+ const textRadiusOffset = boundary && this.showRangeLabelsOutside()
229
+ ? 0
230
+ : this.showTicks()
231
+ ? 10 + segmentOffset
232
+ : 8 + segmentOffset;
233
+ const textPos = polarToCartesian(this.center, this.radius - textRadiusOffset, angle);
234
+ if (boundary && this.showRangeLabelsOutside()) {
235
+ textPos.y += 6;
236
+ }
237
+ this.ticks.push({
238
+ path: this.showTicks() ? this.makeTickPath(angle) : '',
239
+ label: this.axisNumberFormat.format(title),
240
+ textPos
241
+ });
242
+ }
243
+ makeTickPath(angle) {
244
+ const startRadius = this.mode() === 'single' && this.segments().length ? this.radius - 5.5 : this.radius - 4;
245
+ const start = polarToCartesian(this.center, startRadius, angle);
246
+ const end = polarToCartesian(this.center, this.radius + 2, angle);
247
+ return makeLine(start, end);
248
+ }
249
+ addInternalSeries(startAngle, series, reverse = false, color) {
250
+ let nextAngle = valueToRelativeAngle(this.startAngle(), this.endAngle(), this.min(), this.max(), series.value) + startAngle;
251
+ const returnNextAngle = nextAngle;
252
+ if (reverse) {
253
+ [startAngle, nextAngle] = [nextAngle, startAngle];
254
+ }
255
+ startAngle = this.containAngle(startAngle);
256
+ nextAngle = this.containAngle(nextAngle);
257
+ if (startAngle !== nextAngle) {
258
+ this.pushInternalSeries(series, makeArc(this.center, this.radius, startAngle, nextAngle), color);
259
+ }
260
+ else {
261
+ this.pushInternalSeries(series, '', color);
262
+ }
263
+ this.totalSum += series.value;
264
+ return returnNextAngle;
265
+ }
266
+ pushInternalSeries(series, path, color) {
267
+ color ??= series.colorToken;
268
+ this.internalSeries.push({
269
+ series,
270
+ path,
271
+ colorVar: `var(--${color})`,
272
+ valueString: this.numberFormat.format(series.value),
273
+ highlight: false
274
+ });
275
+ }
276
+ containAngle(angle) {
277
+ return Math.max(this.startAngle(), Math.min(this.endAngle(), angle));
278
+ }
279
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiNChartGaugeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
280
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SiNChartGaugeComponent, isStandalone: true, selector: "si-nchart-gauge", inputs: { startAngle: { classPropertyName: "startAngle", publicName: "startAngle", isSignal: true, isRequired: false, transformFunction: null }, endAngle: { classPropertyName: "endAngle", publicName: "endAngle", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: false, transformFunction: null }, segments: { classPropertyName: "segments", publicName: "segments", isSignal: true, isRequired: false, transformFunction: null }, unit: { classPropertyName: "unit", publicName: "unit", isSignal: true, isRequired: false, transformFunction: null }, minNumberOfDecimals: { classPropertyName: "minNumberOfDecimals", publicName: "minNumberOfDecimals", isSignal: true, isRequired: false, transformFunction: null }, maxNumberOfDecimals: { classPropertyName: "maxNumberOfDecimals", publicName: "maxNumberOfDecimals", isSignal: true, isRequired: false, transformFunction: null }, axisNumberOfDecimals: { classPropertyName: "axisNumberOfDecimals", publicName: "axisNumberOfDecimals", isSignal: true, isRequired: false, transformFunction: null }, showTicks: { classPropertyName: "showTicks", publicName: "showTicks", isSignal: true, isRequired: false, transformFunction: null }, showLegend: { classPropertyName: "showLegend", publicName: "showLegend", isSignal: true, isRequired: false, transformFunction: null }, legendPosition: { classPropertyName: "legendPosition", publicName: "legendPosition", isSignal: true, isRequired: false, transformFunction: null }, showRangeLabelsOutside: { classPropertyName: "showRangeLabelsOutside", publicName: "showRangeLabelsOutside", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "\"legend-\" + legendPosition()" } }, usesOnChanges: true, ngImport: i0, template: "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"chart\"\n [attr.viewBox]=\"'0 0 ' + dim.width + ' ' + dim.height\"\n [attr.width]=\"dim.width\"\n [attr.height]=\"dim.height\"\n>\n <g class=\"ticks\">\n @for (tick of ticks; track $index) {\n <path [attr.d]=\"tick.path\" />\n }\n </g>\n <g class=\"tick-labels text-secondary\">\n @for (tick of ticks; track $index) {\n <text text-anchor=\"middle\" [attr.x]=\"tick.textPos.x\" [attr.y]=\"tick.textPos.y\">\n {{ tick.label }}\n </text>\n }\n </g>\n <g class=\"segments\">\n @for (seg of internalSegments; track $index) {\n <path [attr.d]=\"seg.path\" [style.stroke]=\"seg.colorVar\" />\n }\n </g>\n <g class=\"background\">\n <path [attr.d]=\"backgroundPath\" />\n </g>\n <g class=\"data\">\n @for (series of internalSeries; track $index) {\n @if (series.path) {\n <path\n [class.highlight]=\"series.highlight\"\n [attr.d]=\"series.path\"\n [attr.data-id]=\"series.series.id\"\n [style.stroke]=\"series.colorVar\"\n (mouseenter)=\"series.highlight = true\"\n (mouseleave)=\"series.highlight = false\"\n />\n }\n }\n </g>\n <text\n class=\"text-body value\"\n x=\"50\"\n y=\"50\"\n text-anchor=\"middle\"\n [attr.dominant-baseline]=\"valignMiddle ? 'middle' : 'auto'\"\n >\n {{ totalSumString }}\n @if (unit()) {\n <tspan class=\"unit\">{{ unit() }}</tspan>\n }\n </text>\n</svg>\n\n@if (showLegend()) {\n <table class=\"legend-table flex-fill\">\n <tbody>\n @for (series of internalSeries; track $index) {\n <tr [attr.data-id]=\"series.series.id\">\n <td>\n <div\n class=\"color\"\n [class.highlight]=\"series.highlight\"\n [style.color]=\"series.colorVar\"\n (mouseenter)=\"series.highlight = true\"\n (mouseleave)=\"series.highlight = false\"\n >\n </div>\n </td>\n <td class=\"value\">{{ series.valueString }}</td>\n <td class=\"name\">\n <div class=\"text-truncate\">{{ series.series.name }}</div>\n @if (series.series.description) {\n <div class=\"descr text-truncate\">{{ series.series.description }}</div>\n }\n </td>\n </tr>\n }\n </tbody>\n </table>\n}\n", styles: [":host{display:flex}:host.legend-column{flex-direction:column}:host.legend-column .chart{block-size:auto;inline-size:100%;min-block-size:120px;max-block-size:320px}:host.legend-row .chart{block-size:100%;inline-size:auto;min-inline-size:200px}.chart .background,.chart .data{stroke-width:4;fill:none}.chart .background,.chart .ticks{stroke:var(--element-ui-4)}.chart .ticks{stroke-width:.5}.chart .segments{stroke-width:.75;fill:none}.chart .tick-labels,.chart .value{fill:currentColor}.chart .data>.highlight{stroke-width:6}.chart .value{font-size:80%}.chart tspan.unit{font-size:40%}.chart .tick-labels{font-size:25%}.legend-table{border-collapse:collapse;align-self:center}.legend-table td{padding-block:8px;padding-inline:8px}.legend-table .value{text-align:end;white-space:nowrap}.legend-table .name{inline-size:100%;min-inline-size:64px;max-inline-size:0}.legend-table .descr{color:var(--element-text-secondary)}.color{position:relative;flex:0 0 auto;block-size:16px;inline-size:16px}.color:after{content:\"\";position:absolute;inset:2px;background:currentColor;border-radius:50%}.color.highlight:after{inset:0}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
281
+ }
282
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiNChartGaugeComponent, decorators: [{
283
+ type: Component,
284
+ args: [{ selector: 'si-nchart-gauge', changeDetection: ChangeDetectionStrategy.OnPush, host: {
285
+ '[class]': '"legend-" + legendPosition()'
286
+ }, template: "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"chart\"\n [attr.viewBox]=\"'0 0 ' + dim.width + ' ' + dim.height\"\n [attr.width]=\"dim.width\"\n [attr.height]=\"dim.height\"\n>\n <g class=\"ticks\">\n @for (tick of ticks; track $index) {\n <path [attr.d]=\"tick.path\" />\n }\n </g>\n <g class=\"tick-labels text-secondary\">\n @for (tick of ticks; track $index) {\n <text text-anchor=\"middle\" [attr.x]=\"tick.textPos.x\" [attr.y]=\"tick.textPos.y\">\n {{ tick.label }}\n </text>\n }\n </g>\n <g class=\"segments\">\n @for (seg of internalSegments; track $index) {\n <path [attr.d]=\"seg.path\" [style.stroke]=\"seg.colorVar\" />\n }\n </g>\n <g class=\"background\">\n <path [attr.d]=\"backgroundPath\" />\n </g>\n <g class=\"data\">\n @for (series of internalSeries; track $index) {\n @if (series.path) {\n <path\n [class.highlight]=\"series.highlight\"\n [attr.d]=\"series.path\"\n [attr.data-id]=\"series.series.id\"\n [style.stroke]=\"series.colorVar\"\n (mouseenter)=\"series.highlight = true\"\n (mouseleave)=\"series.highlight = false\"\n />\n }\n }\n </g>\n <text\n class=\"text-body value\"\n x=\"50\"\n y=\"50\"\n text-anchor=\"middle\"\n [attr.dominant-baseline]=\"valignMiddle ? 'middle' : 'auto'\"\n >\n {{ totalSumString }}\n @if (unit()) {\n <tspan class=\"unit\">{{ unit() }}</tspan>\n }\n </text>\n</svg>\n\n@if (showLegend()) {\n <table class=\"legend-table flex-fill\">\n <tbody>\n @for (series of internalSeries; track $index) {\n <tr [attr.data-id]=\"series.series.id\">\n <td>\n <div\n class=\"color\"\n [class.highlight]=\"series.highlight\"\n [style.color]=\"series.colorVar\"\n (mouseenter)=\"series.highlight = true\"\n (mouseleave)=\"series.highlight = false\"\n >\n </div>\n </td>\n <td class=\"value\">{{ series.valueString }}</td>\n <td class=\"name\">\n <div class=\"text-truncate\">{{ series.series.name }}</div>\n @if (series.series.description) {\n <div class=\"descr text-truncate\">{{ series.series.description }}</div>\n }\n </td>\n </tr>\n }\n </tbody>\n </table>\n}\n", styles: [":host{display:flex}:host.legend-column{flex-direction:column}:host.legend-column .chart{block-size:auto;inline-size:100%;min-block-size:120px;max-block-size:320px}:host.legend-row .chart{block-size:100%;inline-size:auto;min-inline-size:200px}.chart .background,.chart .data{stroke-width:4;fill:none}.chart .background,.chart .ticks{stroke:var(--element-ui-4)}.chart .ticks{stroke-width:.5}.chart .segments{stroke-width:.75;fill:none}.chart .tick-labels,.chart .value{fill:currentColor}.chart .data>.highlight{stroke-width:6}.chart .value{font-size:80%}.chart tspan.unit{font-size:40%}.chart .tick-labels{font-size:25%}.legend-table{border-collapse:collapse;align-self:center}.legend-table td{padding-block:8px;padding-inline:8px}.legend-table .value{text-align:end;white-space:nowrap}.legend-table .name{inline-size:100%;min-inline-size:64px;max-inline-size:0}.legend-table .descr{color:var(--element-text-secondary)}.color{position:relative;flex:0 0 auto;block-size:16px;inline-size:16px}.color:after{content:\"\";position:absolute;inset:2px;background:currentColor;border-radius:50%}.color.highlight:after{inset:0}\n"] }]
287
+ }] });
288
+
289
+ /**
290
+ * Copyright (c) Siemens 2016 - 2025
291
+ * SPDX-License-Identifier: MIT
292
+ */
293
+
294
+ /**
295
+ * Generated bundle index. Do not edit.
296
+ */
297
+
298
+ export { SiNChartGaugeComponent };
299
+ //# sourceMappingURL=siemens-native-charts-ng-gauge.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siemens-native-charts-ng-gauge.mjs","sources":["../../../../projects/native-charts-ng/gauge/si-nchart-gauge.component.ts","../../../../projects/native-charts-ng/gauge/si-nchart-gauge.component.html","../../../../projects/native-charts-ng/gauge/index.ts","../../../../projects/native-charts-ng/gauge/siemens-native-charts-ng-gauge.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nimport {\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n inject,\n input,\n LOCALE_ID,\n numberAttribute,\n OnChanges,\n OnInit,\n SimpleChanges\n} from '@angular/core';\nimport {\n Coordinate,\n makeArc,\n makeLine,\n polarToCartesian,\n valueToRelativeAngle\n} from '@siemens/native-charts-ng/utils';\n\n/**\n * One series of the gauge chart.\n */\nexport interface GaugeSeries {\n /** value */\n value: number;\n /** color token */\n colorToken: string;\n /** name displayed in legend */\n name: string;\n /** Optional description line in legend */\n description?: string;\n /** ID exposed as `data-id` */\n id?: string;\n}\n\n/**\n * One segment of the gauge chart. The first segment starts at the `min` value of the gauge\n * chart and ends at `endValue`.\n */\nexport interface GaugeSegment {\n /** color token for this segment. */\n colorToken: string;\n /** end value for this segment, exclusive except for last segment where it's inclusive */\n endValue: number;\n}\n\ninterface InternalSeries {\n series: GaugeSeries;\n path: string;\n colorVar: string;\n valueString: string;\n highlight: boolean;\n}\n\ninterface InternalGaugeSegment {\n segment: GaugeSegment;\n path: string;\n colorVar: string;\n}\n\ninterface Tick {\n path: string;\n label: string;\n textPos: Coordinate;\n}\n\n@Component({\n selector: 'si-nchart-gauge',\n templateUrl: './si-nchart-gauge.component.html',\n styleUrl: './si-nchart-gauge.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n '[class]': '\"legend-\" + legendPosition()'\n }\n})\nexport class SiNChartGaugeComponent implements OnInit, OnChanges {\n /**\n * Start angle in degrees\n *\n * @defaultValue -90\n */\n readonly startAngle = input(-90, { transform: numberAttribute });\n /**\n * End angle in degrees\n *\n * @defaultValue 90\n */\n readonly endAngle = input(90, { transform: numberAttribute });\n\n /**\n * Min value, can be negative\n *\n * @defaultValue -100\n */\n readonly min = input(-100, { transform: numberAttribute });\n /**\n * Max value, can be negative\n *\n * @defaultValue 100\n */\n readonly max = input(100, { transform: numberAttribute });\n /**\n * Display mode: `sum` to sum up multiple series or `single` for a single value with optional\n * segmented display.\n *\n * @defaultValue 'sum'\n */\n readonly mode = input<'sum' | 'single'>('sum');\n /**\n * Series\n *\n * @defaultValue []\n */\n readonly series = input<GaugeSeries[]>([]);\n /**\n * Colored segments.\n *\n * @defaultValue []\n */\n readonly segments = input<GaugeSegment[]>([]);\n /**\n * Unit\n *\n * @defaultValue ''\n */\n readonly unit = input('');\n /**\n * Min number of decimals.\n * @defaultValue 0\n */\n readonly minNumberOfDecimals = input(0);\n /**\n * Max number of decimals.\n * @defaultValue 2\n */\n readonly maxNumberOfDecimals = input(2);\n /**\n * Number of decimals on the axis.\n * @defaultValue 0\n */\n readonly axisNumberOfDecimals = input(0);\n /**\n * Whether to show ticks\n *\n * @defaultValue true\n */\n readonly showTicks = input(true, { transform: booleanAttribute });\n /**\n * Whether to show the legend\n *\n * @defaultValue true\n */\n readonly showLegend = input(true, { transform: booleanAttribute });\n /**\n * Legend position:\n * - `column`: chart and legend form a column, i.e. the legend is below the chart.\n * The chart size is driven by the available width.\n * - `row`: chart and legend form a row, i.e. the legend is besides the chart. The\n * The chart size is driven by the available height.\n *\n * @defaultValue 'row'\n */\n readonly legendPosition = input<'row' | 'column'>('row');\n /**\n * Whether to show range start/end labels on the outside of the ring\n *\n * @defaultValue false\n */\n readonly showRangeLabelsOutside = input(false, { transform: booleanAttribute });\n\n protected dim = { width: 100, height: 60 };\n protected center: Coordinate = { x: 50, y: 50 };\n protected radius = 40;\n protected additionalHeight = 10;\n\n protected backgroundPath = '';\n protected internalSeries: InternalSeries[] = [];\n protected ticks: Tick[] = [];\n protected totalSum = 0;\n protected totalSumString = '0';\n protected valignMiddle = false;\n protected internalSegments: InternalGaugeSegment[] = [];\n\n private locale = inject(LOCALE_ID).toString();\n private numberFormat = new Intl.NumberFormat(this.locale, { maximumFractionDigits: 2 });\n private axisNumberFormat = new Intl.NumberFormat(this.locale, {\n minimumFractionDigits: this.axisNumberOfDecimals(),\n maximumFractionDigits: this.axisNumberOfDecimals()\n });\n\n ngOnChanges(changes: SimpleChanges): void {\n let calc = false;\n if (changes.minNumberOfDecimals || changes.maxNumberOfDecimals) {\n this.numberFormat = new Intl.NumberFormat(this.locale, {\n minimumFractionDigits: this.minNumberOfDecimals(),\n maximumFractionDigits: Math.max(this.minNumberOfDecimals(), this.maxNumberOfDecimals())\n });\n calc = true;\n }\n if (changes.axisNumberOfDecimals) {\n this.axisNumberFormat = new Intl.NumberFormat(this.locale, {\n minimumFractionDigits: this.axisNumberOfDecimals(),\n maximumFractionDigits: this.axisNumberOfDecimals()\n });\n calc = true;\n }\n if (changes.startAngle || changes.endAngle) {\n this.init();\n calc = true;\n }\n if (\n changes.series ||\n changes.min ||\n changes.max ||\n changes.showTicks ||\n changes.showRangeLabelsOutside ||\n changes.segments\n ) {\n calc = true;\n }\n if (calc) {\n this.calc();\n }\n }\n\n ngOnInit(): void {\n this.init();\n this.calc();\n }\n\n protected init(): void {\n this.backgroundPath = makeArc(this.center, this.radius, this.startAngle(), this.endAngle());\n\n // auto adjust height\n const maxAngle = Math.max(Math.abs(this.startAngle()), Math.abs(this.endAngle()));\n\n const height = Math.max(50, polarToCartesian(this.center, this.radius, maxAngle).y);\n this.dim.height = height + this.additionalHeight;\n this.valignMiddle = height > 50;\n }\n\n private calc(): void {\n if (this.mode() === 'sum') {\n this.calcSeriesSum();\n } else {\n this.calcSeriesSingle();\n }\n }\n\n private reset(): void {\n this.totalSum = 0;\n this.internalSeries = [];\n this.internalSegments = [];\n this.ticks = [];\n }\n\n private calcSeriesSum(): void {\n this.reset();\n\n const zeroValueAngle =\n this.startAngle() +\n valueToRelativeAngle(this.startAngle(), this.endAngle(), this.min(), this.max(), -this.min());\n\n this.addTick(this.startAngle(), this.min(), true);\n if (this.min() !== 0) {\n this.addTick(zeroValueAngle, 0, false);\n }\n this.addTick(this.endAngle(), this.max(), true);\n\n let nextPosAngle = zeroValueAngle;\n let nextNegAngle = zeroValueAngle;\n for (const series of this.series()) {\n if (series.value >= 0) {\n nextPosAngle = this.addInternalSeries(nextPosAngle, series);\n } else if (series.value < 0) {\n nextNegAngle = this.addInternalSeries(nextNegAngle, series, true);\n }\n }\n\n this.totalSumString = this.numberFormat.format(this.totalSum);\n }\n\n private calcSeriesSingle(): void {\n this.reset();\n\n let angle = this.startAngle();\n let value = this.min();\n for (const segment of this.segments()) {\n const nextAngle =\n valueToRelativeAngle(\n this.startAngle(),\n this.endAngle(),\n this.min(),\n this.max(),\n segment.endValue - value\n ) + angle;\n\n this.internalSegments.push({\n segment,\n colorVar: `var(--${segment.colorToken})`,\n path: makeArc(this.center, this.radius - 3.5, angle, nextAngle)\n });\n\n if (segment.endValue !== this.max()) {\n this.addTick(nextAngle, segment.endValue, false);\n }\n\n angle = nextAngle;\n value = segment.endValue;\n }\n\n this.addTick(this.startAngle(), this.min(), true);\n this.addTick(this.endAngle(), this.max(), true);\n\n const series = this.series()[0];\n if (!series) {\n this.totalSumString = '-';\n return;\n }\n\n const activeSegment = this.segments().find(\n (s, i) => series.value < s.endValue || i == this.segments().length - 1\n );\n this.addInternalSeries(this.startAngle(), series, false, activeSegment?.colorToken);\n\n this.totalSumString = this.numberFormat.format(this.totalSum);\n }\n\n private addTick(angle: number, title: number, boundary: boolean): void {\n const segmentOffset = this.mode() === 'single' && this.segments().length ? 1.25 : 0;\n const textRadiusOffset =\n boundary && this.showRangeLabelsOutside()\n ? 0\n : this.showTicks()\n ? 10 + segmentOffset\n : 8 + segmentOffset;\n const textPos = polarToCartesian(this.center, this.radius - textRadiusOffset, angle);\n\n if (boundary && this.showRangeLabelsOutside()) {\n textPos.y += 6;\n }\n\n this.ticks.push({\n path: this.showTicks() ? this.makeTickPath(angle) : '',\n label: this.axisNumberFormat.format(title),\n textPos\n });\n }\n\n private makeTickPath(angle: number): string {\n const startRadius =\n this.mode() === 'single' && this.segments().length ? this.radius - 5.5 : this.radius - 4;\n const start = polarToCartesian(this.center, startRadius, angle);\n const end = polarToCartesian(this.center, this.radius + 2, angle);\n return makeLine(start, end);\n }\n\n private addInternalSeries(\n startAngle: number,\n series: GaugeSeries,\n reverse = false,\n color?: string\n ): number {\n let nextAngle =\n valueToRelativeAngle(\n this.startAngle(),\n this.endAngle(),\n this.min(),\n this.max(),\n series.value\n ) + startAngle;\n const returnNextAngle = nextAngle;\n\n if (reverse) {\n [startAngle, nextAngle] = [nextAngle, startAngle];\n }\n\n startAngle = this.containAngle(startAngle);\n nextAngle = this.containAngle(nextAngle);\n\n if (startAngle !== nextAngle) {\n this.pushInternalSeries(\n series,\n makeArc(this.center, this.radius, startAngle, nextAngle),\n color\n );\n } else {\n this.pushInternalSeries(series, '', color);\n }\n\n this.totalSum += series.value;\n\n return returnNextAngle;\n }\n\n private pushInternalSeries(series: GaugeSeries, path: string, color?: string): void {\n color ??= series.colorToken;\n this.internalSeries.push({\n series,\n path,\n colorVar: `var(--${color})`,\n valueString: this.numberFormat.format(series.value),\n highlight: false\n });\n }\n\n private containAngle(angle: number): number {\n return Math.max(this.startAngle(), Math.min(this.endAngle(), angle));\n }\n}\n","<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"chart\"\n [attr.viewBox]=\"'0 0 ' + dim.width + ' ' + dim.height\"\n [attr.width]=\"dim.width\"\n [attr.height]=\"dim.height\"\n>\n <g class=\"ticks\">\n @for (tick of ticks; track $index) {\n <path [attr.d]=\"tick.path\" />\n }\n </g>\n <g class=\"tick-labels text-secondary\">\n @for (tick of ticks; track $index) {\n <text text-anchor=\"middle\" [attr.x]=\"tick.textPos.x\" [attr.y]=\"tick.textPos.y\">\n {{ tick.label }}\n </text>\n }\n </g>\n <g class=\"segments\">\n @for (seg of internalSegments; track $index) {\n <path [attr.d]=\"seg.path\" [style.stroke]=\"seg.colorVar\" />\n }\n </g>\n <g class=\"background\">\n <path [attr.d]=\"backgroundPath\" />\n </g>\n <g class=\"data\">\n @for (series of internalSeries; track $index) {\n @if (series.path) {\n <path\n [class.highlight]=\"series.highlight\"\n [attr.d]=\"series.path\"\n [attr.data-id]=\"series.series.id\"\n [style.stroke]=\"series.colorVar\"\n (mouseenter)=\"series.highlight = true\"\n (mouseleave)=\"series.highlight = false\"\n />\n }\n }\n </g>\n <text\n class=\"text-body value\"\n x=\"50\"\n y=\"50\"\n text-anchor=\"middle\"\n [attr.dominant-baseline]=\"valignMiddle ? 'middle' : 'auto'\"\n >\n {{ totalSumString }}\n @if (unit()) {\n <tspan class=\"unit\">{{ unit() }}</tspan>\n }\n </text>\n</svg>\n\n@if (showLegend()) {\n <table class=\"legend-table flex-fill\">\n <tbody>\n @for (series of internalSeries; track $index) {\n <tr [attr.data-id]=\"series.series.id\">\n <td>\n <div\n class=\"color\"\n [class.highlight]=\"series.highlight\"\n [style.color]=\"series.colorVar\"\n (mouseenter)=\"series.highlight = true\"\n (mouseleave)=\"series.highlight = false\"\n >\n </div>\n </td>\n <td class=\"value\">{{ series.valueString }}</td>\n <td class=\"name\">\n <div class=\"text-truncate\">{{ series.series.name }}</div>\n @if (series.series.description) {\n <div class=\"descr text-truncate\">{{ series.series.description }}</div>\n }\n </td>\n </tr>\n }\n </tbody>\n </table>\n}\n","/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nexport * from './si-nchart-gauge.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;MA6EU,sBAAsB,CAAA;AACjC;;;;AAIG;AACM,IAAA,UAAU,GAAG,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AAChE;;;;AAIG;IACM,QAAQ,GAAG,KAAK,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AAE7D;;;;AAIG;AACM,IAAA,GAAG,GAAG,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,C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ACzC;AACJ,wBAAA,SAAS,EAAE;AACZ,qBAAA,EAAA,QAAA,EAAA,k3EAAA,EAAA,MAAA,EAAA,CAAA,gmCAAA,CAAA,EAAA;;;AE9EH;;;AAGG;;ACHH;;AAEG;;;;"}
@@ -0,0 +1,46 @@
1
+ import * as i0 from '@angular/core';
2
+ import { input, computed, ChangeDetectionStrategy, Component } from '@angular/core';
3
+
4
+ /**
5
+ * Copyright (c) Siemens 2016 - 2025
6
+ * SPDX-License-Identifier: MIT
7
+ */
8
+ class SiMicroBarComponent {
9
+ /** @defaultValue 64 */
10
+ width = input(64);
11
+ /** @defaultValue 16 */
12
+ height = input(16);
13
+ /**
14
+ * Micro bar series.
15
+ * Example series can be:
16
+ * @example
17
+ * ```ts
18
+ * Series: MicroBarSeries = { values: [2, 4, 5, 3, 5, 7, 7, 9, 11, 10, 12, 9], colorToken: 'element-data-7'};
19
+ * ```
20
+ */
21
+ series = input.required();
22
+ barWidth = 4;
23
+ padding = 8;
24
+ maxValue = computed(() => {
25
+ const currentSeries = this.series();
26
+ return currentSeries?.values.length ? Math.max(...currentSeries.values) : 1;
27
+ });
28
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiMicroBarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
29
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SiMicroBarComponent, isStandalone: true, selector: "si-micro-bar", inputs: { width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<div\n class=\"bar-container d-flex align-items-end pb-2 pt-2\"\n [style.width.px]=\"width()\"\n [style.height.px]=\"height() + padding\"\n>\n @for (value of series().values; track $index) {\n <div\n [style.height.%]=\"(value / maxValue()) * 100\"\n [style.width.px]=\"barWidth\"\n [style.backgroundColor]=\"'var(--' + series().colorToken + ')'\"\n ></div>\n }\n</div>\n", styles: [".bar-container{gap:1px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
30
+ }
31
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiMicroBarComponent, decorators: [{
32
+ type: Component,
33
+ args: [{ selector: 'si-micro-bar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"bar-container d-flex align-items-end pb-2 pt-2\"\n [style.width.px]=\"width()\"\n [style.height.px]=\"height() + padding\"\n>\n @for (value of series().values; track $index) {\n <div\n [style.height.%]=\"(value / maxValue()) * 100\"\n [style.width.px]=\"barWidth\"\n [style.backgroundColor]=\"'var(--' + series().colorToken + ')'\"\n ></div>\n }\n</div>\n", styles: [".bar-container{gap:1px}\n"] }]
34
+ }] });
35
+
36
+ /**
37
+ * Copyright (c) Siemens 2016 - 2025
38
+ * SPDX-License-Identifier: MIT
39
+ */
40
+
41
+ /**
42
+ * Generated bundle index. Do not edit.
43
+ */
44
+
45
+ export { SiMicroBarComponent };
46
+ //# sourceMappingURL=siemens-native-charts-ng-micro-bar.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siemens-native-charts-ng-micro-bar.mjs","sources":["../../../../projects/native-charts-ng/micro-bar/si-micro-bar.component.ts","../../../../projects/native-charts-ng/micro-bar/si-micro-bar.component.html","../../../../projects/native-charts-ng/micro-bar/index.ts","../../../../projects/native-charts-ng/micro-bar/siemens-native-charts-ng-micro-bar.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nimport { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';\n\nexport interface MicroBarSeries {\n /* Series values */\n values: number[];\n /**\n * Use a data-color. See: {@link https://element.siemens.io/fundamentals/colors/data-visualization-colors/#tokens}\n *\n * @example \"element-data-10\"\n */\n colorToken: string;\n}\n\n@Component({\n selector: 'si-micro-bar',\n templateUrl: './si-micro-bar.component.html',\n styleUrl: './si-micro-bar.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SiMicroBarComponent {\n /** @defaultValue 64 */\n readonly width = input<number>(64);\n /** @defaultValue 16 */\n readonly height = input<number>(16);\n /**\n * Micro bar series.\n * Example series can be:\n * @example\n * ```ts\n * Series: MicroBarSeries = { values: [2, 4, 5, 3, 5, 7, 7, 9, 11, 10, 12, 9], colorToken: 'element-data-7'};\n * ```\n */\n readonly series = input.required<MicroBarSeries>();\n\n protected barWidth = 4;\n protected padding = 8;\n protected readonly maxValue = computed(() => {\n const currentSeries = this.series();\n return currentSeries?.values.length ? Math.max(...currentSeries.values) : 1;\n });\n}\n","<div\n class=\"bar-container d-flex align-items-end pb-2 pt-2\"\n [style.width.px]=\"width()\"\n [style.height.px]=\"height() + padding\"\n>\n @for (value of series().values; track $index) {\n <div\n [style.height.%]=\"(value / maxValue()) * 100\"\n [style.width.px]=\"barWidth\"\n [style.backgroundColor]=\"'var(--' + series().colorToken + ')'\"\n ></div>\n }\n</div>\n","/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nexport * from './si-micro-bar.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAAA;;;AAGG;MAoBU,mBAAmB,CAAA;;AAErB,IAAA,KAAK,GAAG,KAAK,CAAS,EAAE,CAAC;;AAEzB,IAAA,MAAM,GAAG,KAAK,CAAS,EAAE,CAAC;AACnC;;;;;;;AAOG;AACM,IAAA,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAkB;IAExC,QAAQ,GAAG,CAAC;IACZ,OAAO,GAAG,CAAC;AACF,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAK;AAC1C,QAAA,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE;QACnC,OAAO,aAAa,EAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC;AAC7E,KAAC,CAAC;uGApBS,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAnB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,mBAAmB,icCvBhC,8YAaA,EAAA,MAAA,EAAA,CAAA,2BAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FDUa,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAN/B,SAAS;+BACE,cAAc,EAAA,eAAA,EAGP,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,8YAAA,EAAA,MAAA,EAAA,CAAA,2BAAA,CAAA,EAAA;;;AErBjD;;;AAGG;;ACHH;;AAEG;;;;"}
@@ -0,0 +1,100 @@
1
+ import * as i0 from '@angular/core';
2
+ import { input, numberAttribute, computed, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { makeArc, valueToRelativeAngle } from '@siemens/native-charts-ng/utils';
4
+
5
+ /**
6
+ * Copyright (c) Siemens 2016 - 2025
7
+ * SPDX-License-Identifier: MIT
8
+ */
9
+ class SiMicroDonutComponent {
10
+ /**
11
+ * Micro donut series. Can also be an array representing multiple series.
12
+ * Each series, in case of multiple, forms section of the arc, in percentage
13
+ * of the respective value.
14
+ * Example series can be:
15
+ * @example
16
+ * ```ts
17
+ * Series: MicroDonutSeries[] = [{ valuePercent: 40, colorToken: 'element-data-4' }];
18
+ * ```
19
+ * @defaultValue []
20
+ */
21
+ series = input.required();
22
+ /**
23
+ * Radius of donut. The radius is calculated from center of the donut to the mid point of the arc.
24
+ * @defaultValue 7.5
25
+ */
26
+ radius = input(7.5, { transform: numberAttribute });
27
+ arcThickness = computed(() => 0.7 * this.radius());
28
+ dim = computed(() => {
29
+ // Keeping the viewbox width and height only enough to fit the donut.
30
+ // The radius is calculated from center of the donut to the mid point of the arc.
31
+ // Hence half the arc thicknes on both side needs to be added (equals full arc thickness)
32
+ // The buffer space is added because the svg donut gets cropped on certain Os + browser configuration.
33
+ const radius = this.radius();
34
+ const arcThickness = this.arcThickness();
35
+ const size = 2 * radius + arcThickness + this.bufferSpace;
36
+ return { width: size, height: size };
37
+ });
38
+ backgroundPath = computed(() => makeArc(this.center(), this.radius(), this.startAngle, this.endAngle));
39
+ center = computed(() => {
40
+ // Once we have the viewbox dimensions, getting the donut at the center by
41
+ // calculating correct coordinates
42
+ const d = this.dim();
43
+ return {
44
+ x: d.width / 2,
45
+ y: d.height / 2
46
+ };
47
+ });
48
+ min = 0;
49
+ max = 100;
50
+ startAngle = 0;
51
+ endAngle = 360;
52
+ bufferSpace = 4;
53
+ internalSeries = computed(() => {
54
+ const inputSeries = this.series();
55
+ const result = [];
56
+ let nextPosAngle = 0;
57
+ for (const series of inputSeries) {
58
+ // Does not add series if percent is 0 or less
59
+ if (series.valuePercent > 0) {
60
+ const { nextAngle, internal } = this.toInternalSeries(nextPosAngle, series);
61
+ result.push(internal);
62
+ nextPosAngle = nextAngle;
63
+ }
64
+ }
65
+ return result;
66
+ });
67
+ toInternalSeries(startAngle, series, color) {
68
+ let nextAngle = valueToRelativeAngle(this.startAngle, this.endAngle, this.min, this.max, series.valuePercent) + startAngle;
69
+ startAngle = this.containAngle(startAngle);
70
+ nextAngle = this.containAngle(nextAngle);
71
+ color ??= series.colorToken;
72
+ const internal = {
73
+ series,
74
+ path: makeArc(this.center(), this.radius(), startAngle, nextAngle),
75
+ colorVar: `var(--${color})`
76
+ };
77
+ return { nextAngle, internal };
78
+ }
79
+ containAngle(angle) {
80
+ return Math.max(this.startAngle, Math.min(this.endAngle, angle));
81
+ }
82
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiMicroDonutComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
83
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SiMicroDonutComponent, isStandalone: true, selector: "si-micro-donut", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: true, transformFunction: null }, radius: { classPropertyName: "radius", publicName: "radius", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"chart\"\n [attr.viewBox]=\"'0 0 ' + dim().width + ' ' + dim().height\"\n [attr.width]=\"dim().width\"\n [attr.height]=\"dim().height\"\n>\n <g class=\"background\">\n <path [attr.d]=\"backgroundPath()\" [style.stroke-width]=\"arcThickness()\" />\n </g>\n <g class=\"data\">\n @for (series of internalSeries(); track $index) {\n @if (series?.path) {\n <path\n [attr.d]=\"series.path\"\n [attr.data-id]=\"series.series.id\"\n [style.stroke]=\"series.colorVar\"\n [style.stroke-width]=\"arcThickness()\"\n />\n }\n }\n </g>\n</svg>\n", styles: [".chart .background,.chart .data{fill:none}.chart .background{stroke:var(--element-ui-4)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
84
+ }
85
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiMicroDonutComponent, decorators: [{
86
+ type: Component,
87
+ args: [{ selector: 'si-micro-donut', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"chart\"\n [attr.viewBox]=\"'0 0 ' + dim().width + ' ' + dim().height\"\n [attr.width]=\"dim().width\"\n [attr.height]=\"dim().height\"\n>\n <g class=\"background\">\n <path [attr.d]=\"backgroundPath()\" [style.stroke-width]=\"arcThickness()\" />\n </g>\n <g class=\"data\">\n @for (series of internalSeries(); track $index) {\n @if (series?.path) {\n <path\n [attr.d]=\"series.path\"\n [attr.data-id]=\"series.series.id\"\n [style.stroke]=\"series.colorVar\"\n [style.stroke-width]=\"arcThickness()\"\n />\n }\n }\n </g>\n</svg>\n", styles: [".chart .background,.chart .data{fill:none}.chart .background{stroke:var(--element-ui-4)}\n"] }]
88
+ }] });
89
+
90
+ /**
91
+ * Copyright (c) Siemens 2016 - 2025
92
+ * SPDX-License-Identifier: MIT
93
+ */
94
+
95
+ /**
96
+ * Generated bundle index. Do not edit.
97
+ */
98
+
99
+ export { SiMicroDonutComponent };
100
+ //# sourceMappingURL=siemens-native-charts-ng-micro-donut.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siemens-native-charts-ng-micro-donut.mjs","sources":["../../../../projects/native-charts-ng/micro-donut/si-micro-donut.component.ts","../../../../projects/native-charts-ng/micro-donut/si-micro-donut.component.html","../../../../projects/native-charts-ng/micro-donut/index.ts","../../../../projects/native-charts-ng/micro-donut/siemens-native-charts-ng-micro-donut.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nimport {\n ChangeDetectionStrategy,\n Component,\n computed,\n input,\n numberAttribute\n} from '@angular/core';\nimport { Coordinate, makeArc, valueToRelativeAngle } from '@siemens/native-charts-ng/utils';\n\n/**\n * One series of the micro donut chart.\n */\nexport interface MicroDonutSeries {\n /** value in percent */\n valuePercent: number;\n /** color token */\n colorToken: string;\n /** ID exposed as `data-id` */\n id?: string;\n}\n\ninterface InternalSeries {\n series: MicroDonutSeries;\n path: string;\n colorVar: string;\n}\n\n@Component({\n selector: 'si-micro-donut',\n templateUrl: './si-micro-donut.component.html',\n styleUrl: './si-micro-donut.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SiMicroDonutComponent {\n /**\n * Micro donut series. Can also be an array representing multiple series.\n * Each series, in case of multiple, forms section of the arc, in percentage\n * of the respective value.\n * Example series can be:\n * @example\n * ```ts\n * Series: MicroDonutSeries[] = [{ valuePercent: 40, colorToken: 'element-data-4' }];\n * ```\n * @defaultValue []\n */\n readonly series = input.required<MicroDonutSeries[]>();\n /**\n * Radius of donut. The radius is calculated from center of the donut to the mid point of the arc.\n * @defaultValue 7.5\n */\n readonly radius = input(7.5, { transform: numberAttribute });\n\n protected readonly arcThickness = computed(() => 0.7 * this.radius());\n protected readonly dim = computed(() => {\n // Keeping the viewbox width and height only enough to fit the donut.\n // The radius is calculated from center of the donut to the mid point of the arc.\n // Hence half the arc thicknes on both side needs to be added (equals full arc thickness)\n // The buffer space is added because the svg donut gets cropped on certain Os + browser configuration.\n const radius = this.radius();\n const arcThickness = this.arcThickness();\n const size = 2 * radius + arcThickness + this.bufferSpace;\n return { width: size, height: size };\n });\n\n protected readonly backgroundPath = computed(() =>\n makeArc(this.center(), this.radius(), this.startAngle, this.endAngle)\n );\n\n private readonly center = computed<Coordinate>(() => {\n // Once we have the viewbox dimensions, getting the donut at the center by\n // calculating correct coordinates\n const d = this.dim();\n return {\n x: d.width / 2,\n y: d.height / 2\n };\n });\n private readonly min = 0;\n private readonly max = 100;\n private readonly startAngle = 0;\n private readonly endAngle = 360;\n private readonly bufferSpace = 4;\n\n protected readonly internalSeries = computed(() => {\n const inputSeries = this.series();\n const result: InternalSeries[] = [];\n let nextPosAngle = 0;\n\n for (const series of inputSeries) {\n // Does not add series if percent is 0 or less\n if (series.valuePercent > 0) {\n const { nextAngle, internal } = this.toInternalSeries(nextPosAngle, series);\n result.push(internal);\n nextPosAngle = nextAngle;\n }\n }\n return result;\n });\n\n private toInternalSeries(\n startAngle: number,\n series: MicroDonutSeries,\n color?: string\n ): { nextAngle: number; internal: InternalSeries } {\n let nextAngle =\n valueToRelativeAngle(\n this.startAngle,\n this.endAngle,\n this.min,\n this.max,\n series.valuePercent\n ) + startAngle;\n\n startAngle = this.containAngle(startAngle);\n nextAngle = this.containAngle(nextAngle);\n\n color ??= series.colorToken;\n const internal: InternalSeries = {\n series,\n path: makeArc(this.center(), this.radius(), startAngle, nextAngle),\n colorVar: `var(--${color})`\n };\n return { nextAngle, internal };\n }\n\n private containAngle(angle: number): number {\n return Math.max(this.startAngle, Math.min(this.endAngle, angle));\n }\n}\n","<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"chart\"\n [attr.viewBox]=\"'0 0 ' + dim().width + ' ' + dim().height\"\n [attr.width]=\"dim().width\"\n [attr.height]=\"dim().height\"\n>\n <g class=\"background\">\n <path [attr.d]=\"backgroundPath()\" [style.stroke-width]=\"arcThickness()\" />\n </g>\n <g class=\"data\">\n @for (series of internalSeries(); track $index) {\n @if (series?.path) {\n <path\n [attr.d]=\"series.path\"\n [attr.data-id]=\"series.series.id\"\n [style.stroke]=\"series.colorVar\"\n [style.stroke-width]=\"arcThickness()\"\n />\n }\n }\n </g>\n</svg>\n","/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nexport * from './si-micro-donut.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;MAkCU,qBAAqB,CAAA;AAChC;;;;;;;;;;AAUG;AACM,IAAA,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAsB;AACtD;;;AAGG;IACM,MAAM,GAAG,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AAEzC,IAAA,YAAY,GAAG,QAAQ,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;AAClD,IAAA,GAAG,GAAG,QAAQ,CAAC,MAAK;;;;;AAKrC,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE;AAC5B,QAAA,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE;QACxC,MAAM,IAAI,GAAG,CAAC,GAAG,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC,WAAW;QACzD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;AACtC,KAAC,CAAC;IAEiB,cAAc,GAAG,QAAQ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rategy, Component } from '@angular/core';
3
+ import { makePolyline } from '@siemens/native-charts-ng/utils';
4
+
5
+ /**
6
+ * Copyright (c) Siemens 2016 - 2025
7
+ * SPDX-License-Identifier: MIT
8
+ */
9
+ class SiMicroLineComponent {
10
+ /**
11
+ * Micro line series.
12
+ * Example series can be:
13
+ * @example
14
+ * ```ts
15
+ * Series: MicroLineSeries = { values: [2, 3, 6, 5, 4, 7, 8], colorToken: 'element-data-10' };
16
+ * ```
17
+ */
18
+ series = input.required();
19
+ /** @defaultValue 64 */
20
+ width = input(64);
21
+ /** @defaultValue 24 */
22
+ height = input(24);
23
+ strokeWidth = 2;
24
+ path = computed(() => {
25
+ const series = this.series();
26
+ if (!series || series.values.length < 2) {
27
+ return '';
28
+ }
29
+ const points = this.mapToCoordinates(series.values, this.width(), this.height());
30
+ return makePolyline(points);
31
+ });
32
+ mapToCoordinates(values, width, height) {
33
+ const max = Math.max(...values);
34
+ const min = Math.min(...values);
35
+ const scaleX = width / (values.length - 1);
36
+ const scaleY = max !== min ? height / (max - min) : 1;
37
+ return values.map((value, i) => ({
38
+ x: i * scaleX,
39
+ y: height - (value - min) * scaleY
40
+ }));
41
+ }
42
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiMicroLineComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
43
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.0.6", type: SiMicroLineComponent, isStandalone: true, selector: "si-micro-line", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: true, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<svg\n [attr.width]=\"width()\"\n [attr.height]=\"height()\"\n [attr.viewBox]=\"\n -strokeWidth / 2 +\n ' ' +\n -strokeWidth / 2 +\n ' ' +\n (width() + strokeWidth) +\n ' ' +\n (height() + strokeWidth)\n \"\n>\n <path\n fill=\"none\"\n [attr.d]=\"path()\"\n [attr.stroke]=\"'var(--' + series().colorToken + ')'\"\n [attr.stroke-width]=\"strokeWidth\"\n />\n</svg>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush });
44
+ }
45
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiMicroLineComponent, decorators: [{
46
+ type: Component,
47
+ args: [{ selector: 'si-micro-line', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg\n [attr.width]=\"width()\"\n [attr.height]=\"height()\"\n [attr.viewBox]=\"\n -strokeWidth / 2 +\n ' ' +\n -strokeWidth / 2 +\n ' ' +\n (width() + strokeWidth) +\n ' ' +\n (height() + strokeWidth)\n \"\n>\n <path\n fill=\"none\"\n [attr.d]=\"path()\"\n [attr.stroke]=\"'var(--' + series().colorToken + ')'\"\n [attr.stroke-width]=\"strokeWidth\"\n />\n</svg>\n" }]
48
+ }] });
49
+
50
+ /**
51
+ * Copyright (c) Siemens 2016 - 2025
52
+ * SPDX-License-Identifier: MIT
53
+ */
54
+
55
+ /**
56
+ * Generated bundle index. Do not edit.
57
+ */
58
+
59
+ export { SiMicroLineComponent };
60
+ //# sourceMappingURL=siemens-native-charts-ng-micro-line.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siemens-native-charts-ng-micro-line.mjs","sources":["../../../../projects/native-charts-ng/micro-line/si-micro-line.component.ts","../../../../projects/native-charts-ng/micro-line/si-micro-line.component.html","../../../../projects/native-charts-ng/micro-line/index.ts","../../../../projects/native-charts-ng/micro-line/siemens-native-charts-ng-micro-line.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nimport { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';\nimport { Coordinate, makePolyline } from '@siemens/native-charts-ng/utils';\n\nexport interface MicroLineSeries {\n /** Series values */\n values: number[];\n /**\n * Use a data-color. See: {@link https://element.siemens.io/fundamentals/colors/data-visualization-colors/#tokens}\n *\n * @example \"element-data-10\"\n */\n colorToken: string;\n}\n\n@Component({\n selector: 'si-micro-line',\n templateUrl: './si-micro-line.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SiMicroLineComponent {\n /**\n * Micro line series.\n * Example series can be:\n * @example\n * ```ts\n * Series: MicroLineSeries = { values: [2, 3, 6, 5, 4, 7, 8], colorToken: 'element-data-10' };\n * ```\n */\n readonly series = input.required<MicroLineSeries>();\n /** @defaultValue 64 */\n readonly width = input<number>(64);\n /** @defaultValue 24 */\n readonly height = input<number>(24);\n\n protected strokeWidth = 2;\n\n protected readonly path = computed(() => {\n const series = this.series();\n if (!series || series.values.length < 2) {\n return '';\n }\n const points = this.mapToCoordinates(series.values, this.width(), this.height());\n return makePolyline(points);\n });\n\n private mapToCoordinates(values: number[], width: number, height: number): Coordinate[] {\n const max = Math.max(...values);\n const min = Math.min(...values);\n const scaleX = width / (values.length - 1);\n const scaleY = max !== min ? height / (max - min) : 1;\n\n return values.map((value, i) => ({\n x: i * scaleX,\n y: height - (value - min) * scaleY\n }));\n }\n}\n","<svg\n [attr.width]=\"width()\"\n [attr.height]=\"height()\"\n [attr.viewBox]=\"\n -strokeWidth / 2 +\n ' ' +\n -strokeWidth / 2 +\n ' ' +\n (width() + strokeWidth) +\n ' ' +\n (height() + strokeWidth)\n \"\n>\n <path\n fill=\"none\"\n [attr.d]=\"path()\"\n [attr.stroke]=\"'var(--' + series().colorToken + ')'\"\n [attr.stroke-width]=\"strokeWidth\"\n />\n</svg>\n","/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nexport * from './si-micro-line.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;MAoBU,oBAAoB,CAAA;AAC/B;;;;;;;AAOG;AACM,IAAA,MAAM,GAAG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