@perses-dev/bar-chart-plugin 0.13.0 → 0.14.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/__mf/js/BarChart.777a5fe9.js +7 -0
  2. package/__mf/js/async/121.0dfa8a56.js +2 -0
  3. package/__mf/js/async/138.a47c7fc8.js +2 -0
  4. package/__mf/js/async/192.e523747d.js +1 -0
  5. package/__mf/js/async/235.5bb676bf.js +1 -0
  6. package/__mf/js/async/274.becf0c4e.js +2 -0
  7. package/__mf/js/async/319.a1a08706.js +1 -0
  8. package/__mf/js/async/356.4a2d6a5d.js +1 -0
  9. package/__mf/js/async/377.6b67c9b8.js +1 -0
  10. package/__mf/js/async/392.ce5748af.js +2 -0
  11. package/__mf/js/async/407.f9cff9c5.js +4 -0
  12. package/__mf/js/async/407.f9cff9c5.js.LICENSE.txt +9 -0
  13. package/__mf/js/async/435.4802f945.js +1 -0
  14. package/__mf/js/async/458.dd052408.js +1 -0
  15. package/__mf/js/async/470.6bd33fa1.js +2 -0
  16. package/__mf/js/async/496.46cf1305.js +1 -0
  17. package/__mf/js/async/587.e4d2ed78.js +1 -0
  18. package/__mf/js/async/588.ca7f0375.js +1 -0
  19. package/__mf/js/async/603.6e4d4c2a.js +1 -0
  20. package/__mf/js/async/616.6263efeb.js +1 -0
  21. package/__mf/js/async/71.5f1bab20.js +1 -0
  22. package/__mf/js/async/720.e068b3e4.js +101 -0
  23. package/__mf/js/async/77.d762eaa0.js +1 -0
  24. package/__mf/js/async/788.e72a42a8.js +43 -0
  25. package/__mf/js/async/{815.60db8972.js.LICENSE.txt → 788.e72a42a8.js.LICENSE.txt} +41 -1
  26. package/__mf/js/async/823.2a2b516e.js +10 -0
  27. package/__mf/js/async/854.49d186a1.js +1 -0
  28. package/__mf/js/async/873.9b3f6f36.js +1 -0
  29. package/__mf/js/async/934.04010fe7.js +2 -0
  30. package/__mf/js/async/941.88203ba1.js +2 -0
  31. package/__mf/js/async/963.36fb71d2.js +1 -0
  32. package/__mf/js/async/968.66f07975.js +1 -0
  33. package/__mf/js/async/977.b3f21ee5.js +1 -0
  34. package/__mf/js/async/978.d27fe59a.js +1 -0
  35. package/__mf/js/async/__federation_expose_BarChart.07c26459.js +1 -0
  36. package/__mf/js/async/lib-router.a4768e7d.js +2 -0
  37. package/__mf/js/main.e614feb4.js +7 -0
  38. package/lib/BarChart.d.ts +3 -3
  39. package/lib/BarChart.d.ts.map +1 -1
  40. package/lib/BarChart.js +4 -4
  41. package/lib/BarChart.js.map +1 -1
  42. package/lib/BarChartBase.d.ts +4 -2
  43. package/lib/BarChartBase.d.ts.map +1 -1
  44. package/lib/BarChartBase.js +34 -15
  45. package/lib/BarChartBase.js.map +1 -1
  46. package/lib/BarChartExportAction.d.ts +1 -1
  47. package/lib/BarChartExportAction.d.ts.map +1 -1
  48. package/lib/BarChartExportAction.js +5 -5
  49. package/lib/BarChartExportAction.js.map +1 -1
  50. package/lib/BarChartOptionsEditorSettings.d.ts +2 -2
  51. package/lib/BarChartOptionsEditorSettings.d.ts.map +1 -1
  52. package/lib/BarChartOptionsEditorSettings.js +87 -16
  53. package/lib/BarChartOptionsEditorSettings.js.map +1 -1
  54. package/lib/BarChartPanel.d.ts +4 -4
  55. package/lib/BarChartPanel.d.ts.map +1 -1
  56. package/lib/BarChartPanel.js +11 -10
  57. package/lib/BarChartPanel.js.map +1 -1
  58. package/lib/bar-chart-model.d.ts +18 -3
  59. package/lib/bar-chart-model.d.ts.map +1 -1
  60. package/lib/bar-chart-model.js +4 -2
  61. package/lib/bar-chart-model.js.map +1 -1
  62. package/lib/bootstrap.js +2 -2
  63. package/lib/getPluginModule.d.ts +1 -1
  64. package/lib/getPluginModule.d.ts.map +1 -1
  65. package/lib/getPluginModule.js +3 -1
  66. package/lib/getPluginModule.js.map +1 -1
  67. package/lib/index-federation.js +1 -1
  68. package/lib/index.js +5 -5
  69. package/lib/index.js.map +1 -1
  70. package/lib/setup-tests.d.ts +1 -1
  71. package/lib/setup-tests.d.ts.map +1 -1
  72. package/lib/setup-tests.js +2 -2
  73. package/lib/setup-tests.js.map +1 -1
  74. package/lib/tresholds.d.ts +1 -1
  75. package/lib/tresholds.d.ts.map +1 -1
  76. package/lib/tresholds.js +1 -1
  77. package/lib/tresholds.js.map +1 -1
  78. package/lib/utils.d.ts +8 -2
  79. package/lib/utils.d.ts.map +1 -1
  80. package/lib/utils.js +22 -3
  81. package/lib/utils.js.map +1 -1
  82. package/mf-manifest.json +40 -41
  83. package/mf-stats.json +40 -41
  84. package/package.json +10 -10
  85. package/__mf/js/BarChart.9e1e78c7.js +0 -7
  86. package/__mf/js/async/121.473596c1.js +0 -2
  87. package/__mf/js/async/177.3e3ea369.js +0 -1
  88. package/__mf/js/async/187.0c10a71e.js +0 -7
  89. package/__mf/js/async/187.0c10a71e.js.LICENSE.txt +0 -39
  90. package/__mf/js/async/192.d5754c56.js +0 -1
  91. package/__mf/js/async/235.b9e83b0f.js +0 -1
  92. package/__mf/js/async/274.3b869914.js +0 -2
  93. package/__mf/js/async/356.4b7b13a4.js +0 -1
  94. package/__mf/js/async/377.1e6cd99f.js +0 -1
  95. package/__mf/js/async/392.43a49d02.js +0 -2
  96. package/__mf/js/async/435.7b8a2474.js +0 -1
  97. package/__mf/js/async/458.e0bfe246.js +0 -1
  98. package/__mf/js/async/46.822ac417.js +0 -101
  99. package/__mf/js/async/470.bbaeb6f6.js +0 -2
  100. package/__mf/js/async/496.b1d86a71.js +0 -1
  101. package/__mf/js/async/546.966246a4.js +0 -24
  102. package/__mf/js/async/546.966246a4.js.LICENSE.txt +0 -19
  103. package/__mf/js/async/568.93423f6b.js +0 -1
  104. package/__mf/js/async/587.19607cd0.js +0 -1
  105. package/__mf/js/async/588.3e2e88e6.js +0 -1
  106. package/__mf/js/async/603.73790c72.js +0 -1
  107. package/__mf/js/async/616.673776b4.js +0 -1
  108. package/__mf/js/async/71.8dde0897.js +0 -1
  109. package/__mf/js/async/77.64992029.js +0 -1
  110. package/__mf/js/async/815.60db8972.js +0 -39
  111. package/__mf/js/async/823.55761759.js +0 -10
  112. package/__mf/js/async/854.8910fbf0.js +0 -1
  113. package/__mf/js/async/873.2961fe42.js +0 -1
  114. package/__mf/js/async/934.e8708047.js +0 -2
  115. package/__mf/js/async/941.b9c9bdfe.js +0 -2
  116. package/__mf/js/async/963.e557410b.js +0 -1
  117. package/__mf/js/async/968.0da0003e.js +0 -1
  118. package/__mf/js/async/977.4f77cf46.js +0 -1
  119. package/__mf/js/async/978.83c86840.js +0 -1
  120. package/__mf/js/async/__federation_expose_BarChart.cf3b83b6.js +0 -1
  121. package/__mf/js/async/lib-router.9c050a7f.js +0 -2
  122. package/__mf/js/main.8c45ef82.js +0 -7
  123. package/lib/cjs/BarChart.js +0 -45
  124. package/lib/cjs/BarChartBase.js +0 -232
  125. package/lib/cjs/BarChartExportAction.js +0 -124
  126. package/lib/cjs/BarChartOptionsEditorSettings.js +0 -180
  127. package/lib/cjs/BarChartPanel.js +0 -138
  128. package/lib/cjs/bar-chart-model.js +0 -66
  129. package/lib/cjs/bootstrap.js +0 -26
  130. package/lib/cjs/env.d.js +0 -14
  131. package/lib/cjs/getPluginModule.js +0 -39
  132. package/lib/cjs/index-federation.js +0 -55
  133. package/lib/cjs/index.js +0 -40
  134. package/lib/cjs/setup-tests.js +0 -19
  135. package/lib/cjs/tresholds.js +0 -77
  136. package/lib/cjs/utils.js +0 -72
  137. /package/__mf/css/async/{187.85c2cbf6.css → 788.85c2cbf6.css} +0 -0
  138. /package/__mf/js/async/{121.473596c1.js.LICENSE.txt → 121.0dfa8a56.js.LICENSE.txt} +0 -0
  139. /package/__mf/js/async/{274.3b869914.js.LICENSE.txt → 274.becf0c4e.js.LICENSE.txt} +0 -0
  140. /package/__mf/js/async/{392.43a49d02.js.LICENSE.txt → 392.ce5748af.js.LICENSE.txt} +0 -0
  141. /package/__mf/js/async/{470.bbaeb6f6.js.LICENSE.txt → 470.6bd33fa1.js.LICENSE.txt} +0 -0
  142. /package/__mf/js/async/{823.55761759.js.LICENSE.txt → 823.2a2b516e.js.LICENSE.txt} +0 -0
  143. /package/__mf/js/async/{934.e8708047.js.LICENSE.txt → 934.04010fe7.js.LICENSE.txt} +0 -0
  144. /package/__mf/js/async/{941.b9c9bdfe.js.LICENSE.txt → 941.88203ba1.js.LICENSE.txt} +0 -0
  145. /package/__mf/js/async/{lib-router.9c050a7f.js.LICENSE.txt → lib-router.a4768e7d.js.LICENSE.txt} +0 -0
