@siemens/native-charts-ng 48.0.1 → 48.0.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.
|
@@ -8,8 +8,8 @@ import { input, computed, ChangeDetectionStrategy, Component } from '@angular/co
|
|
|
8
8
|
class SiMicrochartBarComponent {
|
|
9
9
|
/** @defaultValue 64 */
|
|
10
10
|
width = input(64);
|
|
11
|
-
/** @defaultValue
|
|
12
|
-
height = input(
|
|
11
|
+
/** @defaultValue 24 */
|
|
12
|
+
height = input(24);
|
|
13
13
|
/**
|
|
14
14
|
* Microchart bar series.
|
|
15
15
|
* Example series can be:
|
|
@@ -20,17 +20,29 @@ class SiMicrochartBarComponent {
|
|
|
20
20
|
*/
|
|
21
21
|
series = input.required();
|
|
22
22
|
barWidth = 4;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
23
|
+
internalSeries = computed(() => {
|
|
24
|
+
const series = this.series();
|
|
25
|
+
const maxValue = Math.max(...series.values, 1);
|
|
26
|
+
const minValue = Math.min(...series.values, 0);
|
|
27
|
+
const allNegative = maxValue <= 0;
|
|
28
|
+
const allPositive = minValue >= 0;
|
|
29
|
+
const range = Math.abs(maxValue) + Math.abs(minValue);
|
|
30
|
+
const zeroPosition = allNegative ? 0 : allPositive ? 100 : (Math.abs(maxValue) / range) * 100;
|
|
31
|
+
const maxRange = allNegative ? Math.abs(minValue) : allPositive ? maxValue : range;
|
|
32
|
+
const int = series.values.map(value => {
|
|
33
|
+
const height = (Math.abs(value) / maxRange) * 100;
|
|
34
|
+
const top = value >= 0 ? zeroPosition - height : zeroPosition;
|
|
35
|
+
const colorToken = value < 0 && series.negativeColorToken ? series.negativeColorToken : series.colorToken;
|
|
36
|
+
return { top, height, colorToken };
|
|
37
|
+
});
|
|
38
|
+
return int;
|
|
27
39
|
});
|
|
28
40
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiMicrochartBarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
29
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SiMicrochartBarComponent, isStandalone: true, selector: "si-microchart-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
|
|
41
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SiMicrochartBarComponent, isStandalone: true, selector: "si-microchart-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 class=\"py-2\" [style.width.px]=\"width()\" [style.height.px]=\"height()\">\n <div class=\"position-relative h-100\">\n @for (item of internalSeries(); track $index) {\n <div\n class=\"position-absolute\"\n [style.height.%]=\"item.height\"\n [style.top.%]=\"item.top\"\n [style.left.px]=\"$index * (barWidth + 1)\"\n [style.width.px]=\"barWidth\"\n [style.backgroundColor]=\"'var(--' + item.colorToken + ')'\"\n ></div>\n }\n </div>\n</div>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
30
42
|
}
|
|
31
43
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiMicrochartBarComponent, decorators: [{
|
|
32
44
|
type: Component,
|
|
33
|
-
args: [{ selector: 'si-microchart-bar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div
|
|
45
|
+
args: [{ selector: 'si-microchart-bar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"py-2\" [style.width.px]=\"width()\" [style.height.px]=\"height()\">\n <div class=\"position-relative h-100\">\n @for (item of internalSeries(); track $index) {\n <div\n class=\"position-absolute\"\n [style.height.%]=\"item.height\"\n [style.top.%]=\"item.top\"\n [style.left.px]=\"$index * (barWidth + 1)\"\n [style.width.px]=\"barWidth\"\n [style.backgroundColor]=\"'var(--' + item.colorToken + ')'\"\n ></div>\n }\n </div>\n</div>\n" }]
|
|
34
46
|
}] });
|
|
35
47
|
|
|
36
48
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siemens-native-charts-ng-microchart-bar.mjs","sources":["../../../../projects/native-charts-ng/microchart-bar/si-microchart-bar.component.ts","../../../../projects/native-charts-ng/microchart-bar/si-microchart-bar.component.html","../../../../projects/native-charts-ng/microchart-bar/index.ts","../../../../projects/native-charts-ng/microchart-bar/siemens-native-charts-ng-microchart-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 MicrochartBarSeries {\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-bar',\n templateUrl: './si-microchart-bar.component.html',\n
|
|
1
|
+
{"version":3,"file":"siemens-native-charts-ng-microchart-bar.mjs","sources":["../../../../projects/native-charts-ng/microchart-bar/si-microchart-bar.component.ts","../../../../projects/native-charts-ng/microchart-bar/si-microchart-bar.component.html","../../../../projects/native-charts-ng/microchart-bar/index.ts","../../../../projects/native-charts-ng/microchart-bar/siemens-native-charts-ng-microchart-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 MicrochartBarSeries {\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 * Color token for negative values\n */\n negativeColorToken?: string;\n}\n\ninterface SeriesInternal {\n top: number;\n height: number;\n colorToken: string;\n}\n\n@Component({\n selector: 'si-microchart-bar',\n templateUrl: './si-microchart-bar.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SiMicrochartBarComponent {\n /** @defaultValue 64 */\n readonly width = input<number>(64);\n /** @defaultValue 24 */\n readonly height = input<number>(24);\n /**\n * Microchart bar series.\n * Example series can be:\n * @example\n * ```ts\n * Series: MicrochartBarSeries = { values: [2, 4, 5, 3, 5, 7, 7, 9, 11, 10, 12, 9], colorToken: 'element-data-7'};\n * ```\n */\n readonly series = input.required<MicrochartBarSeries>();\n\n protected barWidth = 4;\n\n protected readonly internalSeries = computed<SeriesInternal[]>(() => {\n const series = this.series();\n const maxValue = Math.max(...series.values, 1);\n const minValue = Math.min(...series.values, 0);\n const allNegative = maxValue <= 0;\n const allPositive = minValue >= 0;\n const range = Math.abs(maxValue) + Math.abs(minValue);\n const zeroPosition = allNegative ? 0 : allPositive ? 100 : (Math.abs(maxValue) / range) * 100;\n\n const maxRange = allNegative ? Math.abs(minValue) : allPositive ? maxValue : range;\n\n const int = series.values.map<SeriesInternal>(value => {\n const height = (Math.abs(value) / maxRange) * 100;\n const top = value >= 0 ? zeroPosition - height : zeroPosition;\n const colorToken =\n value < 0 && series.negativeColorToken ? series.negativeColorToken : series.colorToken;\n return { top, height, colorToken };\n });\n\n return int;\n });\n}\n","<div class=\"py-2\" [style.width.px]=\"width()\" [style.height.px]=\"height()\">\n <div class=\"position-relative h-100\">\n @for (item of internalSeries(); track $index) {\n <div\n class=\"position-absolute\"\n [style.height.%]=\"item.height\"\n [style.top.%]=\"item.top\"\n [style.left.px]=\"$index * (barWidth + 1)\"\n [style.width.px]=\"barWidth\"\n [style.backgroundColor]=\"'var(--' + item.colorToken + ')'\"\n ></div>\n }\n </div>\n</div>\n","/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nexport * from './si-microchart-bar.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAAA;;;AAGG;MA6BU,wBAAwB,CAAA;;AAE1B,IAAA,KAAK,GAAG,KAAK,CAAS,EAAE,CAAC;;AAEzB,IAAA,MAAM,GAAG,KAAK,CAAS,EAAE,CAAC;AACnC;;;;;;;AAOG;AACM,IAAA,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAuB;IAE7C,QAAQ,GAAG,CAAC;AAEH,IAAA,cAAc,GAAG,QAAQ,CAAmB,MAAK;AAClE,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE;AAC5B,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9C,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9C,QAAA,MAAM,WAAW,GAAG,QAAQ,IAAI,CAAC;AACjC,QAAA,MAAM,WAAW,GAAG,QAAQ,IAAI,CAAC;AACjC,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;AACrD,QAAA,MAAM,YAAY,GAAG,WAAW,GAAG,CAAC,GAAG,WAAW,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,KAAK,IAAI,GAAG;QAE7F,MAAM,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,WAAW,GAAG,QAAQ,GAAG,KAAK;QAElF,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAiB,KAAK,IAAG;AACpD,YAAA,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,QAAQ,IAAI,GAAG;AACjD,YAAA,MAAM,GAAG,GAAG,KAAK,IAAI,CAAC,GAAG,YAAY,GAAG,MAAM,GAAG,YAAY;YAC7D,MAAM,UAAU,GACd,KAAK,GAAG,CAAC,IAAI,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC,UAAU;AACxF,YAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE;AACpC,SAAC,CAAC;AAEF,QAAA,OAAO,GAAG;AACZ,KAAC,CAAC;uGArCS,wBAAwB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAxB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,wBAAwB,scChCrC,6fAcA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FDkBa,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBALpC,SAAS;+BACE,mBAAmB,EAAA,eAAA,EAEZ,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,6fAAA,EAAA;;;AE9BjD;;;AAGG;;ACHH;;AAEG;;;;"}
|
|
@@ -8,11 +8,20 @@ interface MicrochartBarSeries {
|
|
|
8
8
|
* @example "element-data-10"
|
|
9
9
|
*/
|
|
10
10
|
colorToken: string;
|
|
11
|
+
/**
|
|
12
|
+
* Color token for negative values
|
|
13
|
+
*/
|
|
14
|
+
negativeColorToken?: string;
|
|
15
|
+
}
|
|
16
|
+
interface SeriesInternal {
|
|
17
|
+
top: number;
|
|
18
|
+
height: number;
|
|
19
|
+
colorToken: string;
|
|
11
20
|
}
|
|
12
21
|
declare class SiMicrochartBarComponent {
|
|
13
22
|
/** @defaultValue 64 */
|
|
14
23
|
readonly width: _angular_core.InputSignal<number>;
|
|
15
|
-
/** @defaultValue
|
|
24
|
+
/** @defaultValue 24 */
|
|
16
25
|
readonly height: _angular_core.InputSignal<number>;
|
|
17
26
|
/**
|
|
18
27
|
* Microchart bar series.
|
|
@@ -24,8 +33,7 @@ declare class SiMicrochartBarComponent {
|
|
|
24
33
|
*/
|
|
25
34
|
readonly series: _angular_core.InputSignal<MicrochartBarSeries>;
|
|
26
35
|
protected barWidth: number;
|
|
27
|
-
protected
|
|
28
|
-
protected readonly maxValue: _angular_core.Signal<number>;
|
|
36
|
+
protected readonly internalSeries: _angular_core.Signal<SeriesInternal[]>;
|
|
29
37
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiMicrochartBarComponent, never>;
|
|
30
38
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiMicrochartBarComponent, "si-microchart-bar", never, { "width": { "alias": "width"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "series": { "alias": "series"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
31
39
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siemens/native-charts-ng",
|
|
3
3
|
"description": "Element Native charts library.",
|
|
4
|
-
"version": "48.0.
|
|
4
|
+
"version": "48.0.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"types": "./index.d.ts",
|
|
33
33
|
"default": "./fesm2022/siemens-native-charts-ng.mjs"
|
|
34
34
|
},
|
|
35
|
-
"./gauge": {
|
|
36
|
-
"types": "./gauge/index.d.ts",
|
|
37
|
-
"default": "./fesm2022/siemens-native-charts-ng-gauge.mjs"
|
|
38
|
-
},
|
|
39
35
|
"./microchart-bar": {
|
|
40
36
|
"types": "./microchart-bar/index.d.ts",
|
|
41
37
|
"default": "./fesm2022/siemens-native-charts-ng-microchart-bar.mjs"
|
|
42
38
|
},
|
|
39
|
+
"./gauge": {
|
|
40
|
+
"types": "./gauge/index.d.ts",
|
|
41
|
+
"default": "./fesm2022/siemens-native-charts-ng-gauge.mjs"
|
|
42
|
+
},
|
|
43
43
|
"./microchart-donut": {
|
|
44
44
|
"types": "./microchart-donut/index.d.ts",
|
|
45
45
|
"default": "./fesm2022/siemens-native-charts-ng-microchart-donut.mjs"
|