@perses-dev/stat-chart-plugin 0.6.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.
Files changed (127) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +41 -0
  3. package/__mf/css/async/263.1ed8bb01.css +1 -0
  4. package/__mf/css/async/341.1ed8bb01.css +1 -0
  5. package/__mf/css/async/759.1ed8bb01.css +1 -0
  6. package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
  7. package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
  8. package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
  9. package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
  10. package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
  11. package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
  12. package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
  13. package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
  14. package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
  15. package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
  16. package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
  17. package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
  18. package/__mf/js/435.f40076fc.js +5 -0
  19. package/__mf/js/StatChart.b0400032.js +5 -0
  20. package/__mf/js/async/162.6eaaf026.js +73 -0
  21. package/__mf/js/async/162.6eaaf026.js.LICENSE.txt +19 -0
  22. package/__mf/js/async/173.b6c742e7.js +2 -0
  23. package/__mf/js/async/173.b6c742e7.js.LICENSE.txt +19 -0
  24. package/__mf/js/async/214.60d550e8.js +1 -0
  25. package/__mf/js/async/224.978cad14.js +1 -0
  26. package/__mf/js/async/238.6c65e7fc.js +1 -0
  27. package/__mf/js/async/292.4573cfd2.js +1 -0
  28. package/__mf/js/async/298.0f019169.js +1 -0
  29. package/__mf/js/async/318.98a6e364.js +83 -0
  30. package/__mf/js/async/318.98a6e364.js.LICENSE.txt +27 -0
  31. package/__mf/js/async/488.078788e1.js +1 -0
  32. package/__mf/js/async/610.dad41cbd.js +1 -0
  33. package/__mf/js/async/620.415051b8.js +2 -0
  34. package/__mf/js/async/620.415051b8.js.LICENSE.txt +9 -0
  35. package/__mf/js/async/651.4eb924e1.js +1 -0
  36. package/__mf/js/async/656.dbf72cfa.js +1 -0
  37. package/__mf/js/async/694.5088b7d2.js +1 -0
  38. package/__mf/js/async/738.5905ca00.js +1 -0
  39. package/__mf/js/async/740.6ca05ea5.js +1 -0
  40. package/__mf/js/async/75.fb6da1e8.js +1 -0
  41. package/__mf/js/async/770.0eef8b15.js +1 -0
  42. package/__mf/js/async/870.3ed3413d.js +29 -0
  43. package/__mf/js/async/870.3ed3413d.js.LICENSE.txt +59 -0
  44. package/__mf/js/async/877.0e870142.js +65 -0
  45. package/__mf/js/async/960.b6b50cb1.js +2 -0
  46. package/__mf/js/async/960.b6b50cb1.js.LICENSE.txt +8 -0
  47. package/__mf/js/async/964.f3efac0a.js +2 -0
  48. package/__mf/js/async/964.f3efac0a.js.LICENSE.txt +9 -0
  49. package/__mf/js/async/981.0942fcbb.js +2 -0
  50. package/__mf/js/async/981.0942fcbb.js.LICENSE.txt +8 -0
  51. package/__mf/js/async/996.7e490e79.js +2 -0
  52. package/__mf/js/async/996.7e490e79.js.LICENSE.txt +24 -0
  53. package/__mf/js/async/__federation_expose_StatChart.0d43d15e.js +1 -0
  54. package/__mf/js/async/lib-router.3a3f0205.js +2 -0
  55. package/__mf/js/async/lib-router.3a3f0205.js.LICENSE.txt +32 -0
  56. package/__mf/js/main.628b2309.js +1 -0
  57. package/lib/StatChart.d.ts +8 -0
  58. package/lib/StatChart.d.ts.map +1 -0
  59. package/lib/StatChart.js +37 -0
  60. package/lib/StatChart.js.map +1 -0
  61. package/lib/StatChartOptionsEditorSettings.d.ts +4 -0
  62. package/lib/StatChartOptionsEditorSettings.d.ts.map +1 -0
  63. package/lib/StatChartOptionsEditorSettings.js +102 -0
  64. package/lib/StatChartOptionsEditorSettings.js.map +1 -0
  65. package/lib/StatChartPanel.d.ts +7 -0
  66. package/lib/StatChartPanel.d.ts.map +1 -0
  67. package/lib/StatChartPanel.js +119 -0
  68. package/lib/StatChartPanel.js.map +1 -0
  69. package/lib/StatChartValueMappingEditor.d.ts +6 -0
  70. package/lib/StatChartValueMappingEditor.d.ts.map +1 -0
  71. package/lib/StatChartValueMappingEditor.js +28 -0
  72. package/lib/StatChartValueMappingEditor.js.map +1 -0
  73. package/lib/bootstrap.d.ts +2 -0
  74. package/lib/bootstrap.d.ts.map +1 -0
  75. package/lib/bootstrap.js +19 -0
  76. package/lib/bootstrap.js.map +1 -0
  77. package/lib/cjs/StatChart.js +43 -0
  78. package/lib/cjs/StatChartOptionsEditorSettings.js +115 -0
  79. package/lib/cjs/StatChartPanel.js +127 -0
  80. package/lib/cjs/StatChartValueMappingEditor.js +36 -0
  81. package/lib/cjs/bootstrap.js +26 -0
  82. package/lib/cjs/env.d.js +14 -0
  83. package/lib/cjs/getPluginModule.js +27 -0
  84. package/lib/cjs/index-federation.js +55 -0
  85. package/lib/cjs/index.js +29 -0
  86. package/lib/cjs/setup-tests.js +19 -0
  87. package/lib/cjs/stat-chart-model.js +31 -0
  88. package/lib/cjs/utils/calculate-value.js +30 -0
  89. package/lib/cjs/utils/data-transform.js +36 -0
  90. package/lib/cjs/utils/get-color.js +66 -0
  91. package/lib/env.d.js +15 -0
  92. package/lib/env.d.js.map +1 -0
  93. package/lib/getPluginModule.d.ts +6 -0
  94. package/lib/getPluginModule.d.ts.map +1 -0
  95. package/lib/getPluginModule.js +16 -0
  96. package/lib/getPluginModule.js.map +1 -0
  97. package/lib/index-federation.d.ts +1 -0
  98. package/lib/index-federation.d.ts.map +1 -0
  99. package/lib/index-federation.js +15 -0
  100. package/lib/index-federation.js.map +1 -0
  101. package/lib/index.d.ts +7 -0
  102. package/lib/index.d.ts.map +1 -0
  103. package/lib/index.js +8 -0
  104. package/lib/index.js.map +1 -0
  105. package/lib/setup-tests.d.ts +2 -0
  106. package/lib/setup-tests.d.ts.map +1 -0
  107. package/lib/setup-tests.js +17 -0
  108. package/lib/setup-tests.js.map +1 -0
  109. package/lib/stat-chart-model.d.ts +25 -0
  110. package/lib/stat-chart-model.d.ts.map +1 -0
  111. package/lib/stat-chart-model.js +23 -0
  112. package/lib/stat-chart-model.js.map +1 -0
  113. package/lib/utils/calculate-value.d.ts +3 -0
  114. package/lib/utils/calculate-value.d.ts.map +1 -0
  115. package/lib/utils/calculate-value.js +22 -0
  116. package/lib/utils/calculate-value.js.map +1 -0
  117. package/lib/utils/data-transform.d.ts +5 -0
  118. package/lib/utils/data-transform.d.ts.map +1 -0
  119. package/lib/utils/data-transform.js +28 -0
  120. package/lib/utils/data-transform.js.map +1 -0
  121. package/lib/utils/get-color.d.ts +6 -0
  122. package/lib/utils/get-color.d.ts.map +1 -0
  123. package/lib/utils/get-color.js +58 -0
  124. package/lib/utils/get-color.js.map +1 -0
  125. package/mf-manifest.json +320 -0
  126. package/mf-stats.json +365 -0
  127. package/package.json +53 -0