@@ -1,124 +0,0 @@
1
- // Copyright 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, "BarChartExportAction", {
18
- enumerable: true,
19
- get: function() {
20
- return BarChartExportAction;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
25
- const _pluginsystem = require("@perses-dev/plugin-system");
26
- const _components = require("@perses-dev/components");
27
- const _material = require("@mui/material");
28
- const _Download = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Download"));
29
- function _interop_require_default(obj) {
30
- return obj && obj.__esModule ? obj : {
31
- default: obj
32
- };
33
- }
34
- function _getRequireWildcardCache(nodeInterop) {
35
- if (typeof WeakMap !== "function") return null;
36
- var cacheBabelInterop = new WeakMap();
37
- var cacheNodeInterop = new WeakMap();
38
- return (_getRequireWildcardCache = function(nodeInterop) {
39
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
40
- })(nodeInterop);
41
- }
42
- function _interop_require_wildcard(obj, nodeInterop) {
43
- if (!nodeInterop && obj && obj.__esModule) {
44
- return obj;
45
- }
46
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
47
- return {
48
- default: obj
49
- };
50
- }
51
- var cache = _getRequireWildcardCache(nodeInterop);
52
- if (cache && cache.has(obj)) {
53
- return cache.get(obj);
54
- }
55
- var newObj = {
56
- __proto__: null
57
- };
58
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
59
- for(var key in obj){
60
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
61
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
62
- if (desc && (desc.get || desc.set)) {
63
- Object.defineProperty(newObj, key, desc);
64
- } else {
65
- newObj[key] = obj[key];
66
- }
67
- }
68
- }
69
- newObj.default = obj;
70
- if (cache) {
71
- cache.set(obj, newObj);
72
- }
73
- return newObj;
74
- }
75
- const BarChartExportAction = ({ queryResults, definition })=>{
76
- const exportableData = (0, _react.useMemo)(()=>{
77
- return (0, _pluginsystem.extractExportableData)(queryResults);
78
- }, [
79
- queryResults
80
- ]);
81
- const canExport = (0, _react.useMemo)(()=>{
82
- return (0, _pluginsystem.isExportableData)(exportableData);
83
- }, [
84
- exportableData
85
- ]);
86
- const handleExport = (0, _react.useCallback)(()=>{
87
- if (!exportableData || !canExport) return;
88
- try {
89
- const title = definition?.spec?.display?.name || 'Time Series Data';
90
- const csvBlob = (0, _pluginsystem.exportDataAsCSV)({
91
- data: exportableData
92
- });
93
- const baseFilename = (0, _pluginsystem.sanitizeFilename)(title);
94
- const filename = `${baseFilename}_data.csv`;
95
- const link = document.createElement('a');
96
- link.href = URL.createObjectURL(csvBlob);
97
- link.download = filename;
98
- document.body.appendChild(link);
99
- link.click();
100
- document.body.removeChild(link);
101
- URL.revokeObjectURL(link.href);
102
- } catch (error) {
103
- console.error('Time series export failed:', error);
104
- }
105
- }, [
106
- exportableData,
107
- canExport,
108
- definition
109
- ]);
110
- if (!canExport) {
111
- return null;
112
- }
113
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
114
- description: "Export as CSV",
115
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
116
- size: "small",
117
- onClick: handleExport,
118
- "aria-label": "Export time series data as CSV",
119
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Download.default, {
120
- fontSize: "inherit"
121
- })
122
- })
123
- });
124
- };
@@ -1,180 +0,0 @@
1
- // Copyright 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 _react = require("react");
25
- const _material = require("@mui/material");
26
- const _components = require("@perses-dev/components");
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 _omit = /*#__PURE__*/ _interop_require_default(require("lodash/omit"));
31
- const _barchartmodel = require("./bar-chart-model");
32
- function _interop_require_default(obj) {
33
- return obj && obj.__esModule ? obj : {
34
- default: obj
35
- };
36
- }
37
- function BarChartOptionsEditorSettings(props) {
38
- const { onChange, value } = props;
39
- const handleCalculationChange = (newCalculation)=>{
40
- onChange((0, _immer.produce)(value, (draft)=>{
41
- draft.calculation = newCalculation;
42
- }));
43
- };
44
- const handleUnitChange = (newFormat)=>{
45
- onChange((0, _immer.produce)(value, (draft)=>{
46
- draft.format = newFormat;
47
- }));
48
- };
49
- const handleSortChange = (newSort)=>{
50
- onChange((0, _immer.produce)(value, (draft)=>{
51
- draft.sort = newSort;
52
- }));
53
- };
54
- const handleModeChange = (newMode)=>{
55
- onChange((0, _immer.produce)(value, (draft)=>{
56
- draft.mode = newMode;
57
- }));
58
- };
59
- const handleResetSettings = ()=>{
60
- onChange((0, _immer.produce)(value, (draft)=>{
61
- draft.calculation = _pluginsystem.DEFAULT_CALCULATION;
62
- draft.format = _barchartmodel.DEFAULT_FORMAT;
63
- draft.sort = _barchartmodel.DEFAULT_SORT;
64
- draft.mode = _barchartmodel.DEFAULT_MODE;
65
- draft.groupBy = _barchartmodel.DEFAULT_GROUP_BY;
66
- draft.isStacked = _barchartmodel.DEFAULT_IS_STACKED;
67
- draft.orientation = _barchartmodel.DEFAULT_ORIENTATION;
68
- }));
69
- };
70
- // ensures decimalPlaces defaults to correct value
71
- const format = (0, _merge.default)({}, !value.format || (0, _components.isUnitWithShortValues)(value.format) ? _barchartmodel.DEFAULT_FORMAT : (0, _omit.default)(_barchartmodel.DEFAULT_FORMAT, [
72
- 'shortValues'
73
- ]), value.format);
74
- const groupBy = value.groupBy ?? _barchartmodel.DEFAULT_GROUP_BY;
75
- const isStacked = value.isStacked ?? _barchartmodel.DEFAULT_IS_STACKED;
76
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGrid, {
77
- children: [
78
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorColumn, {
79
- children: [
80
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
81
- title: "Misc",
82
- children: [
83
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormatControls, {
84
- value: format,
85
- onChange: handleUnitChange,
86
- disabled: value.mode === 'percentage'
87
- }),
88
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.CalculationSelector, {
89
- value: value.calculation,
90
- onChange: handleCalculationChange
91
- }),
92
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SortSelector, {
93
- value: value.sort,
94
- onChange: handleSortChange
95
- }),
96
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ModeSelector, {
97
- value: value.mode,
98
- onChange: handleModeChange,
99
- disablePercentageMode: (0, _components.isPercentUnit)(format)
100
- }),
101
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.ToggleButtonGroup, {
102
- exclusive: true,
103
- size: "small",
104
- value: value.orientation ?? 'horizontal',
105
- onChange: (_, v)=>v && onChange((0, _immer.produce)(value, (draft)=>{
106
- draft.orientation = v;
107
- })),
108
- children: [
109
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButton, {
110
- value: "horizontal",
111
- children: "Horizontal"
112
- }),
113
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButton, {
114
- value: "vertical",
115
- children: "Vertical"
116
- })
117
- ]
118
- })
119
- ]
120
- }),
121
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
122
- title: "Stacking",
123
- children: [
124
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Autocomplete, {
125
- multiple: true,
126
- freeSolo: true,
127
- value: groupBy,
128
- onChange: (_, newValue)=>{
129
- const filtered = newValue.filter((v)=>v.trim() !== '');
130
- onChange((0, _immer.produce)(value, (draft)=>{
131
- draft.groupBy = filtered;
132
- if (filtered.length === 0) draft.isStacked = false;
133
- }));
134
- },
135
- options: [],
136
- renderTags: (tagValues, getTagProps)=>tagValues.map((option, index)=>/*#__PURE__*/ (0, _react.createElement)(_material.Chip, {
137
- size: "small",
138
- variant: "outlined",
139
- label: option,
140
- ...getTagProps({
141
- index
142
- }),
143
- key: option
144
- })),
145
- renderInput: (params)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
146
- ...params,
147
- size: "small",
148
- label: "Group By Labels",
149
- placeholder: "Type label name + Enter"
150
- })
151
- }),
152
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
153
- control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
154
- size: "small",
155
- checked: isStacked,
156
- disabled: groupBy.length === 0,
157
- onChange: (e)=>onChange((0, _immer.produce)(value, (draft)=>{
158
- draft.isStacked = e.target.checked;
159
- }))
160
- }),
161
- label: "Stack bars"
162
- })
163
- ]
164
- })
165
- ]
166
- }),
167
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
168
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorGroup, {
169
- title: "Reset Settings",
170
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
171
- variant: "outlined",
172
- color: "secondary",
173
- onClick: handleResetSettings,
174
- children: "Reset To Defaults"
175
- })
176
- })
177
- })
178
- ]
179
- });
180
- }
@@ -1,138 +0,0 @@
1
- // Copyright 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 _pluginsystem = require("@perses-dev/plugin-system");
28
- const _utils = require("./utils");
29
- const _BarChartBase = require("./BarChartBase");
30
- function BarChartPanel(props) {
31
- const { spec: { calculation, format, sort, mode, groupBy = [], isStacked = false, orientation = 'horizontal' }, contentDimensions, queryResults } = props;
32
- const chartsTheme = (0, _components.useChartsTheme)();
33
- const PADDING = chartsTheme.container.padding.default;
34
- const barChartData = (0, _react.useMemo)(()=>{
35
- if (groupBy.length > 0) return [];
36
- const calculate = _pluginsystem.CalculationsMap[calculation];
37
- const barChartData = [];
38
- for (const result of queryResults){
39
- for (const seriesData of result.data.series){
40
- const series = {
41
- value: calculate(seriesData.values) ?? null,
42
- label: seriesData.formattedName ?? ''
43
- };
44
- barChartData.push(series);
45
- }
46
- }
47
- const sortedBarChartData = (0, _utils.sortSeriesData)(barChartData, sort);
48
- if (mode === 'percentage') {
49
- return (0, _utils.calculatePercentages)(sortedBarChartData);
50
- } else {
51
- return sortedBarChartData;
52
- }
53
- }, [
54
- queryResults,
55
- sort,
56
- mode,
57
- calculation,
58
- groupBy
59
- ]);
60
- const stackedBarChartData = (0, _react.useMemo)(()=>{
61
- if (groupBy.length === 0) return null;
62
- const calculate = _pluginsystem.CalculationsMap[calculation];
63
- const groupMap = new Map();
64
- const segmentNamesOrdered = [];
65
- const segmentNamesSet = new Set();
66
- for (const queryResult of queryResults){
67
- for (const seriesData of queryResult.data.series){
68
- const labels = seriesData.labels ?? {};
69
- const groupKey = groupBy.map((k)=>labels[k] ?? '').join(' / ');
70
- const remainingEntries = Object.entries(labels).filter(([k])=>!groupBy.includes(k));
71
- const segmentName = remainingEntries.length > 0 ? '{' + remainingEntries.map(([k, v])=>`${k}="${v}"`).join(', ') + '}' : seriesData.formattedName ?? seriesData.name;
72
- if (!groupMap.has(groupKey)) {
73
- groupMap.set(groupKey, new Map());
74
- }
75
- const segMap = groupMap.get(groupKey);
76
- if (!segMap) continue;
77
- const value = calculate(seriesData.values) ?? 0;
78
- segMap.set(segmentName, (segMap.get(segmentName) ?? 0) + value);
79
- if (!segmentNamesSet.has(segmentName)) {
80
- segmentNamesSet.add(segmentName);
81
- segmentNamesOrdered.push(segmentName);
82
- }
83
- }
84
- }
85
- if (groupMap.size === 0) return null;
86
- const getTotalValue = (cat)=>Array.from(groupMap.get(cat)?.values() ?? []).reduce((a, b)=>a + b, 0);
87
- let categories = Array.from(groupMap.keys());
88
- if (sort === 'asc') {
89
- categories = categories.sort((a, b)=>getTotalValue(a) - getTotalValue(b));
90
- } else if (sort === 'desc') {
91
- categories = categories.sort((a, b)=>getTotalValue(b) - getTotalValue(a));
92
- }
93
- const series = segmentNamesOrdered.map((segName)=>{
94
- const values = categories.map((cat)=>{
95
- const rawVal = groupMap.get(cat)?.get(segName) ?? null;
96
- if (mode === 'percentage' && rawVal !== null) {
97
- const total = getTotalValue(cat);
98
- return total > 0 ? rawVal / total * 100 : 0;
99
- }
100
- return rawVal;
101
- });
102
- return {
103
- name: segName,
104
- values
105
- };
106
- });
107
- return {
108
- categories,
109
- series
110
- };
111
- }, [
112
- queryResults,
113
- groupBy,
114
- sort,
115
- mode,
116
- calculation
117
- ]);
118
- if (contentDimensions === undefined) return null;
119
- const effectiveFormat = mode === 'percentage' ? {
120
- unit: 'percent',
121
- decimalPlaces: format?.decimalPlaces
122
- } : format;
123
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
124
- sx: {
125
- padding: `${PADDING}px`
126
- },
127
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_BarChartBase.BarChartBase, {
128
- width: contentDimensions.width - PADDING * 2,
129
- height: contentDimensions.height - PADDING * 2,
130
- data: barChartData,
131
- format: groupBy.length > 0 ? effectiveFormat : format,
132
- mode: mode,
133
- groupedData: stackedBarChartData,
134
- isStacked: isStacked,
135
- orientation: orientation
136
- })
137
- });
138
- }
@@ -1,66 +0,0 @@
1
- // Copyright 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: Object.getOwnPropertyDescriptor(all, name).get
21
- });
22
- }
23
- _export(exports, {
24
- get DEFAULT_FORMAT () {
25
- return DEFAULT_FORMAT;
26
- },
27
- get DEFAULT_GROUP_BY () {
28
- return DEFAULT_GROUP_BY;
29
- },
30
- get DEFAULT_IS_STACKED () {
31
- return DEFAULT_IS_STACKED;
32
- },
33
- get DEFAULT_MODE () {
34
- return DEFAULT_MODE;
35
- },
36
- get DEFAULT_ORIENTATION () {
37
- return DEFAULT_ORIENTATION;
38
- },
39
- get DEFAULT_SORT () {
40
- return DEFAULT_SORT;
41
- },
42
- get createInitialBarChartOptions () {
43
- return createInitialBarChartOptions;
44
- }
45
- });
46
- const _pluginsystem = require("@perses-dev/plugin-system");
47
- const DEFAULT_FORMAT = {
48
- unit: 'decimal',
49
- shortValues: true
50
- };
51
- const DEFAULT_SORT = 'desc';
52
- const DEFAULT_MODE = 'value';
53
- const DEFAULT_ORIENTATION = 'horizontal';
54
- const DEFAULT_GROUP_BY = [];
55
- const DEFAULT_IS_STACKED = false;
56
- function createInitialBarChartOptions() {
57
- return {
58
- calculation: _pluginsystem.DEFAULT_CALCULATION,
59
- format: DEFAULT_FORMAT,
60
- sort: DEFAULT_SORT,
61
- mode: DEFAULT_MODE,
62
- orientation: DEFAULT_ORIENTATION,
63
- groupBy: DEFAULT_GROUP_BY,
64
- isStacked: DEFAULT_IS_STACKED
65
- };
66
- }
@@ -1,26 +0,0 @@
1
- // Copyright 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, {}));
package/lib/cjs/env.d.js DELETED
@@ -1,14 +0,0 @@
1
- // Copyright 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";
@@ -1,39 +0,0 @@
1
- // Copyright 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;
21
- }
22
- });
23
- const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
24
- function _interop_require_default(obj) {
25
- return obj && obj.__esModule ? obj : {
26
- default: obj
27
- };
28
- }
29
- function getPluginModule() {
30
- const { name, version, perses } = _packagejson.default;
31
- return {
32
- kind: 'PluginModule',
33
- metadata: {
34
- name,
35
- version
36
- },
37
- spec: perses
38
- };
39
- }
@@ -1,55 +0,0 @@
1
- "use strict";
2
- function _getRequireWildcardCache(nodeInterop) {
3
- if (typeof WeakMap !== "function") return null;
4
- var cacheBabelInterop = new WeakMap();
5
- var cacheNodeInterop = new WeakMap();
6
- return (_getRequireWildcardCache = function(nodeInterop) {
7
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
8
- })(nodeInterop);
9
- }
10
- function _interop_require_wildcard(obj, nodeInterop) {
11
- if (!nodeInterop && obj && obj.__esModule) {
12
- return obj;
13
- }
14
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
15
- return {
16
- default: obj
17
- };
18
- }
19
- var cache = _getRequireWildcardCache(nodeInterop);
20
- if (cache && cache.has(obj)) {
21
- return cache.get(obj);
22
- }
23
- var newObj = {
24
- __proto__: null
25
- };
26
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
27
- for(var key in obj){
28
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
29
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
30
- if (desc && (desc.get || desc.set)) {
31
- Object.defineProperty(newObj, key, desc);
32
- } else {
33
- newObj[key] = obj[key];
34
- }
35
- }
36
- }
37
- newObj.default = obj;
38
- if (cache) {
39
- cache.set(obj, newObj);
40
- }
41
- return newObj;
42
- }
43
- // Copyright The Perses Authors
44
- // Licensed under the Apache License, Version 2.0 (the "License");
45
- // you may not use this file except in compliance with the License.
46
- // You may obtain a copy of the License at
47
- //
48
- // http://www.apache.org/licenses/LICENSE-2.0
49
- //
50
- // Unless required by applicable law or agreed to in writing, software
51
- // distributed under the License is distributed on an "AS IS" BASIS,
52
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53
- // See the License for the specific language governing permissions and
54
- // limitations under the License.
55
- Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bootstrap")));