@perses-dev/bar-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 (125) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +23 -0
  3. package/__mf/css/async/263.1f61a808.css +1 -0
  4. package/__mf/css/async/341.1f61a808.css +1 -0
  5. package/__mf/css/async/759.1f61a808.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/590.f6491b3d.js +5 -0
  19. package/__mf/js/BarChart.5408c279.js +5 -0
  20. package/__mf/js/async/162.5c4c80cc.js +73 -0
  21. package/__mf/js/async/162.5c4c80cc.js.LICENSE.txt +19 -0
  22. package/__mf/js/async/173.de56afb5.js +2 -0
  23. package/__mf/js/async/173.de56afb5.js.LICENSE.txt +19 -0
  24. package/__mf/js/async/214.39425df9.js +1 -0
  25. package/__mf/js/async/224.02bf0727.js +1 -0
  26. package/__mf/js/async/238.2c28749b.js +1 -0
  27. package/__mf/js/async/292.fc25f0b4.js +1 -0
  28. package/__mf/js/async/296.4e6e1192.js +1 -0
  29. package/__mf/js/async/331.987fc9d1.js +2 -0
  30. package/__mf/js/async/331.987fc9d1.js.LICENSE.txt +21 -0
  31. package/__mf/js/async/360.49d19c17.js +29 -0
  32. package/__mf/js/async/360.49d19c17.js.LICENSE.txt +37 -0
  33. package/__mf/js/async/488.64e4ab62.js +1 -0
  34. package/__mf/js/async/553.cebe1061.js +1 -0
  35. package/__mf/js/async/610.c4c81845.js +1 -0
  36. package/__mf/js/async/620.1ddf3cfa.js +2 -0
  37. package/__mf/js/async/620.1ddf3cfa.js.LICENSE.txt +9 -0
  38. package/__mf/js/async/623.a42c5576.js +1 -0
  39. package/__mf/js/async/656.ebaf4c29.js +1 -0
  40. package/__mf/js/async/69.5f20cd9b.js +10 -0
  41. package/__mf/js/async/69.5f20cd9b.js.LICENSE.txt +27 -0
  42. package/__mf/js/async/694.f18442c5.js +1 -0
  43. package/__mf/js/async/738.0b38462b.js +1 -0
  44. package/__mf/js/async/740.bd4a2dd3.js +1 -0
  45. package/__mf/js/async/75.602a691f.js +1 -0
  46. package/__mf/js/async/762.0d4292e6.js +101 -0
  47. package/__mf/js/async/770.a4ed49b7.js +1 -0
  48. package/__mf/js/async/774.6d4b81a0.js +1 -0
  49. package/__mf/js/async/790.23e35958.js +1 -0
  50. package/__mf/js/async/802.393c9711.js +38 -0
  51. package/__mf/js/async/929.4de7287b.js +1 -0
  52. package/__mf/js/async/930.7db974d8.js +1 -0
  53. package/__mf/js/async/960.07c2f8a6.js +2 -0
  54. package/__mf/js/async/960.07c2f8a6.js.LICENSE.txt +8 -0
  55. package/__mf/js/async/964.d446c7a1.js +2 -0
  56. package/__mf/js/async/964.d446c7a1.js.LICENSE.txt +9 -0
  57. package/__mf/js/async/981.d5ccd920.js +2 -0
  58. package/__mf/js/async/981.d5ccd920.js.LICENSE.txt +8 -0
  59. package/__mf/js/async/996.2287354b.js +2 -0
  60. package/__mf/js/async/996.2287354b.js.LICENSE.txt +24 -0
  61. package/__mf/js/async/__federation_expose_BarChart.7c81d310.js +1 -0
  62. package/__mf/js/async/lib-router.c524d5f3.js +2 -0
  63. package/__mf/js/async/lib-router.c524d5f3.js.LICENSE.txt +32 -0
  64. package/__mf/js/main.c53cadb4.js +1 -0
  65. package/lib/BarChart.d.ts +8 -0
  66. package/lib/BarChart.d.ts.map +1 -0
  67. package/lib/BarChart.js +32 -0
  68. package/lib/BarChart.js.map +1 -0
  69. package/lib/BarChartOptionsEditorSettings.d.ts +4 -0
  70. package/lib/BarChartOptionsEditorSettings.d.ts.map +1 -0
  71. package/lib/BarChartOptionsEditorSettings.js +95 -0
  72. package/lib/BarChartOptionsEditorSettings.js.map +1 -0
  73. package/lib/BarChartPanel.d.ts +7 -0
  74. package/lib/BarChartPanel.d.ts.map +1 -0
  75. package/lib/BarChartPanel.js +62 -0
  76. package/lib/BarChartPanel.js.map +1 -0
  77. package/lib/bar-chart-model.d.ts +27 -0
  78. package/lib/bar-chart-model.d.ts.map +1 -0
  79. package/lib/bar-chart-model.js +31 -0
  80. package/lib/bar-chart-model.js.map +1 -0
  81. package/lib/bootstrap.d.ts +2 -0
  82. package/lib/bootstrap.d.ts.map +1 -0
  83. package/lib/bootstrap.js +19 -0
  84. package/lib/bootstrap.js.map +1 -0
  85. package/lib/cjs/BarChart.js +38 -0
  86. package/lib/cjs/BarChartOptionsEditorSettings.js +108 -0
  87. package/lib/cjs/BarChartPanel.js +70 -0
  88. package/lib/cjs/bar-chart-model.js +51 -0
  89. package/lib/cjs/bootstrap.js +26 -0
  90. package/lib/cjs/env.d.js +14 -0
  91. package/lib/cjs/getPluginModule.js +27 -0
  92. package/lib/cjs/index-federation.js +55 -0
  93. package/lib/cjs/index.js +40 -0
  94. package/lib/cjs/setup-tests.js +19 -0
  95. package/lib/cjs/tresholds.js +65 -0
  96. package/lib/cjs/utils.js +72 -0
  97. package/lib/env.d.js +15 -0
  98. package/lib/env.d.js.map +1 -0
  99. package/lib/getPluginModule.d.ts +6 -0
  100. package/lib/getPluginModule.d.ts.map +1 -0
  101. package/lib/getPluginModule.js +16 -0
  102. package/lib/getPluginModule.js.map +1 -0
  103. package/lib/index-federation.d.ts +1 -0
  104. package/lib/index-federation.d.ts.map +1 -0
  105. package/lib/index-federation.js +15 -0
  106. package/lib/index-federation.js.map +1 -0
  107. package/lib/index.d.ts +6 -0
  108. package/lib/index.d.ts.map +1 -0
  109. package/lib/index.js +19 -0
  110. package/lib/index.js.map +1 -0
  111. package/lib/setup-tests.d.ts +2 -0
  112. package/lib/setup-tests.d.ts.map +1 -0
  113. package/lib/setup-tests.js +17 -0
  114. package/lib/setup-tests.js.map +1 -0
  115. package/lib/tresholds.d.ts +6 -0
  116. package/lib/tresholds.d.ts.map +1 -0
  117. package/lib/tresholds.js +44 -0
  118. package/lib/tresholds.js.map +1 -0
  119. package/lib/utils.d.ts +7 -0
  120. package/lib/utils.d.ts.map +1 -0
  121. package/lib/utils.js +56 -0
  122. package/lib/utils.js.map +1 -0
  123. package/mf-manifest.json +396 -0
  124. package/mf-stats.json +453 -0
  125. package/package.json +53 -0
