@perses-dev/heatmap-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.
- package/LICENSE +201 -0
- package/README.md +23 -0
- package/__mf/css/async/341.2a93d99b.css +1 -0
- package/__mf/css/async/759.2a93d99b.css +1 -0
- package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
- package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
- package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
- package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
- package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
- package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
- package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
- package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
- package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
- package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
- package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
- package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
- package/__mf/js/HeatMapChart.81916a67.js +5 -0
- package/__mf/js/async/173.c3418567.js +2 -0
- package/__mf/js/async/173.c3418567.js.LICENSE.txt +19 -0
- package/__mf/js/async/293.f3a89fef.js +1 -0
- package/__mf/js/async/469.15f49b0f.js +71 -0
- package/__mf/js/async/469.15f49b0f.js.LICENSE.txt +21 -0
- package/__mf/js/async/482.cd2ab58b.js +83 -0
- package/__mf/js/async/482.cd2ab58b.js.LICENSE.txt +61 -0
- package/__mf/js/async/774.0d1a003f.js +1 -0
- package/__mf/js/async/790.930331af.js +1 -0
- package/__mf/js/async/863.e810bfc4.js +2 -0
- package/__mf/js/async/863.e810bfc4.js.LICENSE.txt +9 -0
- package/__mf/js/async/934.6f607fed.js +2 -0
- package/__mf/js/async/934.6f607fed.js.LICENSE.txt +37 -0
- package/__mf/js/async/964.944e7b15.js +2 -0
- package/__mf/js/async/964.944e7b15.js.LICENSE.txt +9 -0
- package/__mf/js/async/981.75e172bb.js +2 -0
- package/__mf/js/async/981.75e172bb.js.LICENSE.txt +8 -0
- package/__mf/js/async/__federation_expose_HeatMapChart.ab402c3a.js +23 -0
- package/__mf/js/main.24d16ad6.js +5 -0
- package/lib/HeatMapChart.d.ts +8 -0
- package/lib/HeatMapChart.d.ts.map +1 -0
- package/lib/HeatMapChart.js +34 -0
- package/lib/HeatMapChart.js.map +1 -0
- package/lib/bootstrap.d.ts +2 -0
- package/lib/bootstrap.d.ts.map +1 -0
- package/lib/bootstrap.js +19 -0
- package/lib/bootstrap.js.map +1 -0
- package/lib/cjs/HeatMapChart.js +40 -0
- package/lib/cjs/bootstrap.js +26 -0
- package/lib/cjs/components/HeatMapChart.js +149 -0
- package/lib/cjs/components/HeatMapChartOptionsEditorSettings.js +85 -0
- package/lib/cjs/components/HeatMapChartPanel.js +178 -0
- package/lib/cjs/components/HeatMapTooltip.js +58 -0
- package/lib/cjs/components/index.js +32 -0
- package/lib/cjs/env.d.js +14 -0
- package/lib/cjs/getPluginModule.js +27 -0
- package/lib/cjs/heat-map-chart-model.js +56 -0
- package/lib/cjs/index-federation.js +55 -0
- package/lib/cjs/index.js +47 -0
- package/lib/cjs/setup-tests.js +19 -0
- package/lib/cjs/utils/data-transform.js +34 -0
- package/lib/cjs/utils/get-formatted-axis-label.js +48 -0
- package/lib/cjs/utils/index.js +32 -0
- package/lib/cjs/utils/thresholds.js +22 -0
- package/lib/components/HeatMapChart.d.ts +27 -0
- package/lib/components/HeatMapChart.d.ts.map +1 -0
- package/lib/components/HeatMapChart.js +141 -0
- package/lib/components/HeatMapChart.js.map +1 -0
- package/lib/components/HeatMapChartOptionsEditorSettings.d.ts +4 -0
- package/lib/components/HeatMapChartOptionsEditorSettings.d.ts.map +1 -0
- package/lib/components/HeatMapChartOptionsEditorSettings.js +72 -0
- package/lib/components/HeatMapChartOptionsEditorSettings.js.map +1 -0
- package/lib/components/HeatMapChartPanel.d.ts +7 -0
- package/lib/components/HeatMapChartPanel.d.ts.map +1 -0
- package/lib/components/HeatMapChartPanel.js +165 -0
- package/lib/components/HeatMapChartPanel.js.map +1 -0
- package/lib/components/HeatMapTooltip.d.ts +16 -0
- package/lib/components/HeatMapTooltip.d.ts.map +1 -0
- package/lib/components/HeatMapTooltip.js +50 -0
- package/lib/components/HeatMapTooltip.js.map +1 -0
- package/lib/components/index.d.ts +4 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/index.js +17 -0
- package/lib/components/index.js.map +1 -0
- package/lib/env.d.js +15 -0
- package/lib/env.d.js.map +1 -0
- package/lib/getPluginModule.d.ts +6 -0
- package/lib/getPluginModule.d.ts.map +1 -0
- package/lib/getPluginModule.js +16 -0
- package/lib/getPluginModule.js.map +1 -0
- package/lib/heat-map-chart-model.d.ts +27 -0
- package/lib/heat-map-chart-model.d.ts.map +1 -0
- package/lib/heat-map-chart-model.js +30 -0
- package/lib/heat-map-chart-model.js.map +1 -0
- package/lib/index-federation.d.ts +1 -0
- package/lib/index-federation.d.ts.map +1 -0
- package/lib/index-federation.js +15 -0
- package/lib/index-federation.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/lib/setup-tests.d.ts +2 -0
- package/lib/setup-tests.d.ts.map +1 -0
- package/lib/setup-tests.js +17 -0
- package/lib/setup-tests.js.map +1 -0
- package/lib/utils/data-transform.d.ts +5 -0
- package/lib/utils/data-transform.d.ts.map +1 -0
- package/lib/utils/data-transform.js +18 -0
- package/lib/utils/data-transform.js.map +1 -0
- package/lib/utils/get-formatted-axis-label.d.ts +2 -0
- package/lib/utils/get-formatted-axis-label.d.ts.map +1 -0
- package/lib/utils/get-formatted-axis-label.js +41 -0
- package/lib/utils/get-formatted-axis-label.js.map +1 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +17 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/thresholds.d.ts +4 -0
- package/lib/utils/thresholds.d.ts.map +1 -0
- package/lib/utils/thresholds.js +14 -0
- package/lib/utils/thresholds.js.map +1 -0
- package/mf-manifest.json +169 -0
- package/mf-stats.json +202 -0
- package/package.json +52 -0
package/lib/bootstrap.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import ReactDOM from 'react-dom/client';
|
|
16
|
+
const root = ReactDOM.createRoot(document.getElementById('root'));
|
|
17
|
+
root.render(/*#__PURE__*/ _jsx(React.StrictMode, {}));
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/bootstrap.tsx"],"sourcesContent":["// Copyright 2025 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 React from 'react';\nimport ReactDOM from 'react-dom/client';\n\nconst root = ReactDOM.createRoot(document.getElementById('root')!);\nroot.render(<React.StrictMode></React.StrictMode>);\n"],"names":["React","ReactDOM","root","createRoot","document","getElementById","render","StrictMode"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,WAAW,QAAQ;AAC1B,OAAOC,cAAc,mBAAmB;AAExC,MAAMC,OAAOD,SAASE,UAAU,CAACC,SAASC,cAAc,CAAC;AACzDH,KAAKI,MAAM,eAAC,KAACN,MAAMO,UAAU"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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, "HeatMapChart", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return HeatMapChart;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _components = require("./components");
|
|
24
|
+
const _heatmapchartmodel = require("./heat-map-chart-model");
|
|
25
|
+
const HeatMapChart = {
|
|
26
|
+
PanelComponent: _components.HeatMapChartPanel,
|
|
27
|
+
supportedQueryTypes: [
|
|
28
|
+
'TimeSeriesQuery'
|
|
29
|
+
],
|
|
30
|
+
queryOptions: {
|
|
31
|
+
mode: 'range'
|
|
32
|
+
},
|
|
33
|
+
panelOptionsEditorComponents: [
|
|
34
|
+
{
|
|
35
|
+
label: 'Settings',
|
|
36
|
+
content: _components.HeatMapChartOptionsEditorSettings
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
createInitialOptions: _heatmapchartmodel.createInitialHeatMapChartOptions
|
|
40
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
18
|
+
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
19
|
+
const _client = /*#__PURE__*/ _interop_require_default(require("react-dom/client"));
|
|
20
|
+
function _interop_require_default(obj) {
|
|
21
|
+
return obj && obj.__esModule ? obj : {
|
|
22
|
+
default: obj
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const root = _client.default.createRoot(document.getElementById('root'));
|
|
26
|
+
root.render(/*#__PURE__*/ (0, _jsxruntime.jsx)(_react.default.StrictMode, {}));
|
|
@@ -0,0 +1,149 @@
|
|
|
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, "HeatMapChart", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return HeatMapChart;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _react = require("react");
|
|
25
|
+
const _components = require("@perses-dev/components");
|
|
26
|
+
const _core = require("echarts/core");
|
|
27
|
+
const _charts = require("echarts/charts");
|
|
28
|
+
const _material = require("@mui/material");
|
|
29
|
+
const _utils = require("../utils");
|
|
30
|
+
const _HeatMapTooltip = require("./HeatMapTooltip");
|
|
31
|
+
(0, _core.use)([
|
|
32
|
+
_charts.HeatmapChart
|
|
33
|
+
]);
|
|
34
|
+
// The default coloring is a blue->yellow->red gradient
|
|
35
|
+
const DEFAULT_VISUAL_MAP_COLORS = [
|
|
36
|
+
'#313695',
|
|
37
|
+
'#4575b4',
|
|
38
|
+
'#74add1',
|
|
39
|
+
'#abd9e9',
|
|
40
|
+
'#e0f3f8',
|
|
41
|
+
'#ffffbf',
|
|
42
|
+
'#fee090',
|
|
43
|
+
'#fdae61',
|
|
44
|
+
'#f46d43',
|
|
45
|
+
'#d73027',
|
|
46
|
+
'#a50026'
|
|
47
|
+
];
|
|
48
|
+
function HeatMapChart({ width, height, data, xAxisCategories, yAxisCategories, yAxisFormat, countFormat, countMin, countMax, timeScale, showVisualMap }) {
|
|
49
|
+
const chartsTheme = (0, _components.useChartsTheme)();
|
|
50
|
+
const theme = (0, _material.useTheme)();
|
|
51
|
+
const { timeZone } = (0, _components.useTimeZone)();
|
|
52
|
+
const option = (0, _react.useMemo)(()=>{
|
|
53
|
+
return {
|
|
54
|
+
tooltip: {
|
|
55
|
+
appendToBody: true,
|
|
56
|
+
formatter: (params)=>{
|
|
57
|
+
return (0, _HeatMapTooltip.generateTooltipHTML)({
|
|
58
|
+
data: params.data.value,
|
|
59
|
+
label: params.data.label,
|
|
60
|
+
marker: params.marker,
|
|
61
|
+
xAxisCategories,
|
|
62
|
+
yAxisCategories,
|
|
63
|
+
theme,
|
|
64
|
+
yAxisFormat: yAxisFormat,
|
|
65
|
+
countFormat: countFormat
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
xAxis: {
|
|
70
|
+
type: 'category',
|
|
71
|
+
data: xAxisCategories,
|
|
72
|
+
axisLabel: {
|
|
73
|
+
hideOverlap: true,
|
|
74
|
+
formatter: (0, _utils.getFormattedHeatmapAxisLabel)(timeScale?.rangeMs ?? 0, timeZone)
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
yAxis: (0, _components.getFormattedAxis)({
|
|
78
|
+
type: 'category',
|
|
79
|
+
data: yAxisCategories
|
|
80
|
+
}, yAxisFormat),
|
|
81
|
+
visualMap: {
|
|
82
|
+
show: showVisualMap ?? false,
|
|
83
|
+
type: 'continuous',
|
|
84
|
+
min: countMin,
|
|
85
|
+
max: countMax,
|
|
86
|
+
realtime: false,
|
|
87
|
+
itemHeight: height - 30,
|
|
88
|
+
itemWidth: 10,
|
|
89
|
+
orient: 'vertical',
|
|
90
|
+
left: 'right',
|
|
91
|
+
top: 'center',
|
|
92
|
+
inRange: {
|
|
93
|
+
color: DEFAULT_VISUAL_MAP_COLORS
|
|
94
|
+
},
|
|
95
|
+
textStyle: {
|
|
96
|
+
color: theme.palette.text.primary,
|
|
97
|
+
textBorderColor: theme.palette.background.default,
|
|
98
|
+
textBorderWidth: 5
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
series: [
|
|
102
|
+
{
|
|
103
|
+
name: 'Gaussian',
|
|
104
|
+
type: 'heatmap',
|
|
105
|
+
data: data,
|
|
106
|
+
emphasis: {
|
|
107
|
+
itemStyle: {
|
|
108
|
+
borderColor: '#333',
|
|
109
|
+
borderWidth: 1
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
progressive: 1000,
|
|
113
|
+
animation: false
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
};
|
|
117
|
+
}, [
|
|
118
|
+
xAxisCategories,
|
|
119
|
+
timeScale?.rangeMs,
|
|
120
|
+
timeZone,
|
|
121
|
+
yAxisCategories,
|
|
122
|
+
yAxisFormat,
|
|
123
|
+
showVisualMap,
|
|
124
|
+
countMin,
|
|
125
|
+
countMax,
|
|
126
|
+
height,
|
|
127
|
+
theme,
|
|
128
|
+
data,
|
|
129
|
+
countFormat
|
|
130
|
+
]);
|
|
131
|
+
const chart = (0, _react.useMemo)(()=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.EChart, {
|
|
132
|
+
sx: {
|
|
133
|
+
width: width,
|
|
134
|
+
height: height,
|
|
135
|
+
padding: `${chartsTheme.container.padding.default}px`
|
|
136
|
+
},
|
|
137
|
+
option: option,
|
|
138
|
+
theme: chartsTheme.echartsTheme
|
|
139
|
+
}), [
|
|
140
|
+
chartsTheme.container.padding.default,
|
|
141
|
+
chartsTheme.echartsTheme,
|
|
142
|
+
height,
|
|
143
|
+
option,
|
|
144
|
+
width
|
|
145
|
+
]);
|
|
146
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
|
|
147
|
+
children: chart
|
|
148
|
+
});
|
|
149
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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, "HeatMapChartOptionsEditorSettings", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return HeatMapChartOptionsEditorSettings;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _material = require("@mui/material");
|
|
25
|
+
const _components = require("@perses-dev/components");
|
|
26
|
+
const _immer = require("immer");
|
|
27
|
+
const _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
|
|
28
|
+
const _heatmapchartmodel = require("../heat-map-chart-model");
|
|
29
|
+
function _interop_require_default(obj) {
|
|
30
|
+
return obj && obj.__esModule ? obj : {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function HeatMapChartOptionsEditorSettings(props) {
|
|
35
|
+
const { onChange, value } = props;
|
|
36
|
+
const handleYAxisFormatChange = (newFormat)=>{
|
|
37
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
38
|
+
draft.yAxisFormat = newFormat;
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
const handleCountFormatChange = (newFormat)=>{
|
|
42
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
43
|
+
draft.countFormat = newFormat;
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
const handleShowVisualMapChange = (_, checked)=>{
|
|
47
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
48
|
+
draft.showVisualMap = checked;
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
// ensures decimalPlaces defaults to correct value
|
|
52
|
+
const yAxisFormat = (0, _merge.default)({}, _heatmapchartmodel.DEFAULT_FORMAT, value.yAxisFormat);
|
|
53
|
+
const countFormat = (0, _merge.default)({}, _heatmapchartmodel.DEFAULT_FORMAT, value.countFormat);
|
|
54
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGrid, {
|
|
55
|
+
children: [
|
|
56
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
|
|
57
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
|
|
58
|
+
title: "Bucket Count",
|
|
59
|
+
children: [
|
|
60
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormatControls, {
|
|
61
|
+
value: countFormat,
|
|
62
|
+
onChange: handleCountFormatChange
|
|
63
|
+
}),
|
|
64
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
65
|
+
label: "Show Visual Map",
|
|
66
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
67
|
+
checked: !!value.showVisualMap,
|
|
68
|
+
onChange: handleShowVisualMapChange
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
})
|
|
73
|
+
}),
|
|
74
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
|
|
75
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorGroup, {
|
|
76
|
+
title: "Y Axis",
|
|
77
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormatControls, {
|
|
78
|
+
value: yAxisFormat,
|
|
79
|
+
onChange: handleYAxisFormatChange
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
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, "HeatMapChartPanel", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return HeatMapChartPanel;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _material = require("@mui/material");
|
|
25
|
+
const _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
|
|
26
|
+
const _react = require("react");
|
|
27
|
+
const _heatmapchartmodel = require("../heat-map-chart-model");
|
|
28
|
+
const _utils = require("../utils");
|
|
29
|
+
const _HeatMapChart = require("./HeatMapChart");
|
|
30
|
+
function _interop_require_default(obj) {
|
|
31
|
+
return obj && obj.__esModule ? obj : {
|
|
32
|
+
default: obj
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const HEATMAP_MIN_HEIGHT = 200;
|
|
36
|
+
const HEATMAP_ITEM_MIN_HEIGHT = 2;
|
|
37
|
+
function HeatMapChartPanel(props) {
|
|
38
|
+
const { spec: pluginSpec, contentDimensions, queryResults } = props;
|
|
39
|
+
// ensures all default format properties set if undef
|
|
40
|
+
const yAxisFormat = (0, _merge.default)({}, _heatmapchartmodel.DEFAULT_FORMAT, pluginSpec.yAxisFormat);
|
|
41
|
+
const countFormat = (0, _merge.default)({}, _heatmapchartmodel.DEFAULT_FORMAT, pluginSpec.countFormat);
|
|
42
|
+
const { data, xAxisCategories, yAxisCategories, countMin, countMax, timeScale } = (0, _react.useMemo)(()=>{
|
|
43
|
+
if (!queryResults || queryResults.length === 0) {
|
|
44
|
+
return {
|
|
45
|
+
data: [],
|
|
46
|
+
xAxisCategories: [],
|
|
47
|
+
yAxisCategories: [],
|
|
48
|
+
countMin: 0,
|
|
49
|
+
countMax: 0,
|
|
50
|
+
timeScale: undefined
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (queryResults.length != 1 || queryResults[0].data.series.length != 1 || queryResults[0].data.series[0].histograms === undefined) {
|
|
54
|
+
return {
|
|
55
|
+
data: [],
|
|
56
|
+
xAxisCategories: [],
|
|
57
|
+
yAxisCategories: [],
|
|
58
|
+
countMin: 0,
|
|
59
|
+
countMax: 0,
|
|
60
|
+
timeScale: undefined
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const series = queryResults[0].data.series[0];
|
|
64
|
+
const timeScale = (0, _utils.getCommonTimeScaleForQueries)(queryResults);
|
|
65
|
+
const xAxisCategories = (0, _utils.generateCompleteTimestamps)(timeScale);
|
|
66
|
+
// Dummy value that will be replaced at the first iteration
|
|
67
|
+
let lowestBound = Infinity;
|
|
68
|
+
let highestBound = -Infinity;
|
|
69
|
+
let countMin = Infinity;
|
|
70
|
+
let countMax = -Infinity;
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
72
|
+
for (const [_, histogram] of series?.histograms ?? []){
|
|
73
|
+
for (const bucket of histogram?.buckets ?? []){
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
75
|
+
const [_, lowerBound, upperBound, count] = bucket;
|
|
76
|
+
const lowerBoundFloat = parseFloat(lowerBound);
|
|
77
|
+
const upperBoundFloat = parseFloat(upperBound);
|
|
78
|
+
const countFloat = parseFloat(count);
|
|
79
|
+
if (lowerBoundFloat < lowestBound) {
|
|
80
|
+
lowestBound = lowerBoundFloat;
|
|
81
|
+
}
|
|
82
|
+
if (upperBoundFloat > highestBound) {
|
|
83
|
+
highestBound = upperBoundFloat;
|
|
84
|
+
}
|
|
85
|
+
if (countFloat < countMin) {
|
|
86
|
+
countMin = countFloat;
|
|
87
|
+
}
|
|
88
|
+
if (countFloat > countMax) {
|
|
89
|
+
countMax = countFloat;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const height = contentDimensions?.height ?? HEATMAP_MIN_HEIGHT;
|
|
94
|
+
const totalRange = highestBound - lowestBound;
|
|
95
|
+
const rangePerItem = totalRange * HEATMAP_ITEM_MIN_HEIGHT / height;
|
|
96
|
+
const totalItems = Math.ceil(height / HEATMAP_ITEM_MIN_HEIGHT);
|
|
97
|
+
// Generating value of the Y axis based on the height divided by the size of a cell (item)
|
|
98
|
+
const yAxisCategories = Array.from({
|
|
99
|
+
length: totalItems
|
|
100
|
+
}, (_, index)=>(lowestBound + index * rangePerItem).toFixed(3));
|
|
101
|
+
const data = [];
|
|
102
|
+
// Logic for filling all cells where a bucket is present
|
|
103
|
+
for (const [time, histogram] of series?.histograms ?? []){
|
|
104
|
+
const itemIndexOnXaxis = xAxisCategories.findIndex((v)=>v === time * 1000);
|
|
105
|
+
for (const bucket of histogram?.buckets ?? []){
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
107
|
+
const [_, lowerBound, upperBound, count] = bucket;
|
|
108
|
+
const yLowerBoundItem = Math.floor((parseFloat(lowerBound) - lowestBound) / rangePerItem);
|
|
109
|
+
const yUpperBoundItem = Math.ceil((parseFloat(upperBound) - lowestBound) / rangePerItem);
|
|
110
|
+
for(let i = 0; i < yUpperBoundItem - yLowerBoundItem; i++){
|
|
111
|
+
// TODO: some bucket may have overlapping cells, we could use avg value. Probably will need to move to a matrix data structure for performance reasons
|
|
112
|
+
data.push({
|
|
113
|
+
value: [
|
|
114
|
+
itemIndexOnXaxis,
|
|
115
|
+
yLowerBoundItem + i,
|
|
116
|
+
parseFloat(count)
|
|
117
|
+
],
|
|
118
|
+
label: count
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
data,
|
|
125
|
+
xAxisCategories,
|
|
126
|
+
yAxisCategories,
|
|
127
|
+
countMin,
|
|
128
|
+
countMax,
|
|
129
|
+
timeScale
|
|
130
|
+
};
|
|
131
|
+
}, [
|
|
132
|
+
contentDimensions?.height,
|
|
133
|
+
queryResults
|
|
134
|
+
]);
|
|
135
|
+
// TODO: add support for multiple queries
|
|
136
|
+
if (queryResults.length > 1) {
|
|
137
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
138
|
+
justifyContent: "center",
|
|
139
|
+
height: "100%",
|
|
140
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
141
|
+
variant: "body2",
|
|
142
|
+
textAlign: "center",
|
|
143
|
+
children: "Only one query at a time is supported for now"
|
|
144
|
+
})
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
// Mo data message handled inside chart component
|
|
148
|
+
if (data.length === 0) {
|
|
149
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
150
|
+
justifyContent: "center",
|
|
151
|
+
height: "100%",
|
|
152
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
153
|
+
variant: "body2",
|
|
154
|
+
textAlign: "center",
|
|
155
|
+
children: "No data available (only native histograms are supported for now)"
|
|
156
|
+
})
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (contentDimensions === undefined) return null;
|
|
160
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
161
|
+
direction: "row",
|
|
162
|
+
justifyContent: "center",
|
|
163
|
+
alignItems: "center",
|
|
164
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_HeatMapChart.HeatMapChart, {
|
|
165
|
+
width: contentDimensions.width,
|
|
166
|
+
height: contentDimensions.height,
|
|
167
|
+
data: data,
|
|
168
|
+
xAxisCategories: xAxisCategories,
|
|
169
|
+
yAxisCategories: yAxisCategories,
|
|
170
|
+
yAxisFormat: yAxisFormat,
|
|
171
|
+
countFormat: countFormat,
|
|
172
|
+
countMin: countMin,
|
|
173
|
+
countMax: countMax,
|
|
174
|
+
timeScale: timeScale,
|
|
175
|
+
showVisualMap: pluginSpec.showVisualMap
|
|
176
|
+
})
|
|
177
|
+
});
|
|
178
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "generateTooltipHTML", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return generateTooltipHTML;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _components = require("@perses-dev/components");
|
|
25
|
+
const _core = require("@perses-dev/core");
|
|
26
|
+
function generateTooltipHTML({ data, label, marker, xAxisCategories, yAxisCategories, theme, yAxisFormat, countFormat }) {
|
|
27
|
+
const [x, y] = data;
|
|
28
|
+
const xAxisLabel = xAxisCategories[x];
|
|
29
|
+
const { formattedDate, formattedTime } = (0, _components.getDateAndTime)(xAxisLabel);
|
|
30
|
+
const tooltipHeader = (0, _material.css)`
|
|
31
|
+
border-bottom: 1px solid ${theme.palette.grey[500]};
|
|
32
|
+
padding-bottom: 8px;
|
|
33
|
+
`;
|
|
34
|
+
const tooltipContentStyles = (0, _material.css)`
|
|
35
|
+
display: flex;
|
|
36
|
+
justify-content: space-between;
|
|
37
|
+
padding-top: 8px;
|
|
38
|
+
`;
|
|
39
|
+
const labelStyles = (0, _material.css)`
|
|
40
|
+
margin-right: 16px;
|
|
41
|
+
`;
|
|
42
|
+
const lowerBound = parseFloat(yAxisCategories[y]);
|
|
43
|
+
const upperBound = yAxisCategories[y + 1] ? parseFloat(yAxisCategories[y + 1]) : parseFloat(yAxisCategories[y]) + parseFloat(yAxisCategories[y]) - parseFloat(yAxisCategories[y - 1]); // Top cell, upper bound need to be calculated from previous cell
|
|
44
|
+
return `
|
|
45
|
+
<div>
|
|
46
|
+
<div style="${tooltipHeader.styles}">${formattedDate} ${formattedTime}</div>
|
|
47
|
+
<div style="${tooltipContentStyles.styles}">
|
|
48
|
+
<div style="${labelStyles.styles}">
|
|
49
|
+
${marker}
|
|
50
|
+
<strong>${(0, _core.formatValue)(lowerBound, yAxisFormat)} - ${(0, _core.formatValue)(upperBound, yAxisFormat)}</strong>
|
|
51
|
+
</div>
|
|
52
|
+
<div>
|
|
53
|
+
${(0, _core.formatValue)(parseFloat(label), countFormat)}
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
_export_star(require("./HeatMapChartOptionsEditorSettings"), exports);
|
|
18
|
+
_export_star(require("./HeatMapChartPanel"), exports);
|
|
19
|
+
_export_star(require("./HeatMapChart"), exports);
|
|
20
|
+
function _export_star(from, to) {
|
|
21
|
+
Object.keys(from).forEach(function(k) {
|
|
22
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
23
|
+
Object.defineProperty(to, k, {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return from[k];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return from;
|
|
32
|
+
}
|
package/lib/cjs/env.d.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
/// <reference types="@rsbuild/core/types" />
|
|
14
|
+
"use strict";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getPluginModule", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getPluginModule;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function getPluginModule() {
|
|
18
|
+
const { name, version, perses } = _packagejson.default;
|
|
19
|
+
return {
|
|
20
|
+
kind: 'PluginModule',
|
|
21
|
+
metadata: {
|
|
22
|
+
name,
|
|
23
|
+
version
|
|
24
|
+
},
|
|
25
|
+
spec: perses
|
|
26
|
+
};
|
|
27
|
+
}
|