@perses-dev/stat-chart-plugin 0.13.0 → 0.15.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mf/js/StatChart.cfc077f0.js +7 -0
- package/__mf/js/async/121.dd7133cb.js +2 -0
- package/__mf/js/async/192.6939be34.js +1 -0
- package/__mf/js/async/2.8caf67bd.js +1 -0
- package/__mf/js/async/235.c6d2c4f5.js +1 -0
- package/__mf/js/async/274.7345c704.js +2 -0
- package/__mf/js/async/345.242802c4.js +29 -0
- package/__mf/js/async/354.6ea77f69.js +4 -0
- package/__mf/js/async/354.6ea77f69.js.LICENSE.txt +9 -0
- package/__mf/js/async/356.b00937de.js +1 -0
- package/__mf/js/async/392.559f0a15.js +2 -0
- package/__mf/js/async/449.6d8fc8b3.js +43 -0
- package/__mf/js/async/{580.4076ee7b.js.LICENSE.txt → 449.6d8fc8b3.js.LICENSE.txt} +41 -1
- package/__mf/js/async/470.16a500aa.js +2 -0
- package/__mf/js/async/570.34dc9996.js +2 -0
- package/__mf/js/async/587.7eb542f2.js +1 -0
- package/__mf/js/async/616.6b72e257.js +1 -0
- package/__mf/js/async/663.2de74425.js +1 -0
- package/__mf/js/async/{866.cb6cbc7a.js → 866.d7ad9e7a.js} +5 -5
- package/__mf/js/async/941.1589eeae.js +2 -0
- package/__mf/js/async/968.ebdf1f2d.js +1 -0
- package/__mf/js/async/970.f5882828.js +2 -0
- package/__mf/js/async/__federation_expose_StatChart.7973125b.js +1 -0
- package/__mf/js/async/lib-router.73f6cef1.js +2 -0
- package/__mf/js/{main.8c422eca.js → main.cd844a8c.js} +3 -3
- package/lib/StatChart.d.ts +3 -3
- package/lib/StatChart.d.ts.map +1 -1
- package/lib/StatChart.js +4 -4
- package/lib/StatChart.js.map +1 -1
- package/lib/StatChartBase.d.ts +4 -4
- package/lib/StatChartBase.d.ts.map +1 -1
- package/lib/StatChartBase.js +12 -12
- package/lib/StatChartBase.js.map +1 -1
- package/lib/StatChartOptionsEditorSettings.d.ts +2 -2
- package/lib/StatChartOptionsEditorSettings.d.ts.map +1 -1
- package/lib/StatChartOptionsEditorSettings.js +8 -8
- package/lib/StatChartOptionsEditorSettings.js.map +1 -1
- package/lib/StatChartPanel.d.ts +4 -4
- package/lib/StatChartPanel.d.ts.map +1 -1
- package/lib/StatChartPanel.js +14 -9
- package/lib/StatChartPanel.js.map +1 -1
- package/lib/StatChartValueMappingEditor.d.ts +3 -3
- package/lib/StatChartValueMappingEditor.d.ts.map +1 -1
- package/lib/StatChartValueMappingEditor.js +1 -1
- package/lib/StatChartValueMappingEditor.js.map +1 -1
- package/lib/bootstrap.js +2 -2
- package/lib/getPluginModule.d.ts +1 -1
- package/lib/getPluginModule.d.ts.map +1 -1
- package/lib/getPluginModule.js +3 -1
- package/lib/getPluginModule.js.map +1 -1
- package/lib/index-federation.js +1 -1
- package/lib/index.js +7 -7
- package/lib/index.js.map +1 -1
- package/lib/setup-tests.d.ts +1 -1
- package/lib/setup-tests.d.ts.map +1 -1
- package/lib/setup-tests.js +2 -2
- package/lib/setup-tests.js.map +1 -1
- package/lib/stat-chart-model.d.ts +3 -3
- package/lib/stat-chart-model.d.ts.map +1 -1
- package/lib/stat-chart-model.js.map +1 -1
- package/lib/utils/calculate-font-size.d.ts +1 -1
- package/lib/utils/calculate-font-size.d.ts.map +1 -1
- package/lib/utils/calculate-font-size.js +2 -2
- package/lib/utils/calculate-font-size.js.map +1 -1
- package/lib/utils/calculate-value.d.ts +3 -2
- package/lib/utils/calculate-value.d.ts.map +1 -1
- package/lib/utils/calculate-value.js +1 -1
- package/lib/utils/calculate-value.js.map +1 -1
- package/lib/utils/data-transform.d.ts +3 -3
- package/lib/utils/data-transform.d.ts.map +1 -1
- package/lib/utils/data-transform.js.map +1 -1
- package/lib/utils/format-stat-chart-value.d.ts +1 -1
- package/lib/utils/format-stat-chart-value.d.ts.map +1 -1
- package/lib/utils/format-stat-chart-value.js +1 -1
- package/lib/utils/format-stat-chart-value.js.map +1 -1
- package/lib/utils/get-color.d.ts +2 -2
- package/lib/utils/get-color.d.ts.map +1 -1
- package/lib/utils/get-color.js +1 -1
- package/lib/utils/get-color.js.map +1 -1
- package/mf-manifest.json +29 -73
- package/mf-stats.json +29 -81
- package/package.json +10 -10
- package/__mf/js/StatChart.2eecc4a4.js +0 -7
- package/__mf/js/async/121.a33651ce.js +0 -2
- package/__mf/js/async/177.4dddf131.js +0 -1
- package/__mf/js/async/187.d7e6b2db.js +0 -7
- package/__mf/js/async/187.d7e6b2db.js.LICENSE.txt +0 -39
- package/__mf/js/async/192.0b251884.js +0 -1
- package/__mf/js/async/2.e8bdc16f.js +0 -1
- package/__mf/js/async/235.f388b6fd.js +0 -1
- package/__mf/js/async/274.b762faf5.js +0 -2
- package/__mf/js/async/356.3f7b970d.js +0 -1
- package/__mf/js/async/392.70b1a3c5.js +0 -2
- package/__mf/js/async/450.bdfbd76f.js +0 -1
- package/__mf/js/async/465.7c60371f.js +0 -2
- package/__mf/js/async/470.cc046da0.js +0 -2
- package/__mf/js/async/546.f27d00a1.js +0 -24
- package/__mf/js/async/546.f27d00a1.js.LICENSE.txt +0 -19
- package/__mf/js/async/558.e8f8691f.js +0 -1
- package/__mf/js/async/570.264704d1.js +0 -2
- package/__mf/js/async/580.4076ee7b.js +0 -66
- package/__mf/js/async/587.7d22fb82.js +0 -1
- package/__mf/js/async/588.c00e3759.js +0 -1
- package/__mf/js/async/616.22b37336.js +0 -1
- package/__mf/js/async/71.1f2caf38.js +0 -1
- package/__mf/js/async/721.5c1c6916.js +0 -1
- package/__mf/js/async/873.13ff7de6.js +0 -1
- package/__mf/js/async/941.230549f5.js +0 -2
- package/__mf/js/async/968.bfd3594f.js +0 -1
- package/__mf/js/async/978.98475f4b.js +0 -1
- package/__mf/js/async/__federation_expose_StatChart.f4a2f598.js +0 -1
- package/__mf/js/async/lib-router.6c58ccc7.js +0 -2
- package/lib/cjs/StatChart.js +0 -43
- package/lib/cjs/StatChartBase.js +0 -263
- package/lib/cjs/StatChartOptionsEditorSettings.js +0 -171
- package/lib/cjs/StatChartPanel.js +0 -130
- package/lib/cjs/StatChartValueMappingEditor.js +0 -36
- package/lib/cjs/bootstrap.js +0 -26
- package/lib/cjs/env.d.js +0 -14
- package/lib/cjs/getPluginModule.js +0 -39
- package/lib/cjs/index-federation.js +0 -55
- package/lib/cjs/index.js +0 -42
- package/lib/cjs/setup-tests.js +0 -19
- package/lib/cjs/stat-chart-model.js +0 -74
- package/lib/cjs/utils/calculate-font-size.js +0 -55
- package/lib/cjs/utils/calculate-value.js +0 -30
- package/lib/cjs/utils/data-transform.js +0 -36
- package/lib/cjs/utils/format-stat-chart-value.js +0 -34
- package/lib/cjs/utils/get-color.js +0 -66
- /package/__mf/css/async/{187.85c2cbf6.css → 449.85c2cbf6.css} +0 -0
- /package/__mf/js/async/{121.a33651ce.js.LICENSE.txt → 121.dd7133cb.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{274.b762faf5.js.LICENSE.txt → 274.7345c704.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.70b1a3c5.js.LICENSE.txt → 392.559f0a15.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{470.cc046da0.js.LICENSE.txt → 470.16a500aa.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{570.264704d1.js.LICENSE.txt → 570.34dc9996.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{866.cb6cbc7a.js.LICENSE.txt → 866.d7ad9e7a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.230549f5.js.LICENSE.txt → 941.1589eeae.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{465.7c60371f.js.LICENSE.txt → 970.f5882828.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.6c58ccc7.js.LICENSE.txt → lib-router.73f6cef1.js.LICENSE.txt} +0 -0
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
// Copyright The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "StatChartOptionsEditorSettings", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return StatChartOptionsEditorSettings;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _material = require("@mui/material");
|
|
25
|
-
const _components = require("@perses-dev/components");
|
|
26
|
-
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
27
|
-
const _immer = require("immer");
|
|
28
|
-
const _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
|
|
29
|
-
const _react = require("react");
|
|
30
|
-
const _statchartmodel = require("./stat-chart-model");
|
|
31
|
-
function _interop_require_default(obj) {
|
|
32
|
-
return obj && obj.__esModule ? obj : {
|
|
33
|
-
default: obj
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
const DEFAULT_FORMAT = {
|
|
37
|
-
unit: 'percent-decimal'
|
|
38
|
-
};
|
|
39
|
-
function StatChartOptionsEditorSettings(props) {
|
|
40
|
-
const { onChange, value } = props;
|
|
41
|
-
// ensures decimalPlaces defaults to correct value
|
|
42
|
-
const format = (0, _merge.default)({}, DEFAULT_FORMAT, value.format);
|
|
43
|
-
const handleCalculationChange = (metricLabel)=>{
|
|
44
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
45
|
-
draft.calculation = metricLabel;
|
|
46
|
-
}));
|
|
47
|
-
};
|
|
48
|
-
const handleMetricLabelChange = (newCalculation)=>{
|
|
49
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
50
|
-
draft.metricLabel = newCalculation;
|
|
51
|
-
}));
|
|
52
|
-
};
|
|
53
|
-
const handleShowLegendChange = (0, _react.useCallback)((_, newShowLegend)=>{
|
|
54
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
55
|
-
draft.legendMode = newShowLegend.id;
|
|
56
|
-
}));
|
|
57
|
-
}, [
|
|
58
|
-
onChange,
|
|
59
|
-
value
|
|
60
|
-
]);
|
|
61
|
-
const handleUnitChange = (newFormat)=>{
|
|
62
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
63
|
-
draft.format = newFormat;
|
|
64
|
-
}));
|
|
65
|
-
};
|
|
66
|
-
const handleSparklineChange = (_, checked)=>{
|
|
67
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
68
|
-
// For now, setting to an empty object when checked, so the stat chart
|
|
69
|
-
// uses the default chart color and line styles. In the future, this
|
|
70
|
-
// will likely be configurable in the UI.
|
|
71
|
-
draft.sparkline = checked ? {} : undefined;
|
|
72
|
-
}));
|
|
73
|
-
};
|
|
74
|
-
const handleThresholdsChange = (thresholds)=>{
|
|
75
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
76
|
-
draft.thresholds = thresholds;
|
|
77
|
-
}));
|
|
78
|
-
};
|
|
79
|
-
const handleFontSizeChange = (fontSize)=>{
|
|
80
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
81
|
-
draft.valueFontSize = fontSize;
|
|
82
|
-
}));
|
|
83
|
-
};
|
|
84
|
-
const handleColorModeChange = (0, _react.useCallback)((_, newColorMode)=>{
|
|
85
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
86
|
-
draft.colorMode = newColorMode.id;
|
|
87
|
-
}));
|
|
88
|
-
}, [
|
|
89
|
-
onChange,
|
|
90
|
-
value
|
|
91
|
-
]);
|
|
92
|
-
const selectShowLegend = (0, _react.useMemo)(()=>{
|
|
93
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
94
|
-
label: "Show",
|
|
95
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
|
|
96
|
-
onChange: handleShowLegendChange,
|
|
97
|
-
options: _statchartmodel.SHOW_LEGEND_LABELS,
|
|
98
|
-
disableClearable: true,
|
|
99
|
-
value: _statchartmodel.SHOW_LEGEND_LABELS.find((i)=>i.id === value.legendMode) ?? _statchartmodel.SHOW_LEGEND_LABELS.find((i)=>i.id === 'auto')
|
|
100
|
-
})
|
|
101
|
-
});
|
|
102
|
-
}, [
|
|
103
|
-
value.legendMode,
|
|
104
|
-
handleShowLegendChange
|
|
105
|
-
]);
|
|
106
|
-
const selectColorMode = (0, _react.useMemo)(()=>{
|
|
107
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
108
|
-
label: "Color mode",
|
|
109
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SettingsAutocomplete, {
|
|
110
|
-
onChange: handleColorModeChange,
|
|
111
|
-
options: _statchartmodel.COLOR_MODE_LABELS.map(({ id, label })=>({
|
|
112
|
-
id,
|
|
113
|
-
label
|
|
114
|
-
})),
|
|
115
|
-
disableClearable: true,
|
|
116
|
-
value: _statchartmodel.COLOR_MODE_LABELS.find((i)=>i.id === value.colorMode) ?? _statchartmodel.COLOR_MODE_LABELS.find((i)=>i.id === 'value')
|
|
117
|
-
})
|
|
118
|
-
});
|
|
119
|
-
}, [
|
|
120
|
-
value.colorMode,
|
|
121
|
-
handleColorModeChange
|
|
122
|
-
]);
|
|
123
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGrid, {
|
|
124
|
-
children: [
|
|
125
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorColumn, {
|
|
126
|
-
children: [
|
|
127
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorGroup, {
|
|
128
|
-
title: "Legend",
|
|
129
|
-
children: selectShowLegend
|
|
130
|
-
}),
|
|
131
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
|
|
132
|
-
title: "Misc",
|
|
133
|
-
children: [
|
|
134
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
135
|
-
label: "Sparkline",
|
|
136
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
137
|
-
checked: !!value.sparkline,
|
|
138
|
-
onChange: handleSparklineChange
|
|
139
|
-
})
|
|
140
|
-
}),
|
|
141
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormatControls, {
|
|
142
|
-
value: format,
|
|
143
|
-
onChange: handleUnitChange
|
|
144
|
-
}),
|
|
145
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.CalculationSelector, {
|
|
146
|
-
value: value.calculation,
|
|
147
|
-
onChange: handleCalculationChange
|
|
148
|
-
}),
|
|
149
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.MetricLabelInput, {
|
|
150
|
-
value: value.metricLabel,
|
|
151
|
-
onChange: handleMetricLabelChange
|
|
152
|
-
}),
|
|
153
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FontSizeSelector, {
|
|
154
|
-
value: value.valueFontSize,
|
|
155
|
-
onChange: handleFontSizeChange
|
|
156
|
-
}),
|
|
157
|
-
selectColorMode
|
|
158
|
-
]
|
|
159
|
-
})
|
|
160
|
-
]
|
|
161
|
-
}),
|
|
162
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
|
|
163
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ThresholdsEditor, {
|
|
164
|
-
disablePercentMode: true,
|
|
165
|
-
thresholds: value.thresholds,
|
|
166
|
-
onChange: handleThresholdsChange
|
|
167
|
-
})
|
|
168
|
-
})
|
|
169
|
-
]
|
|
170
|
-
});
|
|
171
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
// Copyright The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "StatChartPanel", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return StatChartPanel;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _components = require("@perses-dev/components");
|
|
25
|
-
const _material = require("@mui/material");
|
|
26
|
-
const _react = require("react");
|
|
27
|
-
const _datatransform = require("./utils/data-transform");
|
|
28
|
-
const _calculatevalue = require("./utils/calculate-value");
|
|
29
|
-
const _getcolor = require("./utils/get-color");
|
|
30
|
-
const _StatChartBase = require("./StatChartBase");
|
|
31
|
-
const MIN_WIDTH = 100;
|
|
32
|
-
const SPACING = 2;
|
|
33
|
-
const StatChartPanel = (props)=>{
|
|
34
|
-
const { spec, contentDimensions, queryResults } = props;
|
|
35
|
-
const { format, sparkline, valueFontSize: valueFontSize, colorMode } = spec;
|
|
36
|
-
const chartsTheme = (0, _components.useChartsTheme)();
|
|
37
|
-
const statChartData = useStatChartData(queryResults, spec, chartsTheme);
|
|
38
|
-
const isMultiSeries = statChartData.length > 1;
|
|
39
|
-
// Handle three-state showLegend: 'on' | 'off' | 'auto' (or undefined for backward compatibility)
|
|
40
|
-
const shouldShowLegend = spec.legendMode === 'on' ? true : spec.legendMode === 'off' ? false : isMultiSeries;
|
|
41
|
-
if (!contentDimensions) return null;
|
|
42
|
-
// Calculates chart width
|
|
43
|
-
const spacing = SPACING * (statChartData.length - 1);
|
|
44
|
-
let chartWidth = (contentDimensions.width - spacing) / statChartData.length;
|
|
45
|
-
if (isMultiSeries && chartWidth < MIN_WIDTH) {
|
|
46
|
-
chartWidth = MIN_WIDTH;
|
|
47
|
-
}
|
|
48
|
-
const noDataTextStyle = chartsTheme.noDataOption.title.textStyle;
|
|
49
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
50
|
-
height: contentDimensions.height,
|
|
51
|
-
width: contentDimensions.width,
|
|
52
|
-
spacing: `${SPACING}px`,
|
|
53
|
-
direction: "row",
|
|
54
|
-
justifyContent: isMultiSeries ? 'left' : 'center',
|
|
55
|
-
alignItems: "center",
|
|
56
|
-
sx: {
|
|
57
|
-
overflowX: isMultiSeries ? 'scroll' : 'auto'
|
|
58
|
-
},
|
|
59
|
-
children: statChartData.length ? statChartData.map((series, index)=>{
|
|
60
|
-
const sparklineConfig = (0, _datatransform.convertSparkline)(chartsTheme, series.color, sparkline);
|
|
61
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_StatChartBase.StatChartBase, {
|
|
62
|
-
width: chartWidth,
|
|
63
|
-
height: contentDimensions.height,
|
|
64
|
-
data: series,
|
|
65
|
-
format: format,
|
|
66
|
-
sparkline: sparklineConfig,
|
|
67
|
-
showSeriesName: shouldShowLegend,
|
|
68
|
-
valueFontSize: valueFontSize,
|
|
69
|
-
colorMode: colorMode
|
|
70
|
-
}, index);
|
|
71
|
-
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
72
|
-
sx: {
|
|
73
|
-
...noDataTextStyle
|
|
74
|
-
},
|
|
75
|
-
children: "No data"
|
|
76
|
-
})
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
const useStatChartData = (queryResults, spec, chartsTheme)=>{
|
|
80
|
-
return (0, _react.useMemo)(()=>{
|
|
81
|
-
const { calculation, mappings, metricLabel } = spec;
|
|
82
|
-
const statChartData = [];
|
|
83
|
-
for (const result of queryResults){
|
|
84
|
-
for (const seriesData of result.data.series){
|
|
85
|
-
const calculatedValue = (0, _calculatevalue.calculateValue)(calculation, seriesData);
|
|
86
|
-
// get label metric value
|
|
87
|
-
const labelValue = getLabelValue(metricLabel, seriesData.labels);
|
|
88
|
-
// get actual value to display
|
|
89
|
-
const displayValue = getValueOrLabel(calculatedValue, mappings, labelValue);
|
|
90
|
-
const color = (0, _getcolor.getStatChartColor)(chartsTheme, spec, calculatedValue);
|
|
91
|
-
const series = {
|
|
92
|
-
name: seriesData.formattedName ?? '',
|
|
93
|
-
values: seriesData.values
|
|
94
|
-
};
|
|
95
|
-
statChartData.push({
|
|
96
|
-
calculatedValue: displayValue,
|
|
97
|
-
seriesData: series,
|
|
98
|
-
color
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return statChartData;
|
|
103
|
-
}, [
|
|
104
|
-
queryResults,
|
|
105
|
-
spec,
|
|
106
|
-
chartsTheme
|
|
107
|
-
]);
|
|
108
|
-
};
|
|
109
|
-
const getValueOrLabel = (value, mappings, label)=>{
|
|
110
|
-
if (label) {
|
|
111
|
-
return label;
|
|
112
|
-
}
|
|
113
|
-
if (mappings?.length && value !== undefined && value !== null) {
|
|
114
|
-
return (0, _components.applyValueMapping)(value, mappings).value;
|
|
115
|
-
} else {
|
|
116
|
-
return value;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
const getLabelValue = (fieldLabel, labels)=>{
|
|
120
|
-
if (!labels || !fieldLabel) {
|
|
121
|
-
return undefined;
|
|
122
|
-
}
|
|
123
|
-
for (const [key, value] of Object.entries(labels)){
|
|
124
|
-
const regex = (0, _components.createRegexFromString)(fieldLabel);
|
|
125
|
-
if (regex.test(key)) {
|
|
126
|
-
return value;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return undefined;
|
|
130
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// Copyright The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "StatChartValueMappingEditor", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return StatChartValueMappingEditor;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _components = require("@perses-dev/components");
|
|
25
|
-
const StatChartValueMappingEditor = ({ onChange, value })=>{
|
|
26
|
-
function handleValueMappingChange(mappings) {
|
|
27
|
-
onChange({
|
|
28
|
-
...value,
|
|
29
|
-
mappings
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ValueMappingsEditor, {
|
|
33
|
-
mappings: value.mappings ?? [],
|
|
34
|
-
onChange: handleValueMappingChange
|
|
35
|
-
});
|
|
36
|
-
};
|
package/lib/cjs/bootstrap.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Copyright The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
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, {}));
|
package/lib/cjs/env.d.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Copyright The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
/// <reference types="@rsbuild/core/types" />
|
|
14
|
-
"use strict";
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Copyright The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "getPluginModule", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return getPluginModule;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
|
|
24
|
-
function _interop_require_default(obj) {
|
|
25
|
-
return obj && obj.__esModule ? obj : {
|
|
26
|
-
default: obj
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function getPluginModule() {
|
|
30
|
-
const { name, version, perses } = _packagejson.default;
|
|
31
|
-
return {
|
|
32
|
-
kind: 'PluginModule',
|
|
33
|
-
metadata: {
|
|
34
|
-
name,
|
|
35
|
-
version
|
|
36
|
-
},
|
|
37
|
-
spec: perses
|
|
38
|
-
};
|
|
39
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
3
|
-
if (typeof WeakMap !== "function") return null;
|
|
4
|
-
var cacheBabelInterop = new WeakMap();
|
|
5
|
-
var cacheNodeInterop = new WeakMap();
|
|
6
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
7
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
8
|
-
})(nodeInterop);
|
|
9
|
-
}
|
|
10
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
11
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
15
|
-
return {
|
|
16
|
-
default: obj
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
20
|
-
if (cache && cache.has(obj)) {
|
|
21
|
-
return cache.get(obj);
|
|
22
|
-
}
|
|
23
|
-
var newObj = {
|
|
24
|
-
__proto__: null
|
|
25
|
-
};
|
|
26
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
27
|
-
for(var key in obj){
|
|
28
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
29
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
30
|
-
if (desc && (desc.get || desc.set)) {
|
|
31
|
-
Object.defineProperty(newObj, key, desc);
|
|
32
|
-
} else {
|
|
33
|
-
newObj[key] = obj[key];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
newObj.default = obj;
|
|
38
|
-
if (cache) {
|
|
39
|
-
cache.set(obj, newObj);
|
|
40
|
-
}
|
|
41
|
-
return newObj;
|
|
42
|
-
}
|
|
43
|
-
// Copyright The Perses Authors
|
|
44
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
45
|
-
// you may not use this file except in compliance with the License.
|
|
46
|
-
// You may obtain a copy of the License at
|
|
47
|
-
//
|
|
48
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
49
|
-
//
|
|
50
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
51
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
52
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
53
|
-
// See the License for the specific language governing permissions and
|
|
54
|
-
// limitations under the License.
|
|
55
|
-
Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bootstrap")));
|
package/lib/cjs/index.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Copyright The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "getPluginModule", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return _getPluginModule.getPluginModule;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _getPluginModule = require("./getPluginModule");
|
|
24
|
-
_export_star(require("./stat-chart-model"), exports);
|
|
25
|
-
_export_star(require("./StatChart"), exports);
|
|
26
|
-
_export_star(require("./StatChartOptionsEditorSettings"), exports);
|
|
27
|
-
_export_star(require("./StatChartPanel"), exports);
|
|
28
|
-
_export_star(require("./StatChartValueMappingEditor"), exports);
|
|
29
|
-
_export_star(require("./StatChartBase"), exports);
|
|
30
|
-
function _export_star(from, to) {
|
|
31
|
-
Object.keys(from).forEach(function(k) {
|
|
32
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
33
|
-
Object.defineProperty(to, k, {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function() {
|
|
36
|
-
return from[k];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return from;
|
|
42
|
-
}
|
package/lib/cjs/setup-tests.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Copyright The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
require("@testing-library/jest-dom");
|
|
18
|
-
// Always mock e-charts during tests since we don't have a proper canvas in jsdom
|
|
19
|
-
jest.mock('echarts/core');
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// Copyright The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
function _export(target, all) {
|
|
18
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
get COLOR_MODE_LABELS () {
|
|
25
|
-
return COLOR_MODE_LABELS;
|
|
26
|
-
},
|
|
27
|
-
get SHOW_LEGEND_LABELS () {
|
|
28
|
-
return SHOW_LEGEND_LABELS;
|
|
29
|
-
},
|
|
30
|
-
get createInitialStatChartOptions () {
|
|
31
|
-
return createInitialStatChartOptions;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
const COLOR_MODE_LABELS = [
|
|
35
|
-
{
|
|
36
|
-
id: 'none',
|
|
37
|
-
label: 'None'
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
id: 'value',
|
|
41
|
-
label: 'Text'
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
id: 'background_solid',
|
|
45
|
-
label: 'Background'
|
|
46
|
-
}
|
|
47
|
-
];
|
|
48
|
-
const SHOW_LEGEND_LABELS = [
|
|
49
|
-
{
|
|
50
|
-
id: 'auto',
|
|
51
|
-
label: 'Auto',
|
|
52
|
-
description: 'Show legend for multi-series, hide legend for single series'
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
id: 'on',
|
|
56
|
-
label: 'On',
|
|
57
|
-
description: 'Always show legend'
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
id: 'off',
|
|
61
|
-
label: 'Off',
|
|
62
|
-
description: 'Always hide legend'
|
|
63
|
-
}
|
|
64
|
-
];
|
|
65
|
-
function createInitialStatChartOptions() {
|
|
66
|
-
return {
|
|
67
|
-
calculation: 'last-number',
|
|
68
|
-
format: {
|
|
69
|
-
unit: 'decimal'
|
|
70
|
-
},
|
|
71
|
-
sparkline: {},
|
|
72
|
-
legendMode: 'auto'
|
|
73
|
-
};
|
|
74
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// Copyright The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "useOptimalFontSize", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return useOptimalFontSize;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _components = require("@perses-dev/components");
|
|
24
|
-
let canvasContext;
|
|
25
|
-
function getGlobalCanvasContext() {
|
|
26
|
-
if (!canvasContext) {
|
|
27
|
-
canvasContext = document.createElement('canvas').getContext('2d');
|
|
28
|
-
if (canvasContext === null) {
|
|
29
|
-
throw new Error('Canvas context is null.');
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return canvasContext;
|
|
33
|
-
}
|
|
34
|
-
function useOptimalFontSize({ text, fontWeight, width, height, lineHeight, maxSize, fontSizeOverride }) {
|
|
35
|
-
const ctx = getGlobalCanvasContext();
|
|
36
|
-
const { echartsTheme } = (0, _components.useChartsTheme)();
|
|
37
|
-
// if user has selected a font size in the settings, use it instead of calculating the optimal size
|
|
38
|
-
if (fontSizeOverride !== undefined) {
|
|
39
|
-
return Number(fontSizeOverride);
|
|
40
|
-
}
|
|
41
|
-
const textStyle = echartsTheme.textStyle;
|
|
42
|
-
const fontSize = Number(textStyle?.fontSize) ?? 12;
|
|
43
|
-
const fontFamily = textStyle?.fontFamily ?? 'Lato';
|
|
44
|
-
// set the font on the canvas context
|
|
45
|
-
const fontStyle = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
46
|
-
ctx.font = fontStyle;
|
|
47
|
-
// measure the width of the text with the given font style
|
|
48
|
-
const textMetrics = ctx.measureText(text);
|
|
49
|
-
// check how much bigger we can make the font while staying within the width and height
|
|
50
|
-
const fontSizeBasedOnWidth = width / textMetrics.width * fontSize;
|
|
51
|
-
const fontSizeBasedOnHeight = height / lineHeight;
|
|
52
|
-
// return the smaller font size
|
|
53
|
-
const finalFontSize = Math.min(fontSizeBasedOnHeight, fontSizeBasedOnWidth);
|
|
54
|
-
return maxSize ? Math.min(finalFontSize, maxSize) : finalFontSize;
|
|
55
|
-
}
|