@perses-dev/flame-chart-plugin 0.2.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 (198) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +23 -0
  3. package/__mf/css/async/325.f56729ca.css +1 -0
  4. package/__mf/css/async/341.f56729ca.css +1 -0
  5. package/__mf/css/async/908.f56729ca.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/FlameChart.96aae761.js +5 -0
  19. package/__mf/js/async/109.f7e97e30.js +73 -0
  20. package/__mf/js/async/109.f7e97e30.js.LICENSE.txt +35 -0
  21. package/__mf/js/async/173.40a64c5c.js +2 -0
  22. package/__mf/js/async/173.40a64c5c.js.LICENSE.txt +19 -0
  23. package/__mf/js/async/214.f491540e.js +1 -0
  24. package/__mf/js/async/224.511d05b6.js +1 -0
  25. package/__mf/js/async/238.5fdc556e.js +1 -0
  26. package/__mf/js/async/29.8b55315e.js +1 -0
  27. package/__mf/js/async/292.643bbcde.js +1 -0
  28. package/__mf/js/async/32.a46fc45f.js +110 -0
  29. package/__mf/js/async/32.a46fc45f.js.LICENSE.txt +49 -0
  30. package/__mf/js/async/325.80031d25.js +1 -0
  31. package/__mf/js/async/362.c587718a.js +1 -0
  32. package/__mf/js/async/409.fd2d437e.js +1 -0
  33. package/__mf/js/async/464.bb266d9b.js +7 -0
  34. package/__mf/js/async/464.bb266d9b.js.LICENSE.txt +21 -0
  35. package/__mf/js/async/488.807096d6.js +1 -0
  36. package/__mf/js/async/600.fdf527b8.js +38 -0
  37. package/__mf/js/async/651.9eb6f201.js +1 -0
  38. package/__mf/js/async/69.a1079bc1.js +2 -0
  39. package/__mf/js/async/69.a1079bc1.js.LICENSE.txt +24 -0
  40. package/__mf/js/async/694.15848123.js +1 -0
  41. package/__mf/js/async/738.0b2ab393.js +1 -0
  42. package/__mf/js/async/740.65aa69e2.js +1 -0
  43. package/__mf/js/async/75.3435fe3f.js +1 -0
  44. package/__mf/js/async/770.bc6ab5a3.js +1 -0
  45. package/__mf/js/async/863.8b7bdf43.js +2 -0
  46. package/__mf/js/async/863.8b7bdf43.js.LICENSE.txt +9 -0
  47. package/__mf/js/async/908.0672909d.js +1 -0
  48. package/__mf/js/async/960.d56a397e.js +2 -0
  49. package/__mf/js/async/960.d56a397e.js.LICENSE.txt +8 -0
  50. package/__mf/js/async/964.86d91e52.js +2 -0
  51. package/__mf/js/async/964.86d91e52.js.LICENSE.txt +9 -0
  52. package/__mf/js/async/981.4de2d5c8.js +2 -0
  53. package/__mf/js/async/981.4de2d5c8.js.LICENSE.txt +8 -0
  54. package/__mf/js/async/__federation_expose_FlameChart.aaa6df30.js +17 -0
  55. package/__mf/js/async/lib-router.00804bbc.js +2 -0
  56. package/__mf/js/async/lib-router.00804bbc.js.LICENSE.txt +32 -0
  57. package/__mf/js/main.4931a266.js +5 -0
  58. package/lib/FlameChart.d.ts +8 -0
  59. package/lib/FlameChart.d.ts.map +1 -0
  60. package/lib/FlameChart.js +32 -0
  61. package/lib/FlameChart.js.map +1 -0
  62. package/lib/bootstrap.d.ts +2 -0
  63. package/lib/bootstrap.d.ts.map +1 -0
  64. package/lib/bootstrap.js +19 -0
  65. package/lib/bootstrap.js.map +1 -0
  66. package/lib/cjs/FlameChart.js +38 -0
  67. package/lib/cjs/bootstrap.js +26 -0
  68. package/lib/cjs/components/CustomBreadcrumb.js +96 -0
  69. package/lib/cjs/components/FlameChart.js +341 -0
  70. package/lib/cjs/components/FlameChartOptionsEditorSettings.js +87 -0
  71. package/lib/cjs/components/FlameChartPanel.js +147 -0
  72. package/lib/cjs/components/PaletteSelector.js +49 -0
  73. package/lib/cjs/components/SearchBar.js +59 -0
  74. package/lib/cjs/components/SeriesChart.js +189 -0
  75. package/lib/cjs/components/Settings.js +202 -0
  76. package/lib/cjs/components/SwitchSelector.js +37 -0
  77. package/lib/cjs/components/TableChart.js +143 -0
  78. package/lib/cjs/components/index.js +39 -0
  79. package/lib/cjs/env.d.js +14 -0
  80. package/lib/cjs/flame-chart-model.js +31 -0
  81. package/lib/cjs/getPluginModule.js +39 -0
  82. package/lib/cjs/index-federation.js +55 -0
  83. package/lib/cjs/index.js +37 -0
  84. package/lib/cjs/setup-tests.js +19 -0
  85. package/lib/cjs/utils/data-model.js +18 -0
  86. package/lib/cjs/utils/data-transform.js +152 -0
  87. package/lib/cjs/utils/format.js +87 -0
  88. package/lib/cjs/utils/palette-gen.js +68 -0
  89. package/lib/cjs/utils/palette.js +62 -0
  90. package/lib/cjs/utils/series-tooltip.js +51 -0
  91. package/lib/cjs/utils/tooltip.js +76 -0
  92. package/lib/cjs/utils/ui-text.js +30 -0
  93. package/lib/cjs/utils/utils.js +108 -0
  94. package/lib/components/CustomBreadcrumb.d.ts +9 -0
  95. package/lib/components/CustomBreadcrumb.d.ts.map +1 -0
  96. package/lib/components/CustomBreadcrumb.js +83 -0
  97. package/lib/components/CustomBreadcrumb.js.map +1 -0
  98. package/lib/components/FlameChart.d.ts +13 -0
  99. package/lib/components/FlameChart.d.ts.map +1 -0
  100. package/lib/components/FlameChart.js +328 -0
  101. package/lib/components/FlameChart.js.map +1 -0
  102. package/lib/components/FlameChartOptionsEditorSettings.d.ts +4 -0
  103. package/lib/components/FlameChartOptionsEditorSettings.d.ts.map +1 -0
  104. package/lib/components/FlameChartOptionsEditorSettings.js +79 -0
  105. package/lib/components/FlameChartOptionsEditorSettings.js.map +1 -0
  106. package/lib/components/FlameChartPanel.d.ts +7 -0
  107. package/lib/components/FlameChartPanel.d.ts.map +1 -0
  108. package/lib/components/FlameChartPanel.js +139 -0
  109. package/lib/components/FlameChartPanel.js.map +1 -0
  110. package/lib/components/PaletteSelector.d.ts +8 -0
  111. package/lib/components/PaletteSelector.d.ts.map +1 -0
  112. package/lib/components/PaletteSelector.js +41 -0
  113. package/lib/components/PaletteSelector.js.map +1 -0
  114. package/lib/components/SearchBar.d.ts +7 -0
  115. package/lib/components/SearchBar.d.ts.map +1 -0
  116. package/lib/components/SearchBar.js +46 -0
  117. package/lib/components/SearchBar.js.map +1 -0
  118. package/lib/components/SeriesChart.d.ts +9 -0
  119. package/lib/components/SeriesChart.d.ts.map +1 -0
  120. package/lib/components/SeriesChart.js +181 -0
  121. package/lib/components/SeriesChart.js.map +1 -0
  122. package/lib/components/Settings.d.ts +11 -0
  123. package/lib/components/Settings.d.ts.map +1 -0
  124. package/lib/components/Settings.js +189 -0
  125. package/lib/components/Settings.js.map +1 -0
  126. package/lib/components/SwitchSelector.d.ts +8 -0
  127. package/lib/components/SwitchSelector.d.ts.map +1 -0
  128. package/lib/components/SwitchSelector.js +29 -0
  129. package/lib/components/SwitchSelector.js.map +1 -0
  130. package/lib/components/TableChart.d.ts +12 -0
  131. package/lib/components/TableChart.d.ts.map +1 -0
  132. package/lib/components/TableChart.js +135 -0
  133. package/lib/components/TableChart.js.map +1 -0
  134. package/lib/components/index.d.ts +11 -0
  135. package/lib/components/index.d.ts.map +1 -0
  136. package/lib/components/index.js +24 -0
  137. package/lib/components/index.js.map +1 -0
  138. package/lib/env.d.js +15 -0
  139. package/lib/env.d.js.map +1 -0
  140. package/lib/flame-chart-model.d.ts +18 -0
  141. package/lib/flame-chart-model.d.ts.map +1 -0
  142. package/lib/flame-chart-model.js +23 -0
  143. package/lib/flame-chart-model.js.map +1 -0
  144. package/lib/getPluginModule.d.ts +6 -0
  145. package/lib/getPluginModule.d.ts.map +1 -0
  146. package/lib/getPluginModule.js +28 -0
  147. package/lib/getPluginModule.js.map +1 -0
  148. package/lib/index-federation.d.ts +1 -0
  149. package/lib/index-federation.d.ts.map +1 -0
  150. package/lib/index-federation.js +15 -0
  151. package/lib/index-federation.js.map +1 -0
  152. package/lib/index.d.ts +3 -0
  153. package/lib/index.d.ts.map +1 -0
  154. package/lib/index.js +16 -0
  155. package/lib/index.js.map +1 -0
  156. package/lib/setup-tests.d.ts +2 -0
  157. package/lib/setup-tests.d.ts.map +1 -0
  158. package/lib/setup-tests.js +17 -0
  159. package/lib/setup-tests.js.map +1 -0
  160. package/lib/utils/data-model.d.ts +37 -0
  161. package/lib/utils/data-model.d.ts.map +1 -0
  162. package/lib/utils/data-model.js +19 -0
  163. package/lib/utils/data-model.js.map +1 -0
  164. package/lib/utils/data-transform.d.ts +19 -0
  165. package/lib/utils/data-transform.d.ts.map +1 -0
  166. package/lib/utils/data-transform.js +138 -0
  167. package/lib/utils/data-transform.js.map +1 -0
  168. package/lib/utils/format.d.ts +3 -0
  169. package/lib/utils/format.d.ts.map +1 -0
  170. package/lib/utils/format.js +71 -0
  171. package/lib/utils/format.js.map +1 -0
  172. package/lib/utils/palette-gen.d.ts +14 -0
  173. package/lib/utils/palette-gen.d.ts.map +1 -0
  174. package/lib/utils/palette-gen.js +56 -0
  175. package/lib/utils/palette-gen.js.map +1 -0
  176. package/lib/utils/palette.d.ts +5 -0
  177. package/lib/utils/palette.d.ts.map +1 -0
  178. package/lib/utils/palette.js +51 -0
  179. package/lib/utils/palette.js.map +1 -0
  180. package/lib/utils/series-tooltip.d.ts +3 -0
  181. package/lib/utils/series-tooltip.d.ts.map +1 -0
  182. package/lib/utils/series-tooltip.js +43 -0
  183. package/lib/utils/series-tooltip.js.map +1 -0
  184. package/lib/utils/tooltip.d.ts +6 -0
  185. package/lib/utils/tooltip.d.ts.map +1 -0
  186. package/lib/utils/tooltip.js +29 -0
  187. package/lib/utils/tooltip.js.map +1 -0
  188. package/lib/utils/ui-text.d.ts +9 -0
  189. package/lib/utils/ui-text.d.ts.map +1 -0
  190. package/lib/utils/ui-text.js +22 -0
  191. package/lib/utils/ui-text.js.map +1 -0
  192. package/lib/utils/utils.d.ts +36 -0
  193. package/lib/utils/utils.d.ts.map +1 -0
  194. package/lib/utils/utils.js +92 -0
  195. package/lib/utils/utils.js.map +1 -0
  196. package/mf-manifest.json +274 -0
  197. package/mf-stats.json +322 -0
  198. package/package.json +64 -0