@@ -0,0 +1,27 @@
1
+ import { ModeOption, SortOption } from '@perses-dev/components';
2
+ import { CalculationType, Definition, FormatOptions } from '@perses-dev/core';
3
+ import { OptionsEditorProps } from '@perses-dev/plugin-system';
4
+ export declare const DEFAULT_FORMAT: FormatOptions;
5
+ export declare const DEFAULT_SORT: SortOption;
6
+ export declare const DEFAULT_MODE: ModeOption;
7
+ /**
8
+ * The schema for a BarChart panel.
9
+ */
10
+ export interface BarChartDefinition extends Definition<BarChartOptions> {
11
+ kind: 'BarChart';
12
+ }
13
+ /**
14
+ * The Options object type supported by the BarChart panel plugin.
15
+ */
16
+ export interface BarChartOptions {
17
+ calculation: CalculationType;
18
+ format?: FormatOptions;
19
+ sort?: SortOption;
20
+ mode?: ModeOption;
21
+ }
22
+ export type BarChartOptionsEditorProps = OptionsEditorProps<BarChartOptions>;
23
+ /**
24
+ * Creates the initial/empty options for a BarChart panel.
25
+ */
26
+ export declare function createInitialBarChartOptions(): BarChartOptions;
27
+ //# sourceMappingURL=bar-chart-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bar-chart-model.d.ts","sourceRoot":"","sources":["../../src/bar-chart-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAuB,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,eAAO,MAAM,cAAc,EAAE,aAAsD,CAAC;AACpF,eAAO,MAAM,YAAY,EAAE,UAAmB,CAAC;AAC/C,eAAO,MAAM,YAAY,EAAE,UAAoB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,UAAU,CAAC,eAAe,CAAC;IACrE,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,eAAe,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,MAAM,0BAA0B,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;AAE7E;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,eAAe,CAO9D"}
@@ -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
+ import { DEFAULT_CALCULATION } from '@perses-dev/core';
14
+ export const DEFAULT_FORMAT = {
15
+ unit: 'decimal',
16
+ shortValues: true
17
+ };
18
+ export const DEFAULT_SORT = 'desc';
19
+ export const DEFAULT_MODE = 'value';
20
+ /**
21
+ * Creates the initial/empty options for a BarChart panel.
22
+ */ export function createInitialBarChartOptions() {
23
+ return {
24
+ calculation: DEFAULT_CALCULATION,
25
+ format: DEFAULT_FORMAT,
26
+ sort: DEFAULT_SORT,
27
+ mode: DEFAULT_MODE
28
+ };
29
+ }
30
+
31
+ //# sourceMappingURL=bar-chart-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bar-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 { ModeOption, SortOption } from '@perses-dev/components';\nimport { CalculationType, DEFAULT_CALCULATION, Definition, FormatOptions } from '@perses-dev/core';\nimport { OptionsEditorProps } from '@perses-dev/plugin-system';\n\nexport const DEFAULT_FORMAT: FormatOptions = { unit: 'decimal', shortValues: true };\nexport const DEFAULT_SORT: SortOption = 'desc';\nexport const DEFAULT_MODE: ModeOption = 'value';\n\n/**\n * The schema for a BarChart panel.\n */\nexport interface BarChartDefinition extends Definition<BarChartOptions> {\n kind: 'BarChart';\n}\n\n/**\n * The Options object type supported by the BarChart panel plugin.\n */\nexport interface BarChartOptions {\n calculation: CalculationType;\n format?: FormatOptions;\n sort?: SortOption;\n mode?: ModeOption;\n}\n\nexport type BarChartOptionsEditorProps = OptionsEditorProps<BarChartOptions>;\n\n/**\n * Creates the initial/empty options for a BarChart panel.\n */\nexport function createInitialBarChartOptions(): BarChartOptions {\n return {\n calculation: DEFAULT_CALCULATION,\n format: DEFAULT_FORMAT,\n sort: DEFAULT_SORT,\n mode: DEFAULT_MODE,\n };\n}\n"],"names":["DEFAULT_CALCULATION","DEFAULT_FORMAT","unit","shortValues","DEFAULT_SORT","DEFAULT_MODE","createInitialBarChartOptions","calculation","format","sort","mode"],"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,SAA0BA,mBAAmB,QAAmC,mBAAmB;AAGnG,OAAO,MAAMC,iBAAgC;IAAEC,MAAM;IAAWC,aAAa;AAAK,EAAE;AACpF,OAAO,MAAMC,eAA2B,OAAO;AAC/C,OAAO,MAAMC,eAA2B,QAAQ;AAqBhD;;CAEC,GACD,OAAO,SAASC;IACd,OAAO;QACLC,aAAaP;QACbQ,QAAQP;QACRQ,MAAML;QACNM,MAAML;IACR;AACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
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 { jsx as _jsx } from "react/jsx-runtime";
14
+ import React from 'react';
15
+ import ReactDOM from 'react-dom/client';
16
+ const root = ReactDOM.createRoot(document.getElementById('root'));
17
+ root.render(/*#__PURE__*/ _jsx(React.StrictMode, {}));
18
+
19
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bootstrap.tsx"],"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 React from 'react';\nimport ReactDOM from 'react-dom/client';\n\nconst root = ReactDOM.createRoot(document.getElementById('root')!);\nroot.render(<React.StrictMode></React.StrictMode>);\n"],"names":["React","ReactDOM","root","createRoot","document","getElementById","render","StrictMode"],"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,OAAOA,WAAW,QAAQ;AAC1B,OAAOC,cAAc,mBAAmB;AAExC,MAAMC,OAAOD,SAASE,UAAU,CAACC,SAASC,cAAc,CAAC;AACzDH,KAAKI,MAAM,eAAC,KAACN,MAAMO,UAAU"}
@@ -0,0 +1,38 @@
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, "BarChart", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return BarChart;
21
+ }
22
+ });
23
+ const _barchartmodel = require("./bar-chart-model");
24
+ const _BarChartOptionsEditorSettings = require("./BarChartOptionsEditorSettings");
25
+ const _BarChartPanel = require("./BarChartPanel");
26
+ const BarChart = {
27
+ PanelComponent: _BarChartPanel.BarChartPanel,
28
+ panelOptionsEditorComponents: [
29
+ {
30
+ label: 'Settings',
31
+ content: _BarChartOptionsEditorSettings.BarChartOptionsEditorSettings
32
+ }
33
+ ],
34
+ supportedQueryTypes: [
35
+ 'TimeSeriesQuery'
36
+ ],
37
+ createInitialOptions: _barchartmodel.createInitialBarChartOptions
38
+ };
@@ -0,0 +1,108 @@
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, "BarChartOptionsEditorSettings", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return BarChartOptionsEditorSettings;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _material = require("@mui/material");
25
+ const _components = require("@perses-dev/components");
26
+ const _core = require("@perses-dev/core");
27
+ const _pluginsystem = require("@perses-dev/plugin-system");
28
+ const _immer = require("immer");
29
+ const _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
30
+ const _barchartmodel = require("./bar-chart-model");
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ function BarChartOptionsEditorSettings(props) {
37
+ const { onChange, value } = props;
38
+ const handleCalculationChange = (newCalculation)=>{
39
+ onChange((0, _immer.produce)(value, (draft)=>{
40
+ draft.calculation = newCalculation;
41
+ }));
42
+ };
43
+ const handleUnitChange = (newFormat)=>{
44
+ onChange((0, _immer.produce)(value, (draft)=>{
45
+ draft.format = newFormat;
46
+ }));
47
+ };
48
+ const handleSortChange = (newSort)=>{
49
+ onChange((0, _immer.produce)(value, (draft)=>{
50
+ draft.sort = newSort;
51
+ }));
52
+ };
53
+ const handleModeChange = (newMode)=>{
54
+ onChange((0, _immer.produce)(value, (draft)=>{
55
+ draft.mode = newMode;
56
+ }));
57
+ };
58
+ const handleResetSettings = ()=>{
59
+ onChange((0, _immer.produce)(value, (draft)=>{
60
+ draft.calculation = _core.DEFAULT_CALCULATION;
61
+ draft.format = _barchartmodel.DEFAULT_FORMAT;
62
+ draft.sort = _barchartmodel.DEFAULT_SORT;
63
+ draft.mode = _barchartmodel.DEFAULT_MODE;
64
+ }));
65
+ };
66
+ // ensures decimalPlaces defaults to correct value
67
+ const format = (0, _merge.default)({}, _barchartmodel.DEFAULT_FORMAT, value.format);
68
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGrid, {
69
+ children: [
70
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
71
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
72
+ title: "Misc",
73
+ children: [
74
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormatControls, {
75
+ value: format,
76
+ onChange: handleUnitChange,
77
+ disabled: value.mode === 'percentage'
78
+ }),
79
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.CalculationSelector, {
80
+ value: value.calculation,
81
+ onChange: handleCalculationChange
82
+ }),
83
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SortSelector, {
84
+ value: value.sort,
85
+ onChange: handleSortChange
86
+ }),
87
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ModeSelector, {
88
+ value: value.mode,
89
+ onChange: handleModeChange,
90
+ disablePercentageMode: (0, _core.isPercentUnit)(format)
91
+ })
92
+ ]
93
+ })
94
+ }),
95
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
96
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorGroup, {
97
+ title: "Reset Settings",
98
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
99
+ variant: "outlined",
100
+ color: "secondary",
101
+ onClick: handleResetSettings,
102
+ children: "Reset To Defaults"
103
+ })
104
+ })
105
+ })
106
+ ]
107
+ });
108
+ }
@@ -0,0 +1,70 @@
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, "BarChartPanel", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return BarChartPanel;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _components = require("@perses-dev/components");
25
+ const _material = require("@mui/material");
26
+ const _react = require("react");
27
+ const _core = require("@perses-dev/core");
28
+ const _utils = require("./utils");
29
+ function BarChartPanel(props) {
30
+ const { spec: { calculation, format, sort, mode }, contentDimensions, queryResults } = props;
31
+ const chartsTheme = (0, _components.useChartsTheme)();
32
+ const PADDING = chartsTheme.container.padding.default;
33
+ const barChartData = (0, _react.useMemo)(()=>{
34
+ const calculate = _core.CalculationsMap[calculation];
35
+ const barChartData = [];
36
+ for (const result of queryResults){
37
+ for (const seriesData of result.data.series){
38
+ const series = {
39
+ value: calculate(seriesData.values) ?? null,
40
+ label: seriesData.formattedName ?? ''
41
+ };
42
+ barChartData.push(series);
43
+ }
44
+ }
45
+ const sortedBarChartData = (0, _utils.sortSeriesData)(barChartData, sort);
46
+ if (mode === 'percentage') {
47
+ return (0, _utils.calculatePercentages)(sortedBarChartData);
48
+ } else {
49
+ return sortedBarChartData;
50
+ }
51
+ }, [
52
+ queryResults,
53
+ sort,
54
+ mode,
55
+ calculation
56
+ ]);
57
+ if (contentDimensions === undefined) return null;
58
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
59
+ sx: {
60
+ padding: `${PADDING}px`
61
+ },
62
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.BarChart, {
63
+ width: contentDimensions.width - PADDING * 2,
64
+ height: contentDimensions.height - PADDING * 2,
65
+ data: barChartData,
66
+ format: format,
67
+ mode: mode
68
+ })
69
+ });
70
+ }
@@ -0,0 +1,51 @@
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
+ DEFAULT_FORMAT: function() {
25
+ return DEFAULT_FORMAT;
26
+ },
27
+ DEFAULT_MODE: function() {
28
+ return DEFAULT_MODE;
29
+ },
30
+ DEFAULT_SORT: function() {
31
+ return DEFAULT_SORT;
32
+ },
33
+ createInitialBarChartOptions: function() {
34
+ return createInitialBarChartOptions;
35
+ }
36
+ });
37
+ const _core = require("@perses-dev/core");
38
+ const DEFAULT_FORMAT = {
39
+ unit: 'decimal',
40
+ shortValues: true
41
+ };
42
+ const DEFAULT_SORT = 'desc';
43
+ const DEFAULT_MODE = 'value';
44
+ function createInitialBarChartOptions() {
45
+ return {
46
+ calculation: _core.DEFAULT_CALCULATION,
47
+ format: DEFAULT_FORMAT,
48
+ sort: DEFAULT_SORT,
49
+ mode: DEFAULT_MODE
50
+ };
51
+ }
@@ -0,0 +1,26 @@
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
+ const _jsxruntime = require("react/jsx-runtime");
18
+ const _react = /*#__PURE__*/ _interop_require_default(require("react"));
19
+ const _client = /*#__PURE__*/ _interop_require_default(require("react-dom/client"));
20
+ function _interop_require_default(obj) {
21
+ return obj && obj.__esModule ? obj : {
22
+ default: obj
23
+ };
24
+ }
25
+ const root = _client.default.createRoot(document.getElementById('root'));
26
+ root.render(/*#__PURE__*/ (0, _jsxruntime.jsx)(_react.default.StrictMode, {}));
@@ -0,0 +1,14 @@
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
+ "use strict";
@@ -0,0 +1,27 @@
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;
9
+ }
10
+ });
11
+ const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
12
+ function _interop_require_default(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ function getPluginModule() {
18
+ const { name, version, perses } = _packagejson.default;
19
+ return {
20
+ kind: 'PluginModule',
21
+ metadata: {
22
+ name,
23
+ version
24
+ },
25
+ spec: perses
26
+ };
27
+ }
@@ -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,40 @@
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, "getPluginModule", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return _getPluginModule.getPluginModule;
21
+ }
22
+ });
23
+ _export_star(require("./bar-chart-model"), exports);
24
+ _export_star(require("./BarChart"), exports);
25
+ _export_star(require("./BarChartOptionsEditorSettings"), exports);
26
+ const _getPluginModule = require("./getPluginModule");
27
+ _export_star(require("./utils"), exports);
28
+ function _export_star(from, to) {
29
+ Object.keys(from).forEach(function(k) {
30
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
31
+ Object.defineProperty(to, k, {
32
+ enumerable: true,
33
+ get: function() {
34
+ return from[k];
35
+ }
36
+ });
37
+ }
38
+ });
39
+ return from;
40
+ }
@@ -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,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ convertThresholds: function() {
13
+ return convertThresholds;
14
+ },
15
+ defaultThresholdInput: function() {
16
+ return defaultThresholdInput;
17
+ }
18
+ });
19
+ const _zip = /*#__PURE__*/ _interop_require_default(require("lodash/zip"));
20
+ function _interop_require_default(obj) {
21
+ return obj && obj.__esModule ? obj : {
22
+ default: obj
23
+ };
24
+ }
25
+ const defaultThresholdInput = {
26
+ steps: [
27
+ {
28
+ value: 0
29
+ }
30
+ ]
31
+ };
32
+ function convertThresholds(thresholds, unit, max, palette) {
33
+ const defaultThresholdColor = thresholds.defaultColor ?? palette.defaultColor;
34
+ const defaultThresholdSteps = [
35
+ [
36
+ 0,
37
+ defaultThresholdColor
38
+ ]
39
+ ];
40
+ if (thresholds.steps !== undefined) {
41
+ // https://echarts.apache.org/en/option.html#series-gauge.axisLine.lineStyle.color
42
+ // color segments must be decimal between 0 and 1
43
+ const segmentMax = 1;
44
+ const valuesArr = thresholds.steps.map((step)=>{
45
+ if (thresholds.mode === 'percent') {
46
+ return step.value / 100;
47
+ }
48
+ return step.value / max;
49
+ });
50
+ valuesArr.push(segmentMax);
51
+ const colorsArr = thresholds.steps.map((step, index)=>step.color ?? palette.palette[index]);
52
+ colorsArr.unshift(defaultThresholdColor);
53
+ const zippedArr = (0, _zip.default)(valuesArr, colorsArr);
54
+ return zippedArr.map((elem)=>{
55
+ const convertedValues = elem[0] ?? segmentMax;
56
+ const convertedColors = elem[1] ?? defaultThresholdColor;
57
+ return [
58
+ convertedValues,
59
+ convertedColors
60
+ ];
61
+ });
62
+ } else {
63
+ return defaultThresholdSteps;
64
+ }
65
+ }