@perses-dev/flame-chart-plugin 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +23 -0
  3. package/__mf/css/async/325.f56729ca.css +1 -0
  4. package/__mf/css/async/341.f56729ca.css +1 -0
  5. package/__mf/css/async/908.f56729ca.css +1 -0
  6. package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
  7. package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
  8. package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
  9. package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
  10. package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
  11. package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
  12. package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
  13. package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
  14. package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
  15. package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
  16. package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
  17. package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
  18. package/__mf/js/FlameChart.96aae761.js +5 -0
  19. package/__mf/js/async/109.f7e97e30.js +73 -0
  20. package/__mf/js/async/109.f7e97e30.js.LICENSE.txt +35 -0
  21. package/__mf/js/async/173.40a64c5c.js +2 -0
  22. package/__mf/js/async/173.40a64c5c.js.LICENSE.txt +19 -0
  23. package/__mf/js/async/214.f491540e.js +1 -0
  24. package/__mf/js/async/224.511d05b6.js +1 -0
  25. package/__mf/js/async/238.5fdc556e.js +1 -0
  26. package/__mf/js/async/29.8b55315e.js +1 -0
  27. package/__mf/js/async/292.643bbcde.js +1 -0
  28. package/__mf/js/async/32.a46fc45f.js +110 -0
  29. package/__mf/js/async/32.a46fc45f.js.LICENSE.txt +49 -0
  30. package/__mf/js/async/325.80031d25.js +1 -0
  31. package/__mf/js/async/362.c587718a.js +1 -0
  32. package/__mf/js/async/409.fd2d437e.js +1 -0
  33. package/__mf/js/async/464.bb266d9b.js +7 -0
  34. package/__mf/js/async/464.bb266d9b.js.LICENSE.txt +21 -0
  35. package/__mf/js/async/488.807096d6.js +1 -0
  36. package/__mf/js/async/600.fdf527b8.js +38 -0
  37. package/__mf/js/async/651.9eb6f201.js +1 -0
  38. package/__mf/js/async/69.a1079bc1.js +2 -0
  39. package/__mf/js/async/69.a1079bc1.js.LICENSE.txt +24 -0
  40. package/__mf/js/async/694.15848123.js +1 -0
  41. package/__mf/js/async/738.0b2ab393.js +1 -0
  42. package/__mf/js/async/740.65aa69e2.js +1 -0
  43. package/__mf/js/async/75.3435fe3f.js +1 -0
  44. package/__mf/js/async/770.bc6ab5a3.js +1 -0
  45. package/__mf/js/async/863.8b7bdf43.js +2 -0
  46. package/__mf/js/async/863.8b7bdf43.js.LICENSE.txt +9 -0
  47. package/__mf/js/async/908.0672909d.js +1 -0
  48. package/__mf/js/async/960.d56a397e.js +2 -0
  49. package/__mf/js/async/960.d56a397e.js.LICENSE.txt +8 -0
  50. package/__mf/js/async/964.86d91e52.js +2 -0
  51. package/__mf/js/async/964.86d91e52.js.LICENSE.txt +9 -0
  52. package/__mf/js/async/981.4de2d5c8.js +2 -0
  53. package/__mf/js/async/981.4de2d5c8.js.LICENSE.txt +8 -0
  54. package/__mf/js/async/__federation_expose_FlameChart.aaa6df30.js +17 -0
  55. package/__mf/js/async/lib-router.00804bbc.js +2 -0
  56. package/__mf/js/async/lib-router.00804bbc.js.LICENSE.txt +32 -0
  57. package/__mf/js/main.4931a266.js +5 -0
  58. package/lib/FlameChart.d.ts +8 -0
  59. package/lib/FlameChart.d.ts.map +1 -0
  60. package/lib/FlameChart.js +32 -0
  61. package/lib/FlameChart.js.map +1 -0
  62. package/lib/bootstrap.d.ts +2 -0
  63. package/lib/bootstrap.d.ts.map +1 -0
  64. package/lib/bootstrap.js +19 -0
  65. package/lib/bootstrap.js.map +1 -0
  66. package/lib/cjs/FlameChart.js +38 -0
  67. package/lib/cjs/bootstrap.js +26 -0
  68. package/lib/cjs/components/CustomBreadcrumb.js +96 -0
  69. package/lib/cjs/components/FlameChart.js +341 -0
  70. package/lib/cjs/components/FlameChartOptionsEditorSettings.js +87 -0
  71. package/lib/cjs/components/FlameChartPanel.js +147 -0
  72. package/lib/cjs/components/PaletteSelector.js +49 -0
  73. package/lib/cjs/components/SearchBar.js +59 -0
  74. package/lib/cjs/components/SeriesChart.js +189 -0
  75. package/lib/cjs/components/Settings.js +202 -0
  76. package/lib/cjs/components/SwitchSelector.js +37 -0
  77. package/lib/cjs/components/TableChart.js +143 -0
  78. package/lib/cjs/components/index.js +39 -0
  79. package/lib/cjs/env.d.js +14 -0
  80. package/lib/cjs/flame-chart-model.js +31 -0
  81. package/lib/cjs/getPluginModule.js +39 -0
  82. package/lib/cjs/index-federation.js +55 -0
  83. package/lib/cjs/index.js +37 -0
  84. package/lib/cjs/setup-tests.js +19 -0
  85. package/lib/cjs/utils/data-model.js +18 -0
  86. package/lib/cjs/utils/data-transform.js +152 -0
  87. package/lib/cjs/utils/format.js +87 -0
  88. package/lib/cjs/utils/palette-gen.js +68 -0
  89. package/lib/cjs/utils/palette.js +62 -0
  90. package/lib/cjs/utils/series-tooltip.js +51 -0
  91. package/lib/cjs/utils/tooltip.js +76 -0
  92. package/lib/cjs/utils/ui-text.js +30 -0
  93. package/lib/cjs/utils/utils.js +108 -0
  94. package/lib/components/CustomBreadcrumb.d.ts +9 -0
  95. package/lib/components/CustomBreadcrumb.d.ts.map +1 -0
  96. package/lib/components/CustomBreadcrumb.js +83 -0
  97. package/lib/components/CustomBreadcrumb.js.map +1 -0
  98. package/lib/components/FlameChart.d.ts +13 -0
  99. package/lib/components/FlameChart.d.ts.map +1 -0
  100. package/lib/components/FlameChart.js +328 -0
  101. package/lib/components/FlameChart.js.map +1 -0
  102. package/lib/components/FlameChartOptionsEditorSettings.d.ts +4 -0
  103. package/lib/components/FlameChartOptionsEditorSettings.d.ts.map +1 -0
  104. package/lib/components/FlameChartOptionsEditorSettings.js +79 -0
  105. package/lib/components/FlameChartOptionsEditorSettings.js.map +1 -0
  106. package/lib/components/FlameChartPanel.d.ts +7 -0
  107. package/lib/components/FlameChartPanel.d.ts.map +1 -0
  108. package/lib/components/FlameChartPanel.js +139 -0
  109. package/lib/components/FlameChartPanel.js.map +1 -0
  110. package/lib/components/PaletteSelector.d.ts +8 -0
  111. package/lib/components/PaletteSelector.d.ts.map +1 -0
  112. package/lib/components/PaletteSelector.js +41 -0
  113. package/lib/components/PaletteSelector.js.map +1 -0
  114. package/lib/components/SearchBar.d.ts +7 -0
  115. package/lib/components/SearchBar.d.ts.map +1 -0
  116. package/lib/components/SearchBar.js +46 -0
  117. package/lib/components/SearchBar.js.map +1 -0
  118. package/lib/components/SeriesChart.d.ts +9 -0
  119. package/lib/components/SeriesChart.d.ts.map +1 -0
  120. package/lib/components/SeriesChart.js +181 -0
  121. package/lib/components/SeriesChart.js.map +1 -0
  122. package/lib/components/Settings.d.ts +11 -0
  123. package/lib/components/Settings.d.ts.map +1 -0
  124. package/lib/components/Settings.js +189 -0
  125. package/lib/components/Settings.js.map +1 -0
  126. package/lib/components/SwitchSelector.d.ts +8 -0
  127. package/lib/components/SwitchSelector.d.ts.map +1 -0
  128. package/lib/components/SwitchSelector.js +29 -0
  129. package/lib/components/SwitchSelector.js.map +1 -0
  130. package/lib/components/TableChart.d.ts +12 -0
  131. package/lib/components/TableChart.d.ts.map +1 -0
  132. package/lib/components/TableChart.js +135 -0
  133. package/lib/components/TableChart.js.map +1 -0
  134. package/lib/components/index.d.ts +11 -0
  135. package/lib/components/index.d.ts.map +1 -0
  136. package/lib/components/index.js +24 -0
  137. package/lib/components/index.js.map +1 -0
  138. package/lib/env.d.js +15 -0
  139. package/lib/env.d.js.map +1 -0
  140. package/lib/flame-chart-model.d.ts +18 -0
  141. package/lib/flame-chart-model.d.ts.map +1 -0
  142. package/lib/flame-chart-model.js +23 -0
  143. package/lib/flame-chart-model.js.map +1 -0
  144. package/lib/getPluginModule.d.ts +6 -0
  145. package/lib/getPluginModule.d.ts.map +1 -0
  146. package/lib/getPluginModule.js +28 -0
  147. package/lib/getPluginModule.js.map +1 -0
  148. package/lib/index-federation.d.ts +1 -0
  149. package/lib/index-federation.d.ts.map +1 -0
  150. package/lib/index-federation.js +15 -0
  151. package/lib/index-federation.js.map +1 -0
  152. package/lib/index.d.ts +3 -0
  153. package/lib/index.d.ts.map +1 -0
  154. package/lib/index.js +16 -0
  155. package/lib/index.js.map +1 -0
  156. package/lib/setup-tests.d.ts +2 -0
  157. package/lib/setup-tests.d.ts.map +1 -0
  158. package/lib/setup-tests.js +17 -0
  159. package/lib/setup-tests.js.map +1 -0
  160. package/lib/utils/data-model.d.ts +37 -0
  161. package/lib/utils/data-model.d.ts.map +1 -0
  162. package/lib/utils/data-model.js +19 -0
  163. package/lib/utils/data-model.js.map +1 -0
  164. package/lib/utils/data-transform.d.ts +19 -0
  165. package/lib/utils/data-transform.d.ts.map +1 -0
  166. package/lib/utils/data-transform.js +138 -0
  167. package/lib/utils/data-transform.js.map +1 -0
  168. package/lib/utils/format.d.ts +3 -0
  169. package/lib/utils/format.d.ts.map +1 -0
  170. package/lib/utils/format.js +71 -0
  171. package/lib/utils/format.js.map +1 -0
  172. package/lib/utils/palette-gen.d.ts +14 -0
  173. package/lib/utils/palette-gen.d.ts.map +1 -0
  174. package/lib/utils/palette-gen.js +56 -0
  175. package/lib/utils/palette-gen.js.map +1 -0
  176. package/lib/utils/palette.d.ts +5 -0
  177. package/lib/utils/palette.d.ts.map +1 -0
  178. package/lib/utils/palette.js +51 -0
  179. package/lib/utils/palette.js.map +1 -0
  180. package/lib/utils/series-tooltip.d.ts +3 -0
  181. package/lib/utils/series-tooltip.d.ts.map +1 -0
  182. package/lib/utils/series-tooltip.js +43 -0
  183. package/lib/utils/series-tooltip.js.map +1 -0
  184. package/lib/utils/tooltip.d.ts +6 -0
  185. package/lib/utils/tooltip.d.ts.map +1 -0
  186. package/lib/utils/tooltip.js +29 -0
  187. package/lib/utils/tooltip.js.map +1 -0
  188. package/lib/utils/ui-text.d.ts +9 -0
  189. package/lib/utils/ui-text.d.ts.map +1 -0
  190. package/lib/utils/ui-text.js +22 -0
  191. package/lib/utils/ui-text.js.map +1 -0
  192. package/lib/utils/utils.d.ts +36 -0
  193. package/lib/utils/utils.d.ts.map +1 -0
  194. package/lib/utils/utils.js +92 -0
  195. package/lib/utils/utils.js.map +1 -0
  196. package/mf-manifest.json +274 -0
  197. package/mf-stats.json +322 -0
  198. package/package.json +64 -0