@@ -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, "FlameChart", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return FlameChart;
21
+ }
22
+ });
23
+ const _flamechartmodel = require("./flame-chart-model");
24
+ const _FlameChartOptionsEditorSettings = require("./components/FlameChartOptionsEditorSettings");
25
+ const _FlameChartPanel = require("./components/FlameChartPanel");
26
+ const FlameChart = {
27
+ PanelComponent: _FlameChartPanel.FlameChartPanel,
28
+ supportedQueryTypes: [
29
+ 'ProfileQuery'
30
+ ],
31
+ panelOptionsEditorComponents: [
32
+ {
33
+ label: 'Settings',
34
+ content: _FlameChartOptionsEditorSettings.FlameChartOptionsEditorSettings
35
+ }
36
+ ],
37
+ createInitialOptions: _flamechartmodel.createInitialFlameChartOptions
38
+ };
@@ -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,96 @@
1
+ // Copyright 2025 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, "CustomBreadcrumb", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return CustomBreadcrumb;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _material = require("@mui/material");
25
+ const _ChevronRight = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ChevronRight"));
26
+ const _EyeOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/EyeOutline"));
27
+ const _Close = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Close"));
28
+ const _Chip = /*#__PURE__*/ _interop_require_default(require("@mui/material/Chip"));
29
+ const _styles = require("@mui/material/styles");
30
+ const _core = require("@perses-dev/core");
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ const StyledBreadcrumb = (0, _styles.styled)(_Chip.default)(({ theme })=>{
37
+ const backgroundColor = theme.palette.mode === 'light' ? theme.palette.grey[100] : theme.palette.grey[800];
38
+ return {
39
+ backgroundColor,
40
+ height: theme.spacing(3),
41
+ color: theme.palette.text.primary,
42
+ fontWeight: theme.typography.fontWeightRegular,
43
+ '&:hover, &:focus': {
44
+ backgroundColor: (0, _styles.emphasize)(backgroundColor, 0.06)
45
+ },
46
+ '&:active': {
47
+ boxShadow: theme.shadows[1],
48
+ backgroundColor: (0, _styles.emphasize)(backgroundColor, 0.12)
49
+ }
50
+ };
51
+ });
52
+ function CustomBreadcrumb(props) {
53
+ const { totalValue, totalSample, otherItemSample, onSelectedIdChange } = props;
54
+ const handleClick = (event)=>{
55
+ event.preventDefault();
56
+ onSelectedIdChange(0);
57
+ };
58
+ const splitedValue = totalValue.split('(');
59
+ const totalValueText = splitedValue[splitedValue.length - 1]?.slice(0, -1);
60
+ const totalLabel = (0, _core.formatValue)(totalSample, {
61
+ unit: 'decimal',
62
+ decimalPlaces: 2,
63
+ shortValues: true
64
+ }) + ' samples';
65
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
66
+ direction: "row",
67
+ spacing: 1,
68
+ minHeight: 40,
69
+ alignItems: "center",
70
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Breadcrumbs, {
71
+ separator: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChevronRight.default, {
72
+ fontSize: "small"
73
+ }),
74
+ "aria-label": "breadcrumb",
75
+ sx: {
76
+ justifyContent: 'center'
77
+ },
78
+ children: [
79
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(StyledBreadcrumb, {
80
+ label: totalValueText + ' | ' + totalLabel
81
+ }),
82
+ otherItemSample !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsx)(StyledBreadcrumb, {
83
+ label: (otherItemSample / totalSample * 100).toFixed(2) + '% of total',
84
+ icon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_EyeOutline.default, {
85
+ fontSize: "small",
86
+ color: "secondary"
87
+ }),
88
+ deleteIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Close.default, {
89
+ fontSize: "small"
90
+ }),
91
+ onDelete: handleClick
92
+ })
93
+ ]
94
+ })
95
+ });
96
+ }
@@ -0,0 +1,341 @@
1
+ // Copyright 2025 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, "FlameChart", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return FlameChart;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _material = require("@mui/material");
25
+ const _react = require("react");
26
+ const _components = require("@perses-dev/components");
27
+ const _Refresh = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Refresh"));
28
+ const _EyeOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/EyeOutline"));
29
+ const _ContentCopy = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ContentCopy"));
30
+ const _datatransform = require("../utils/data-transform");
31
+ const _tooltip = require("../utils/tooltip");
32
+ const _CustomBreadcrumb = require("./CustomBreadcrumb");
33
+ function _interop_require_default(obj) {
34
+ return obj && obj.__esModule ? obj : {
35
+ default: obj
36
+ };
37
+ }
38
+ const ITEM_GAP = 2; // vertical gap between flame chart items
39
+ const Y_MIN_SMALL = 6; // min value of y axis for small containers
40
+ const Y_MIN_LARGE = 20; // min value of y axis for large containers
41
+ const LARGE_CONTAINER_THRESHOLD = 600;
42
+ const CONTAINER_PADDING = 10;
43
+ const BREADCRUMB_SPACE = 50;
44
+ function FlameChart(props) {
45
+ const { width, height, data, palette, selectedId, searchValue, onSelectedIdChange } = props;
46
+ const theme = (0, _material.useTheme)();
47
+ const chartsTheme = (0, _components.useChartsTheme)();
48
+ const [menuPosition, setMenuPosition] = (0, _react.useState)(null);
49
+ const [selectedItem, setSelectedItem] = (0, _react.useState)({
50
+ id: 0,
51
+ name: ''
52
+ });
53
+ const [isCopied, setIsCopied] = (0, _react.useState)(false);
54
+ const seriesData = (0, _react.useMemo)(()=>(0, _datatransform.recursionJson)(palette, data.metadata, data.profile.stackTrace, searchValue, selectedId), [
55
+ palette,
56
+ data.metadata,
57
+ data.profile.stackTrace,
58
+ selectedId,
59
+ searchValue
60
+ ]);
61
+ const handleItemClick = (params)=>{
62
+ const data = params.data;
63
+ const functionName = data.value[6];
64
+ const functionId = data.name;
65
+ setSelectedItem({
66
+ id: functionId,
67
+ name: functionName
68
+ });
69
+ // To ensure that the cursor is positioned inside the menu when it opens,
70
+ // we adjust the click event coordinates as follows:
71
+ if ('event' in params) {
72
+ const mouseEvent = params.event;
73
+ setMenuPosition({
74
+ mouseX: mouseEvent.event.clientX - 2,
75
+ mouseY: mouseEvent.event.clientY - 4
76
+ });
77
+ }
78
+ };
79
+ const handleFocusBlock = ()=>{
80
+ onSelectedIdChange(selectedItem.id);
81
+ handleClose();
82
+ };
83
+ const handleCopyFunctionName = ()=>{
84
+ if ((selectedId || selectedId === 0) && selectedItem.name) {
85
+ navigator.clipboard.writeText(selectedItem.name);
86
+ }
87
+ setIsCopied(true);
88
+ };
89
+ const handleResetGraph = ()=>{
90
+ if (selectedId) {
91
+ onSelectedIdChange(0);
92
+ }
93
+ handleClose();
94
+ };
95
+ const handleClose = ()=>{
96
+ setMenuPosition(null);
97
+ if (isCopied) setIsCopied(false);
98
+ };
99
+ const renderItem = (params, api)=>{
100
+ const level = api.value(0);
101
+ const start = api.coord([
102
+ api.value(1),
103
+ level
104
+ ]);
105
+ const end = api.coord([
106
+ api.value(2),
107
+ level
108
+ ]);
109
+ const height = (api.size && api.size([
110
+ 0,
111
+ 1
112
+ ]) || [
113
+ 0,
114
+ 20
115
+ ])[1];
116
+ const width = (end?.[0] ?? 0) - (start?.[0] ?? 0);
117
+ return {
118
+ type: 'rect',
119
+ transition: [
120
+ 'shape'
121
+ ],
122
+ shape: {
123
+ x: start?.[0],
124
+ y: (start?.[1] ?? 0) - (height ?? 0) / 2,
125
+ width,
126
+ height: (height ?? ITEM_GAP) - ITEM_GAP,
127
+ r: 0
128
+ },
129
+ style: {
130
+ fill: api.visual('color')
131
+ },
132
+ emphasis: {
133
+ style: {
134
+ stroke: '#000'
135
+ }
136
+ },
137
+ textConfig: {
138
+ position: 'insideLeft'
139
+ },
140
+ textContent: {
141
+ style: {
142
+ text: api.value(3),
143
+ fill: '#000',
144
+ width: width - 4,
145
+ overflow: 'truncate',
146
+ ellipsis: '..',
147
+ truncateMinChar: 1
148
+ },
149
+ emphasis: {
150
+ style: {
151
+ stroke: '#000',
152
+ lineWidth: 0.5
153
+ }
154
+ }
155
+ }
156
+ };
157
+ };
158
+ const option = (0, _react.useMemo)(()=>{
159
+ if (data.profile.stackTrace === undefined) return chartsTheme.noDataOption;
160
+ const maxDepth = Math.max(...seriesData.map((s)=>s.value[0])); // maximum depth of the stack trace
161
+ const yAxisMax = Math.max(height > LARGE_CONTAINER_THRESHOLD ? Y_MIN_LARGE : Y_MIN_SMALL, maxDepth);
162
+ const totalStart = seriesData[0]?.value[1]; // start value of the total function
163
+ const totalEnd = seriesData[0]?.value[2]; // end value of the total function
164
+ const xAxisMin = totalStart;
165
+ const xAxisMax = totalEnd;
166
+ // compute flame chart padding top and bottom
167
+ const padding = (height / (yAxisMax - 1) - ITEM_GAP) / 2 + 1;
168
+ const option = {
169
+ tooltip: {
170
+ appendToBody: true,
171
+ confine: true,
172
+ formatter: (params)=>(0, _tooltip.generateTooltip)(params, data.metadata?.units),
173
+ backgroundColor: theme.palette.background.paper,
174
+ borderColor: theme.palette.background.paper,
175
+ textStyle: {
176
+ color: theme.palette.text.primary
177
+ }
178
+ },
179
+ xAxis: {
180
+ show: false,
181
+ min: xAxisMin,
182
+ max: xAxisMax,
183
+ axisLabel: {
184
+ show: false
185
+ }
186
+ },
187
+ yAxis: {
188
+ show: false,
189
+ max: yAxisMax,
190
+ inverse: true,
191
+ axisLabel: {
192
+ show: false
193
+ }
194
+ },
195
+ axisLabel: {
196
+ overflow: 'truncate',
197
+ width: width / 3
198
+ },
199
+ grid: {
200
+ left: 5,
201
+ right: 5,
202
+ top: padding + 5,
203
+ bottom: padding
204
+ },
205
+ series: [
206
+ {
207
+ type: 'custom',
208
+ renderItem,
209
+ encode: {
210
+ x: [
211
+ 0,
212
+ 1,
213
+ 2
214
+ ],
215
+ y: 0
216
+ },
217
+ data: seriesData
218
+ }
219
+ ]
220
+ };
221
+ return option;
222
+ }, [
223
+ data,
224
+ chartsTheme,
225
+ theme,
226
+ width,
227
+ seriesData,
228
+ height
229
+ ]);
230
+ // Use useMemo to memoize the flame chart component and prevent unnecessary re-renders.
231
+ // This ensures the chart does not re-render when the onClick event updates state variables
232
+ // like menuPosition or selectedId.
233
+ const flameChart = (0, _react.useMemo)(()=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.EChart, {
234
+ sx: {
235
+ width: width,
236
+ height: height - 2 * CONTAINER_PADDING - BREADCRUMB_SPACE
237
+ },
238
+ option: option,
239
+ theme: chartsTheme.echartsTheme,
240
+ onEvents: {
241
+ click: handleItemClick
242
+ }
243
+ }), [
244
+ chartsTheme.echartsTheme,
245
+ height,
246
+ option,
247
+ width
248
+ ]);
249
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
250
+ style: {
251
+ width: width,
252
+ height: height
253
+ },
254
+ alignItems: "center",
255
+ children: [
256
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_CustomBreadcrumb.CustomBreadcrumb, {
257
+ totalValue: seriesData[0]?.value[3] || '',
258
+ totalSample: seriesData[0]?.value[8] || 0,
259
+ otherItemSample: (0, _datatransform.findTotalSampleByName)(seriesData, selectedId),
260
+ onSelectedIdChange: onSelectedIdChange
261
+ }),
262
+ flameChart,
263
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Menu, {
264
+ sx: {
265
+ '& .MuiPaper-root': {
266
+ backgroundColor: theme.palette.background.paper,
267
+ color: theme.palette.text.primary,
268
+ padding: '5px',
269
+ paddingBottom: '0px'
270
+ },
271
+ '& .MuiMenuItem-root': {
272
+ '&:hover': {
273
+ backgroundColor: theme.palette.action.hover
274
+ }
275
+ }
276
+ },
277
+ open: menuPosition !== null,
278
+ onClose: handleClose,
279
+ anchorReference: "anchorPosition",
280
+ anchorPosition: menuPosition !== null ? {
281
+ top: menuPosition.mouseY,
282
+ left: menuPosition.mouseX
283
+ } : undefined,
284
+ children: [
285
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
286
+ sx: {
287
+ paddingLeft: '16px',
288
+ paddingBottom: '8px'
289
+ },
290
+ children: selectedItem.name
291
+ }),
292
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {
293
+ sx: {
294
+ backgroundColor: theme.palette.divider
295
+ }
296
+ }),
297
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.MenuItem, {
298
+ onClick: handleFocusBlock,
299
+ children: [
300
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_EyeOutline.default, {
301
+ fontSize: "small",
302
+ color: "secondary",
303
+ sx: {
304
+ marginRight: '10px'
305
+ }
306
+ }),
307
+ "Focus block"
308
+ ]
309
+ }),
310
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.MenuItem, {
311
+ onClick: handleCopyFunctionName,
312
+ disabled: isCopied,
313
+ children: [
314
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_ContentCopy.default, {
315
+ fontSize: "small",
316
+ color: "secondary",
317
+ sx: {
318
+ marginRight: '10px'
319
+ }
320
+ }),
321
+ isCopied ? 'Copied' : 'Copy function name'
322
+ ]
323
+ }),
324
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.MenuItem, {
325
+ onClick: handleResetGraph,
326
+ children: [
327
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_Refresh.default, {
328
+ fontSize: "small",
329
+ color: "secondary",
330
+ sx: {
331
+ marginRight: '10px'
332
+ }
333
+ }),
334
+ "Reset graph"
335
+ ]
336
+ })
337
+ ]
338
+ })
339
+ ]
340
+ });
341
+ }
@@ -0,0 +1,87 @@
1
+ // Copyright 2025 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, "FlameChartOptionsEditorSettings", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return FlameChartOptionsEditorSettings;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _components = require("@perses-dev/components");
25
+ const _material = require("@mui/material");
26
+ const _utils = require("../utils/utils");
27
+ const _PaletteSelector = require("./PaletteSelector");
28
+ const _SwitchSelector = require("./SwitchSelector");
29
+ function FlameChartOptionsEditorSettings(props) {
30
+ const { value } = props;
31
+ const { handlePaletteChange } = (0, _utils.usePaletteState)(props);
32
+ const { handleShowSettingsChange } = (0, _utils.useShowSettingsState)(props);
33
+ const { handleShowSeriesChange } = (0, _utils.useShowSeriesState)(props);
34
+ const { handleShowTableChange } = (0, _utils.useShowTableState)(props);
35
+ const { handleShowFlameGraphChange } = (0, _utils.useShowFlameGraphState)(props);
36
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGrid, {
37
+ children: [
38
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
39
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorGroup, {
40
+ title: "Misc",
41
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PaletteSelector.PaletteSelector, {
42
+ value: value.palette,
43
+ onChange: handlePaletteChange
44
+ })
45
+ })
46
+ }),
47
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
48
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
49
+ title: "Panels to display",
50
+ children: [
51
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_SwitchSelector.SwitchSelector, {
52
+ label: "Show Options",
53
+ value: value.showSettings,
54
+ onChange: handleShowSettingsChange
55
+ }),
56
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_SwitchSelector.SwitchSelector, {
57
+ label: "Show Series",
58
+ value: value.showSeries,
59
+ onChange: handleShowSeriesChange
60
+ }),
61
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_SwitchSelector.SwitchSelector, {
62
+ label: "Show Table",
63
+ value: value.showTable,
64
+ onChange: handleShowTableChange
65
+ }),
66
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_SwitchSelector.SwitchSelector, {
67
+ label: "Show Flame Graph",
68
+ value: value.showFlameGraph,
69
+ onChange: handleShowFlameGraphChange
70
+ })
71
+ ]
72
+ })
73
+ }),
74
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
75
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorGroup, {
76
+ title: "Reset Settings",
77
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
78
+ variant: "outlined",
79
+ color: "secondary",
80
+ onClick: ()=>(0, _utils.resetSettings)(props),
81
+ children: "Reset To Defaults"
82
+ })
83
+ })
84
+ })
85
+ ]
86
+ });
87
+ }