@siemens/native-charts-ng 48.1.0 → 48.2.0-rc.1
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/README.md
CHANGED
|
@@ -18,6 +18,6 @@ You can set a seed for running the tests in a specific using an environment vari
|
|
|
18
18
|
|
|
19
19
|
## License
|
|
20
20
|
|
|
21
|
-
Code and documentation
|
|
21
|
+
Code and documentation Copyright (c) Siemens 2016 - 2025
|
|
22
22
|
|
|
23
23
|
See [LICENSE.md](https://github.com/siemens/element/blob/main/LICENSE.md).
|
|
@@ -20,31 +20,67 @@ class SiMicrochartLineComponent {
|
|
|
20
20
|
width = input(64);
|
|
21
21
|
/** @defaultValue 24 */
|
|
22
22
|
height = input(24);
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Display circular markers at each data point on the line.
|
|
25
|
+
* When enabled, markers help highlight individual values and improve readability.
|
|
26
|
+
*
|
|
27
|
+
* @defaultValue false
|
|
28
|
+
*/
|
|
29
|
+
showMarkers = input(false);
|
|
30
|
+
/**
|
|
31
|
+
* Line width in pixels.
|
|
32
|
+
*
|
|
33
|
+
* @defaultValue 2
|
|
34
|
+
*/
|
|
35
|
+
lineWidth = input(2);
|
|
36
|
+
/**
|
|
37
|
+
* Marker color token. If not provided, uses the series color token.
|
|
38
|
+
* Use a data-color. See: {@link https://element.siemens.io/fundamentals/colors/data-visualization-colors/#tokens}
|
|
39
|
+
*
|
|
40
|
+
* @example "element-data-2"
|
|
41
|
+
*/
|
|
42
|
+
markerColor = input();
|
|
43
|
+
markerRadius = computed(() => this.lineWidth());
|
|
44
|
+
viewBox = computed(() => {
|
|
45
|
+
return `0 0 ${this.width()} ${this.height()}`;
|
|
46
|
+
});
|
|
24
47
|
path = computed(() => {
|
|
25
48
|
const series = this.series();
|
|
26
49
|
if (!series || series.values.length < 2) {
|
|
27
50
|
return '';
|
|
28
51
|
}
|
|
29
|
-
const points = this.mapToCoordinates(series.values
|
|
52
|
+
const points = this.mapToCoordinates(series.values);
|
|
30
53
|
return makePolyline(points);
|
|
31
54
|
});
|
|
32
|
-
|
|
55
|
+
markerPoints = computed(() => {
|
|
56
|
+
const series = this.series();
|
|
57
|
+
if (series?.values.length === 0) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
return this.mapToCoordinates(series.values);
|
|
61
|
+
});
|
|
62
|
+
mapToCoordinates(values) {
|
|
33
63
|
const max = Math.max(...values);
|
|
34
64
|
const min = Math.min(...values);
|
|
35
|
-
|
|
36
|
-
|
|
65
|
+
// Calculate available space, accounting for marker radius or line width
|
|
66
|
+
// This helps avoid the markers on the edges or the edges of the line getting cropped.
|
|
67
|
+
const horizontalMargin = this.showMarkers() ? this.markerRadius() : this.lineWidth() / 2;
|
|
68
|
+
const verticalMargin = this.showMarkers() ? this.markerRadius() : this.lineWidth() / 2;
|
|
69
|
+
const availableWidth = this.width() - horizontalMargin * 2;
|
|
70
|
+
const availableHeight = this.height() - verticalMargin * 2;
|
|
71
|
+
const scaleX = values.length > 1 ? availableWidth / (values.length - 1) : 0;
|
|
72
|
+
const scaleY = max !== min ? availableHeight / (max - min) : 1;
|
|
37
73
|
return values.map((value, i) => ({
|
|
38
|
-
x: i * scaleX,
|
|
39
|
-
y: height - (value - min) * scaleY
|
|
74
|
+
x: horizontalMargin + i * scaleX,
|
|
75
|
+
y: this.height() - verticalMargin - (value - min) * scaleY
|
|
40
76
|
}));
|
|
41
77
|
}
|
|
42
78
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiMicrochartLineComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
43
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
|
79
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SiMicrochartLineComponent, isStandalone: true, selector: "si-microchart-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 }, showMarkers: { classPropertyName: "showMarkers", publicName: "showMarkers", isSignal: true, isRequired: false, transformFunction: null }, lineWidth: { classPropertyName: "lineWidth", publicName: "lineWidth", isSignal: true, isRequired: false, transformFunction: null }, markerColor: { classPropertyName: "markerColor", publicName: "markerColor", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<svg [attr.width]=\"width()\" [attr.height]=\"height()\" [attr.viewBox]=\"viewBox()\">\n <path\n fill=\"none\"\n [attr.d]=\"path()\"\n [attr.stroke]=\"'var(--' + series().colorToken + ')'\"\n [attr.stroke-width]=\"lineWidth()\"\n />\n @if (showMarkers()) {\n @for (point of markerPoints(); track point.x) {\n <circle\n [attr.cx]=\"point.x\"\n [attr.cy]=\"point.y\"\n [attr.r]=\"markerRadius()\"\n [attr.fill]=\"'var(--' + (markerColor() ?? series().colorToken) + ')'\"\n />\n }\n }\n</svg>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
44
80
|
}
|
|
45
81
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiMicrochartLineComponent, decorators: [{
|
|
46
82
|
type: Component,
|
|
47
|
-
args: [{ selector: 'si-microchart-line', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg
|
|
83
|
+
args: [{ selector: 'si-microchart-line', changeDetection: ChangeDetectionStrategy.OnPush, template: "<svg [attr.width]=\"width()\" [attr.height]=\"height()\" [attr.viewBox]=\"viewBox()\">\n <path\n fill=\"none\"\n [attr.d]=\"path()\"\n [attr.stroke]=\"'var(--' + series().colorToken + ')'\"\n [attr.stroke-width]=\"lineWidth()\"\n />\n @if (showMarkers()) {\n @for (point of markerPoints(); track point.x) {\n <circle\n [attr.cx]=\"point.x\"\n [attr.cy]=\"point.y\"\n [attr.r]=\"markerRadius()\"\n [attr.fill]=\"'var(--' + (markerColor() ?? series().colorToken) + ')'\"\n />\n }\n }\n</svg>\n" }]
|
|
48
84
|
}] });
|
|
49
85
|
|
|
50
86
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siemens-native-charts-ng-microchart-line.mjs","sources":["../../../../projects/native-charts-ng/microchart-line/si-microchart-line.component.ts","../../../../projects/native-charts-ng/microchart-line/si-microchart-line.component.html","../../../../projects/native-charts-ng/microchart-line/index.ts","../../../../projects/native-charts-ng/microchart-line/siemens-native-charts-ng-microchart-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 MicrochartLineSeries {\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-microchart-line',\n templateUrl: './si-microchart-line.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SiMicrochartLineComponent {\n /**\n * Microchart line series.\n * Example series can be:\n * @example\n * ```ts\n * Series: MicrochartLineSeries = { values: [2, 3, 6, 5, 4, 7, 8], colorToken: 'element-data-10' };\n * ```\n */\n readonly series = input.required<MicrochartLineSeries>();\n /** @defaultValue 64 */\n readonly width = input<number>(64);\n /** @defaultValue 24 */\n readonly height = input<number>(24);\n\n
|
|
1
|
+
{"version":3,"file":"siemens-native-charts-ng-microchart-line.mjs","sources":["../../../../projects/native-charts-ng/microchart-line/si-microchart-line.component.ts","../../../../projects/native-charts-ng/microchart-line/si-microchart-line.component.html","../../../../projects/native-charts-ng/microchart-line/index.ts","../../../../projects/native-charts-ng/microchart-line/siemens-native-charts-ng-microchart-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 MicrochartLineSeries {\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-microchart-line',\n templateUrl: './si-microchart-line.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SiMicrochartLineComponent {\n /**\n * Microchart line series.\n * Example series can be:\n * @example\n * ```ts\n * Series: MicrochartLineSeries = { values: [2, 3, 6, 5, 4, 7, 8], colorToken: 'element-data-10' };\n * ```\n */\n readonly series = input.required<MicrochartLineSeries>();\n /** @defaultValue 64 */\n readonly width = input<number>(64);\n /** @defaultValue 24 */\n readonly height = input<number>(24);\n /**\n * Display circular markers at each data point on the line.\n * When enabled, markers help highlight individual values and improve readability.\n *\n * @defaultValue false\n */\n readonly showMarkers = input<boolean>(false);\n /**\n * Line width in pixels.\n *\n * @defaultValue 2\n */\n readonly lineWidth = input<number>(2);\n /**\n * Marker color token. If not provided, uses the series color token.\n * Use a data-color. See: {@link https://element.siemens.io/fundamentals/colors/data-visualization-colors/#tokens}\n *\n * @example \"element-data-2\"\n */\n readonly markerColor = input<string>();\n\n protected readonly markerRadius = computed(() => this.lineWidth());\n protected readonly viewBox = computed(() => {\n return `0 0 ${this.width()} ${this.height()}`;\n });\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);\n return makePolyline(points);\n });\n\n protected readonly markerPoints = computed(() => {\n const series = this.series();\n if (series?.values.length === 0) {\n return [];\n }\n return this.mapToCoordinates(series.values);\n });\n\n private mapToCoordinates(values: number[]): Coordinate[] {\n const max = Math.max(...values);\n const min = Math.min(...values);\n\n // Calculate available space, accounting for marker radius or line width\n // This helps avoid the markers on the edges or the edges of the line getting cropped.\n const horizontalMargin = this.showMarkers() ? this.markerRadius() : this.lineWidth() / 2;\n const verticalMargin = this.showMarkers() ? this.markerRadius() : this.lineWidth() / 2;\n\n const availableWidth = this.width() - horizontalMargin * 2;\n const availableHeight = this.height() - verticalMargin * 2;\n\n const scaleX = values.length > 1 ? availableWidth / (values.length - 1) : 0;\n const scaleY = max !== min ? availableHeight / (max - min) : 1;\n\n return values.map((value, i) => ({\n x: horizontalMargin + i * scaleX,\n y: this.height() - verticalMargin - (value - min) * scaleY\n }));\n }\n}\n","<svg [attr.width]=\"width()\" [attr.height]=\"height()\" [attr.viewBox]=\"viewBox()\">\n <path\n fill=\"none\"\n [attr.d]=\"path()\"\n [attr.stroke]=\"'var(--' + series().colorToken + ')'\"\n [attr.stroke-width]=\"lineWidth()\"\n />\n @if (showMarkers()) {\n @for (point of markerPoints(); track point.x) {\n <circle\n [attr.cx]=\"point.x\"\n [attr.cy]=\"point.y\"\n [attr.r]=\"markerRadius()\"\n [attr.fill]=\"'var(--' + (markerColor() ?? series().colorToken) + ')'\"\n />\n }\n }\n</svg>\n","/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nexport * from './si-microchart-line.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;MAoBU,yBAAyB,CAAA;AACpC;;;;;;;AAOG;AACM,IAAA,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAwB;;AAE/C,IAAA,KAAK,GAAG,KAAK,CAAS,EAAE,CAAC;;AAEzB,IAAA,MAAM,GAAG,KAAK,CAAS,EAAE,CAAC;AACnC;;;;;AAKG;AACM,IAAA,WAAW,GAAG,KAAK,CAAU,KAAK,CAAC;AAC5C;;;;AAIG;AACM,IAAA,SAAS,GAAG,KAAK,CAAS,CAAC,CAAC;AACrC;;;;;AAKG;IACM,WAAW,GAAG,KA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import { Coordinate } from '@siemens/native-charts-ng/utils';
|
|
2
3
|
|
|
3
4
|
interface MicrochartLineSeries {
|
|
4
5
|
/** Series values */
|
|
@@ -24,11 +25,33 @@ declare class SiMicrochartLineComponent {
|
|
|
24
25
|
readonly width: _angular_core.InputSignal<number>;
|
|
25
26
|
/** @defaultValue 24 */
|
|
26
27
|
readonly height: _angular_core.InputSignal<number>;
|
|
27
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Display circular markers at each data point on the line.
|
|
30
|
+
* When enabled, markers help highlight individual values and improve readability.
|
|
31
|
+
*
|
|
32
|
+
* @defaultValue false
|
|
33
|
+
*/
|
|
34
|
+
readonly showMarkers: _angular_core.InputSignal<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Line width in pixels.
|
|
37
|
+
*
|
|
38
|
+
* @defaultValue 2
|
|
39
|
+
*/
|
|
40
|
+
readonly lineWidth: _angular_core.InputSignal<number>;
|
|
41
|
+
/**
|
|
42
|
+
* Marker color token. If not provided, uses the series color token.
|
|
43
|
+
* Use a data-color. See: {@link https://element.siemens.io/fundamentals/colors/data-visualization-colors/#tokens}
|
|
44
|
+
*
|
|
45
|
+
* @example "element-data-2"
|
|
46
|
+
*/
|
|
47
|
+
readonly markerColor: _angular_core.InputSignal<string | undefined>;
|
|
48
|
+
protected readonly markerRadius: _angular_core.Signal<number>;
|
|
49
|
+
protected readonly viewBox: _angular_core.Signal<string>;
|
|
28
50
|
protected readonly path: _angular_core.Signal<string>;
|
|
51
|
+
protected readonly markerPoints: _angular_core.Signal<Coordinate[]>;
|
|
29
52
|
private mapToCoordinates;
|
|
30
53
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiMicrochartLineComponent, never>;
|
|
31
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiMicrochartLineComponent, "si-microchart-line", never, { "series": { "alias": "series"; "required": true; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
54
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiMicrochartLineComponent, "si-microchart-line", never, { "series": { "alias": "series"; "required": true; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "showMarkers": { "alias": "showMarkers"; "required": false; "isSignal": true; }; "lineWidth": { "alias": "lineWidth"; "required": false; "isSignal": true; }; "markerColor": { "alias": "markerColor"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
32
55
|
}
|
|
33
56
|
|
|
34
57
|
export { SiMicrochartLineComponent };
|