@perses-dev/flame-chart-plugin 0.6.0 → 0.7.0-beta.1

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 (180) hide show
  1. package/__mf/js/{FlameChart.8940202b.js → FlameChart.75e60eeb.js} +7 -7
  2. package/__mf/js/async/121.b114caf4.js +2 -0
  3. package/__mf/js/async/168.6611ee4e.js +1 -0
  4. package/__mf/js/async/183.92eba0e3.js +2 -0
  5. package/__mf/js/async/192.8ce3d05c.js +1 -0
  6. package/__mf/js/async/2.9b63234c.js +1 -0
  7. package/__mf/js/async/235.b209897c.js +1 -0
  8. package/__mf/js/async/274.e53c6dc1.js +2 -0
  9. package/__mf/js/async/354.12841635.js +4 -0
  10. package/__mf/js/async/354.12841635.js.LICENSE.txt +9 -0
  11. package/__mf/js/async/356.8389aa5c.js +1 -0
  12. package/__mf/js/async/392.800bb82c.js +2 -0
  13. package/__mf/js/async/40.8889cead.js +43 -0
  14. package/__mf/js/async/{657.9473a80f.js.LICENSE.txt → 40.8889cead.js.LICENSE.txt} +41 -1
  15. package/__mf/js/async/43.71599a15.js +2 -0
  16. package/__mf/js/async/464.b8482365.js +1 -0
  17. package/__mf/js/async/470.1af0a163.js +2 -0
  18. package/__mf/js/async/587.2887e89e.js +1 -0
  19. package/__mf/js/async/616.d35b2918.js +1 -0
  20. package/__mf/js/async/663.d6e01d16.js +1 -0
  21. package/__mf/js/async/787.a8f426c4.js +1 -0
  22. package/__mf/js/async/802.f2161316.js +110 -0
  23. package/__mf/js/async/867.d3758c62.js +1 -0
  24. package/__mf/js/async/873.fd0c9e57.js +1 -0
  25. package/__mf/js/async/941.e44ab19f.js +2 -0
  26. package/__mf/js/async/968.5e8d690f.js +1 -0
  27. package/__mf/js/async/__federation_expose_FlameChart.668f250d.js +17 -0
  28. package/__mf/js/async/lib-router.d7bf8c32.js +2 -0
  29. package/__mf/js/{main.08e04feb.js → main.0d13937b.js} +3 -3
  30. package/lib/FlameChart.d.ts +3 -3
  31. package/lib/FlameChart.d.ts.map +1 -1
  32. package/lib/FlameChart.js +2 -2
  33. package/lib/FlameChart.js.map +1 -1
  34. package/lib/bootstrap.js +2 -2
  35. package/lib/components/CustomBreadcrumb.d.ts +1 -1
  36. package/lib/components/CustomBreadcrumb.d.ts.map +1 -1
  37. package/lib/components/CustomBreadcrumb.js +8 -8
  38. package/lib/components/CustomBreadcrumb.js.map +1 -1
  39. package/lib/components/FlameChart.d.ts +2 -2
  40. package/lib/components/FlameChart.d.ts.map +1 -1
  41. package/lib/components/FlameChart.js +10 -10
  42. package/lib/components/FlameChart.js.map +1 -1
  43. package/lib/components/FlameChartOptionsEditorSettings.d.ts +2 -2
  44. package/lib/components/FlameChartOptionsEditorSettings.d.ts.map +1 -1
  45. package/lib/components/FlameChartOptionsEditorSettings.js +6 -6
  46. package/lib/components/FlameChartOptionsEditorSettings.js.map +1 -1
  47. package/lib/components/FlameChartPanel.d.ts +4 -4
  48. package/lib/components/FlameChartPanel.d.ts.map +1 -1
  49. package/lib/components/FlameChartPanel.js +88 -71
  50. package/lib/components/FlameChartPanel.js.map +1 -1
  51. package/lib/components/PaletteSelector.d.ts +1 -1
  52. package/lib/components/PaletteSelector.d.ts.map +1 -1
  53. package/lib/components/PaletteSelector.js +2 -2
  54. package/lib/components/PaletteSelector.js.map +1 -1
  55. package/lib/components/SearchBar.d.ts +1 -1
  56. package/lib/components/SearchBar.d.ts.map +1 -1
  57. package/lib/components/SearchBar.js +3 -3
  58. package/lib/components/SearchBar.js.map +1 -1
  59. package/lib/components/SeriesChart.d.ts +2 -2
  60. package/lib/components/SeriesChart.d.ts.map +1 -1
  61. package/lib/components/SeriesChart.js +6 -6
  62. package/lib/components/SeriesChart.js.map +1 -1
  63. package/lib/components/Settings.d.ts +2 -2
  64. package/lib/components/Settings.d.ts.map +1 -1
  65. package/lib/components/Settings.js +6 -6
  66. package/lib/components/Settings.js.map +1 -1
  67. package/lib/components/SwitchSelector.d.ts +1 -1
  68. package/lib/components/SwitchSelector.d.ts.map +1 -1
  69. package/lib/components/SwitchSelector.js +3 -3
  70. package/lib/components/SwitchSelector.js.map +1 -1
  71. package/lib/components/TableChart.d.ts +2 -2
  72. package/lib/components/TableChart.d.ts.map +1 -1
  73. package/lib/components/TableChart.js +6 -6
  74. package/lib/components/TableChart.js.map +1 -1
  75. package/lib/components/index.js +10 -10
  76. package/lib/components/index.js.map +1 -1
  77. package/lib/flame-chart-model.d.ts +2 -2
  78. package/lib/flame-chart-model.d.ts.map +1 -1
  79. package/lib/flame-chart-model.js.map +1 -1
  80. package/lib/getPluginModule.d.ts +1 -1
  81. package/lib/getPluginModule.d.ts.map +1 -1
  82. package/lib/getPluginModule.js +3 -1
  83. package/lib/getPluginModule.js.map +1 -1
  84. package/lib/index-federation.js +1 -1
  85. package/lib/index.js +2 -2
  86. package/lib/index.js.map +1 -1
  87. package/lib/setup-tests.d.ts +1 -1
  88. package/lib/setup-tests.d.ts.map +1 -1
  89. package/lib/setup-tests.js +2 -2
  90. package/lib/setup-tests.js.map +1 -1
  91. package/lib/utils/data-transform.d.ts +2 -2
  92. package/lib/utils/data-transform.d.ts.map +1 -1
  93. package/lib/utils/data-transform.js +2 -2
  94. package/lib/utils/data-transform.js.map +1 -1
  95. package/lib/utils/format.js +2 -2
  96. package/lib/utils/palette-gen.js +1 -1
  97. package/lib/utils/palette-gen.js.map +1 -1
  98. package/lib/utils/palette.js +1 -1
  99. package/lib/utils/series-tooltip.d.ts +1 -1
  100. package/lib/utils/series-tooltip.d.ts.map +1 -1
  101. package/lib/utils/series-tooltip.js +1 -1
  102. package/lib/utils/series-tooltip.js.map +1 -1
  103. package/lib/utils/tooltip.d.ts +1 -1
  104. package/lib/utils/tooltip.d.ts.map +1 -1
  105. package/lib/utils/tooltip.js +2 -2
  106. package/lib/utils/tooltip.js.map +1 -1
  107. package/lib/utils/utils.d.ts +2 -2
  108. package/lib/utils/utils.d.ts.map +1 -1
  109. package/lib/utils/utils.js +1 -1
  110. package/lib/utils/utils.js.map +1 -1
  111. package/mf-manifest.json +31 -53
  112. package/mf-stats.json +31 -57
  113. package/package.json +10 -10
  114. package/__mf/js/async/121.7241788e.js +0 -2
  115. package/__mf/js/async/177.d1b72566.js +0 -1
  116. package/__mf/js/async/187.d2c3954d.js +0 -7
  117. package/__mf/js/async/187.d2c3954d.js.LICENSE.txt +0 -39
  118. package/__mf/js/async/192.2e230dc2.js +0 -1
  119. package/__mf/js/async/2.3d2f3d32.js +0 -1
  120. package/__mf/js/async/235.f7949644.js +0 -1
  121. package/__mf/js/async/274.f1ae4a6c.js +0 -2
  122. package/__mf/js/async/356.941c6c54.js +0 -1
  123. package/__mf/js/async/367.8beb758e.js +0 -110
  124. package/__mf/js/async/392.157fda9a.js +0 -2
  125. package/__mf/js/async/43.2eeeac07.js +0 -2
  126. package/__mf/js/async/470.55030a0b.js +0 -2
  127. package/__mf/js/async/546.d47a49c6.js +0 -24
  128. package/__mf/js/async/546.d47a49c6.js.LICENSE.txt +0 -19
  129. package/__mf/js/async/587.8bcd9e70.js +0 -1
  130. package/__mf/js/async/588.0012e8ae.js +0 -1
  131. package/__mf/js/async/597.fee7f09c.js +0 -1
  132. package/__mf/js/async/616.da14f6a0.js +0 -1
  133. package/__mf/js/async/657.9473a80f.js +0 -39
  134. package/__mf/js/async/698.06b3786e.js +0 -1
  135. package/__mf/js/async/71.126af909.js +0 -1
  136. package/__mf/js/async/740.c1f5cc4b.js +0 -1
  137. package/__mf/js/async/873.cd4654cd.js +0 -1
  138. package/__mf/js/async/941.c00ae16d.js +0 -2
  139. package/__mf/js/async/968.f7510839.js +0 -1
  140. package/__mf/js/async/97.fd587361.js +0 -1
  141. package/__mf/js/async/978.e1b5b66e.js +0 -1
  142. package/__mf/js/async/__federation_expose_FlameChart.7a8d049a.js +0 -17
  143. package/__mf/js/async/lib-router.1a328ab9.js +0 -2
  144. package/lib/cjs/FlameChart.js +0 -37
  145. package/lib/cjs/bootstrap.js +0 -26
  146. package/lib/cjs/components/CustomBreadcrumb.js +0 -96
  147. package/lib/cjs/components/FlameChart.js +0 -341
  148. package/lib/cjs/components/FlameChartOptionsEditorSettings.js +0 -104
  149. package/lib/cjs/components/FlameChartPanel.js +0 -164
  150. package/lib/cjs/components/PaletteSelector.js +0 -49
  151. package/lib/cjs/components/SearchBar.js +0 -59
  152. package/lib/cjs/components/SeriesChart.js +0 -189
  153. package/lib/cjs/components/Settings.js +0 -202
  154. package/lib/cjs/components/SwitchSelector.js +0 -37
  155. package/lib/cjs/components/TableChart.js +0 -143
  156. package/lib/cjs/components/index.js +0 -39
  157. package/lib/cjs/env.d.js +0 -14
  158. package/lib/cjs/flame-chart-model.js +0 -31
  159. package/lib/cjs/getPluginModule.js +0 -39
  160. package/lib/cjs/index-federation.js +0 -55
  161. package/lib/cjs/index.js +0 -37
  162. package/lib/cjs/setup-tests.js +0 -19
  163. package/lib/cjs/utils/data-model.js +0 -18
  164. package/lib/cjs/utils/data-transform.js +0 -163
  165. package/lib/cjs/utils/format.js +0 -88
  166. package/lib/cjs/utils/palette-gen.js +0 -68
  167. package/lib/cjs/utils/palette.js +0 -62
  168. package/lib/cjs/utils/series-tooltip.js +0 -51
  169. package/lib/cjs/utils/tooltip.js +0 -76
  170. package/lib/cjs/utils/ui-text.js +0 -30
  171. package/lib/cjs/utils/utils.js +0 -122
  172. /package/__mf/css/async/{187.85c2cbf6.css → 40.85c2cbf6.css} +0 -0
  173. /package/__mf/js/async/{121.7241788e.js.LICENSE.txt → 121.b114caf4.js.LICENSE.txt} +0 -0
  174. /package/__mf/js/async/{274.f1ae4a6c.js.LICENSE.txt → 274.e53c6dc1.js.LICENSE.txt} +0 -0
  175. /package/__mf/js/async/{392.157fda9a.js.LICENSE.txt → 392.800bb82c.js.LICENSE.txt} +0 -0
  176. /package/__mf/js/async/{43.2eeeac07.js.LICENSE.txt → 43.71599a15.js.LICENSE.txt} +0 -0
  177. /package/__mf/js/async/{470.55030a0b.js.LICENSE.txt → 470.1af0a163.js.LICENSE.txt} +0 -0
  178. /package/__mf/js/async/{367.8beb758e.js.LICENSE.txt → 802.f2161316.js.LICENSE.txt} +0 -0
  179. /package/__mf/js/async/{941.c00ae16d.js.LICENSE.txt → 941.e44ab19f.js.LICENSE.txt} +0 -0
  180. /package/__mf/js/async/{lib-router.1a328ab9.js.LICENSE.txt → lib-router.d7bf8c32.js.LICENSE.txt} +0 -0