@@ -0,0 +1,55 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ function _getRequireWildcardCache(nodeInterop) {
15
+ if (typeof WeakMap !== "function") return null;
16
+ var cacheBabelInterop = new WeakMap();
17
+ var cacheNodeInterop = new WeakMap();
18
+ return (_getRequireWildcardCache = function(nodeInterop) {
19
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
20
+ })(nodeInterop);
21
+ }
22
+ function _interop_require_wildcard(obj, nodeInterop) {
23
+ if (!nodeInterop && obj && obj.__esModule) {
24
+ return obj;
25
+ }
26
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
27
+ return {
28
+ default: obj
29
+ };
30
+ }
31
+ var cache = _getRequireWildcardCache(nodeInterop);
32
+ if (cache && cache.has(obj)) {
33
+ return cache.get(obj);
34
+ }
35
+ var newObj = {
36
+ __proto__: null
37
+ };
38
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
39
+ for(var key in obj){
40
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
41
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
42
+ if (desc && (desc.get || desc.set)) {
43
+ Object.defineProperty(newObj, key, desc);
44
+ } else {
45
+ newObj[key] = obj[key];
46
+ }
47
+ }
48
+ }
49
+ newObj.default = obj;
50
+ if (cache) {
51
+ cache.set(obj, newObj);
52
+ }
53
+ return newObj;
54
+ }
55
+ Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bootstrap")));
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getPluginModule", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _getPluginModule.getPluginModule;
9
+ }
10
+ });
11
+ const _getPluginModule = require("./getPluginModule");
12
+ _export_star(require("./stat-chart-model"), exports);
13
+ _export_star(require("./StatChart"), exports);
14
+ _export_star(require("./StatChartOptionsEditorSettings"), exports);
15
+ _export_star(require("./StatChartPanel"), exports);
16
+ _export_star(require("./StatChartValueMappingEditor"), exports);
17
+ function _export_star(from, to) {
18
+ Object.keys(from).forEach(function(k) {
19
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
20
+ Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
26
+ }
27
+ });
28
+ return from;
29
+ }
@@ -0,0 +1,19 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ require("@testing-library/jest-dom");
18
+ // Always mock e-charts during tests since we don't have a proper canvas in jsdom
19
+ jest.mock('echarts/core');
@@ -0,0 +1,31 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "createInitialStatChartOptions", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return createInitialStatChartOptions;
21
+ }
22
+ });
23
+ function createInitialStatChartOptions() {
24
+ return {
25
+ calculation: 'last-number',
26
+ format: {
27
+ unit: 'decimal'
28
+ },
29
+ sparkline: {}
30
+ };
31
+ }
@@ -0,0 +1,30 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "calculateValue", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return calculateValue;
21
+ }
22
+ });
23
+ const _core = require("@perses-dev/core");
24
+ const calculateValue = (calculation, seriesData)=>{
25
+ if (_core.CalculationsMap[calculation] === undefined) {
26
+ console.warn(`Invalid StatChart panel calculation ${calculation}, fallback to ${_core.DEFAULT_CALCULATION}`);
27
+ }
28
+ const calculate = _core.CalculationsMap[calculation] ?? _core.CalculationsMap[_core.DEFAULT_CALCULATION];
29
+ return calculate(seriesData.values);
30
+ };
@@ -0,0 +1,36 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "convertSparkline", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return convertSparkline;
21
+ }
22
+ });
23
+ function convertSparkline(chartsTheme, color, sparkline) {
24
+ if (sparkline === undefined) return;
25
+ return {
26
+ lineStyle: {
27
+ width: sparkline.width ?? chartsTheme.sparkline.width,
28
+ color,
29
+ opacity: 1
30
+ },
31
+ areaStyle: {
32
+ color,
33
+ opacity: 0.4
34
+ }
35
+ };
36
+ }
@@ -0,0 +1,66 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "getStatChartColor", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return getStatChartColor;
21
+ }
22
+ });
23
+ const _core = require("@perses-dev/core");
24
+ function getStatChartColor(chartsTheme, spec, value) {
25
+ const { mappings, thresholds } = spec ?? {};
26
+ // Determine the default color from thresholds or theme
27
+ const defaultColor = thresholds?.defaultColor ?? chartsTheme.thresholds.defaultColor;
28
+ if (!value || !thresholds?.steps && !mappings) {
29
+ return defaultColor;
30
+ }
31
+ // Check mappings first
32
+ if (mappings?.length) {
33
+ const colorFromMappings = getColorFromMappings(value, mappings);
34
+ if (colorFromMappings) {
35
+ return colorFromMappings;
36
+ }
37
+ }
38
+ // Check thresholds next
39
+ if (thresholds) {
40
+ const colorFromThresholds = getColorFromThresholds(value, thresholds, chartsTheme, defaultColor);
41
+ if (colorFromThresholds) {
42
+ return colorFromThresholds;
43
+ }
44
+ }
45
+ // Fallback to default color
46
+ return defaultColor;
47
+ }
48
+ function getColorFromMappings(value, mappings) {
49
+ if (mappings?.length && value) {
50
+ const { color } = (0, _core.applyValueMapping)(value, mappings);
51
+ return color || null;
52
+ }
53
+ return null;
54
+ }
55
+ function getColorFromThresholds(value, thresholds, chartsTheme, defaultColor) {
56
+ if (thresholds?.steps && typeof value === 'number') {
57
+ const matchingColors = thresholds.steps.map((step, index)=>{
58
+ if (value >= step.value) {
59
+ return step.color ?? chartsTheme.thresholds.palette[index] ?? defaultColor;
60
+ }
61
+ return null;
62
+ }).filter((color)=>color !== null);
63
+ return matchingColors[matchingColors.length - 1] ?? null;
64
+ }
65
+ return null;
66
+ }
package/lib/env.d.js ADDED
@@ -0,0 +1,15 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /// <reference types="@rsbuild/core/types" />
14
+
15
+ //# sourceMappingURL=env.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/env.d.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/// <reference types=\"@rsbuild/core/types\" />\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6CAA6C"}
@@ -0,0 +1,6 @@
1
+ import { PluginModuleResource } from '@perses-dev/plugin-system';
2
+ /**
3
+ * Returns the plugin module information from package.json
4
+ */
5
+ export declare function getPluginModule(): PluginModuleResource;
6
+ //# sourceMappingURL=getPluginModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAGnF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}
@@ -0,0 +1,16 @@
1
+ import packageJson from '../package.json';
2
+ /**
3
+ * Returns the plugin module information from package.json
4
+ */ export function getPluginModule() {
5
+ const { name, version, perses } = packageJson;
6
+ return {
7
+ kind: 'PluginModule',
8
+ metadata: {
9
+ name,
10
+ version
11
+ },
12
+ spec: perses
13
+ };
14
+ }
15
+
16
+ //# sourceMappingURL=getPluginModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/getPluginModule.ts"],"sourcesContent":["import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\nimport packageJson from '../package.json';\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AACA,OAAOA,iBAAiB,kBAAkB;AAE1C;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGJ;IAClC,OAAO;QACLK,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index-federation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-federation.d.ts","sourceRoot":"","sources":["../../src/index-federation.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import('./bootstrap');
14
+
15
+ //# sourceMappingURL=index-federation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index-federation.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport('./bootstrap');\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export { getPluginModule } from './getPluginModule';
2
+ export * from './stat-chart-model';
3
+ export * from './StatChart';
4
+ export * from './StatChartOptionsEditorSettings';
5
+ export * from './StatChartPanel';
6
+ export * from './StatChartValueMappingEditor';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,kCAAkC,CAAC;AACjD,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export { getPluginModule } from './getPluginModule';
2
+ export * from './stat-chart-model';
3
+ export * from './StatChart';
4
+ export * from './StatChartOptionsEditorSettings';
5
+ export * from './StatChartPanel';
6
+ export * from './StatChartValueMappingEditor';
7
+
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getPluginModule } from './getPluginModule';\nexport * from './stat-chart-model';\nexport * from './StatChart';\nexport * from './StatChartOptionsEditorSettings';\nexport * from './StatChartPanel';\nexport * from './StatChartValueMappingEditor';\n"],"names":["getPluginModule"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,qBAAqB;AACnC,cAAc,cAAc;AAC5B,cAAc,mCAAmC;AACjD,cAAc,mBAAmB;AACjC,cAAc,gCAAgC"}
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ //# sourceMappingURL=setup-tests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,2BAA2B,CAAC"}
@@ -0,0 +1,17 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import '@testing-library/jest-dom';
14
+ // Always mock e-charts during tests since we don't have a proper canvas in jsdom
15
+ jest.mock('echarts/core');
16
+
17
+ //# sourceMappingURL=setup-tests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport '@testing-library/jest-dom';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n"],"names":["jest","mock"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,4BAA4B;AAEnC,iFAAiF;AACjFA,KAAKC,IAAI,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { CalculationType, Definition, ThresholdOptions, FormatOptions, ValueMapping } from '@perses-dev/core';
2
+ import { FontSizeOption } from '@perses-dev/components';
3
+ import { OptionsEditorProps } from '@perses-dev/plugin-system';
4
+ /**
5
+ * The schema for a StatChart panel.
6
+ */
7
+ export interface StatChartDefinition extends Definition<StatChartOptions> {
8
+ kind: 'StatChart';
9
+ }
10
+ export interface StatChartOptions {
11
+ calculation: CalculationType;
12
+ format: FormatOptions;
13
+ metricLabel?: string;
14
+ thresholds?: ThresholdOptions;
15
+ sparkline?: StatChartSparklineOptions;
16
+ valueFontSize?: FontSizeOption;
17
+ mappings?: ValueMapping[];
18
+ }
19
+ export interface StatChartSparklineOptions {
20
+ color?: string;
21
+ width?: number;
22
+ }
23
+ export type StatChartOptionsEditorProps = OptionsEditorProps<StatChartOptions>;
24
+ export declare function createInitialStatChartOptions(): StatChartOptions;
25
+ //# sourceMappingURL=stat-chart-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stat-chart-model.d.ts","sourceRoot":"","sources":["../../src/stat-chart-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC9G,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,UAAU,CAAC,gBAAgB,CAAC;IACvE,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,eAAe,CAAC;IAC7B,MAAM,EAAE,aAAa,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,SAAS,CAAC,EAAE,yBAAyB,CAAC;IACtC,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,2BAA2B,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;AAE/E,wBAAgB,6BAA6B,IAAI,gBAAgB,CAQhE"}
@@ -0,0 +1,23 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export function createInitialStatChartOptions() {
14
+ return {
15
+ calculation: 'last-number',
16
+ format: {
17
+ unit: 'decimal'
18
+ },
19
+ sparkline: {}
20
+ };
21
+ }
22
+
23
+ //# sourceMappingURL=stat-chart-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/stat-chart-model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { CalculationType, Definition, ThresholdOptions, FormatOptions, ValueMapping } from '@perses-dev/core';\nimport { FontSizeOption } from '@perses-dev/components';\nimport { OptionsEditorProps } from '@perses-dev/plugin-system';\n\n/**\n * The schema for a StatChart panel.\n */\nexport interface StatChartDefinition extends Definition<StatChartOptions> {\n kind: 'StatChart';\n}\n\nexport interface StatChartOptions {\n calculation: CalculationType;\n format: FormatOptions;\n metricLabel?: string;\n thresholds?: ThresholdOptions;\n sparkline?: StatChartSparklineOptions;\n valueFontSize?: FontSizeOption;\n mappings?: ValueMapping[];\n}\n\nexport interface StatChartSparklineOptions {\n color?: string;\n width?: number;\n}\n\nexport type StatChartOptionsEditorProps = OptionsEditorProps<StatChartOptions>;\n\nexport function createInitialStatChartOptions(): StatChartOptions {\n return {\n calculation: 'last-number',\n format: {\n unit: 'decimal',\n },\n sparkline: {},\n };\n}\n"],"names":["createInitialStatChartOptions","calculation","format","unit","sparkline"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA8BjC,OAAO,SAASA;IACd,OAAO;QACLC,aAAa;QACbC,QAAQ;YACNC,MAAM;QACR;QACAC,WAAW,CAAC;IACd;AACF"}
@@ -0,0 +1,3 @@
1
+ import { CalculationsMap, CalculationType, TimeSeries } from '@perses-dev/core';
2
+ export declare const calculateValue: (calculation: CalculationType, seriesData: TimeSeries) => ReturnType<(typeof CalculationsMap)[CalculationType]>;
3
+ //# sourceMappingURL=calculate-value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate-value.d.ts","sourceRoot":"","sources":["../../../src/utils/calculate-value.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAuB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAErG,eAAO,MAAM,cAAc,GACzB,aAAa,eAAe,EAC5B,YAAY,UAAU,KACrB,UAAU,CAAC,CAAC,OAAO,eAAe,EAAE,eAAe,CAAC,CAMtD,CAAC"}
@@ -0,0 +1,22 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { CalculationsMap, DEFAULT_CALCULATION } from '@perses-dev/core';
14
+ export const calculateValue = (calculation, seriesData)=>{
15
+ if (CalculationsMap[calculation] === undefined) {
16
+ console.warn(`Invalid StatChart panel calculation ${calculation}, fallback to ${DEFAULT_CALCULATION}`);
17
+ }
18
+ const calculate = CalculationsMap[calculation] ?? CalculationsMap[DEFAULT_CALCULATION];
19
+ return calculate(seriesData.values);
20
+ };
21
+
22
+ //# sourceMappingURL=calculate-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/calculate-value.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { CalculationsMap, CalculationType, DEFAULT_CALCULATION, TimeSeries } from '@perses-dev/core';\n\nexport const calculateValue = (\n calculation: CalculationType,\n seriesData: TimeSeries\n): ReturnType<(typeof CalculationsMap)[CalculationType]> => {\n if (CalculationsMap[calculation] === undefined) {\n console.warn(`Invalid StatChart panel calculation ${calculation}, fallback to ${DEFAULT_CALCULATION}`);\n }\n const calculate = CalculationsMap[calculation] ?? CalculationsMap[DEFAULT_CALCULATION];\n return calculate(seriesData.values);\n};\n"],"names":["CalculationsMap","DEFAULT_CALCULATION","calculateValue","calculation","seriesData","undefined","console","warn","calculate","values"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,eAAe,EAAmBC,mBAAmB,QAAoB,mBAAmB;AAErG,OAAO,MAAMC,iBAAiB,CAC5BC,aACAC;IAEA,IAAIJ,eAAe,CAACG,YAAY,KAAKE,WAAW;QAC9CC,QAAQC,IAAI,CAAC,CAAC,oCAAoC,EAAEJ,YAAY,cAAc,EAAEF,qBAAqB;IACvG;IACA,MAAMO,YAAYR,eAAe,CAACG,YAAY,IAAIH,eAAe,CAACC,oBAAoB;IACtF,OAAOO,UAAUJ,WAAWK,MAAM;AACpC,EAAE"}
@@ -0,0 +1,5 @@
1
+ import { PersesChartsTheme } from '@perses-dev/components';
2
+ import { LineSeriesOption } from 'echarts/charts';
3
+ import { StatChartSparklineOptions } from '../stat-chart-model';
4
+ export declare function convertSparkline(chartsTheme: PersesChartsTheme, color: string, sparkline?: StatChartSparklineOptions): LineSeriesOption | undefined;
5
+ //# sourceMappingURL=data-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-transform.d.ts","sourceRoot":"","sources":["../../../src/utils/data-transform.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,iBAAiB,EAC9B,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,yBAAyB,GACpC,gBAAgB,GAAG,SAAS,CAc9B"}
@@ -0,0 +1,28 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export function convertSparkline(chartsTheme, color, sparkline) {
14
+ if (sparkline === undefined) return;
15
+ return {
16
+ lineStyle: {
17
+ width: sparkline.width ?? chartsTheme.sparkline.width,
18
+ color,
19
+ opacity: 1
20
+ },
21
+ areaStyle: {
22
+ color,
23
+ opacity: 0.4
24
+ }
25
+ };
26
+ }
27
+
28
+ //# sourceMappingURL=data-transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/data-transform.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PersesChartsTheme } from '@perses-dev/components';\nimport { LineSeriesOption } from 'echarts/charts';\nimport { StatChartSparklineOptions } from '../stat-chart-model';\n\nexport function convertSparkline(\n chartsTheme: PersesChartsTheme,\n color: string,\n sparkline?: StatChartSparklineOptions\n): LineSeriesOption | undefined {\n if (sparkline === undefined) return;\n\n return {\n lineStyle: {\n width: sparkline.width ?? chartsTheme.sparkline.width,\n color,\n opacity: 1,\n },\n areaStyle: {\n color,\n opacity: 0.4,\n },\n };\n}\n"],"names":["convertSparkline","chartsTheme","color","sparkline","undefined","lineStyle","width","opacity","areaStyle"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAMjC,OAAO,SAASA,iBACdC,WAA8B,EAC9BC,KAAa,EACbC,SAAqC;IAErC,IAAIA,cAAcC,WAAW;IAE7B,OAAO;QACLC,WAAW;YACTC,OAAOH,UAAUG,KAAK,IAAIL,YAAYE,SAAS,CAACG,KAAK;YACrDJ;YACAK,SAAS;QACX;QACAC,WAAW;YACTN;YACAK,SAAS;QACX;IACF;AACF"}
@@ -0,0 +1,6 @@
1
+ import { PersesChartsTheme } from '@perses-dev/components';
2
+ import { StatChartOptions } from '../stat-chart-model';
3
+ type StatChartValue = number | string | null;
4
+ export declare function getStatChartColor(chartsTheme: PersesChartsTheme, spec?: StatChartOptions, value?: StatChartValue): string;
5
+ export {};
6
+ //# sourceMappingURL=get-color.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-color.d.ts","sourceRoot":"","sources":["../../../src/utils/get-color.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAE7C,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,iBAAiB,EAC9B,IAAI,CAAC,EAAE,gBAAgB,EACvB,KAAK,CAAC,EAAE,cAAc,GACrB,MAAM,CA4BR"}
@@ -0,0 +1,58 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { applyValueMapping } from '@perses-dev/core';
14
+ export function getStatChartColor(chartsTheme, spec, value) {
15
+ const { mappings, thresholds } = spec ?? {};
16
+ // Determine the default color from thresholds or theme
17
+ const defaultColor = thresholds?.defaultColor ?? chartsTheme.thresholds.defaultColor;
18
+ if (!value || !thresholds?.steps && !mappings) {
19
+ return defaultColor;
20
+ }
21
+ // Check mappings first
22
+ if (mappings?.length) {
23
+ const colorFromMappings = getColorFromMappings(value, mappings);
24
+ if (colorFromMappings) {
25
+ return colorFromMappings;
26
+ }
27
+ }
28
+ // Check thresholds next
29
+ if (thresholds) {
30
+ const colorFromThresholds = getColorFromThresholds(value, thresholds, chartsTheme, defaultColor);
31
+ if (colorFromThresholds) {
32
+ return colorFromThresholds;
33
+ }
34
+ }
35
+ // Fallback to default color
36
+ return defaultColor;
37
+ }
38
+ function getColorFromMappings(value, mappings) {
39
+ if (mappings?.length && value) {
40
+ const { color } = applyValueMapping(value, mappings);
41
+ return color || null;
42
+ }
43
+ return null;
44
+ }
45
+ function getColorFromThresholds(value, thresholds, chartsTheme, defaultColor) {
46
+ if (thresholds?.steps && typeof value === 'number') {
47
+ const matchingColors = thresholds.steps.map((step, index)=>{
48
+ if (value >= step.value) {
49
+ return step.color ?? chartsTheme.thresholds.palette[index] ?? defaultColor;
50
+ }
51
+ return null;
52
+ }).filter((color)=>color !== null);
53
+ return matchingColors[matchingColors.length - 1] ?? null;
54
+ }
55
+ return null;
56
+ }
57
+
58
+ //# sourceMappingURL=get-color.js.map