@@ -0,0 +1,147 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "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 _FlameChart = require("./FlameChart");
28
+ const _Settings = require("./Settings");
29
+ const _TableChart = require("./TableChart");
30
+ const _SeriesChart = require("./SeriesChart");
31
+ const LARGE_PANEL_TRESHOLD = 600;
32
+ const DEFAULT_SERIES_CHART_HEIGHT = 200;
33
+ const FlameChartPanel = (props)=>{
34
+ const { contentDimensions, queryResults, spec } = props;
35
+ const isMobileSize = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.down('sm'));
36
+ // selectedId equals 0 => Flame Graph is not zoomed in
37
+ // selectedId different from 0 => Flame Graph is zoomed in
38
+ const [selectedId, setSelectedId] = (0, _react.useState)(0);
39
+ const [searchValue, setSearchValue] = (0, _react.useState)('');
40
+ // This spec is used to manage settings temporarily
41
+ const [liveSpec, setLiveSpec] = (0, _react.useState)(spec);
42
+ // keep liveSpec up to date
43
+ (0, _react.useEffect)(()=>{
44
+ setLiveSpec(spec);
45
+ setSelectedId(0);
46
+ setSearchValue('');
47
+ }, [
48
+ spec
49
+ ]);
50
+ const chartsTheme = (0, _components.useChartsTheme)();
51
+ const flameChartData = queryResults[0];
52
+ if (contentDimensions === undefined) return null;
53
+ const noDataTextStyle = chartsTheme.noDataOption.title.textStyle;
54
+ const onChangePalette = (newPalette)=>{
55
+ setLiveSpec((prev)=>{
56
+ return {
57
+ ...prev,
58
+ palette: newPalette
59
+ };
60
+ });
61
+ };
62
+ const onDisplayChange = (value)=>{
63
+ let showTable = true;
64
+ let showFlameGraph = true;
65
+ if (value === 'table') {
66
+ showFlameGraph = false;
67
+ } else if (value === 'flame-graph') {
68
+ showTable = false;
69
+ }
70
+ setLiveSpec((prev)=>{
71
+ return {
72
+ ...prev,
73
+ showTable: showTable,
74
+ showFlameGraph: showFlameGraph
75
+ };
76
+ });
77
+ };
78
+ const PADDING = liveSpec.showSeries && liveSpec.showSettings ? 32 : liveSpec.showSeries || liveSpec.showSettings ? 16 : 0;
79
+ const SETTINGS_HEIGHT = liveSpec.showSettings ? 30 : 0;
80
+ const SERIES_CHART_HEIGHT = liveSpec.showSeries ? contentDimensions.height < DEFAULT_SERIES_CHART_HEIGHT ? contentDimensions.height : DEFAULT_SERIES_CHART_HEIGHT : 0;
81
+ const TABLE_FLAME_CHART_HEIGHT = contentDimensions.height - (contentDimensions.height > LARGE_PANEL_TRESHOLD ? SERIES_CHART_HEIGHT + SETTINGS_HEIGHT + PADDING : 0);
82
+ const TABLE_CHART_WIDTH = isMobileSize ? contentDimensions.width : liveSpec.showFlameGraph ? 0.4 * contentDimensions.width : contentDimensions.width;
83
+ const FLAME_CHART_WIDTH = isMobileSize ? contentDimensions.width : liveSpec.showTable ? 0.6 * contentDimensions.width : contentDimensions.width;
84
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
85
+ height: contentDimensions.height,
86
+ width: contentDimensions.width,
87
+ justifyContent: "center",
88
+ alignItems: "center",
89
+ children: queryResults.length > 1 ? // display a message if there is more than one query
90
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
91
+ sx: {
92
+ ...noDataTextStyle
93
+ },
94
+ children: "There is more than one query. Please make sure that you provided only one query."
95
+ }) : flameChartData ? /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
96
+ gap: 2,
97
+ sx: {
98
+ overflowY: 'auto',
99
+ scrollbarGutter: 'stable both-edges',
100
+ paddingTop: liveSpec.showSeries ? 0 : 1
101
+ },
102
+ children: [
103
+ liveSpec.showSeries && /*#__PURE__*/ (0, _jsxruntime.jsx)(_SeriesChart.SeriesChart, {
104
+ width: contentDimensions.width,
105
+ height: SERIES_CHART_HEIGHT,
106
+ data: flameChartData.data
107
+ }),
108
+ liveSpec.showSettings && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Settings.Settings, {
109
+ onSelectedIdChange: setSelectedId,
110
+ onChangePalette: onChangePalette,
111
+ onDisplayChange: onDisplayChange,
112
+ value: liveSpec,
113
+ selectedId: selectedId
114
+ }),
115
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
116
+ direction: isMobileSize ? 'column' : 'row',
117
+ justifyContent: "center",
118
+ alignItems: isMobileSize ? 'center' : 'top',
119
+ children: [
120
+ liveSpec.showTable && /*#__PURE__*/ (0, _jsxruntime.jsx)(_TableChart.TableChart, {
121
+ width: TABLE_CHART_WIDTH,
122
+ height: TABLE_FLAME_CHART_HEIGHT,
123
+ data: flameChartData.data,
124
+ searchValue: searchValue,
125
+ onSearchValueChange: setSearchValue,
126
+ onSelectedIdChange: setSelectedId
127
+ }),
128
+ liveSpec.showFlameGraph && /*#__PURE__*/ (0, _jsxruntime.jsx)(_FlameChart.FlameChart, {
129
+ width: FLAME_CHART_WIDTH,
130
+ height: TABLE_FLAME_CHART_HEIGHT,
131
+ data: flameChartData.data,
132
+ palette: liveSpec.palette,
133
+ selectedId: selectedId,
134
+ searchValue: searchValue,
135
+ onSelectedIdChange: setSelectedId
136
+ })
137
+ ]
138
+ })
139
+ ]
140
+ }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
141
+ sx: {
142
+ ...noDataTextStyle
143
+ },
144
+ children: "No data"
145
+ })
146
+ });
147
+ };
@@ -0,0 +1,49 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License | Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing | software
9
+ // distributed under the License is distributed on an "AS IS" BASIS |
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND | either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "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
+ }
@@ -0,0 +1,59 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License | Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing | software
9
+ // distributed under the License is distributed on an "AS IS" BASIS |
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND | either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "SearchBar", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return SearchBar;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _material = require("@mui/material");
25
+ const _Magnify = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Magnify"));
26
+ function _interop_require_default(obj) {
27
+ return obj && obj.__esModule ? obj : {
28
+ default: obj
29
+ };
30
+ }
31
+ function SearchBar(props) {
32
+ const { searchValue, onSearchValueChange } = props;
33
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
34
+ size: "small",
35
+ variant: "outlined",
36
+ placeholder: "Search...",
37
+ fullWidth: true,
38
+ value: searchValue,
39
+ onChange: (event)=>onSearchValueChange(event.target.value),
40
+ slotProps: {
41
+ input: {
42
+ startAdornment: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputAdornment, {
43
+ position: "start",
44
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Magnify.default, {
45
+ fontSize: "small"
46
+ })
47
+ }),
48
+ endAdornment: searchValue !== '' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputAdornment, {
49
+ position: "end",
50
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
51
+ label: "Clear",
52
+ size: "small",
53
+ onClick: ()=>onSearchValueChange('')
54
+ })
55
+ })
56
+ }
57
+ }
58
+ });
59
+ }
@@ -0,0 +1,189 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License | Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing | software
9
+ // distributed under the License is distributed on an "AS IS" BASIS |
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND | either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "SeriesChart", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return SeriesChart;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _react = require("react");
25
+ const _material = require("@mui/material");
26
+ const _components = require("@perses-dev/components");
27
+ const _pluginsystem = require("@perses-dev/plugin-system");
28
+ const _format = require("../utils/format");
29
+ const _seriestooltip = require("../utils/series-tooltip");
30
+ const LINE_WIDTH = 1.25;
31
+ const POINT_SIZE_OFFSET = 2;
32
+ function SeriesChart(props) {
33
+ const { width, height, data } = props;
34
+ const chartsTheme = (0, _components.useChartsTheme)();
35
+ const theme = (0, _material.useTheme)();
36
+ const { setTimeRange } = (0, _pluginsystem.useTimeRange)();
37
+ const chartRef = (0, _react.useRef)();
38
+ const handleEvents = (0, _react.useMemo)(()=>{
39
+ return {
40
+ datazoom: (params)=>{
41
+ if (params.batch[0] === undefined) return;
42
+ const xAxisStartValue = params.batch?.[0]?.startValue;
43
+ const xAxisEndValue = params.batch?.[0]?.endValue;
44
+ if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {
45
+ const zoomEvent = {
46
+ start: xAxisStartValue,
47
+ end: xAxisEndValue
48
+ };
49
+ setTimeRange({
50
+ start: new Date(zoomEvent.start),
51
+ end: new Date(zoomEvent.end)
52
+ });
53
+ }
54
+ },
55
+ finished: ()=>{
56
+ if (chartRef.current !== undefined) {
57
+ (0, _components.enableDataZoom)(chartRef.current);
58
+ }
59
+ }
60
+ };
61
+ }, [
62
+ setTimeRange
63
+ ]);
64
+ const seriesData = (0, _react.useMemo)(()=>{
65
+ const timeLine = data.timeline || {};
66
+ const startTime = timeLine.startTime;
67
+ const durationDelta = timeLine.durationDelta;
68
+ return timeLine.samples.map((sample, index)=>({
69
+ id: index,
70
+ value: [
71
+ (startTime + index * durationDelta) * 1000,
72
+ Number(sample)
73
+ ]
74
+ }));
75
+ }, [
76
+ data.timeline
77
+ ]);
78
+ const option = (0, _react.useMemo)(()=>{
79
+ const seriesMapping = {
80
+ type: 'line',
81
+ color: theme.palette.primary.main,
82
+ sampling: 'lttb',
83
+ showSymbol: true,
84
+ showAllSymbol: true,
85
+ symbolSize: LINE_WIDTH + POINT_SIZE_OFFSET,
86
+ lineStyle: {
87
+ width: LINE_WIDTH,
88
+ opacity: 0.95
89
+ },
90
+ areaStyle: {
91
+ opacity: 0
92
+ },
93
+ data: seriesData
94
+ };
95
+ const timeLine = data.timeline || {};
96
+ const option = {
97
+ series: seriesMapping,
98
+ xAxis: {
99
+ type: 'time',
100
+ min: timeLine.startTime * 1000,
101
+ max: (timeLine.startTime + timeLine.samples.length * timeLine.durationDelta) * 1000,
102
+ axisLabel: {
103
+ hideOverlap: true
104
+ },
105
+ axisPointer: {
106
+ snap: false
107
+ }
108
+ },
109
+ yAxis: {
110
+ type: 'value',
111
+ axisLabel: {
112
+ formatter: (value)=>{
113
+ return (0, _format.formatItemValue)(data.metadata?.units, value);
114
+ }
115
+ }
116
+ },
117
+ animation: false,
118
+ tooltip: {
119
+ show: true,
120
+ showContent: true,
121
+ trigger: 'axis',
122
+ appendToBody: true,
123
+ confine: true,
124
+ backgroundColor: theme.palette.background.paper,
125
+ borderColor: theme.palette.background.paper,
126
+ textStyle: {
127
+ color: theme.palette.text.primary
128
+ },
129
+ formatter: (params)=>(0, _seriestooltip.getSeriesTooltip)(params[0]?.data || {}, data.metadata?.units || '', data.metadata?.name || '', theme.palette.primary.main, theme.palette.divider)
130
+ },
131
+ axisPointer: {
132
+ type: 'line',
133
+ z: 0,
134
+ triggerEmphasis: true,
135
+ triggerTooltip: false,
136
+ snap: false
137
+ },
138
+ toolbox: {
139
+ feature: {
140
+ dataZoom: {
141
+ icon: null,
142
+ yAxisIndex: 'none'
143
+ }
144
+ }
145
+ },
146
+ grid: {
147
+ left: 10,
148
+ right: 10,
149
+ top: 10,
150
+ bottom: 10
151
+ }
152
+ };
153
+ return option;
154
+ }, [
155
+ data.timeline,
156
+ data.metadata,
157
+ seriesData,
158
+ theme
159
+ ]);
160
+ const seriesChart = (0, _react.useMemo)(()=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.EChart, {
161
+ style: {
162
+ width: width,
163
+ height: height
164
+ },
165
+ option: option,
166
+ theme: chartsTheme.echartsTheme,
167
+ onEvents: handleEvents,
168
+ _instance: chartRef
169
+ }), [
170
+ chartsTheme.echartsTheme,
171
+ height,
172
+ option,
173
+ width,
174
+ handleEvents
175
+ ]);
176
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
177
+ width: width,
178
+ height: height,
179
+ alignItems: "center",
180
+ justifyContent: "center",
181
+ onMouseEnter: ()=>{
182
+ // This is necessary to ensure that the data zoom feature is enabled after the theme is changed.
183
+ if (chartRef.current !== undefined) {
184
+ (0, _components.enableDataZoom)(chartRef.current);
185
+ }
186
+ },
187
+ children: seriesChart
188
+ });
189
+ }
@@ -0,0 +1,202 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "Settings", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return Settings;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _react = require("react");
25
+ const _Refresh = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Refresh"));
26
+ const _Palette = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Palette"));
27
+ const _material = require("@mui/material");
28
+ const _components = require("@perses-dev/components");
29
+ const _uitext = require("../utils/ui-text");
30
+ function _interop_require_default(obj) {
31
+ return obj && obj.__esModule ? obj : {
32
+ default: obj
33
+ };
34
+ }
35
+ function Settings(props) {
36
+ const { value, selectedId, onSelectedIdChange, onChangePalette, onDisplayChange } = props;
37
+ const theme = (0, _material.useTheme)();
38
+ const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
39
+ const open = Boolean(anchorEl);
40
+ const customButtonStyle = {
41
+ fontSize: '12px',
42
+ padding: '2px 6px',
43
+ minWidth: 'auto'
44
+ };
45
+ const handleChangeColorShemeClick = (event)=>{
46
+ setAnchorEl(event.currentTarget);
47
+ };
48
+ const handleByPackageNameClick = ()=>{
49
+ onChangePalette('package-name');
50
+ handleClose();
51
+ };
52
+ const handleByValueClick = ()=>{
53
+ onChangePalette('value');
54
+ handleClose();
55
+ };
56
+ const handleClose = ()=>{
57
+ setAnchorEl(null);
58
+ };
59
+ const isTableSelected = ()=>selectedView === 'table';
60
+ const isFlameGraphSelected = ()=>selectedView === 'flame-graph';
61
+ const isBothSelected = ()=>selectedView === 'both';
62
+ // Update selected view based on the value of showTable and showFlameGraph
63
+ const selectedView = (0, _react.useMemo)(()=>{
64
+ if (!value.showTable && !value.showFlameGraph) {
65
+ return 'none';
66
+ } else if (value.showTable && value.showFlameGraph) {
67
+ return 'both';
68
+ } else if (value.showTable) {
69
+ return 'table';
70
+ } else {
71
+ return 'flame-graph';
72
+ }
73
+ }, [
74
+ value.showTable,
75
+ value.showFlameGraph
76
+ ]);
77
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
78
+ spacing: "10px",
79
+ direction: "row",
80
+ justifyContent: "center",
81
+ alignItems: "center",
82
+ children: [
83
+ selectedId !== 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
84
+ description: _uitext.TOOLTIP_TEXT.resetFlameGraph,
85
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ToolbarIconButton, {
86
+ "aria-label": _uitext.TOOLTIP_TEXT.resetFlameGraph,
87
+ onClick: ()=>onSelectedIdChange(0),
88
+ color: "primary",
89
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Refresh.default, {
90
+ fontSize: "small"
91
+ })
92
+ })
93
+ }),
94
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
95
+ children: [
96
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
97
+ description: _uitext.TOOLTIP_TEXT.changeColorSheme,
98
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ToolbarIconButton, {
99
+ id: "change-color-sheme-button",
100
+ "aria-label": _uitext.TOOLTIP_TEXT.changeColorSheme,
101
+ "aria-controls": open ? 'change-color-sheme-menu' : undefined,
102
+ "aria-haspopup": "true",
103
+ "aria-expanded": open ? 'true' : undefined,
104
+ onClick: handleChangeColorShemeClick,
105
+ color: "primary",
106
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Palette.default, {
107
+ fontSize: "small"
108
+ })
109
+ })
110
+ }),
111
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Menu, {
112
+ id: "change-color-sheme-menu",
113
+ slotProps: {
114
+ list: {
115
+ 'aria-labelledby': 'change-color-sheme-button'
116
+ }
117
+ },
118
+ anchorEl: anchorEl,
119
+ open: open,
120
+ onClose: handleClose,
121
+ slots: {
122
+ transition: _material.Fade
123
+ },
124
+ anchorOrigin: {
125
+ vertical: 'bottom',
126
+ horizontal: 'center'
127
+ },
128
+ transformOrigin: {
129
+ vertical: 'top',
130
+ horizontal: 'center'
131
+ },
132
+ sx: {
133
+ mt: 1,
134
+ '& .MuiPaper-root': {
135
+ backgroundColor: theme.palette.background.paper,
136
+ padding: '0 5px'
137
+ },
138
+ '& .MuiMenuItem-root:hover': {
139
+ backgroundColor: theme.palette.action.hover
140
+ }
141
+ },
142
+ children: [
143
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
144
+ onClick: handleByPackageNameClick,
145
+ selected: value.palette === 'package-name',
146
+ children: "By package name"
147
+ }),
148
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
149
+ onClick: handleByValueClick,
150
+ selected: value.palette === 'value',
151
+ children: "By value"
152
+ })
153
+ ]
154
+ })
155
+ ]
156
+ }),
157
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
158
+ direction: "row",
159
+ sx: {
160
+ border: `1px solid ${theme.palette.primary.main}`,
161
+ borderRadius: `${theme.shape.borderRadius}px`,
162
+ padding: '2px'
163
+ },
164
+ children: [
165
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
166
+ description: _uitext.TOOLTIP_TEXT.showTable,
167
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
168
+ variant: isTableSelected() ? 'contained' : 'text',
169
+ color: "primary",
170
+ size: "small",
171
+ onClick: ()=>onDisplayChange('table'),
172
+ sx: customButtonStyle,
173
+ children: "Table"
174
+ })
175
+ }),
176
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
177
+ description: _uitext.TOOLTIP_TEXT.showFlameGraph,
178
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
179
+ variant: isFlameGraphSelected() ? 'contained' : 'text',
180
+ color: "primary",
181
+ size: "small",
182
+ onClick: ()=>onDisplayChange('flame-graph'),
183
+ sx: customButtonStyle,
184
+ children: "Flame Graph"
185
+ })
186
+ }),
187
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
188
+ description: _uitext.TOOLTIP_TEXT.showBoth,
189
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
190
+ variant: isBothSelected() ? 'contained' : 'text',
191
+ color: "primary",
192
+ size: "small",
193
+ onClick: ()=>onDisplayChange('both'),
194
+ sx: customButtonStyle,
195
+ children: "Both"
196
+ })
197
+ })
198
+ ]
199
+ })
200
+ ]
201
+ });
202
+ }
@@ -0,0 +1,37 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License | Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing | software
9
+ // distributed under the License is distributed on an "AS IS" BASIS |
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND | either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "SwitchSelector", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return SwitchSelector;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _components = require("@perses-dev/components");
25
+ const _material = require("@mui/material");
26
+ function SwitchSelector({ onChange, value, label }) {
27
+ const handleValuesChange = (_, checked)=>{
28
+ onChange(checked);
29
+ };
30
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
31
+ label: label,
32
+ control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
33
+ checked: value,
34
+ onChange: handleValuesChange
35
+ })
36
+ });
37
+ }