@perses-dev/gauge-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 (118) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +41 -0
  3. package/__mf/css/async/263.683bd428.css +1 -0
  4. package/__mf/css/async/341.683bd428.css +1 -0
  5. package/__mf/css/async/759.683bd428.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/481.157b10da.js +5 -0
  19. package/__mf/js/GaugeChart.ab54e56d.js +5 -0
  20. package/__mf/js/async/162.e82ae267.js +73 -0
  21. package/__mf/js/async/162.e82ae267.js.LICENSE.txt +19 -0
  22. package/__mf/js/async/173.5bfb1682.js +2 -0
  23. package/__mf/js/async/173.5bfb1682.js.LICENSE.txt +19 -0
  24. package/__mf/js/async/214.6d1beb4f.js +1 -0
  25. package/__mf/js/async/224.dd9ee618.js +1 -0
  26. package/__mf/js/async/238.3b90e0d1.js +1 -0
  27. package/__mf/js/async/292.d6d07d9c.js +1 -0
  28. package/__mf/js/async/296.6e15d7c1.js +1 -0
  29. package/__mf/js/async/301.2cb371d7.js +1 -0
  30. package/__mf/js/async/488.6e73b2c9.js +1 -0
  31. package/__mf/js/async/553.db3ebdeb.js +1 -0
  32. package/__mf/js/async/610.ba53bb1f.js +1 -0
  33. package/__mf/js/async/620.eb985bf1.js +2 -0
  34. package/__mf/js/async/620.eb985bf1.js.LICENSE.txt +9 -0
  35. package/__mf/js/async/623.afdd0af8.js +1 -0
  36. package/__mf/js/async/656.75485b0e.js +1 -0
  37. package/__mf/js/async/694.8b956cd7.js +1 -0
  38. package/__mf/js/async/738.e2de8ee4.js +1 -0
  39. package/__mf/js/async/740.a7a03e99.js +1 -0
  40. package/__mf/js/async/75.4ebd94ad.js +1 -0
  41. package/__mf/js/async/770.1ddcdb57.js +1 -0
  42. package/__mf/js/async/774.db64c396.js +1 -0
  43. package/__mf/js/async/790.4aa856ac.js +1 -0
  44. package/__mf/js/async/808.4e339e11.js +37 -0
  45. package/__mf/js/async/870.e225b77a.js +29 -0
  46. package/__mf/js/async/870.e225b77a.js.LICENSE.txt +59 -0
  47. package/__mf/js/async/885.6fe431cc.js +102 -0
  48. package/__mf/js/async/929.fde3d617.js +10 -0
  49. package/__mf/js/async/929.fde3d617.js.LICENSE.txt +27 -0
  50. package/__mf/js/async/930.dbd05e3e.js +1 -0
  51. package/__mf/js/async/960.fb84169e.js +2 -0
  52. package/__mf/js/async/960.fb84169e.js.LICENSE.txt +8 -0
  53. package/__mf/js/async/964.80d5e8c0.js +2 -0
  54. package/__mf/js/async/964.80d5e8c0.js.LICENSE.txt +9 -0
  55. package/__mf/js/async/981.6ecc2fa1.js +2 -0
  56. package/__mf/js/async/981.6ecc2fa1.js.LICENSE.txt +8 -0
  57. package/__mf/js/async/996.ec5992e5.js +2 -0
  58. package/__mf/js/async/996.ec5992e5.js.LICENSE.txt +24 -0
  59. package/__mf/js/async/__federation_expose_GaugeChart.8d994ab0.js +1 -0
  60. package/__mf/js/async/lib-router.c799dfc6.js +2 -0
  61. package/__mf/js/async/lib-router.c799dfc6.js.LICENSE.txt +32 -0
  62. package/__mf/js/main.7be7ddac.js +1 -0
  63. package/lib/GaugeChart.d.ts +8 -0
  64. package/lib/GaugeChart.d.ts.map +1 -0
  65. package/lib/GaugeChart.js +33 -0
  66. package/lib/GaugeChart.js.map +1 -0
  67. package/lib/GaugeChartOptionsEditorSettings.d.ts +4 -0
  68. package/lib/GaugeChartOptionsEditorSettings.d.ts.map +1 -0
  69. package/lib/GaugeChartOptionsEditorSettings.js +88 -0
  70. package/lib/GaugeChartOptionsEditorSettings.js.map +1 -0
  71. package/lib/GaugeChartPanel.d.ts +8 -0
  72. package/lib/GaugeChartPanel.d.ts.map +1 -0
  73. package/lib/GaugeChartPanel.js +126 -0
  74. package/lib/GaugeChartPanel.js.map +1 -0
  75. package/lib/bootstrap.d.ts +2 -0
  76. package/lib/bootstrap.d.ts.map +1 -0
  77. package/lib/bootstrap.js +19 -0
  78. package/lib/bootstrap.js.map +1 -0
  79. package/lib/cjs/GaugeChart.js +39 -0
  80. package/lib/cjs/GaugeChartOptionsEditorSettings.js +101 -0
  81. package/lib/cjs/GaugeChartPanel.js +147 -0
  82. package/lib/cjs/bootstrap.js +26 -0
  83. package/lib/cjs/env.d.js +14 -0
  84. package/lib/cjs/gauge-chart-model.js +57 -0
  85. package/lib/cjs/getPluginModule.js +27 -0
  86. package/lib/cjs/index-federation.js +55 -0
  87. package/lib/cjs/index.js +29 -0
  88. package/lib/cjs/setup-tests.js +19 -0
  89. package/lib/cjs/thresholds.js +77 -0
  90. package/lib/env.d.js +15 -0
  91. package/lib/env.d.js.map +1 -0
  92. package/lib/gauge-chart-model.d.ts +26 -0
  93. package/lib/gauge-chart-model.d.ts.map +1 -0
  94. package/lib/gauge-chart-model.js +37 -0
  95. package/lib/gauge-chart-model.js.map +1 -0
  96. package/lib/getPluginModule.d.ts +6 -0
  97. package/lib/getPluginModule.d.ts.map +1 -0
  98. package/lib/getPluginModule.js +16 -0
  99. package/lib/getPluginModule.js.map +1 -0
  100. package/lib/index-federation.d.ts +1 -0
  101. package/lib/index-federation.d.ts.map +1 -0
  102. package/lib/index-federation.js +15 -0
  103. package/lib/index-federation.js.map +1 -0
  104. package/lib/index.d.ts +7 -0
  105. package/lib/index.d.ts.map +1 -0
  106. package/lib/index.js +8 -0
  107. package/lib/index.js.map +1 -0
  108. package/lib/setup-tests.d.ts +2 -0
  109. package/lib/setup-tests.d.ts.map +1 -0
  110. package/lib/setup-tests.js +17 -0
  111. package/lib/setup-tests.js.map +1 -0
  112. package/lib/thresholds.d.ts +6 -0
  113. package/lib/thresholds.d.ts.map +1 -0
  114. package/lib/thresholds.js +56 -0
  115. package/lib/thresholds.js.map +1 -0
  116. package/mf-manifest.json +396 -0
  117. package/mf-stats.json +453 -0
  118. package/package.json +50 -0
