@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
package/lib/FlameChart.js CHANGED
@@ -10,8 +10,8 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { createInitialFlameChartOptions } from './flame-chart-model';
14
- import { FlameChartPanel, FlameChartOptionsEditorSettings } from './components';
13
+ import { FlameChartPanel, FlameChartOptionsEditorSettings } from "./components/index.js";
14
+ import { createInitialFlameChartOptions } from "./flame-chart-model.js";
15
15
  /**
16
16
  * The core FlameChart panel plugin for Perses.
17
17
  */ export const FlameChart = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/FlameChart.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PanelPlugin } from '@perses-dev/plugin-system';\nimport { createInitialFlameChartOptions, FlameChartOptions } from './flame-chart-model';\nimport { FlameChartPanel, FlameChartPanelProps, FlameChartOptionsEditorSettings } from './components';\n\n/**\n * The core FlameChart panel plugin for Perses.\n */\nexport const FlameChart: PanelPlugin<FlameChartOptions, FlameChartPanelProps> = {\n PanelComponent: FlameChartPanel,\n supportedQueryTypes: ['ProfileQuery'],\n panelOptionsEditorComponents: [\n {\n label: 'Settings',\n content: FlameChartOptionsEditorSettings,\n },\n ],\n createInitialOptions: createInitialFlameChartOptions,\n};\n"],"names":["createInitialFlameChartOptions","FlameChartPanel","FlameChartOptionsEditorSettings","FlameChart","PanelComponent","supportedQueryTypes","panelOptionsEditorComponents","label","content","createInitialOptions"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,8BAA8B,QAA2B,sBAAsB;AACxF,SAASC,eAAe,EAAwBC,+BAA+B,QAAQ,eAAe;AAEtG;;CAEC,GACD,OAAO,MAAMC,aAAmE;IAC9EC,gBAAgBH;IAChBI,qBAAqB;QAAC;KAAe;IACrCC,8BAA8B;QAC5B;YACEC,OAAO;YACPC,SAASN;QACX;KACD;IACDO,sBAAsBT;AACxB,EAAE"}