@@ -1,341 +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, "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.buildSamples)(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
- style: {
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
- }
@@ -1,104 +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, "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
- const { handleTraceHeightChange } = (0, _utils.useTraceHeightState)(props);
37
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGrid, {
38
- children: [
39
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
40
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
41
- title: "Misc",
42
- children: [
43
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_PaletteSelector.PaletteSelector, {
44
- value: value.palette,
45
- onChange: handlePaletteChange
46
- }),
47
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
48
- label: "Trace Height",
49
- control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
50
- type: "number",
51
- value: value.traceHeight ?? '',
52
- slotProps: {
53
- htmlInput: {
54
- min: 0,
55
- step: 1
56
- }
57
- },
58
- onChange: handleTraceHeightChange
59
- })
60
- })
61
- ]
62
- })
63
- }),
64
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
65
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
66
- title: "Panels to display",
67
- children: [
68
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_SwitchSelector.SwitchSelector, {
69
- label: "Show Options",
70
- value: value.showSettings,
71
- onChange: handleShowSettingsChange
72
- }),
73
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_SwitchSelector.SwitchSelector, {
74
- label: "Show Series",
75
- value: value.showSeries,
76
- onChange: handleShowSeriesChange
77
- }),
78
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_SwitchSelector.SwitchSelector, {
79
- label: "Show Table",
80
- value: value.showTable,
81
- onChange: handleShowTableChange
82
- }),
83
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_SwitchSelector.SwitchSelector, {
84
- label: "Show Flame Graph",
85
- value: value.showFlameGraph,
86
- onChange: handleShowFlameGraphChange
87
- })
88
- ]
89
- })
90
- }),
91
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
92
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorGroup, {
93
- title: "Reset Settings",
94
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
95
- variant: "outlined",
96
- color: "secondary",
97
- onClick: ()=>(0, _utils.resetSettings)(props),
98
- children: "Reset To Defaults"
99
- })
100
- })
101
- })
102
- ]
103
- });
104
- }
@@ -1,164 +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, "FlameChartPanel", {
18
- enumerable: true,
19
- get: function() {
20
- return FlameChartPanel;
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 _datatransform = require("../utils/data-transform");
28
- const _FlameChart = require("./FlameChart");
29
- const _Settings = require("./Settings");
30
- const _TableChart = require("./TableChart");
31
- const _SeriesChart = require("./SeriesChart");
32
- const LARGE_PANEL_THRESHOLD = 600;
33
- const DEFAULT_SERIES_CHART_HEIGHT = 200;
34
- const FlameChartPanel = (props)=>{
35
- const { contentDimensions, queryResults, spec } = props;
36
- const isMobileSize = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.down('sm'));
37
- // selectedId equals 0 => Flame Graph is not zoomed in
38
- // selectedId different from 0 => Flame Graph is zoomed in
39
- const [selectedId, setSelectedId] = (0, _react.useState)(0);
40
- const [searchValue, setSearchValue] = (0, _react.useState)('');
41
- // This spec is used to manage settings temporarily
42
- const [liveSpec, setLiveSpec] = (0, _react.useState)(spec);
43
- // keep liveSpec up to date
44
- (0, _react.useEffect)(()=>{
45
- setLiveSpec(spec);
46
- setSelectedId(0);
47
- setSearchValue('');
48
- }, [
49
- spec
50
- ]);
51
- const chartsTheme = (0, _components.useChartsTheme)();
52
- const flameChartData = (0, _react.useMemo)(()=>{
53
- return queryResults[0];
54
- }, [
55
- queryResults
56
- ]);
57
- const selectedStackTrace = (0, _react.useMemo)(()=>{
58
- if (!flameChartData) return undefined;
59
- if (!selectedId) return flameChartData.data.profile.stackTrace;
60
- return (0, _datatransform.filterStackTraceById)(flameChartData.data.profile.stackTrace, selectedId);
61
- }, [
62
- flameChartData,
63
- selectedId
64
- ]);
65
- const maxDepth = (0, _react.useMemo)(()=>selectedStackTrace ? (0, _datatransform.getMaxDepth)(selectedStackTrace) : 0, [
66
- selectedStackTrace
67
- ]);
68
- const noDataTextStyle = chartsTheme.noDataOption.title.textStyle;
69
- const onChangePalette = (newPalette)=>{
70
- setLiveSpec((prev)=>{
71
- return {
72
- ...prev,
73
- palette: newPalette
74
- };
75
- });
76
- };
77
- const onDisplayChange = (value)=>{
78
- let showTable = true;
79
- let showFlameGraph = true;
80
- if (value === 'table') {
81
- showFlameGraph = false;
82
- } else if (value === 'flame-graph') {
83
- showTable = false;
84
- }
85
- setLiveSpec((prev)=>{
86
- return {
87
- ...prev,
88
- showTable: showTable,
89
- showFlameGraph: showFlameGraph
90
- };
91
- });
92
- };
93
- if (!contentDimensions) return null;
94
- const PADDING = liveSpec.showSeries && liveSpec.showSettings ? 32 : liveSpec.showSeries || liveSpec.showSettings ? 16 : 0;
95
- const SETTINGS_HEIGHT = liveSpec.showSettings ? 30 : 0;
96
- const SERIES_CHART_HEIGHT = liveSpec.showSeries ? contentDimensions.height < DEFAULT_SERIES_CHART_HEIGHT ? contentDimensions.height : DEFAULT_SERIES_CHART_HEIGHT : 0;
97
- const TABLE_FLAME_CHART_HEIGHT = liveSpec.traceHeight ? Math.max(contentDimensions.height - (contentDimensions.height > LARGE_PANEL_THRESHOLD ? SERIES_CHART_HEIGHT + SETTINGS_HEIGHT + PADDING : 0), maxDepth * liveSpec.traceHeight) : contentDimensions.height - (contentDimensions.height > LARGE_PANEL_THRESHOLD ? SERIES_CHART_HEIGHT + SETTINGS_HEIGHT + PADDING : 0);
98
- const TABLE_CHART_WIDTH = isMobileSize ? contentDimensions.width : liveSpec.showFlameGraph ? 0.4 * contentDimensions.width : contentDimensions.width;
99
- const FLAME_CHART_WIDTH = isMobileSize ? contentDimensions.width : liveSpec.showTable ? 0.6 * contentDimensions.width : contentDimensions.width;
100
- // TODO (gladorme): allow users to override height (useful for explorer for stack traces with high depth)
101
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
102
- height: contentDimensions.height,
103
- width: contentDimensions.width,
104
- justifyContent: "center",
105
- alignItems: "center",
106
- children: queryResults.length > 1 ? // display a message if there is more than one query
107
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
108
- sx: {
109
- ...noDataTextStyle
110
- },
111
- children: "There is more than one query. Please make sure that you provided only one query."
112
- }) : flameChartData ? /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
113
- gap: 2,
114
- sx: {
115
- overflowY: 'auto',
116
- scrollbarGutter: 'stable both-edges',
117
- paddingTop: liveSpec.showSettings || liveSpec.showSeries ? 1 : 0
118
- },
119
- children: [
120
- liveSpec.showSeries && /*#__PURE__*/ (0, _jsxruntime.jsx)(_SeriesChart.SeriesChart, {
121
- width: contentDimensions.width,
122
- height: SERIES_CHART_HEIGHT,
123
- data: flameChartData.data
124
- }),
125
- liveSpec.showSettings && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Settings.Settings, {
126
- onSelectedIdChange: setSelectedId,
127
- onChangePalette: onChangePalette,
128
- onDisplayChange: onDisplayChange,
129
- value: liveSpec,
130
- selectedId: selectedId
131
- }),
132
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
133
- direction: isMobileSize ? 'column' : 'row',
134
- justifyContent: "center",
135
- alignItems: isMobileSize ? 'center' : 'top',
136
- children: [
137
- liveSpec.showTable && /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableChart.TableChart, {
138
- width: TABLE_CHART_WIDTH,
139
- height: TABLE_FLAME_CHART_HEIGHT,
140
- data: flameChartData.data,
141
- searchValue: searchValue,
142
- onSearchValueChange: setSearchValue,
143
- onSelectedIdChange: setSelectedId
144
- }),
145
- liveSpec.showFlameGraph && /*#__PURE__*/ (0, _jsxruntime.jsx)(_FlameChart.FlameChart, {
146
- width: FLAME_CHART_WIDTH,
147
- height: TABLE_FLAME_CHART_HEIGHT,
148
- data: flameChartData.data,
149
- palette: liveSpec.palette,
150
- selectedId: selectedId,
151
- searchValue: searchValue,
152
- onSelectedIdChange: setSelectedId
153
- })
154
- ]
155
- })
156
- ]
157
- }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
158
- sx: {
159
- ...noDataTextStyle
160
- },
161
- children: "No data"
162
- })
163
- });
164
- };
@@ -1,49 +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, "PaletteSelector", {
18
- enumerable: true,
19
- get: function() {
20
- return PaletteSelector;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _components = require("@perses-dev/components");
25
- const PALETTE_OPTIONS = [
26
- {
27
- id: 'package-name',
28
- label: 'By Package Name'
29
- },
30
- {
31
- id: 'value',
32
- label: 'By Value'
33
- }
34
- ];
35
- function PaletteSelector({ onChange, value = 'package-name' }) {
36
- const handlePaletteChange = (_, { id })=>{
37
- onChange(id);
38
- };
39
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
40
- label: "Palette",
41
- control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
42
- value: PALETTE_OPTIONS.find((o)=>o.id === value),
43
- options: PALETTE_OPTIONS,
44
- getOptionLabel: (o)=>o.label,
45
- onChange: handlePaletteChange,
46
- disableClearable: true
47
- })
48
- });
49
- }