@@ -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
+ _export_star(require("./gauge-chart-model"), exports);
12
+ _export_star(require("./GaugeChart"), exports);
13
+ _export_star(require("./GaugeChartOptionsEditorSettings"), exports);
14
+ _export_star(require("./GaugeChartPanel"), exports);
15
+ const _getPluginModule = require("./getPluginModule");
16
+ _export_star(require("./thresholds"), 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,77 @@
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
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ convertThresholds: function() {
25
+ return convertThresholds;
26
+ },
27
+ defaultThresholdInput: function() {
28
+ return defaultThresholdInput;
29
+ }
30
+ });
31
+ const _zip = /*#__PURE__*/ _interop_require_default(require("lodash/zip"));
32
+ function _interop_require_default(obj) {
33
+ return obj && obj.__esModule ? obj : {
34
+ default: obj
35
+ };
36
+ }
37
+ const defaultThresholdInput = {
38
+ steps: [
39
+ {
40
+ value: 0
41
+ }
42
+ ]
43
+ };
44
+ function convertThresholds(thresholds, unit, max, palette) {
45
+ const defaultThresholdColor = thresholds.defaultColor ?? palette.defaultColor;
46
+ const defaultThresholdSteps = [
47
+ [
48
+ 0,
49
+ defaultThresholdColor
50
+ ]
51
+ ];
52
+ if (thresholds.steps !== undefined) {
53
+ // https://echarts.apache.org/en/option.html#series-gauge.axisLine.lineStyle.color
54
+ // color segments must be decimal between 0 and 1
55
+ const segmentMax = 1;
56
+ const valuesArr = thresholds.steps.map((step)=>{
57
+ if (thresholds.mode === 'percent') {
58
+ return step.value / 100;
59
+ }
60
+ return step.value / max;
61
+ });
62
+ valuesArr.push(segmentMax);
63
+ const colorsArr = thresholds.steps.map((step, index)=>step.color ?? palette.palette[index]);
64
+ colorsArr.unshift(defaultThresholdColor);
65
+ const zippedArr = (0, _zip.default)(valuesArr, colorsArr);
66
+ return zippedArr.map((elem)=>{
67
+ const convertedValues = elem[0] ?? segmentMax;
68
+ const convertedColors = elem[1] ?? defaultThresholdColor;
69
+ return [
70
+ convertedValues,
71
+ convertedColors
72
+ ];
73
+ });
74
+ } else {
75
+ return defaultThresholdSteps;
76
+ }
77
+ }
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,26 @@
1
+ import { CalculationType, Definition, ThresholdOptions, FormatOptions } from '@perses-dev/core';
2
+ import { OptionsEditorProps } from '@perses-dev/plugin-system';
3
+ export declare const DEFAULT_FORMAT: FormatOptions;
4
+ export declare const DEFAULT_MAX_PERCENT = 100;
5
+ export declare const DEFAULT_MAX_PERCENT_DECIMAL = 1;
6
+ /**
7
+ * The schema for a GaugeChart panel.
8
+ */
9
+ export interface GaugeChartDefinition extends Definition<GaugeChartOptions> {
10
+ kind: 'GaugeChart';
11
+ }
12
+ /**
13
+ * The Options object type supported by the GaugeChart panel plugin.
14
+ */
15
+ export interface GaugeChartOptions {
16
+ calculation: CalculationType;
17
+ format?: FormatOptions;
18
+ thresholds?: ThresholdOptions;
19
+ max?: number;
20
+ }
21
+ export type GaugeChartOptionsEditorProps = OptionsEditorProps<GaugeChartOptions>;
22
+ /**
23
+ * Creates the initial/empty options for a GaugeChart panel.
24
+ */
25
+ export declare function createInitialGaugeChartOptions(): GaugeChartOptions;
26
+ //# sourceMappingURL=gauge-chart-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gauge-chart-model.d.ts","sourceRoot":"","sources":["../../src/gauge-chart-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,eAAO,MAAM,cAAc,EAAE,aAA2C,CAAC;AACzE,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IACzE,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,eAAe,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,4BAA4B,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;AAEjF;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,iBAAiB,CAelE"}
@@ -0,0 +1,37 @@
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 const DEFAULT_FORMAT = {
14
+ unit: 'percent-decimal'
15
+ };
16
+ export const DEFAULT_MAX_PERCENT = 100;
17
+ export const DEFAULT_MAX_PERCENT_DECIMAL = 1;
18
+ /**
19
+ * Creates the initial/empty options for a GaugeChart panel.
20
+ */ export function createInitialGaugeChartOptions() {
21
+ return {
22
+ calculation: 'last-number',
23
+ format: DEFAULT_FORMAT,
24
+ thresholds: {
25
+ steps: [
26
+ {
27
+ value: 0.8
28
+ },
29
+ {
30
+ value: 0.9
31
+ }
32
+ ]
33
+ }
34
+ };
35
+ }
36
+
37
+ //# sourceMappingURL=gauge-chart-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/gauge-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 } from '@perses-dev/core';\nimport { OptionsEditorProps } from '@perses-dev/plugin-system';\n\nexport const DEFAULT_FORMAT: FormatOptions = { unit: 'percent-decimal' };\nexport const DEFAULT_MAX_PERCENT = 100;\nexport const DEFAULT_MAX_PERCENT_DECIMAL = 1;\n\n/**\n * The schema for a GaugeChart panel.\n */\nexport interface GaugeChartDefinition extends Definition<GaugeChartOptions> {\n kind: 'GaugeChart';\n}\n\n/**\n * The Options object type supported by the GaugeChart panel plugin.\n */\nexport interface GaugeChartOptions {\n calculation: CalculationType;\n format?: FormatOptions;\n thresholds?: ThresholdOptions;\n max?: number;\n}\n\nexport type GaugeChartOptionsEditorProps = OptionsEditorProps<GaugeChartOptions>;\n\n/**\n * Creates the initial/empty options for a GaugeChart panel.\n */\nexport function createInitialGaugeChartOptions(): GaugeChartOptions {\n return {\n calculation: 'last-number',\n format: DEFAULT_FORMAT,\n thresholds: {\n steps: [\n {\n value: 0.8,\n },\n {\n value: 0.9,\n },\n ],\n },\n };\n}\n"],"names":["DEFAULT_FORMAT","unit","DEFAULT_MAX_PERCENT","DEFAULT_MAX_PERCENT_DECIMAL","createInitialGaugeChartOptions","calculation","format","thresholds","steps","value"],"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;AAKjC,OAAO,MAAMA,iBAAgC;IAAEC,MAAM;AAAkB,EAAE;AACzE,OAAO,MAAMC,sBAAsB,IAAI;AACvC,OAAO,MAAMC,8BAA8B,EAAE;AAqB7C;;CAEC,GACD,OAAO,SAASC;IACd,OAAO;QACLC,aAAa;QACbC,QAAQN;QACRO,YAAY;YACVC,OAAO;gBACL;oBACEC,OAAO;gBACT;gBACA;oBACEA,OAAO;gBACT;aACD;QACH;IACF;AACF"}
@@ -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 * from './gauge-chart-model';
2
+ export * from './GaugeChart';
3
+ export * from './GaugeChartOptionsEditorSettings';
4
+ export * from './GaugeChartPanel';
5
+ export { getPluginModule } from './getPluginModule';
6
+ export * from './thresholds';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,cAAc,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from './gauge-chart-model';
2
+ export * from './GaugeChart';
3
+ export * from './GaugeChartOptionsEditorSettings';
4
+ export * from './GaugeChartPanel';
5
+ export { getPluginModule } from './getPluginModule';
6
+ export * from './thresholds';
7
+
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './gauge-chart-model';\nexport * from './GaugeChart';\nexport * from './GaugeChartOptionsEditorSettings';\nexport * from './GaugeChartPanel';\nexport { getPluginModule } from './getPluginModule';\nexport * from './thresholds';\n"],"names":["getPluginModule"],"mappings":"AAAA,cAAc,sBAAsB;AACpC,cAAc,eAAe;AAC7B,cAAc,oCAAoC;AAClD,cAAc,oBAAoB;AAClC,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,eAAe"}
@@ -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,6 @@
1
+ import { ThresholdColorPalette, ThresholdOptions, FormatOptions } from '@perses-dev/core';
2
+ export type GaugeColorStop = [number, string];
3
+ export type EChartsAxisLineColors = GaugeColorStop[];
4
+ export declare const defaultThresholdInput: ThresholdOptions;
5
+ export declare function convertThresholds(thresholds: ThresholdOptions, unit: FormatOptions, max: number, palette: ThresholdColorPalette): EChartsAxisLineColors;
6
+ //# sourceMappingURL=thresholds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thresholds.d.ts","sourceRoot":"","sources":["../../src/thresholds.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,qBAAqB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGvG,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG,cAAc,EAAE,CAAC;AAErD,eAAO,MAAM,qBAAqB,EAAE,gBAA4C,CAAC;AAEjF,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,aAAa,EACnB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,GAC7B,qBAAqB,CA4BvB"}
@@ -0,0 +1,56 @@
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 zip from 'lodash/zip';
14
+ export const defaultThresholdInput = {
15
+ steps: [
16
+ {
17
+ value: 0
18
+ }
19
+ ]
20
+ };
21
+ export function convertThresholds(thresholds, unit, max, palette) {
22
+ const defaultThresholdColor = thresholds.defaultColor ?? palette.defaultColor;
23
+ const defaultThresholdSteps = [
24
+ [
25
+ 0,
26
+ defaultThresholdColor
27
+ ]
28
+ ];
29
+ if (thresholds.steps !== undefined) {
30
+ // https://echarts.apache.org/en/option.html#series-gauge.axisLine.lineStyle.color
31
+ // color segments must be decimal between 0 and 1
32
+ const segmentMax = 1;
33
+ const valuesArr = thresholds.steps.map((step)=>{
34
+ if (thresholds.mode === 'percent') {
35
+ return step.value / 100;
36
+ }
37
+ return step.value / max;
38
+ });
39
+ valuesArr.push(segmentMax);
40
+ const colorsArr = thresholds.steps.map((step, index)=>step.color ?? palette.palette[index]);
41
+ colorsArr.unshift(defaultThresholdColor);
42
+ const zippedArr = zip(valuesArr, colorsArr);
43
+ return zippedArr.map((elem)=>{
44
+ const convertedValues = elem[0] ?? segmentMax;
45
+ const convertedColors = elem[1] ?? defaultThresholdColor;
46
+ return [
47
+ convertedValues,
48
+ convertedColors
49
+ ];
50
+ });
51
+ } else {
52
+ return defaultThresholdSteps;
53
+ }
54
+ }
55
+
56
+ //# sourceMappingURL=thresholds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/thresholds.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 { StepOptions, ThresholdColorPalette, ThresholdOptions, FormatOptions } from '@perses-dev/core';\nimport zip from 'lodash/zip';\n\nexport type GaugeColorStop = [number, string];\n\nexport type EChartsAxisLineColors = GaugeColorStop[];\n\nexport const defaultThresholdInput: ThresholdOptions = { steps: [{ value: 0 }] };\n\nexport function convertThresholds(\n thresholds: ThresholdOptions,\n unit: FormatOptions,\n max: number,\n palette: ThresholdColorPalette\n): EChartsAxisLineColors {\n const defaultThresholdColor = thresholds.defaultColor ?? palette.defaultColor;\n const defaultThresholdSteps: EChartsAxisLineColors = [[0, defaultThresholdColor]];\n\n if (thresholds.steps !== undefined) {\n // https://echarts.apache.org/en/option.html#series-gauge.axisLine.lineStyle.color\n // color segments must be decimal between 0 and 1\n const segmentMax = 1;\n const valuesArr: number[] = thresholds.steps.map((step: StepOptions) => {\n if (thresholds.mode === 'percent') {\n return step.value / 100;\n }\n return step.value / max;\n });\n valuesArr.push(segmentMax);\n\n const colorsArr = thresholds.steps.map((step: StepOptions, index) => step.color ?? palette.palette[index]);\n colorsArr.unshift(defaultThresholdColor);\n\n const zippedArr = zip(valuesArr, colorsArr);\n return zippedArr.map((elem) => {\n const convertedValues = elem[0] ?? segmentMax;\n const convertedColors = elem[1] ?? defaultThresholdColor;\n return [convertedValues, convertedColors];\n });\n } else {\n return defaultThresholdSteps;\n }\n}\n"],"names":["zip","defaultThresholdInput","steps","value","convertThresholds","thresholds","unit","max","palette","defaultThresholdColor","defaultColor","defaultThresholdSteps","undefined","segmentMax","valuesArr","map","step","mode","push","colorsArr","index","color","unshift","zippedArr","elem","convertedValues","convertedColors"],"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;AAGjC,OAAOA,SAAS,aAAa;AAM7B,OAAO,MAAMC,wBAA0C;IAAEC,OAAO;QAAC;YAAEC,OAAO;QAAE;KAAE;AAAC,EAAE;AAEjF,OAAO,SAASC,kBACdC,UAA4B,EAC5BC,IAAmB,EACnBC,GAAW,EACXC,OAA8B;IAE9B,MAAMC,wBAAwBJ,WAAWK,YAAY,IAAIF,QAAQE,YAAY;IAC7E,MAAMC,wBAA+C;QAAC;YAAC;YAAGF;SAAsB;KAAC;IAEjF,IAAIJ,WAAWH,KAAK,KAAKU,WAAW;QAClC,kFAAkF;QAClF,iDAAiD;QACjD,MAAMC,aAAa;QACnB,MAAMC,YAAsBT,WAAWH,KAAK,CAACa,GAAG,CAAC,CAACC;YAChD,IAAIX,WAAWY,IAAI,KAAK,WAAW;gBACjC,OAAOD,KAAKb,KAAK,GAAG;YACtB;YACA,OAAOa,KAAKb,KAAK,GAAGI;QACtB;QACAO,UAAUI,IAAI,CAACL;QAEf,MAAMM,YAAYd,WAAWH,KAAK,CAACa,GAAG,CAAC,CAACC,MAAmBI,QAAUJ,KAAKK,KAAK,IAAIb,QAAQA,OAAO,CAACY,MAAM;QACzGD,UAAUG,OAAO,CAACb;QAElB,MAAMc,YAAYvB,IAAIc,WAAWK;QACjC,OAAOI,UAAUR,GAAG,CAAC,CAACS;YACpB,MAAMC,kBAAkBD,IAAI,CAAC,EAAE,IAAIX;YACnC,MAAMa,kBAAkBF,IAAI,CAAC,EAAE,IAAIf;YACnC,OAAO;gBAACgB;gBAAiBC;aAAgB;QAC3C;IACF,OAAO;QACL,OAAOf;IACT;AACF"}