1
+ {"version":3,"sources":["../../src/FlameChart.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { PanelPlugin } from '@perses-dev/plugin-system';\n\nimport type { FlameChartPanelProps } from './components';\nimport { FlameChartPanel, FlameChartOptionsEditorSettings } from './components';\nimport type { FlameChartOptions } from './flame-chart-model';\nimport { createInitialFlameChartOptions } from './flame-chart-model';\n\n/**\n * The core FlameChart panel plugin for Perses.\n */\nexport const FlameChart: PanelPlugin<FlameChartOptions, FlameChartPanelProps> = {\n PanelComponent: FlameChartPanel,\n supportedQueryTypes: ['ProfileQuery'],\n panelOptionsEditorComponents: [\n {\n label: 'Settings',\n content: FlameChartOptionsEditorSettings,\n },\n ],\n createInitialOptions: createInitialFlameChartOptions,\n};\n"],"names":["FlameChartPanel","FlameChartOptionsEditorSettings","createInitialFlameChartOptions","FlameChart","PanelComponent","supportedQueryTypes","panelOptionsEditorComponents","label","content","createInitialOptions"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAKjC,SAASA,eAAe,EAAEC,+BAA+B,QAAQ,wBAAe;AAEhF,SAASC,8BAA8B,QAAQ,yBAAsB;AAErE;;CAEC,GACD,OAAO,MAAMC,aAAmE;IAC9EC,gBAAgBJ;IAChBK,qBAAqB;QAAC;KAAe;IACrCC,8BAA8B;QAC5B;YACEC,OAAO;YACPC,SAASP;QACX;KACD;IACDQ,sBAAsBP;AACxB,EAAE"}
package/lib/bootstrap.js CHANGED
@@ -11,8 +11,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import React from 'react';
15
- import ReactDOM from 'react-dom/client';
14
+ import React from "react";
15
+ import ReactDOM from "react-dom/client";
16
16
  const root = ReactDOM.createRoot(document.getElementById('root'));
17
17
  root.render(/*#__PURE__*/ _jsx(React.StrictMode, {}));
18
18
 
@@ -1,4 +1,4 @@
1
- import { ReactElement } from 'react';
1
+ import type { ReactElement } from 'react';
2
2
  export interface CustomBreadcrumbProps {
3
3
  totalValue: string;
4
4
  totalSample: number;
@@ -1 +1 @@
1
- {"version":3,"file":"CustomBreadcrumb.d.ts","sourceRoot":"","sources":["../../../src/components/CustomBreadcrumb.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AASrC,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAmBD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,CAgC3E"}
1
+ {"version":3,"file":"CustomBreadcrumb.d.ts","sourceRoot":"","sources":["../../../src/components/CustomBreadcrumb.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAmBD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,CAgC3E"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License | Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,14 +11,13 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND | either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { Stack, Breadcrumbs } from '@mui/material';
15
- import ChevronRightIcon from 'mdi-material-ui/ChevronRight';
16
- import EyeIcon from 'mdi-material-ui/EyeOutline';
17
- import CloseIcon from 'mdi-material-ui/Close';
18
- import Chip from '@mui/material/Chip';
19
- import { emphasize, styled } from '@mui/material/styles';
20
- import { formatValue } from '@perses-dev/components';
14
+ import { Stack, Breadcrumbs } from "@mui/material";
15
+ import Chip from "@mui/material/Chip";
16
+ import { emphasize, styled } from "@mui/material/styles";
17
+ import { formatValue } from "@perses-dev/components";
18
+ import ChevronRightIcon from "mdi-material-ui/ChevronRight";
19
+ import CloseIcon from "mdi-material-ui/Close";
20
+ import EyeIcon from "mdi-material-ui/EyeOutline";
21
21
  const StyledBreadcrumb = styled(Chip)(({ theme })=>{
22
22
  const backgroundColor = theme.palette.mode === 'light' ? theme.palette.grey[100] : theme.palette.grey[800];
23
23
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/CustomBreadcrumb.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License | Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing | software\n// distributed under the License is distributed on an \"AS IS\" BASIS |\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND | either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement } from 'react';\nimport { Stack, Breadcrumbs } from '@mui/material';\nimport ChevronRightIcon from 'mdi-material-ui/ChevronRight';\nimport EyeIcon from 'mdi-material-ui/EyeOutline';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport Chip from '@mui/material/Chip';\nimport { emphasize, styled } from '@mui/material/styles';\nimport { formatValue } from '@perses-dev/components';\n\nexport interface CustomBreadcrumbProps {\n totalValue: string;\n totalSample: number;\n otherItemSample: number | undefined;\n onSelectedIdChange: (newId: number) => void;\n}\n\nconst StyledBreadcrumb = styled(Chip)(({ theme }) => {\n const backgroundColor = theme.palette.mode === 'light' ? theme.palette.grey[100] : theme.palette.grey[800];\n return {\n backgroundColor,\n height: theme.spacing(3),\n color: theme.palette.text.primary,\n fontWeight: theme.typography.fontWeightRegular,\n '&:hover, &:focus': {\n backgroundColor: emphasize(backgroundColor, 0.06),\n },\n '&:active': {\n boxShadow: theme.shadows[1],\n backgroundColor: emphasize(backgroundColor, 0.12),\n },\n };\n});\n\nexport function CustomBreadcrumb(props: CustomBreadcrumbProps): ReactElement {\n const { totalValue, totalSample, otherItemSample, onSelectedIdChange } = props;\n\n const handleClick = (event: React.MouseEvent<Element, MouseEvent>): void => {\n event.preventDefault();\n onSelectedIdChange(0);\n };\n\n const splitedValue = totalValue.split('(');\n const totalValueText = splitedValue[splitedValue.length - 1]?.slice(0, -1);\n\n const totalLabel = formatValue(totalSample, { unit: 'decimal', decimalPlaces: 2, shortValues: true }) + ' samples';\n\n return (\n <Stack direction=\"row\" spacing={1} minHeight={40} alignItems=\"center\">\n <Breadcrumbs\n separator={<ChevronRightIcon fontSize=\"small\" />}\n aria-label=\"breadcrumb\"\n sx={{ justifyContent: 'center' }}\n >\n <StyledBreadcrumb label={totalValueText + ' | ' + totalLabel} />\n {otherItemSample !== undefined && (\n <StyledBreadcrumb\n label={((otherItemSample / totalSample) * 100).toFixed(2) + '% of total'}\n icon={<EyeIcon fontSize=\"small\" color=\"secondary\" />}\n deleteIcon={<CloseIcon fontSize=\"small\" />}\n onDelete={handleClick}\n />\n )}\n </Breadcrumbs>\n </Stack>\n );\n}\n"],"names":["Stack","Breadcrumbs","ChevronRightIcon","EyeIcon","CloseIcon","Chip","emphasize","styled","formatValue","StyledBreadcrumb","theme","backgroundColor","palette","mode","grey","height","spacing","color","text","primary","fontWeight","typography","fontWeightRegular","boxShadow","shadows","CustomBreadcrumb","props","totalValue","totalSample","otherItemSample","onSelectedIdChange","handleClick","event","preventDefault","splitedValue","split","totalValueText","length","slice","totalLabel","unit","decimalPlaces","shortValues","direction","minHeight","alignItems","separator","fontSize","aria-label","sx","justifyContent","label","undefined","toFixed","icon","deleteIcon","onDelete"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,wEAAw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QAAM2C,WAAU;QAAM3B,SAAS;QAAG4B,WAAW;QAAIC,YAAW;kBAC3D,cAAA,MAAC5C;YACC6C,yBAAW,KAAC5C;gBAAiB6C,UAAS;;YACtCC,cAAW;YACXC,IAAI;gBAAEC,gBAAgB;YAAS;;8BAE/B,KAACzC;oBAAiB0C,OAAOf,iBAAiB,UAAUG;;gBACnDV,oBAAoBuB,2BACnB,KAAC3C;oBACC0C,OAAO,AAAC,CAAA,AAACtB,kBAAkBD,cAAe,GAAE,EAAGyB,OAAO,CAAC,KAAK;oBAC5DC,oBAAM,KAACnD;wBAAQ4C,UAAS;wBAAQ9B,OAAM;;oBACtCsC,0BAAY,KAACnD;wBAAU2C,UAAS;;oBAChCS,UAAUzB;;;;;AAMtB"}
1
+ {"version":3,"sources":["../../../src/components/CustomBreadcrumb.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License | Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing | software\n// distributed under the License is distributed on an \"AS IS\" BASIS |\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND | either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Stack, Breadcrumbs } from '@mui/material';\nimport Chip from '@mui/material/Chip';\nimport { emphasize, styled } from '@mui/material/styles';\nimport { formatValue } from '@perses-dev/components';\nimport ChevronRightIcon from 'mdi-material-ui/ChevronRight';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport EyeIcon from 'mdi-material-ui/EyeOutline';\nimport type { ReactElement } from 'react';\n\nexport interface CustomBreadcrumbProps {\n totalValue: string;\n totalSample: number;\n otherItemSample: number | undefined;\n onSelectedIdChange: (newId: number) => void;\n}\n\nconst StyledBreadcrumb = styled(Chip)(({ theme }) => {\n const backgroundColor = theme.palette.mode === 'light' ? theme.palette.grey[100] : theme.palette.grey[800];\n return {\n backgroundColor,\n height: theme.spacing(3),\n color: theme.palette.text.primary,\n fontWeight: theme.typography.fontWeightRegular,\n '&:hover, &:focus': {\n backgroundColor: emphasize(backgroundColor, 0.06),\n },\n '&:active': {\n boxShadow: theme.shadows[1],\n backgroundColor: emphasize(backgroundColor, 0.12),\n },\n };\n});\n\nexport function CustomBreadcrumb(props: CustomBreadcrumbProps): ReactElement {\n const { totalValue, totalSample, otherItemSample, onSelectedIdChange } = props;\n\n const handleClick = (event: React.MouseEvent<Element, MouseEvent>): void => {\n event.preventDefault();\n onSelectedIdChange(0);\n };\n\n const splitedValue = totalValue.split('(');\n const totalValueText = splitedValue[splitedValue.length - 1]?.slice(0, -1);\n\n const totalLabel = formatValue(totalSample, { unit: 'decimal', decimalPlaces: 2, shortValues: true }) + ' samples';\n\n return (\n <Stack direction=\"row\" spacing={1} minHeight={40} alignItems=\"center\">\n <Breadcrumbs\n separator={<ChevronRightIcon fontSize=\"small\" />}\n aria-label=\"breadcrumb\"\n sx={{ justifyContent: 'center' }}\n >\n <StyledBreadcrumb label={totalValueText + ' | ' + totalLabel} />\n {otherItemSample !== undefined && (\n <StyledBreadcrumb\n label={((otherItemSample / totalSample) * 100).toFixed(2) + '% of total'}\n icon={<EyeIcon fontSize=\"small\" color=\"secondary\" />}\n deleteIcon={<CloseIcon fontSize=\"small\" />}\n onDelete={handleClick}\n />\n )}\n </Breadcrumbs>\n </Stack>\n );\n}\n"],"names":["Stack","Breadcrumbs","Chip","emphasize","styled","formatValue","ChevronRightIcon","CloseIcon","EyeIcon","StyledBreadcrumb","theme","backgroundColor","palette","mode","grey","height","spacing","color","text","primary","fontWeight","typography","fontWeightRegular","boxShadow","shadows","CustomBreadcrumb","props","totalValue","totalSample","otherItemSample","onSelectedIdChange","handleClick","event","preventDefault","splitedValue","split","totalValueText","length","slice","totalLabel","unit","decimalPlaces","shortValues","direction","minHeight","alignItems","separator","fontSize","aria-label","sx","justifyContent","label","undefined","toFixed","icon","deleteIcon","onDelete"],"mappings":";AAAA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IAExE,MAAMC,aAAalC,YAAYuB,aAAa;QAAEY,MAAM;QAAWC,eAAe;QAAGC,aAAa;IAAK,KAAK;IAExG,qBACE,KAAC1C;QAAM2C,WAAU;QAAM3B,SAAS;QAAG4B,WAAW;QAAIC,YAAW;kBAC3D,cAAA,MAAC5C;YACC6C,yBAAW,KAACxC;gBAAiByC,UAAS;;YACtCC,cAAW;YACXC,IAAI;gBAAEC,gBAAgB;YAAS;;8BAE/B,KAACzC;oBAAiB0C,OAAOf,iBAAiB,UAAUG;;gBACnDV,oBAAoBuB,2BACnB,KAAC3C;oBACC0C,OAAO,AAAC,CAAA,AAACtB,kBAAkBD,cAAe,GAAE,EAAGyB,OAAO,CAAC,KAAK;oBAC5DC,oBAAM,KAAC9C;wBAAQuC,UAAS;wBAAQ9B,OAAM;;oBACtCsC,0BAAY,KAAChD;wBAAUwC,UAAS;;oBAChCS,UAAUzB;;;;;AAMtB"}
@@ -1,5 +1,5 @@
1
- import { ReactElement } from 'react';
2
- import { ProfileData } from '@perses-dev/spec';
1
+ import type { ProfileData } from '@perses-dev/spec';
2
+ import type { ReactElement } from 'react';
3
3
  export interface FlameChartProps {
4
4
  width: number;
5
5
  height: number;
@@ -1 +1 @@
1
- {"version":3,"file":"FlameChart.d.ts","sourceRoot":"","sources":["../../../src/components/FlameChart.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAE,YAAY,EAAiC,MAAM,OAAO,CAAC;AAMpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAa/C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CAqP/D"}
1
+ {"version":3,"file":"FlameChart.d.ts","sourceRoot":"","sources":["../../../src/components/FlameChart.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAWpD,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,OAAO,CAAC;AAetD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CAqP/D"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,16 +11,15 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { Stack, Box, Menu, MenuItem, Divider, useTheme } from '@mui/material';
15
- import { useState, useMemo } from 'react';
16
- import { useChartsTheme, EChart } from '@perses-dev/components';
17
- import RefreshIcon from 'mdi-material-ui/Refresh';
18
- import EyeIcon from 'mdi-material-ui/EyeOutline';
19
- import ContentCopyIcon from 'mdi-material-ui/ContentCopy';
20
- import { buildSamples, findTotalSampleByName } from '../utils/data-transform';
21
- import { generateTooltip } from '../utils/tooltip';
22
- import { CustomBreadcrumb } from './CustomBreadcrumb';
14
+ import { Stack, Box, Menu, MenuItem, Divider, useTheme } from "@mui/material";
15
+ import { useChartsTheme, EChart } from "@perses-dev/components";
16
+ import ContentCopyIcon from "mdi-material-ui/ContentCopy";
17
+ import EyeIcon from "mdi-material-ui/EyeOutline";
18
+ import RefreshIcon from "mdi-material-ui/Refresh";
19
+ import { useState, useMemo } from "react";
20
+ import { buildSamples, findTotalSampleByName } from "../utils/data-transform.js";
21
+ import { generateTooltip } from "../utils/tooltip.js";
22
+ import { CustomBreadcrumb } from "./CustomBreadcrumb.js";
23
23
  const ITEM_GAP = 2; // vertical gap between flame chart items
24
24
  const Y_MIN_SMALL = 6; // min value of y axis for small containers
25
25
  const Y_MIN_LARGE = 20; // min value of y axis for large containers
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/FlameChart.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n CustomSeriesRenderItem,\n CustomSeriesRenderItemAPI,\n CustomSeriesRenderItemParams,\n CustomSeriesRenderItemReturn,\n} from 'echarts';\nimport { Stack, Box, Menu, MenuItem, Divider, useTheme } from '@mui/material';\nimport { ReactElement, useState, useMemo, MouseEvent } from 'react';\nimport { useChartsTheme, EChart, MouseEventsParameters } from '@perses-dev/components';\nimport RefreshIcon from 'mdi-material-ui/Refresh';\nimport EyeIcon from 'mdi-material-ui/EyeOutline';\nimport ContentCopyIcon from 'mdi-material-ui/ContentCopy';\nimport { EChartsCoreOption } from 'echarts/core';\nimport { ProfileData } from '@perses-dev/spec';\nimport { buildSamples, findTotalSampleByName } from '../utils/data-transform';\nimport { generateTooltip } from '../utils/tooltip';\nimport { FlameChartSample as Sample } from '../utils/data-model';\nimport { CustomBreadcrumb } from './CustomBreadcrumb';\n\nconst ITEM_GAP = 2; // vertical gap between flame chart items\nconst Y_MIN_SMALL = 6; // min value of y axis for small containers\nconst Y_MIN_LARGE = 20; // min value of y axis for large containers\nconst LARGE_CONTAINER_THRESHOLD = 600;\nconst CONTAINER_PADDING = 10;\nconst BREADCRUMB_SPACE = 50;\n\nexport interface FlameChartProps {\n width: number;\n height: number;\n data: ProfileData;\n palette: 'package-name' | 'value';\n selectedId: number;\n searchValue: string;\n onSelectedIdChange: (newId: number) => void;\n}\n\nexport function FlameChart(props: FlameChartProps): ReactElement {\n const { width, height, data, palette, selectedId, searchValue, onSelectedIdChange } = props;\n const theme = useTheme();\n const chartsTheme = useChartsTheme();\n const [menuPosition, setMenuPosition] = useState<{ mouseX: number; mouseY: number } | null>(null);\n const [selectedItem, setSelectedItem] = useState<{ id: number; name: string }>({ id: 0, name: '' });\n const [isCopied, setIsCopied] = useState(false);\n\n const seriesData = useMemo(\n () => buildSamples(palette, data.metadata, data.profile.stackTrace, searchValue, selectedId),\n [palette, data.metadata, data.profile.stackTrace, selectedId, searchValue]\n );\n\n const handleItemClick = (params: MouseEventsParameters<Sample>): void => {\n const data: Sample = params.data;\n const functionName = data.value[6];\n const functionId = data.name;\n setSelectedItem({ id: functionId, name: functionName });\n\n // To ensure that the cursor is positioned inside the menu when it opens,\n // we adjust the click event coordinates as follows:\n if ('event' in params) {\n const mouseEvent = params.event as { event: MouseEvent };\n setMenuPosition({\n mouseX: mouseEvent.event.clientX - 2,\n mouseY: mouseEvent.event.clientY - 4,\n });\n }\n };\n\n const handleFocusBlock = (): void => {\n onSelectedIdChange(selectedItem.id);\n handleClose();\n };\n\n const handleCopyFunctionName = (): void => {\n if ((selectedId || selectedId === 0) && selectedItem.name) {\n navigator.clipboard.writeText(selectedItem.name);\n }\n setIsCopied(true);\n };\n\n const handleResetGraph = (): void => {\n if (selectedId) {\n onSelectedIdChange(0);\n }\n handleClose();\n };\n\n const handleClose = (): void => {\n setMenuPosition(null);\n if (isCopied) setIsCopied(false);\n };\n\n const renderItem: CustomSeriesRenderItem = (params: CustomSeriesRenderItemParams, api: CustomSeriesRenderItemAPI) => {\n const level = api.value(0);\n const start = api.coord([api.value(1), level]);\n const end = api.coord([api.value(2), level]);\n const height = (((api.size && api.size([0, 1])) || [0, 20]) as number[])[1];\n const width = (end?.[0] ?? 0) - (start?.[0] ?? 0);\n\n return {\n type: 'rect',\n transition: ['shape'],\n shape: {\n x: start?.[0],\n y: (start?.[1] ?? 0) - (height ?? 0) / 2,\n width,\n height: (height ?? ITEM_GAP) - ITEM_GAP,\n r: 0,\n },\n style: {\n fill: api.visual('color'),\n },\n emphasis: {\n style: {\n stroke: '#000',\n },\n },\n textConfig: {\n position: 'insideLeft',\n },\n textContent: {\n style: {\n text: api.value(3),\n fill: '#000',\n width: width - 4,\n overflow: 'truncate',\n ellipsis: '..',\n truncateMinChar: 1,\n },\n emphasis: {\n style: {\n stroke: '#000',\n lineWidth: 0.5,\n },\n },\n },\n } as CustomSeriesRenderItemReturn;\n };\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data.profile.stackTrace === undefined) return chartsTheme.noDataOption;\n\n const maxDepth = Math.max(...seriesData.map((s) => s.value[0])); // maximum depth of the stack trace\n const yAxisMax = Math.max(height > LARGE_CONTAINER_THRESHOLD ? Y_MIN_LARGE : Y_MIN_SMALL, maxDepth);\n const totalStart = seriesData[0]?.value[1]; // start value of the total function\n const totalEnd = seriesData[0]?.value[2]; // end value of the total function\n const xAxisMin = totalStart;\n const xAxisMax = totalEnd;\n\n // compute flame chart padding top and bottom\n const padding = (height / (yAxisMax - 1) - ITEM_GAP) / 2 + 1;\n\n const option = {\n tooltip: {\n appendToBody: true,\n confine: true,\n formatter: (params: Sample): string => generateTooltip(params, data.metadata?.units),\n backgroundColor: theme.palette.background.paper,\n borderColor: theme.palette.background.paper,\n textStyle: {\n color: theme.palette.text.primary,\n },\n },\n xAxis: {\n show: false,\n min: xAxisMin,\n max: xAxisMax,\n axisLabel: {\n show: false,\n },\n },\n yAxis: {\n show: false,\n max: yAxisMax,\n inverse: true, // Reverse Y axis\n axisLabel: {\n show: false,\n },\n },\n axisLabel: {\n overflow: 'truncate',\n width: width / 3,\n },\n grid: {\n left: 5,\n right: 5,\n top: padding + 5,\n bottom: padding,\n },\n series: [\n {\n type: 'custom',\n renderItem,\n encode: {\n x: [0, 1, 2],\n y: 0,\n },\n data: seriesData,\n },\n ],\n };\n\n return option;\n }, [data, chartsTheme, theme, width, seriesData, height]);\n\n // Use useMemo to memoize the flame chart component and prevent unnecessary re-renders.\n // This ensures the chart does not re-render when the onClick event updates state variables\n // like menuPosition or selectedId.\n const flameChart = useMemo(\n () => (\n <EChart\n style={{\n width: width,\n height: height - 2 * CONTAINER_PADDING - BREADCRUMB_SPACE,\n }}\n option={option} // even data is in this prop\n theme={chartsTheme.echartsTheme}\n onEvents={{\n click: handleItemClick as (params: MouseEventsParameters<unknown>) => void,\n }}\n />\n ),\n [chartsTheme.echartsTheme, height, option, width]\n );\n\n return (\n <Stack\n style={{\n width: width,\n height: height,\n }}\n alignItems=\"center\"\n >\n <CustomBreadcrumb\n totalValue={seriesData[0]?.value[3] || ''} // name of the total function\n totalSample={seriesData[0]?.value[8] || 0} // total sample of the total function\n otherItemSample={findTotalSampleByName(seriesData, selectedId)} // total sample of the selected function\n onSelectedIdChange={onSelectedIdChange}\n />\n {flameChart}\n <Menu\n sx={{\n '& .MuiPaper-root': {\n backgroundColor: theme.palette.background.paper,\n color: theme.palette.text.primary,\n padding: '5px',\n paddingBottom: '0px',\n },\n '& .MuiMenuItem-root': {\n '&:hover': {\n backgroundColor: theme.palette.action.hover,\n },\n },\n }}\n open={menuPosition !== null}\n onClose={handleClose}\n anchorReference=\"anchorPosition\"\n anchorPosition={menuPosition !== null ? { top: menuPosition.mouseY, left: menuPosition.mouseX } : undefined}\n >\n <Box\n sx={{\n paddingLeft: '16px',\n paddingBottom: '8px',\n }}\n >\n {selectedItem.name}\n </Box>\n <Divider sx={{ backgroundColor: theme.palette.divider }} />\n <MenuItem onClick={handleFocusBlock}>\n <EyeIcon fontSize=\"small\" color=\"secondary\" sx={{ marginRight: '10px' }} />\n Focus block\n </MenuItem>\n <MenuItem onClick={handleCopyFunctionName} disabled={isCopied}>\n <ContentCopyIcon fontSize=\"small\" color=\"secondary\" sx={{ marginRight: '10px' }} />\n {isCopied ? 'Copied' : 'Copy function name'}\n </MenuItem>\n <MenuItem onClick={handleResetGraph}>\n <RefreshIcon fontSize=\"small\" color=\"secondary\" sx={{ marginRight: '10px' }} />\n Reset graph\n </MenuItem>\n </Menu>\n </Stack>\n );\n}\n"],"names":["Stack","Box","Menu","MenuItem","Divider","useTheme","useState","useMemo","useChartsTheme","EChart","RefreshIcon","EyeIcon","ContentCopyIcon","buildSamples","findTotalSampleByName","generateTooltip","CustomBreadcrumb","ITEM_GAP","Y_MIN_SMALL","Y_MIN_LARGE","LARGE_CONTAINER_THRESHOLD","CONTAINER_PADDING","BREADCRUMB_SPACE","FlameChart","props","width","height","data","palette","selectedId","searchValue","onSelectedIdChange","theme","chartsTheme","menuPosition","setMenuPosition","selectedItem","setSelectedItem","id","name","isCopied","setIsCopied","seriesData","metadata","profile","stackTrace","handleItemClick","params","functionName","value","functionId","mouseEvent","event","mouseX","clientX","mouseY","clientY","handleFocusBlock","handleClose","handleCopyFunctionName","navigator","clipboard","writeText","handleResetGraph","renderItem","api","level","start","coord","end","size","type","transition","shape","x","y","r","style","fill","visual","emphasis","stroke","textConfig","position","textContent","text","overflow","ellipsis","truncateMinChar","lineWidth","option","undefined","noDataOption","maxDepth","Math","max","map","s","yAxisMax","totalStart","totalEnd","xAxisMin","xAxisMax","padding","tooltip","appendToBody","confine","formatter","units","backgroundColor","background","paper","borderColor","textStyle","color","primary","xAxis","show","min","axisLabel","yAxis","inverse","grid","left","right","top","bottom","series","encode","flameChart","echartsTheme","onEvents","click","alignItems","totalValue","totalSample","otherItemSample","sx","paddingBottom","action","hover","open","onClose","anchorReference","anchorPosition","paddingLeft","divider","onClick","fontSize","marginRight","disabled"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAQjC,SAASA,KAAK,EAAEC,GAAG,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,gBAAgB;AAC9E,SAAuBC,QAAQ,EAAEC,OAAO,QAAoB,QAAQ;AACpE,SAASC,cAAc,EAAEC,MAAM,QAA+B,yBAAyB;AACvF,OAAOC,iBAAiB,0BAA0B;AAClD,OAAOC,aAAa,6BAA6B;AACjD,OAAOC,qBAAqB,8BAA8B;AAG1D,SAASC,YAAY,EAAEC,qBAAqB,QAAQ,0BAA0B;AAC9E,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,MAAMC,WAAW,GAAG,yCAAyC;AAC7D,MAAMC,cAAc,GAAG,2CAA2C;AAClE,MAAMC,cAAc,IAAI,2CAA2C;AACnE,MAAMC,4BAA4B;AAClC,MAAMC,oBAAoB;AAC1B,MAAMC,mBAAmB;AAYzB,OAAO,SAASC,WAAWC,KAAsB;IAC/C,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,UAAU,EAAEC,WAAW,EAAEC,kBAAkB,EAAE,GAAGP;IACtF,MAAMQ,QAAQ3B;IACd,MAAM4B,cAAczB;IACpB,MAAM,CAAC0B,cAAcC,gBAAgB,GAAG7B,SAAoD;IAC5F,MAAM,CAAC8B,cAAcC,gBAAgB,GAAG/B,SAAuC;QAAEgC,IAAI;QAAGC,MAAM;IAAG;IACjG,MAAM,CAACC,UAAUC,YAAY,GA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BAASgJ,SAAS1F;;0CACjB,KAAC9C;gCAAQyI,UAAS;gCAAQlC,OAAM;gCAAYuB,IAAI;oCAAEY,aAAa;gCAAO;;4BAAK;;;kCAG7E,MAAClJ;wBAASgJ,SAASxF;wBAAwB2F,UAAU9G;;0CACnD,KAAC5B;gCAAgBwI,UAAS;gCAAQlC,OAAM;gCAAYuB,IAAI;oCAAEY,aAAa;gCAAO;;4BAC7E7G,WAAW,WAAW;;;kCAEzB,MAACrC;wBAASgJ,SAASpF;;0CACjB,KAACrD;gCAAY0I,UAAS;gCAAQlC,OAAM;gCAAYuB,IAAI;oCAAEY,aAAa;gCAAO;;4BAAK;;;;;;;AAMzF"}
1
+ {"version":3,"sources":["../../../src/components/FlameChart.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Stack, Box, Menu, MenuItem, Divider, useTheme } from '@mui/material';\nimport type { MouseEventsParameters } from '@perses-dev/components';\nimport { useChartsTheme, EChart } from '@perses-dev/components';\nimport type { ProfileData } from '@perses-dev/spec';\nimport type {\n CustomSeriesRenderItem,\n CustomSeriesRenderItemAPI,\n CustomSeriesRenderItemParams,\n CustomSeriesRenderItemReturn,\n} from 'echarts';\nimport type { EChartsCoreOption } from 'echarts/core';\nimport ContentCopyIcon from 'mdi-material-ui/ContentCopy';\nimport EyeIcon from 'mdi-material-ui/EyeOutline';\nimport RefreshIcon from 'mdi-material-ui/Refresh';\nimport type { ReactElement, MouseEvent } from 'react';\nimport { useState, useMemo } from 'react';\n\nimport type { FlameChartSample as Sample } from '../utils/data-model';\nimport { buildSamples, findTotalSampleByName } from '../utils/data-transform';\nimport { generateTooltip } from '../utils/tooltip';\nimport { CustomBreadcrumb } from './CustomBreadcrumb';\n\nconst ITEM_GAP = 2; // vertical gap between flame chart items\nconst Y_MIN_SMALL = 6; // min value of y axis for small containers\nconst Y_MIN_LARGE = 20; // min value of y axis for large containers\nconst LARGE_CONTAINER_THRESHOLD = 600;\nconst CONTAINER_PADDING = 10;\nconst BREADCRUMB_SPACE = 50;\n\nexport interface FlameChartProps {\n width: number;\n height: number;\n data: ProfileData;\n palette: 'package-name' | 'value';\n selectedId: number;\n searchValue: string;\n onSelectedIdChange: (newId: number) => void;\n}\n\nexport function FlameChart(props: FlameChartProps): ReactElement {\n const { width, height, data, palette, selectedId, searchValue, onSelectedIdChange } = props;\n const theme = useTheme();\n const chartsTheme = useChartsTheme();\n const [menuPosition, setMenuPosition] = useState<{ mouseX: number; mouseY: number } | null>(null);\n const [selectedItem, setSelectedItem] = useState<{ id: number; name: string }>({ id: 0, name: '' });\n const [isCopied, setIsCopied] = useState(false);\n\n const seriesData = useMemo(\n () => buildSamples(palette, data.metadata, data.profile.stackTrace, searchValue, selectedId),\n [palette, data.metadata, data.profile.stackTrace, selectedId, searchValue],\n );\n\n const handleItemClick = (params: MouseEventsParameters<Sample>): void => {\n const data: Sample = params.data;\n const functionName = data.value[6];\n const functionId = data.name;\n setSelectedItem({ id: functionId, name: functionName });\n\n // To ensure that the cursor is positioned inside the menu when it opens,\n // we adjust the click event coordinates as follows:\n if ('event' in params) {\n const mouseEvent = params.event as { event: MouseEvent };\n setMenuPosition({\n mouseX: mouseEvent.event.clientX - 2,\n mouseY: mouseEvent.event.clientY - 4,\n });\n }\n };\n\n const handleFocusBlock = (): void => {\n onSelectedIdChange(selectedItem.id);\n handleClose();\n };\n\n const handleCopyFunctionName = (): void => {\n if ((selectedId || selectedId === 0) && selectedItem.name) {\n navigator.clipboard.writeText(selectedItem.name);\n }\n setIsCopied(true);\n };\n\n const handleResetGraph = (): void => {\n if (selectedId) {\n onSelectedIdChange(0);\n }\n handleClose();\n };\n\n const handleClose = (): void => {\n setMenuPosition(null);\n if (isCopied) setIsCopied(false);\n };\n\n const renderItem: CustomSeriesRenderItem = (params: CustomSeriesRenderItemParams, api: CustomSeriesRenderItemAPI) => {\n const level = api.value(0);\n const start = api.coord([api.value(1), level]);\n const end = api.coord([api.value(2), level]);\n const height = (((api.size && api.size([0, 1])) || [0, 20]) as number[])[1];\n const width = (end?.[0] ?? 0) - (start?.[0] ?? 0);\n\n return {\n type: 'rect',\n transition: ['shape'],\n shape: {\n x: start?.[0],\n y: (start?.[1] ?? 0) - (height ?? 0) / 2,\n width,\n height: (height ?? ITEM_GAP) - ITEM_GAP,\n r: 0,\n },\n style: {\n fill: api.visual('color'),\n },\n emphasis: {\n style: {\n stroke: '#000',\n },\n },\n textConfig: {\n position: 'insideLeft',\n },\n textContent: {\n style: {\n text: api.value(3),\n fill: '#000',\n width: width - 4,\n overflow: 'truncate',\n ellipsis: '..',\n truncateMinChar: 1,\n },\n emphasis: {\n style: {\n stroke: '#000',\n lineWidth: 0.5,\n },\n },\n },\n } as CustomSeriesRenderItemReturn;\n };\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data.profile.stackTrace === undefined) return chartsTheme.noDataOption;\n\n const maxDepth = Math.max(...seriesData.map((s) => s.value[0])); // maximum depth of the stack trace\n const yAxisMax = Math.max(height > LARGE_CONTAINER_THRESHOLD ? Y_MIN_LARGE : Y_MIN_SMALL, maxDepth);\n const totalStart = seriesData[0]?.value[1]; // start value of the total function\n const totalEnd = seriesData[0]?.value[2]; // end value of the total function\n const xAxisMin = totalStart;\n const xAxisMax = totalEnd;\n\n // compute flame chart padding top and bottom\n const padding = (height / (yAxisMax - 1) - ITEM_GAP) / 2 + 1;\n\n const option = {\n tooltip: {\n appendToBody: true,\n confine: true,\n formatter: (params: Sample): string => generateTooltip(params, data.metadata?.units),\n backgroundColor: theme.palette.background.paper,\n borderColor: theme.palette.background.paper,\n textStyle: {\n color: theme.palette.text.primary,\n },\n },\n xAxis: {\n show: false,\n min: xAxisMin,\n max: xAxisMax,\n axisLabel: {\n show: false,\n },\n },\n yAxis: {\n show: false,\n max: yAxisMax,\n inverse: true, // Reverse Y axis\n axisLabel: {\n show: false,\n },\n },\n axisLabel: {\n overflow: 'truncate',\n width: width / 3,\n },\n grid: {\n left: 5,\n right: 5,\n top: padding + 5,\n bottom: padding,\n },\n series: [\n {\n type: 'custom',\n renderItem,\n encode: {\n x: [0, 1, 2],\n y: 0,\n },\n data: seriesData,\n },\n ],\n };\n\n return option;\n }, [data, chartsTheme, theme, width, seriesData, height]);\n\n // Use useMemo to memoize the flame chart component and prevent unnecessary re-renders.\n // This ensures the chart does not re-render when the onClick event updates state variables\n // like menuPosition or selectedId.\n const flameChart = useMemo(\n () => (\n <EChart\n style={{\n width: width,\n height: height - 2 * CONTAINER_PADDING - BREADCRUMB_SPACE,\n }}\n option={option} // even data is in this prop\n theme={chartsTheme.echartsTheme}\n onEvents={{\n click: handleItemClick as (params: MouseEventsParameters<unknown>) => void,\n }}\n />\n ),\n [chartsTheme.echartsTheme, height, option, width],\n );\n\n return (\n <Stack\n style={{\n width: width,\n height: height,\n }}\n alignItems=\"center\"\n >\n <CustomBreadcrumb\n totalValue={seriesData[0]?.value[3] || ''} // name of the total function\n totalSample={seriesData[0]?.value[8] || 0} // total sample of the total function\n otherItemSample={findTotalSampleByName(seriesData, selectedId)} // total sample of the selected function\n onSelectedIdChange={onSelectedIdChange}\n />\n {flameChart}\n <Menu\n sx={{\n '& .MuiPaper-root': {\n backgroundColor: theme.palette.background.paper,\n color: theme.palette.text.primary,\n padding: '5px',\n paddingBottom: '0px',\n },\n '& .MuiMenuItem-root': {\n '&:hover': {\n backgroundColor: theme.palette.action.hover,\n },\n },\n }}\n open={menuPosition !== null}\n onClose={handleClose}\n anchorReference=\"anchorPosition\"\n anchorPosition={menuPosition !== null ? { top: menuPosition.mouseY, left: menuPosition.mouseX } : undefined}\n >\n <Box\n sx={{\n paddingLeft: '16px',\n paddingBottom: '8px',\n }}\n >\n {selectedItem.name}\n </Box>\n <Divider sx={{ backgroundColor: theme.palette.divider }} />\n <MenuItem onClick={handleFocusBlock}>\n <EyeIcon fontSize=\"small\" color=\"secondary\" sx={{ marginRight: '10px' }} />\n Focus block\n </MenuItem>\n <MenuItem onClick={handleCopyFunctionName} disabled={isCopied}>\n <ContentCopyIcon fontSize=\"small\" color=\"secondary\" sx={{ marginRight: '10px' }} />\n {isCopied ? 'Copied' : 'Copy function name'}\n </MenuItem>\n <MenuItem onClick={handleResetGraph}>\n <RefreshIcon fontSize=\"small\" color=\"secondary\" sx={{ marginRight: '10px' }} />\n Reset graph\n </MenuItem>\n </Menu>\n </Stack>\n );\n}\n"],"names":["Stack","Box","Menu","MenuItem","Divider","useTheme","useChartsTheme","EChart","ContentCopyIcon","EyeIcon","RefreshIcon","useState","useMemo","buildSamples","findTotalSampleByName","generateTooltip","CustomBreadcrumb","ITEM_GAP","Y_MIN_SMALL","Y_MIN_LARGE","LARGE_CONTAINER_THRESHOLD","CONTAINER_PADDING","BREADCRUMB_SPACE","FlameChart","props","width","height","data","palette","selectedId","searchValue","onSelectedIdChange","theme","chartsTheme","menuPosition","setMenuPosition","selectedItem","setSelectedItem","id","name","isCopied","setIsCopied","seriesData","metadata","profile","stackTrace","handleItemClick","params","functionName","value","functionId","mouseEvent","event","mouseX","clientX","mouseY","clientY","handleFocusBlock","handleClose","handleCopyFunctionName","navigator","clipboard","writeText","handleResetGraph","renderItem","api","level","start","coord","end","size","type","transition","shape","x","y","r","style","fill","visual","emphasis","stroke","textConfig","position","textContent","text","overflow","ellipsis","truncateMinChar","lineWidth","option","undefined","noDataOption","maxDepth","Math","max","map","s","yAxisMax","totalStart","totalEnd","xAxisMin","xAxisMax","padding","tooltip","appendToBody","confine","formatter","units","backgroundColor","background","paper","borderColor","textStyle","color","primary","xAxis","show","min","axisLabel","yAxis","inverse","grid","left","right","top","bottom","series","encode","flameChart","echartsTheme","onEvents","click","alignItems","totalValue","totalSample","otherItemSample","sx","paddingBottom","action","hover","open","onClose","anchorReference","anchorPosition","paddingLeft","divider","onClick","fontSize","marginRight","disabled"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,KAAK,EAAEC,GAAG,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,gBAAgB;AAE9E,SAASC,cAAc,EAAEC,MAAM,QAAQ,yBAAyB;AAShE,OAAOC,qBAAqB,8BAA8B;AAC1D,OAAOC,aAAa,6BAA6B;AACjD,OAAOC,iBAAiB,0BAA0B;AAElD,SAASC,QAAQ,EAAEC,OAAO,QAAQ,QAAQ;AAG1C,SAASC,YAAY,EAAEC,qBAAqB,QAAQ,6BAA0B;AAC9E,SAASC,eAAe,QAAQ,sBAAmB;AACnD,SAASC,gBAAgB,QAAQ,wBAAqB;AAEtD,MAAMC,WAAW,GAAG,yCAAyC;AAC7D,MAAMC,cAAc,GAAG,2CAA2C;AAClE,MAAMC,cAAc,IAAI,2CAA2C;AACnE,MAAMC,4BAA4B;AAClC,MAAMC,oBAAoB;AAC1B,MAAMC,mBAAmB;AAYzB,OAAO,SAASC,WAAWC,KAAsB;IAC/C,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,UAAU,EAAEC,WAAW,EAAEC,kBAAkB,EAAE,GAAGP;IACtF,MAAMQ,QAAQ3B;IACd,MAAM4B,cAAc3B;IACpB,MAAM,CAAC4B,cAAcC,gBAAgB,GAAGxB,SAAoD;IAC5F,MAAM,CAACyB,cAAcC,gBAAgB,GAAG1B,SAAuC;QAAE2B,IAAI;QAAGC,MAAM;IAAG;IACjG,MAAM,CAACC,UAAUC,YAAY,GAAG9B,SA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AAS1F;;0CACjB,KAAChD;gCAAQ2I,UAAS;gCAAQlC,OAAM;gCAAYuB,IAAI;oCAAEY,aAAa;gCAAO;;4BAAK;;;kCAG7E,MAAClJ;wBAASgJ,SAASxF;wBAAwB2F,UAAU9G;;0CACnD,KAAChC;gCAAgB4I,UAAS;gCAAQlC,OAAM;gCAAYuB,IAAI;oCAAEY,aAAa;gCAAO;;4BAC7E7G,WAAW,WAAW;;;kCAEzB,MAACrC;wBAASgJ,SAASpF;;0CACjB,KAACrD;gCAAY0I,UAAS;gCAAQlC,OAAM;gCAAYuB,IAAI;oCAAEY,aAAa;gCAAO;;4BAAK;;;;;;;AAMzF"}
@@ -1,4 +1,4 @@
1
- import { ReactElement } from 'react';
2
- import { FlameChartOptionsEditorProps } from '../flame-chart-model';
1
+ import type { ReactElement } from 'react';
2
+ import type { FlameChartOptionsEditorProps } from '../flame-chart-model';
3
3
  export declare function FlameChartOptionsEditorSettings(props: FlameChartOptionsEditorProps): ReactElement;
4
4
  //# sourceMappingURL=FlameChartOptionsEditorSettings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FlameChartOptionsEditorSettings.d.ts","sourceRoot":"","sources":["../../../src/components/FlameChartOptionsEditorSettings.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAQrC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAapE,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,4BAA4B,GAAG,YAAY,CA6CjG"}
1
+ {"version":3,"file":"FlameChartOptionsEditorSettings.d.ts","sourceRoot":"","sources":["../../../src/components/FlameChartOptionsEditorSettings.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAazE,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,4BAA4B,GAAG,YAAY,CA6CjG"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,12 +11,11 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { OptionsEditorGroup, OptionsEditorGrid, OptionsEditorColumn, OptionsEditorControl } from '@perses-dev/components';
15
- import { Button, TextField } from '@mui/material';
16
- import { usePaletteState, useShowSettingsState, useShowSeriesState, useShowTableState, useShowFlameGraphState, resetSettings, useTraceHeightState } from '../utils/utils';
17
- import { PaletteSelector } from './PaletteSelector';
18
- import { SwitchSelector } from './SwitchSelector';
14
+ import { Button, TextField } from "@mui/material";
15
+ import { OptionsEditorGroup, OptionsEditorGrid, OptionsEditorColumn, OptionsEditorControl } from "@perses-dev/components";
16
+ import { usePaletteState, useShowSettingsState, useShowSeriesState, useShowTableState, useShowFlameGraphState, resetSettings, useTraceHeightState } from "../utils/utils.js";
17
+ import { PaletteSelector } from "./PaletteSelector.js";
18
+ import { SwitchSelector } from "./SwitchSelector.js";
19
19
  export function FlameChartOptionsEditorSettings(props) {
20
20
  const { value } = props;
21
21
  const { handlePaletteChange } = usePaletteState(props);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/FlameChartOptionsEditorSettings.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement } from 'react';\nimport {\n OptionsEditorGroup,\n OptionsEditorGrid,\n OptionsEditorColumn,\n OptionsEditorControl,\n} from '@perses-dev/components';\nimport { Button, TextField } from '@mui/material';\nimport { FlameChartOptionsEditorProps } from '../flame-chart-model';\nimport {\n usePaletteState,\n useShowSettingsState,\n useShowSeriesState,\n useShowTableState,\n useShowFlameGraphState,\n resetSettings,\n useTraceHeightState,\n} from '../utils/utils';\nimport { PaletteSelector } from './PaletteSelector';\nimport { SwitchSelector } from './SwitchSelector';\n\nexport function FlameChartOptionsEditorSettings(props: FlameChartOptionsEditorProps): ReactElement {\n const { value } = props;\n\n const { handlePaletteChange } = usePaletteState(props);\n const { handleShowSettingsChange } = useShowSettingsState(props);\n const { handleShowSeriesChange } = useShowSeriesState(props);\n const { handleShowTableChange } = useShowTableState(props);\n const { handleShowFlameGraphChange } = useShowFlameGraphState(props);\n const { handleTraceHeightChange } = useTraceHeightState(props);\n\n return (\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Misc\">\n <PaletteSelector value={value.palette} onChange={handlePaletteChange} />\n <OptionsEditorControl\n label=\"Trace Height\"\n control={\n <TextField\n type=\"number\"\n value={value.traceHeight ?? ''}\n slotProps={{ htmlInput: { min: 0, step: 1 } }}\n onChange={handleTraceHeightChange}\n />\n }\n />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Panels to display\">\n <SwitchSelector label=\"Show Options\" value={value.showSettings} onChange={handleShowSettingsChange} />\n <SwitchSelector label=\"Show Series\" value={value.showSeries} onChange={handleShowSeriesChange} />\n <SwitchSelector label=\"Show Table\" value={value.showTable} onChange={handleShowTableChange} />\n <SwitchSelector label=\"Show Flame Graph\" value={value.showFlameGraph} onChange={handleShowFlameGraphChange} />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Reset Settings\">\n <Button variant=\"outlined\" color=\"secondary\" onClick={() => resetSettings(props)}>\n Reset To Defaults\n </Button>\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n );\n}\n"],"names":["OptionsEditorGroup","OptionsEditorGrid","OptionsEditorColumn","OptionsEditorControl","Button","TextField","usePaletteState","useShowSettingsState","useShowSeriesState","useShowTableState","useShowFlameGraphState","resetSettings","useTraceHeightState","PaletteSelector","SwitchSelector","FlameChartOptionsEditorSettings","props","value","handlePaletteChange","handleShowSettingsChange","handleShowSeriesChange","handleShowTableChange","handleShowFlameGraphChange","handleTraceHeightChange","title","palette","onChange","label","control","type","traceHeight","slotProps","htmlInput","min","step","showSettings","showSeries","showTable","showFlameGraph","variant","color","onClick"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SACEA,kBAAkB,EAClBC,iBAAiB,EACjBC,mBAAmB,EACnBC,oBAAoB,QACf,yBAAyB;AAChC,SAASC,MAAM,EAAEC,SAAS,QAAQ,gBAAgB;AAElD,SACEC,eAAe,EACfC,oBAAoB,EACpBC,kBAAkB,EAClBC,iBAAiB,EACjBC,sBAAsB,EACtBC,aAAa,EACbC,mBAAmB,QACd,iBAAiB;AACxB,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,cAAc,QAAQ,mBAAmB;AAElD,OAAO,SAASC,gCAAgCC,KAAmC;IACjF,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAElB,MAAM,EAAEE,mBAAmB,EAAE,GAAGZ,gBAAgBU;IAChD,MAAM,EAAEG,wBAAwB,EAAE,GAAGZ,qBAAqBS;IAC1D,MAAM,EAAEI,sBAAsB,EAAE,GAAGZ,mBAAmBQ;IACtD,MAAM,EAAEK,qBAAqB,EAAE,GAAGZ,kBAAkBO;IACpD,MAAM,EAAEM,0BAA0B,EAAE,GAAGZ,uBAAuBM;IAC9D,MAAM,EAAEO,uBAAuB,EAAE,GAAGX,oBAAoBI;IAExD,qBACE,MAACf;;0BACC,KAACC;0BACC,cAAA,MAACF;oBAAmBwB,OAAM;;sCACxB,KAACX;4BAAgBI,OAAOA,MAAMQ,OAAO;4BAAEC,UAAUR;;sCACjD,KAACf;4BACCwB,OAAM;4BACNC,uBACE,KAACvB;gCACCwB,MAAK;gCACLZ,OAAOA,MAAMa,WAAW,IAAI;gCAC5BC,WAAW;oCAAEC,WAAW;wCAAEC,KAAK;wCAAGC,MAAM;oCAAE;gCAAE;gCAC5CR,UAAUH;;;;;;0BAMpB,KAACrB;0BACC,cAAA,MAACF;oBAAmBwB,OAAM;;sCACxB,KAACV;4BAAea,OAAM;4BAAeV,OAAOA,MAAMkB,YAAY;4BAAET,UAAUP;;sCAC1E,KAACL;4BAAea,OAAM;4BAAcV,OAAOA,MAAMmB,UAAU;4BAAEV,UAAUN;;sCACvE,KAACN;4BAAea,OAAM;4BAAaV,OAAOA,MAAMoB,SAAS;4BAAEX,UAAUL;;sCACrE,KAACP;4BAAea,OAAM;4BAAmBV,OAAOA,MAAMqB,cAAc;4BAAEZ,UAAUJ;;;;;0BAGpF,KAACpB;0BACC,cAAA,KAACF;oBAAmBwB,OAAM;8BACxB,cAAA,KAACpB;wBAAOmC,SAAQ;wBAAWC,OAAM;wBAAYC,SAAS,IAAM9B,cAAcK;kCAAQ;;;;;;AAO5F"}
1
+ {"version":3,"sources":["../../../src/components/FlameChartOptionsEditorSettings.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Button, TextField } from '@mui/material';\nimport {\n OptionsEditorGroup,\n OptionsEditorGrid,\n OptionsEditorColumn,\n OptionsEditorControl,\n} from '@perses-dev/components';\nimport type { ReactElement } from 'react';\n\nimport type { FlameChartOptionsEditorProps } from '../flame-chart-model';\nimport {\n usePaletteState,\n useShowSettingsState,\n useShowSeriesState,\n useShowTableState,\n useShowFlameGraphState,\n resetSettings,\n useTraceHeightState,\n} from '../utils/utils';\nimport { PaletteSelector } from './PaletteSelector';\nimport { SwitchSelector } from './SwitchSelector';\n\nexport function FlameChartOptionsEditorSettings(props: FlameChartOptionsEditorProps): ReactElement {\n const { value } = props;\n\n const { handlePaletteChange } = usePaletteState(props);\n const { handleShowSettingsChange } = useShowSettingsState(props);\n const { handleShowSeriesChange } = useShowSeriesState(props);\n const { handleShowTableChange } = useShowTableState(props);\n const { handleShowFlameGraphChange } = useShowFlameGraphState(props);\n const { handleTraceHeightChange } = useTraceHeightState(props);\n\n return (\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Misc\">\n <PaletteSelector value={value.palette} onChange={handlePaletteChange} />\n <OptionsEditorControl\n label=\"Trace Height\"\n control={\n <TextField\n type=\"number\"\n value={value.traceHeight ?? ''}\n slotProps={{ htmlInput: { min: 0, step: 1 } }}\n onChange={handleTraceHeightChange}\n />\n }\n />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Panels to display\">\n <SwitchSelector label=\"Show Options\" value={value.showSettings} onChange={handleShowSettingsChange} />\n <SwitchSelector label=\"Show Series\" value={value.showSeries} onChange={handleShowSeriesChange} />\n <SwitchSelector label=\"Show Table\" value={value.showTable} onChange={handleShowTableChange} />\n <SwitchSelector label=\"Show Flame Graph\" value={value.showFlameGraph} onChange={handleShowFlameGraphChange} />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Reset Settings\">\n <Button variant=\"outlined\" color=\"secondary\" onClick={() => resetSettings(props)}>\n Reset To Defaults\n </Button>\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n );\n}\n"],"names":["Button","TextField","OptionsEditorGroup","OptionsEditorGrid","OptionsEditorColumn","OptionsEditorControl","usePaletteState","useShowSettingsState","useShowSeriesState","useShowTableState","useShowFlameGraphState","resetSettings","useTraceHeightState","PaletteSelector","SwitchSelector","FlameChartOptionsEditorSettings","props","value","handlePaletteChange","handleShowSettingsChange","handleShowSeriesChange","handleShowTableChange","handleShowFlameGraphChange","handleTraceHeightChange","title","palette","onChange","label","control","type","traceHeight","slotProps","htmlInput","min","step","showSettings","showSeries","showTable","showFlameGraph","variant","color","onClick"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,MAAM,EAAEC,SAAS,QAAQ,gBAAgB;AAClD,SACEC,kBAAkB,EAClBC,iBAAiB,EACjBC,mBAAmB,EACnBC,oBAAoB,QACf,yBAAyB;AAIhC,SACEC,eAAe,EACfC,oBAAoB,EACpBC,kBAAkB,EAClBC,iBAAiB,EACjBC,sBAAsB,EACtBC,aAAa,EACbC,mBAAmB,QACd,oBAAiB;AACxB,SAASC,eAAe,QAAQ,uBAAoB;AACpD,SAASC,cAAc,QAAQ,sBAAmB;AAElD,OAAO,SAASC,gCAAgCC,KAAmC;IACjF,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAElB,MAAM,EAAEE,mBAAmB,EAAE,GAAGZ,gBAAgBU;IAChD,MAAM,EAAEG,wBAAwB,EAAE,GAAGZ,qBAAqBS;IAC1D,MAAM,EAAEI,sBAAsB,EAAE,GAAGZ,mBAAmBQ;IACtD,MAAM,EAAEK,qBAAqB,EAAE,GAAGZ,kBAAkBO;IACpD,MAAM,EAAEM,0BAA0B,EAAE,GAAGZ,uBAAuBM;IAC9D,MAAM,EAAEO,uBAAuB,EAAE,GAAGX,oBAAoBI;IAExD,qBACE,MAACb;;0BACC,KAACC;0BACC,cAAA,MAACF;oBAAmBsB,OAAM;;sCACxB,KAACX;4BAAgBI,OAAOA,MAAMQ,OAAO;4BAAEC,UAAUR;;sCACjD,KAACb;4BACCsB,OAAM;4BACNC,uBACE,KAAC3B;gCACC4B,MAAK;gCACLZ,OAAOA,MAAMa,WAAW,IAAI;gCAC5BC,WAAW;oCAAEC,WAAW;wCAAEC,KAAK;wCAAGC,MAAM;oCAAE;gCAAE;gCAC5CR,UAAUH;;;;;;0BAMpB,KAACnB;0BACC,cAAA,MAACF;oBAAmBsB,OAAM;;sCACxB,KAACV;4BAAea,OAAM;4BAAeV,OAAOA,MAAMkB,YAAY;4BAAET,UAAUP;;sCAC1E,KAACL;4BAAea,OAAM;4BAAcV,OAAOA,MAAMmB,UAAU;4BAAEV,UAAUN;;sCACvE,KAACN;4BAAea,OAAM;4BAAaV,OAAOA,MAAMoB,SAAS;4BAAEX,UAAUL;;sCACrE,KAACP;4BAAea,OAAM;4BAAmBV,OAAOA,MAAMqB,cAAc;4BAAEZ,UAAUJ;;;;;0BAGpF,KAAClB;0BACC,cAAA,KAACF;oBAAmBsB,OAAM;8BACxB,cAAA,KAACxB;wBAAOuC,SAAQ;wBAAWC,OAAM;wBAAYC,SAAS,IAAM9B,cAAcK;kCAAQ;;;;;;AAO5F"}
@@ -1,7 +1,7 @@
1
- import { FC } from 'react';
2
- import { PanelProps } from '@perses-dev/plugin-system';
3
- import { ProfileData } from '@perses-dev/spec';
4
- import { FlameChartOptions } from '../flame-chart-model';
1
+ import type { PanelProps } from '@perses-dev/plugin-system';
2
+ import type { ProfileData } from '@perses-dev/spec';
3
+ import type { FC } from 'react';
4
+ import type { FlameChartOptions } from '../flame-chart-model';
5
5
  export type FlameChartPanelProps = PanelProps<FlameChartOptions, ProfileData>;
6
6
  export declare const FlameChartPanel: FC<FlameChartPanelProps>;
7
7
  //# sourceMappingURL=FlameChartPanel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FlameChartPanel.d.ts","sourceRoot":"","sources":["../../../src/components/FlameChartPanel.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,EAAE,EAAgC,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAc,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAUzD,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;AAE9E,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CA+JpD,CAAC"}
1
+ {"version":3,"file":"FlameChartPanel.d.ts","sourceRoot":"","sources":["../../../src/components/FlameChartPanel.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,kBAAkB,CAAC;AAEhE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAU9D,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;AAE9E,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CA2JpD,CAAC"}
@@ -11,14 +11,14 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { useChartsTheme } from '@perses-dev/components';
15
- import { Stack, Typography, useMediaQuery, useTheme } from '@mui/material';
16
- import { useState, useEffect, useMemo } from 'react';
17
- import { filterStackTraceById, getMaxDepth } from '../utils/data-transform';
18
- import { FlameChart } from './FlameChart';
19
- import { Settings } from './Settings';
20
- import { TableChart } from './TableChart';
21
- import { SeriesChart } from './SeriesChart';
14
+ import { Stack, Typography, useMediaQuery, useTheme } from "@mui/material";
15
+ import { useChartsTheme } from "@perses-dev/components";
16
+ import { useState, useEffect, useMemo } from "react";
17
+ import { filterStackTraceById, getMaxDepth } from "../utils/data-transform.js";
18
+ import { FlameChart } from "./FlameChart.js";
19
+ import { SeriesChart } from "./SeriesChart.js";
20
+ import { Settings } from "./Settings.js";
21
+ import { TableChart } from "./TableChart.js";
22
22
  const LARGE_PANEL_THRESHOLD = 600;
23
23
  const DEFAULT_SERIES_CHART_HEIGHT = 200;
24
24
  export const FlameChartPanel = (props)=>{
@@ -81,75 +81,92 @@ export const FlameChartPanel = (props)=>{
81
81
  });
82
82
  };
83
83
  if (!contentDimensions) return null;
84
- const PADDING = liveSpec.showSeries && liveSpec.showSettings ? 32 : liveSpec.showSeries || liveSpec.showSettings ? 16 : 0;
84
+ let padding = 0;
85
+ if (liveSpec.showSeries && liveSpec.showSettings) {
86
+ padding = 32;
87
+ } else if (liveSpec.showSeries || liveSpec.showSettings) {
88
+ padding = 16;
89
+ }
85
90
  const SETTINGS_HEIGHT = liveSpec.showSettings ? 30 : 0;
86
- const SERIES_CHART_HEIGHT = liveSpec.showSeries ? contentDimensions.height < DEFAULT_SERIES_CHART_HEIGHT ? contentDimensions.height : DEFAULT_SERIES_CHART_HEIGHT : 0;
87
- 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);
88
- const TABLE_CHART_WIDTH = isMobileSize ? contentDimensions.width : liveSpec.showFlameGraph ? 0.4 * contentDimensions.width : contentDimensions.width;
89
- const FLAME_CHART_WIDTH = isMobileSize ? contentDimensions.width : liveSpec.showTable ? 0.6 * contentDimensions.width : contentDimensions.width;
91
+ const seriesChartHeight = liveSpec.showSeries ? Math.min(contentDimensions.height, DEFAULT_SERIES_CHART_HEIGHT) : 0;
92
+ const reservedHeight = contentDimensions.height > LARGE_PANEL_THRESHOLD ? seriesChartHeight + SETTINGS_HEIGHT + padding : 0;
93
+ const availableChartHeight = contentDimensions.height - reservedHeight;
94
+ const tableFlameChartHeight = liveSpec.traceHeight ? Math.max(availableChartHeight, maxDepth * liveSpec.traceHeight) : availableChartHeight;
95
+ let tableChartWidth = contentDimensions.width;
96
+ if (!isMobileSize && liveSpec.showFlameGraph) {
97
+ tableChartWidth = 0.4 * contentDimensions.width;
98
+ }
99
+ let flameChartWidth = contentDimensions.width;
100
+ if (!isMobileSize && liveSpec.showTable) {
101
+ flameChartWidth = 0.6 * contentDimensions.width;
102
+ }
90
103
  // TODO (gladorme): allow users to override height (useful for explorer for stack traces with high depth)
91
- return /*#__PURE__*/ _jsx(Stack, {
104
+ return /*#__PURE__*/ _jsxs(Stack, {
92
105
  height: contentDimensions.height,
93
106
  width: contentDimensions.width,
94
107
  justifyContent: "center",
95
108
  alignItems: "center",
96
- children: queryResults.length > 1 ? // display a message if there is more than one query
97
- /*#__PURE__*/ _jsx(Typography, {
98
- sx: {
99
- ...noDataTextStyle
100
- },
101
- children: "There is more than one query. Please make sure that you provided only one query."
102
- }) : flameChartData ? /*#__PURE__*/ _jsxs(Stack, {
103
- gap: 2,
104
- sx: {
105
- overflowY: 'auto',
106
- scrollbarGutter: 'stable both-edges',
107
- paddingTop: liveSpec.showSettings || liveSpec.showSeries ? 1 : 0
108
- },
109
- children: [
110
- liveSpec.showSeries && /*#__PURE__*/ _jsx(SeriesChart, {
111
- width: contentDimensions.width,
112
- height: SERIES_CHART_HEIGHT,
113
- data: flameChartData.data
114
- }),
115
- liveSpec.showSettings && /*#__PURE__*/ _jsx(Settings, {
116
- onSelectedIdChange: setSelectedId,
117
- onChangePalette: onChangePalette,
118
- onDisplayChange: onDisplayChange,
119
- value: liveSpec,
120
- selectedId: selectedId
121
- }),
122
- /*#__PURE__*/ _jsxs(Stack, {
123
- direction: isMobileSize ? 'column' : 'row',
124
- justifyContent: "center",
125
- alignItems: isMobileSize ? 'center' : 'top',
126
- children: [
127
- liveSpec.showTable && /*#__PURE__*/ _jsx(TableChart, {
128
- width: TABLE_CHART_WIDTH,
129
- height: TABLE_FLAME_CHART_HEIGHT,
130
- data: flameChartData.data,
131
- searchValue: searchValue,
132
- onSearchValueChange: setSearchValue,
133
- onSelectedIdChange: setSelectedId
134
- }),
135
- liveSpec.showFlameGraph && /*#__PURE__*/ _jsx(FlameChart, {
136
- width: FLAME_CHART_WIDTH,
137
- height: TABLE_FLAME_CHART_HEIGHT,
138
- data: flameChartData.data,
139
- palette: liveSpec.palette,
140
- selectedId: selectedId,
141
- searchValue: searchValue,
142
- onSelectedIdChange: setSelectedId
143
- })
144
- ]
145
- })
146
- ]
147
- }) : /*#__PURE__*/ _jsx(Typography, {
148
- sx: {
149
- ...noDataTextStyle
150
- },
151
- children: "No data"
152
- })
109
+ children: [
110
+ queryResults.length > 1 && // display a message if there is more than one query
111
+ /*#__PURE__*/ _jsx(Typography, {
112
+ sx: {
113
+ ...noDataTextStyle
114
+ },
115
+ children: "There is more than one query. Please make sure that you provided only one query."
116
+ }),
117
+ queryResults.length <= 1 && flameChartData && /*#__PURE__*/ _jsxs(Stack, {
118
+ gap: 2,
119
+ sx: {
120
+ overflowY: 'auto',
121
+ scrollbarGutter: 'stable both-edges',
122
+ paddingTop: liveSpec.showSettings || liveSpec.showSeries ? 1 : 0
123
+ },
124
+ children: [
125
+ liveSpec.showSeries && /*#__PURE__*/ _jsx(SeriesChart, {
126
+ width: contentDimensions.width,
127
+ height: seriesChartHeight,
128
+ data: flameChartData.data
129
+ }),
130
+ liveSpec.showSettings && /*#__PURE__*/ _jsx(Settings, {
131
+ onSelectedIdChange: setSelectedId,
132
+ onChangePalette: onChangePalette,
133
+ onDisplayChange: onDisplayChange,
134
+ value: liveSpec,
135
+ selectedId: selectedId
136
+ }),
137
+ /*#__PURE__*/ _jsxs(Stack, {
138
+ direction: isMobileSize ? 'column' : 'row',
139
+ justifyContent: "center",
140
+ alignItems: isMobileSize ? 'center' : 'top',
141
+ children: [
142
+ liveSpec.showTable && /*#__PURE__*/ _jsx(TableChart, {
143
+ width: tableChartWidth,
144
+ height: tableFlameChartHeight,
145
+ data: flameChartData.data,
146
+ searchValue: searchValue,
147
+ onSearchValueChange: setSearchValue,
148
+ onSelectedIdChange: setSelectedId
149
+ }),
150
+ liveSpec.showFlameGraph && /*#__PURE__*/ _jsx(FlameChart, {
151
+ width: flameChartWidth,
152
+ height: tableFlameChartHeight,
153
+ data: flameChartData.data,
154
+ palette: liveSpec.palette,
155
+ selectedId: selectedId,
156
+ searchValue: searchValue,
157
+ onSelectedIdChange: setSelectedId
158
+ })
159
+ ]
160
+ })
161
+ ]
162
+ }),
163
+ queryResults.length <= 1 && !flameChartData && /*#__PURE__*/ _jsx(Typography, {
164
+ sx: {
165
+ ...noDataTextStyle
166
+ },
167
+ children: "No data"
168
+ })
169
+ ]
153
170
  });
154
171
  };
155
172