@perses-dev/histogram-chart-plugin 0.9.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.1e19d050.css +1 -0
- package/__mf/css/async/759.1e19d050.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/HistogramChart.93af6e55.js +5 -0
- package/__mf/js/async/173.1e8a2c14.js +2 -0
- package/__mf/js/async/173.1e8a2c14.js.LICENSE.txt +19 -0
- package/__mf/js/async/293.280a8f4f.js +1 -0
- package/__mf/js/async/39.719defa2.js +144 -0
- package/__mf/js/async/39.719defa2.js.LICENSE.txt +21 -0
- package/__mf/js/async/774.b18c4a5c.js +1 -0
- package/__mf/js/async/790.15c77240.js +1 -0
- package/__mf/js/async/814.7ccaa658.js +10 -0
- package/__mf/js/async/814.7ccaa658.js.LICENSE.txt +61 -0
- package/__mf/js/async/863.bd42f0c4.js +2 -0
- package/__mf/js/async/863.bd42f0c4.js.LICENSE.txt +9 -0
- package/__mf/js/async/934.27722fd3.js +2 -0
- package/__mf/js/async/934.27722fd3.js.LICENSE.txt +37 -0
- package/__mf/js/async/964.b6419e33.js +2 -0
- package/__mf/js/async/964.b6419e33.js.LICENSE.txt +9 -0
- package/__mf/js/async/981.b29ba452.js +2 -0
- package/__mf/js/async/981.b29ba452.js.LICENSE.txt +8 -0
- package/__mf/js/async/__federation_expose_HistogramChart.d98de268.js +1 -0
- package/__mf/js/main.534b29fb.js +5 -0
- package/lib/HistogramChart.d.ts +8 -0
- package/lib/HistogramChart.d.ts.map +1 -0
- package/lib/HistogramChart.js +34 -0
- package/lib/HistogramChart.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/HistogramChart.js +40 -0
- package/lib/cjs/bootstrap.js +26 -0
- package/lib/cjs/components/HistogramChart.js +154 -0
- package/lib/cjs/components/HistogramChartOptionsEditorSettings.js +120 -0
- package/lib/cjs/components/HistogramChartPanel.js +103 -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/histogram-chart-model.js +60 -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/index.js +30 -0
- package/lib/cjs/utils/thresholds.js +22 -0
- package/lib/components/HistogramChart.d.ts +16 -0
- package/lib/components/HistogramChart.d.ts.map +1 -0
- package/lib/components/HistogramChart.js +146 -0
- package/lib/components/HistogramChart.js.map +1 -0
- package/lib/components/HistogramChartOptionsEditorSettings.d.ts +4 -0
- package/lib/components/HistogramChartOptionsEditorSettings.d.ts.map +1 -0
- package/lib/components/HistogramChartOptionsEditorSettings.js +107 -0
- package/lib/components/HistogramChartOptionsEditorSettings.js.map +1 -0
- package/lib/components/HistogramChartPanel.d.ts +7 -0
- package/lib/components/HistogramChartPanel.d.ts.map +1 -0
- package/lib/components/HistogramChartPanel.js +90 -0
- package/lib/components/HistogramChartPanel.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/histogram-chart-model.d.ts +29 -0
- package/lib/histogram-chart-model.d.ts.map +1 -0
- package/lib/histogram-chart-model.js +31 -0
- package/lib/histogram-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/index.d.ts +2 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +15 -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 +199 -0
- package/package.json +55 -0
|
@@ -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, "HistogramChart", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return HistogramChart;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _components = require("./components");
|
|
24
|
+
const _histogramchartmodel = require("./histogram-chart-model");
|
|
25
|
+
const HistogramChart = {
|
|
26
|
+
PanelComponent: _components.HistogramChartPanel,
|
|
27
|
+
supportedQueryTypes: [
|
|
28
|
+
'TimeSeriesQuery'
|
|
29
|
+
],
|
|
30
|
+
queryOptions: {
|
|
31
|
+
mode: 'instant'
|
|
32
|
+
},
|
|
33
|
+
panelOptionsEditorComponents: [
|
|
34
|
+
{
|
|
35
|
+
label: 'Settings',
|
|
36
|
+
content: _components.HistogramChartOptionsEditorSettings
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
createInitialOptions: _histogramchartmodel.createInitialHistogramChartOptions
|
|
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,154 @@
|
|
|
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, "HistogramChart", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return HistogramChart;
|
|
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 _utils = require("../utils");
|
|
29
|
+
(0, _core.use)([
|
|
30
|
+
_charts.CustomChart
|
|
31
|
+
]);
|
|
32
|
+
function HistogramChart({ width, height, data, format, min, max, thresholds }) {
|
|
33
|
+
const chartsTheme = (0, _components.useChartsTheme)();
|
|
34
|
+
const transformedData = (0, _react.useMemo)(()=>{
|
|
35
|
+
return data.buckets.map(([bucket, lowerBound, upperBound, count])=>{
|
|
36
|
+
return {
|
|
37
|
+
value: [
|
|
38
|
+
parseFloat(lowerBound),
|
|
39
|
+
parseFloat(upperBound),
|
|
40
|
+
parseFloat(count),
|
|
41
|
+
bucket
|
|
42
|
+
],
|
|
43
|
+
itemStyle: {
|
|
44
|
+
color: (0, _utils.getColorFromThresholds)(parseFloat(lowerBound), thresholds, chartsTheme, chartsTheme.echartsTheme[0])
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}, [
|
|
49
|
+
chartsTheme,
|
|
50
|
+
data.buckets,
|
|
51
|
+
thresholds
|
|
52
|
+
]);
|
|
53
|
+
const minXAxis = (0, _react.useMemo)(()=>{
|
|
54
|
+
if (min) {
|
|
55
|
+
return min;
|
|
56
|
+
}
|
|
57
|
+
if (transformedData && transformedData[0]) {
|
|
58
|
+
return Math.min(0, Math.floor(transformedData[0]?.value[0] ?? 0));
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}, [
|
|
62
|
+
min,
|
|
63
|
+
transformedData
|
|
64
|
+
]);
|
|
65
|
+
const maxXAxis = (0, _react.useMemo)(()=>{
|
|
66
|
+
if (max) {
|
|
67
|
+
return max;
|
|
68
|
+
}
|
|
69
|
+
if (transformedData && transformedData[transformedData.length - 1]) {
|
|
70
|
+
return Math.ceil(transformedData[transformedData.length - 1]?.value[1] ?? 1);
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}, [
|
|
74
|
+
max,
|
|
75
|
+
transformedData
|
|
76
|
+
]);
|
|
77
|
+
const option = (0, _react.useMemo)(()=>{
|
|
78
|
+
if (!transformedData) return chartsTheme.noDataOption;
|
|
79
|
+
return {
|
|
80
|
+
title: {
|
|
81
|
+
show: false
|
|
82
|
+
},
|
|
83
|
+
tooltip: {},
|
|
84
|
+
xAxis: {
|
|
85
|
+
scale: false,
|
|
86
|
+
min: minXAxis,
|
|
87
|
+
max: maxXAxis
|
|
88
|
+
},
|
|
89
|
+
yAxis: (0, _components.getFormattedAxis)({}, format),
|
|
90
|
+
series: [
|
|
91
|
+
{
|
|
92
|
+
type: 'custom',
|
|
93
|
+
renderItem: function(params, api) {
|
|
94
|
+
const yValue = api.value(2);
|
|
95
|
+
const start = api.coord([
|
|
96
|
+
api.value(0),
|
|
97
|
+
yValue
|
|
98
|
+
]);
|
|
99
|
+
const size = api.size?.([
|
|
100
|
+
api.value(1) - api.value(0),
|
|
101
|
+
yValue
|
|
102
|
+
]);
|
|
103
|
+
const style = api.style?.();
|
|
104
|
+
return {
|
|
105
|
+
type: 'rect',
|
|
106
|
+
shape: {
|
|
107
|
+
x: start[0],
|
|
108
|
+
y: start[1],
|
|
109
|
+
width: size[0],
|
|
110
|
+
height: size[1]
|
|
111
|
+
},
|
|
112
|
+
style: style
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
label: {
|
|
116
|
+
show: false
|
|
117
|
+
},
|
|
118
|
+
dimensions: [
|
|
119
|
+
'from',
|
|
120
|
+
'to'
|
|
121
|
+
],
|
|
122
|
+
encode: {
|
|
123
|
+
x: [
|
|
124
|
+
0,
|
|
125
|
+
1
|
|
126
|
+
],
|
|
127
|
+
y: 2,
|
|
128
|
+
tooltip: [
|
|
129
|
+
0,
|
|
130
|
+
1
|
|
131
|
+
],
|
|
132
|
+
itemName: 2
|
|
133
|
+
},
|
|
134
|
+
data: transformedData
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
};
|
|
138
|
+
}, [
|
|
139
|
+
chartsTheme.noDataOption,
|
|
140
|
+
format,
|
|
141
|
+
maxXAxis,
|
|
142
|
+
minXAxis,
|
|
143
|
+
transformedData
|
|
144
|
+
]);
|
|
145
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.EChart, {
|
|
146
|
+
sx: {
|
|
147
|
+
width: width,
|
|
148
|
+
height: height,
|
|
149
|
+
padding: `${chartsTheme.container.padding.default}px`
|
|
150
|
+
},
|
|
151
|
+
option: option,
|
|
152
|
+
theme: chartsTheme.echartsTheme
|
|
153
|
+
});
|
|
154
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
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, "HistogramChartOptionsEditorSettings", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return HistogramChartOptionsEditorSettings;
|
|
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 _histogramchartmodel = require("../histogram-chart-model");
|
|
29
|
+
function _interop_require_default(obj) {
|
|
30
|
+
return obj && obj.__esModule ? obj : {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function HistogramChartOptionsEditorSettings(props) {
|
|
35
|
+
const { onChange, value } = props;
|
|
36
|
+
const handleUnitChange = (newFormat)=>{
|
|
37
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
38
|
+
draft.format = newFormat;
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
const handleThresholdsChange = (thresholds)=>{
|
|
42
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
43
|
+
draft.thresholds = thresholds;
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
// ensures decimalPlaces defaults to correct value
|
|
47
|
+
const format = (0, _merge.default)({}, _histogramchartmodel.DEFAULT_FORMAT, value.format);
|
|
48
|
+
const thresholds = (0, _merge.default)({}, _histogramchartmodel.DEFAULT_THRESHOLDS, value.thresholds);
|
|
49
|
+
// max only needs to be set explicitly for units other than percent and percent-decimal
|
|
50
|
+
let minPlaceholder = 'Enter value';
|
|
51
|
+
if (format.unit === 'percent') {
|
|
52
|
+
minPlaceholder = _histogramchartmodel.DEFAULT_MIN_PERCENT.toString();
|
|
53
|
+
} else if (format.unit === 'percent-decimal') {
|
|
54
|
+
minPlaceholder = _histogramchartmodel.DEFAULT_MIN_PERCENT_DECIMAL.toString();
|
|
55
|
+
}
|
|
56
|
+
// max only needs to be set explicitly for units other than percent and percent-decimal
|
|
57
|
+
let maxPlaceholder = 'Enter value';
|
|
58
|
+
if (format.unit === 'percent') {
|
|
59
|
+
maxPlaceholder = _histogramchartmodel.DEFAULT_MAX_PERCENT.toString();
|
|
60
|
+
} else if (format.unit === 'percent-decimal') {
|
|
61
|
+
maxPlaceholder = _histogramchartmodel.DEFAULT_MAX_PERCENT_DECIMAL.toString();
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGrid, {
|
|
64
|
+
children: [
|
|
65
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
|
|
66
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
|
|
67
|
+
title: "Misc",
|
|
68
|
+
children: [
|
|
69
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormatControls, {
|
|
70
|
+
value: format,
|
|
71
|
+
onChange: handleUnitChange
|
|
72
|
+
}),
|
|
73
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
74
|
+
label: "Min",
|
|
75
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
76
|
+
type: "number",
|
|
77
|
+
value: value.min ?? '',
|
|
78
|
+
onChange: (e)=>{
|
|
79
|
+
// ensure empty value resets to undef to allow chart to calculate max
|
|
80
|
+
const newValue = e.target.value ? Number(e.target.value) : undefined;
|
|
81
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
82
|
+
draft.min = newValue;
|
|
83
|
+
}));
|
|
84
|
+
},
|
|
85
|
+
placeholder: minPlaceholder,
|
|
86
|
+
sx: {
|
|
87
|
+
width: '100%'
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
}),
|
|
91
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
92
|
+
label: "Max",
|
|
93
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
94
|
+
type: "number",
|
|
95
|
+
value: value.max ?? '',
|
|
96
|
+
onChange: (e)=>{
|
|
97
|
+
// ensure empty value resets to undef to allow chart to calculate max
|
|
98
|
+
const newValue = e.target.value ? Number(e.target.value) : undefined;
|
|
99
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
100
|
+
draft.max = newValue;
|
|
101
|
+
}));
|
|
102
|
+
},
|
|
103
|
+
placeholder: maxPlaceholder,
|
|
104
|
+
sx: {
|
|
105
|
+
width: '100%'
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
|
|
113
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ThresholdsEditor, {
|
|
114
|
+
thresholds: thresholds,
|
|
115
|
+
onChange: handleThresholdsChange
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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, "HistogramChartPanel", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return HistogramChartPanel;
|
|
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 _components = require("@perses-dev/components");
|
|
28
|
+
const _histogramchartmodel = require("../histogram-chart-model");
|
|
29
|
+
const _HistogramChart = require("./HistogramChart");
|
|
30
|
+
function _interop_require_default(obj) {
|
|
31
|
+
return obj && obj.__esModule ? obj : {
|
|
32
|
+
default: obj
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const HISTOGRAM_MIN_WIDTH = 90;
|
|
36
|
+
function HistogramChartPanel(props) {
|
|
37
|
+
const { spec: pluginSpec, contentDimensions, queryResults } = props;
|
|
38
|
+
const { min, max } = pluginSpec;
|
|
39
|
+
const chartsTheme = (0, _components.useChartsTheme)();
|
|
40
|
+
// ensures all default format properties set if undef
|
|
41
|
+
const format = (0, _merge.default)({}, _histogramchartmodel.DEFAULT_FORMAT, pluginSpec.format);
|
|
42
|
+
const thresholds = (0, _merge.default)({}, _histogramchartmodel.DEFAULT_THRESHOLDS, pluginSpec.thresholds);
|
|
43
|
+
const histogramData = (0, _react.useMemo)(()=>{
|
|
44
|
+
const histograms = [];
|
|
45
|
+
for (const result of queryResults){
|
|
46
|
+
for (const timeSeries of result.data.series){
|
|
47
|
+
if (!timeSeries.histograms || timeSeries.histograms.length === 0) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const [, histoBuckets] = timeSeries.histograms[0];
|
|
51
|
+
if (histoBuckets && histoBuckets.buckets) {
|
|
52
|
+
histograms.push({
|
|
53
|
+
buckets: histoBuckets.buckets
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return histograms;
|
|
59
|
+
}, [
|
|
60
|
+
queryResults
|
|
61
|
+
]);
|
|
62
|
+
// no data message handled inside chart component
|
|
63
|
+
if (histogramData.length === 0) {
|
|
64
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
65
|
+
justifyContent: "center",
|
|
66
|
+
height: "100%",
|
|
67
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
68
|
+
variant: "body2",
|
|
69
|
+
textAlign: "center",
|
|
70
|
+
children: "No data available (only native histograms are supported for now)"
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (contentDimensions === undefined) return null;
|
|
75
|
+
// accounts for showing a separate chart for each time series
|
|
76
|
+
let chartWidth = contentDimensions.width / histogramData.length - chartsTheme.container.padding.default;
|
|
77
|
+
if (chartWidth < HISTOGRAM_MIN_WIDTH && histogramData.length > 1) {
|
|
78
|
+
// enables horizontal scroll when charts overflow outside of panel
|
|
79
|
+
chartWidth = HISTOGRAM_MIN_WIDTH;
|
|
80
|
+
}
|
|
81
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
82
|
+
direction: "row",
|
|
83
|
+
justifyContent: "center",
|
|
84
|
+
alignItems: "center",
|
|
85
|
+
sx: {
|
|
86
|
+
// so scrollbar only shows when necessary
|
|
87
|
+
overflowX: histogramData.length > 1 ? 'scroll' : 'auto'
|
|
88
|
+
},
|
|
89
|
+
children: histogramData.map((series, seriesIndex)=>{
|
|
90
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
91
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_HistogramChart.HistogramChart, {
|
|
92
|
+
width: chartWidth,
|
|
93
|
+
height: contentDimensions.height,
|
|
94
|
+
data: series,
|
|
95
|
+
format: format,
|
|
96
|
+
min: min,
|
|
97
|
+
max: max,
|
|
98
|
+
thresholds: thresholds
|
|
99
|
+
})
|
|
100
|
+
}, `histogram-series-${seriesIndex}`);
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
}
|
|
@@ -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("./HistogramChartOptionsEditorSettings"), exports);
|
|
18
|
+
_export_star(require("./HistogramChartPanel"), exports);
|
|
19
|
+
_export_star(require("./HistogramChart"), 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
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
DEFAULT_FORMAT: function() {
|
|
25
|
+
return DEFAULT_FORMAT;
|
|
26
|
+
},
|
|
27
|
+
DEFAULT_MAX_PERCENT: function() {
|
|
28
|
+
return DEFAULT_MAX_PERCENT;
|
|
29
|
+
},
|
|
30
|
+
DEFAULT_MAX_PERCENT_DECIMAL: function() {
|
|
31
|
+
return DEFAULT_MAX_PERCENT_DECIMAL;
|
|
32
|
+
},
|
|
33
|
+
DEFAULT_MIN_PERCENT: function() {
|
|
34
|
+
return DEFAULT_MIN_PERCENT;
|
|
35
|
+
},
|
|
36
|
+
DEFAULT_MIN_PERCENT_DECIMAL: function() {
|
|
37
|
+
return DEFAULT_MIN_PERCENT_DECIMAL;
|
|
38
|
+
},
|
|
39
|
+
DEFAULT_THRESHOLDS: function() {
|
|
40
|
+
return DEFAULT_THRESHOLDS;
|
|
41
|
+
},
|
|
42
|
+
createInitialHistogramChartOptions: function() {
|
|
43
|
+
return createInitialHistogramChartOptions;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const DEFAULT_FORMAT = {
|
|
47
|
+
unit: 'decimal'
|
|
48
|
+
};
|
|
49
|
+
const DEFAULT_THRESHOLDS = {
|
|
50
|
+
defaultColor: '#56b4e9'
|
|
51
|
+
};
|
|
52
|
+
const DEFAULT_MIN_PERCENT = 0;
|
|
53
|
+
const DEFAULT_MAX_PERCENT = 100;
|
|
54
|
+
const DEFAULT_MIN_PERCENT_DECIMAL = 0;
|
|
55
|
+
const DEFAULT_MAX_PERCENT_DECIMAL = 1;
|
|
56
|
+
function createInitialHistogramChartOptions() {
|
|
57
|
+
return {
|
|
58
|
+
format: DEFAULT_FORMAT
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
15
|
+
if (typeof WeakMap !== "function") return null;
|
|
16
|
+
var cacheBabelInterop = new WeakMap();
|
|
17
|
+
var cacheNodeInterop = new WeakMap();
|
|
18
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
19
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
20
|
+
})(nodeInterop);
|
|
21
|
+
}
|
|
22
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
23
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
27
|
+
return {
|
|
28
|
+
default: obj
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
32
|
+
if (cache && cache.has(obj)) {
|
|
33
|
+
return cache.get(obj);
|
|
34
|
+
}
|
|
35
|
+
var newObj = {
|
|
36
|
+
__proto__: null
|
|
37
|
+
};
|
|
38
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
39
|
+
for(var key in obj){
|
|
40
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
41
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
42
|
+
if (desc && (desc.get || desc.set)) {
|
|
43
|
+
Object.defineProperty(newObj, key, desc);
|
|
44
|
+
} else {
|
|
45
|
+
newObj[key] = obj[key];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
newObj.default = obj;
|
|
50
|
+
if (cache) {
|
|
51
|
+
cache.set(obj, newObj);
|
|
52
|
+
}
|
|
53
|
+
return newObj;
|
|
54
|
+
}
|
|
55
|
+
Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bootstrap")));
|