@perses-dev/pie-chart-plugin 0.14.0 → 0.15.0-beta.2
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/{PieChart.a102eecb.js → PieChart.5c25af4b.js} +4 -4
- package/__mf/js/async/121.3f985aad.js +2 -0
- package/__mf/js/async/192.e77db572.js +1 -0
- package/__mf/js/async/2.0d6a1680.js +1 -0
- package/__mf/js/async/235.2bb8ba2f.js +1 -0
- package/__mf/js/async/237.418111c6.js +2 -0
- package/__mf/js/async/274.0fa32f07.js +2 -0
- package/__mf/js/async/356.b5aee61d.js +1 -0
- package/__mf/js/async/376.d72b6d45.js +110 -0
- package/__mf/js/async/392.311100c7.js +2 -0
- package/__mf/js/async/407.2557a182.js +4 -0
- package/__mf/js/async/407.2557a182.js.LICENSE.txt +9 -0
- package/__mf/js/async/469.a5d124bd.js +1 -0
- package/__mf/js/async/470.7f042d46.js +2 -0
- package/__mf/js/async/496.ea85fb9d.js +1 -0
- package/__mf/js/async/554.ffbb20fd.js +2 -0
- package/__mf/js/async/587.fceb5f76.js +1 -0
- package/__mf/js/async/588.a2bbd130.js +1 -0
- package/__mf/js/async/603.312da395.js +1 -0
- package/__mf/js/async/616.cebd9b21.js +1 -0
- package/__mf/js/async/66.77308b27.js +1 -0
- package/__mf/js/async/71.87ecdff0.js +1 -0
- package/__mf/js/async/77.9d431bfa.js +1 -0
- package/__mf/js/async/788.cf73b628.js +43 -0
- package/__mf/js/async/{576.9e075806.js.LICENSE.txt → 788.cf73b628.js.LICENSE.txt} +41 -1
- package/__mf/js/async/873.48c1c973.js +1 -0
- package/__mf/js/async/941.1d0acff2.js +2 -0
- package/__mf/js/async/968.69813416.js +1 -0
- package/__mf/js/async/978.d64118ad.js +1 -0
- package/__mf/js/async/__federation_expose_PieChart.2e3c97fd.js +4 -0
- package/__mf/js/async/lib-router.64f2eab9.js +2 -0
- package/__mf/js/{main.bb1593b7.js → main.fa92d32d.js} +2 -2
- package/lib/PieChart.d.ts +3 -3
- package/lib/PieChart.d.ts.map +1 -1
- package/lib/PieChart.js +3 -3
- package/lib/PieChart.js.map +1 -1
- package/lib/PieChartBase.d.ts +2 -2
- package/lib/PieChartBase.d.ts.map +1 -1
- package/lib/PieChartBase.js +8 -8
- package/lib/PieChartBase.js.map +1 -1
- package/lib/PieChartOptionsEditorSettings.d.ts +2 -2
- package/lib/PieChartOptionsEditorSettings.d.ts.map +1 -1
- package/lib/PieChartOptionsEditorSettings.js +13 -10
- package/lib/PieChartOptionsEditorSettings.js.map +1 -1
- package/lib/PieChartPanel.d.ts +4 -4
- package/lib/PieChartPanel.d.ts.map +1 -1
- package/lib/PieChartPanel.js +9 -9
- package/lib/PieChartPanel.js.map +1 -1
- package/lib/bootstrap.js +2 -2
- package/lib/colors.js +3 -3
- package/lib/colors.js.map +1 -1
- 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 +6 -6
- package/lib/index.js.map +1 -1
- package/lib/pie-chart-model.d.ts +3 -3
- package/lib/pie-chart-model.d.ts.map +1 -1
- package/lib/pie-chart-model.js +1 -1
- package/lib/pie-chart-model.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/utils.d.ts +3 -3
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +5 -5
- package/lib/utils.js.map +1 -1
- package/mf-manifest.json +36 -33
- package/mf-stats.json +36 -33
- package/package.json +10 -10
- package/__mf/js/async/121.61df50b5.js +0 -2
- package/__mf/js/async/177.7624b91a.js +0 -1
- package/__mf/js/async/187.65618c74.js +0 -7
- package/__mf/js/async/187.65618c74.js.LICENSE.txt +0 -39
- package/__mf/js/async/192.d45ba757.js +0 -1
- package/__mf/js/async/2.651ba6ec.js +0 -1
- package/__mf/js/async/235.495df342.js +0 -1
- package/__mf/js/async/274.5c1e13d7.js +0 -2
- package/__mf/js/async/356.5cd094ae.js +0 -1
- package/__mf/js/async/376.196cec5c.js +0 -110
- package/__mf/js/async/392.281005cf.js +0 -2
- package/__mf/js/async/469.ea0276a5.js +0 -1
- package/__mf/js/async/470.0b301928.js +0 -2
- package/__mf/js/async/546.b800e1ff.js +0 -24
- package/__mf/js/async/546.b800e1ff.js.LICENSE.txt +0 -19
- package/__mf/js/async/554.507b3545.js +0 -2
- package/__mf/js/async/558.9bb26cf7.js +0 -1
- package/__mf/js/async/576.9e075806.js +0 -39
- package/__mf/js/async/587.a59f7544.js +0 -1
- package/__mf/js/async/603.224eeb96.js +0 -1
- package/__mf/js/async/616.702bde53.js +0 -1
- package/__mf/js/async/66.13296185.js +0 -1
- package/__mf/js/async/663.d4632bd2.js +0 -1
- package/__mf/js/async/873.8941a36f.js +0 -1
- package/__mf/js/async/941.b972dd8a.js +0 -2
- package/__mf/js/async/968.6009cb29.js +0 -1
- package/__mf/js/async/__federation_expose_PieChart.9cd45fce.js +0 -4
- package/__mf/js/async/lib-router.c182f4dd.js +0 -2
- package/lib/cjs/PieChart.js +0 -38
- package/lib/cjs/PieChartBase.js +0 -100
- package/lib/cjs/PieChartOptionsEditorSettings.js +0 -247
- package/lib/cjs/PieChartPanel.js +0 -155
- package/lib/cjs/bootstrap.js +0 -26
- package/lib/cjs/colors.js +0 -207
- 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 -41
- package/lib/cjs/pie-chart-model.js +0 -53
- package/lib/cjs/setup-tests.js +0 -19
- package/lib/cjs/utils.js +0 -163
- /package/__mf/css/async/{187.85c2cbf6.css → 788.85c2cbf6.css} +0 -0
- /package/__mf/js/async/{121.61df50b5.js.LICENSE.txt → 121.3f985aad.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{274.5c1e13d7.js.LICENSE.txt → 274.0fa32f07.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{376.196cec5c.js.LICENSE.txt → 376.d72b6d45.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.281005cf.js.LICENSE.txt → 392.311100c7.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{470.0b301928.js.LICENSE.txt → 470.7f042d46.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{554.507b3545.js.LICENSE.txt → 554.ffbb20fd.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.b972dd8a.js.LICENSE.txt → 941.1d0acff2.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.c182f4dd.js.LICENSE.txt → lib-router.64f2eab9.js.LICENSE.txt} +0 -0
|
@@ -1,247 +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, "PieChartOptionsEditorSettings", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return PieChartOptionsEditorSettings;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
|
|
25
|
-
const _omit = /*#__PURE__*/ _interop_require_default(require("lodash/omit"));
|
|
26
|
-
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
27
|
-
const _immer = require("immer");
|
|
28
|
-
const _components = require("@perses-dev/components");
|
|
29
|
-
const _material = require("@mui/material");
|
|
30
|
-
const _react = require("react");
|
|
31
|
-
const _piechartmodel = require("./pie-chart-model");
|
|
32
|
-
function _interop_require_default(obj) {
|
|
33
|
-
return obj && obj.__esModule ? obj : {
|
|
34
|
-
default: obj
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function PieChartOptionsEditorSettings(props) {
|
|
38
|
-
const { onChange, value } = props;
|
|
39
|
-
const handleCalculationChange = (newCalculation)=>{
|
|
40
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
41
|
-
draft.calculation = newCalculation;
|
|
42
|
-
}));
|
|
43
|
-
};
|
|
44
|
-
const handleLegendChange = (newLegend)=>{
|
|
45
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
46
|
-
draft.legend = newLegend;
|
|
47
|
-
}));
|
|
48
|
-
};
|
|
49
|
-
const handleUnitChange = (newFormat)=>{
|
|
50
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
51
|
-
draft.format = newFormat;
|
|
52
|
-
}));
|
|
53
|
-
};
|
|
54
|
-
const handleSortChange = (newSort)=>{
|
|
55
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
56
|
-
draft.sort = newSort;
|
|
57
|
-
}));
|
|
58
|
-
};
|
|
59
|
-
const handleModeChange = (newMode)=>{
|
|
60
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
61
|
-
draft.mode = newMode;
|
|
62
|
-
}));
|
|
63
|
-
};
|
|
64
|
-
const handleShowLabelsChange = (_, checked)=>{
|
|
65
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
66
|
-
draft.showLabels = checked;
|
|
67
|
-
}));
|
|
68
|
-
};
|
|
69
|
-
const chartsTheme = (0, _components.useChartsTheme)();
|
|
70
|
-
const themePalette = chartsTheme.echartsTheme.color;
|
|
71
|
-
const colorPalette = (0, _react.useMemo)(()=>{
|
|
72
|
-
return value.colorPalette || undefined;
|
|
73
|
-
}, [
|
|
74
|
-
value.colorPalette
|
|
75
|
-
]);
|
|
76
|
-
const handleColorChange = (color)=>{
|
|
77
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
78
|
-
if (Array.isArray(color)) {
|
|
79
|
-
draft.colorPalette = color;
|
|
80
|
-
} else if (typeof color === 'string') {
|
|
81
|
-
draft.colorPalette = [
|
|
82
|
-
color
|
|
83
|
-
];
|
|
84
|
-
} else {
|
|
85
|
-
draft.colorPalette = undefined;
|
|
86
|
-
}
|
|
87
|
-
}));
|
|
88
|
-
};
|
|
89
|
-
// ensures decimalPlaces defaults to correct value
|
|
90
|
-
const format = (0, _merge.default)({}, !value.format || (0, _components.isUnitWithShortValues)(value.format) ? _piechartmodel.DEFAULT_FORMAT : (0, _omit.default)(_piechartmodel.DEFAULT_FORMAT, [
|
|
91
|
-
'shortValues'
|
|
92
|
-
]), value.format);
|
|
93
|
-
const colorScheme = (0, _react.useMemo)(()=>{
|
|
94
|
-
return Array.isArray(colorPalette) ? colorPalette.length === 1 ? 'gradient' : 'theme' : 'default';
|
|
95
|
-
}, [
|
|
96
|
-
colorPalette
|
|
97
|
-
]);
|
|
98
|
-
const handleColorSchemeChange = (scheme)=>{
|
|
99
|
-
if (scheme === 'theme') {
|
|
100
|
-
handleColorChange(themePalette);
|
|
101
|
-
} else if (scheme === 'default') {
|
|
102
|
-
handleColorChange();
|
|
103
|
-
} else {
|
|
104
|
-
// gradient: keep existing single color if present (user-chosen via OptionsColorPicker)
|
|
105
|
-
if (Array.isArray(colorPalette) && colorPalette.length === 1) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
// initialize with a sensible default so the color picker shows a color
|
|
109
|
-
handleColorChange([
|
|
110
|
-
'#ff0000'
|
|
111
|
-
]);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const colorHelpText = (0, _react.useMemo)(()=>{
|
|
115
|
-
if (colorPalette === undefined) {
|
|
116
|
-
return 'Colors will be automatically assigned using metrics name hash.';
|
|
117
|
-
}
|
|
118
|
-
if (Array.isArray(colorPalette) && colorPalette.length > 1) {
|
|
119
|
-
return 'Colors will be automatically assigned using the current theme color palette.';
|
|
120
|
-
}
|
|
121
|
-
if (Array.isArray(colorPalette) && colorPalette.length === 1) {
|
|
122
|
-
return 'All series will use a gradient based on the selected color.';
|
|
123
|
-
}
|
|
124
|
-
return undefined;
|
|
125
|
-
}, [
|
|
126
|
-
colorPalette
|
|
127
|
-
]);
|
|
128
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGrid, {
|
|
129
|
-
children: [
|
|
130
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorColumn, {
|
|
131
|
-
children: [
|
|
132
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.LegendOptionsEditor, {
|
|
133
|
-
calculation: "comparison",
|
|
134
|
-
value: value.legend,
|
|
135
|
-
onChange: handleLegendChange
|
|
136
|
-
}),
|
|
137
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
|
|
138
|
-
title: "Misc",
|
|
139
|
-
children: [
|
|
140
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
141
|
-
label: "Show Labels",
|
|
142
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
143
|
-
checked: Boolean(value.showLabels),
|
|
144
|
-
onChange: handleShowLabelsChange
|
|
145
|
-
})
|
|
146
|
-
}),
|
|
147
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormatControls, {
|
|
148
|
-
value: format,
|
|
149
|
-
onChange: handleUnitChange,
|
|
150
|
-
disabled: value.mode === 'percentage'
|
|
151
|
-
}),
|
|
152
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.CalculationSelector, {
|
|
153
|
-
value: value.calculation,
|
|
154
|
-
onChange: handleCalculationChange
|
|
155
|
-
}),
|
|
156
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SortSelector, {
|
|
157
|
-
value: value.sort,
|
|
158
|
-
onChange: handleSortChange
|
|
159
|
-
}),
|
|
160
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ModeSelector, {
|
|
161
|
-
value: value.mode,
|
|
162
|
-
onChange: handleModeChange,
|
|
163
|
-
disablePercentageMode: (0, _components.isPercentUnit)(format)
|
|
164
|
-
})
|
|
165
|
-
]
|
|
166
|
-
})
|
|
167
|
-
]
|
|
168
|
-
}),
|
|
169
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorColumn, {
|
|
170
|
-
children: [
|
|
171
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorGroup, {
|
|
172
|
-
title: "Colors",
|
|
173
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
174
|
-
spacing: 2,
|
|
175
|
-
children: [
|
|
176
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
177
|
-
direction: "row",
|
|
178
|
-
spacing: 2,
|
|
179
|
-
alignItems: "center",
|
|
180
|
-
children: [
|
|
181
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.FormControl, {
|
|
182
|
-
size: "small",
|
|
183
|
-
sx: {
|
|
184
|
-
minWidth: 150
|
|
185
|
-
},
|
|
186
|
-
children: [
|
|
187
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputLabel, {
|
|
188
|
-
children: "Color Scheme"
|
|
189
|
-
}),
|
|
190
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Select, {
|
|
191
|
-
value: colorScheme,
|
|
192
|
-
label: "Color Scheme",
|
|
193
|
-
onChange: (e)=>handleColorSchemeChange(e.target.value),
|
|
194
|
-
children: [
|
|
195
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
196
|
-
value: "default",
|
|
197
|
-
children: "Default"
|
|
198
|
-
}),
|
|
199
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
200
|
-
value: "theme",
|
|
201
|
-
children: "Theme"
|
|
202
|
-
}),
|
|
203
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
204
|
-
value: "gradient",
|
|
205
|
-
children: "Gradient"
|
|
206
|
-
})
|
|
207
|
-
]
|
|
208
|
-
})
|
|
209
|
-
]
|
|
210
|
-
}),
|
|
211
|
-
Array.isArray(colorPalette) && colorPalette.length === 1 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsColorPicker, {
|
|
212
|
-
label: "Color",
|
|
213
|
-
color: colorPalette?.[0] ?? themePalette[0] ?? '#ff0000',
|
|
214
|
-
onColorChange: (c)=>handleColorChange([
|
|
215
|
-
c
|
|
216
|
-
])
|
|
217
|
-
})
|
|
218
|
-
]
|
|
219
|
-
}),
|
|
220
|
-
colorHelpText && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
221
|
-
variant: "body2",
|
|
222
|
-
color: "text.secondary",
|
|
223
|
-
children: colorHelpText
|
|
224
|
-
})
|
|
225
|
-
]
|
|
226
|
-
})
|
|
227
|
-
}),
|
|
228
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorGroup, {
|
|
229
|
-
title: "Reset Settings",
|
|
230
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
231
|
-
variant: "outlined",
|
|
232
|
-
color: "secondary",
|
|
233
|
-
onClick: ()=>{
|
|
234
|
-
onChange((0, _immer.produce)(value, (draft)=>{
|
|
235
|
-
// reset button removes all optional panel options
|
|
236
|
-
draft.legend = undefined;
|
|
237
|
-
draft.colorPalette = undefined;
|
|
238
|
-
}));
|
|
239
|
-
},
|
|
240
|
-
children: "Reset To Defaults"
|
|
241
|
-
})
|
|
242
|
-
})
|
|
243
|
-
]
|
|
244
|
-
})
|
|
245
|
-
]
|
|
246
|
-
});
|
|
247
|
-
}
|
package/lib/cjs/PieChartPanel.js
DELETED
|
@@ -1,155 +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, "PieChartPanel", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return PieChartPanel;
|
|
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 _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
|
|
28
|
-
const _react = require("react");
|
|
29
|
-
const _utils = require("./utils");
|
|
30
|
-
const _colors = require("./colors");
|
|
31
|
-
const _PieChartBase = require("./PieChartBase");
|
|
32
|
-
function _interop_require_default(obj) {
|
|
33
|
-
return obj && obj.__esModule ? obj : {
|
|
34
|
-
default: obj
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function PieChartPanel(props) {
|
|
38
|
-
const { spec: { calculation, sort, mode, format: formatOptions, legend: pieChartLegend, colorPalette: colorPalette }, contentDimensions, queryResults } = props;
|
|
39
|
-
const chartsTheme = (0, _components.useChartsTheme)();
|
|
40
|
-
const chartId = (0, _components.useId)('time-series-panel');
|
|
41
|
-
const seriesNames = queryResults.flatMap((result)=>result?.data.series?.map((series)=>series.name) || []);
|
|
42
|
-
// Memoize the color list so it only regenerates when color/palette/series count changes
|
|
43
|
-
const colorList = (0, _react.useMemo)(()=>{
|
|
44
|
-
return (0, _colors.getSeriesColor)(seriesNames, colorPalette);
|
|
45
|
-
}, [
|
|
46
|
-
colorPalette,
|
|
47
|
-
seriesNames
|
|
48
|
-
]);
|
|
49
|
-
const pieChartData = (0, _react.useMemo)(()=>{
|
|
50
|
-
const calculate = _pluginsystem.CalculationsMap[calculation];
|
|
51
|
-
const pieChartData = [];
|
|
52
|
-
queryResults.forEach((result, queryIndex)=>{
|
|
53
|
-
const series = result?.data.series ?? [];
|
|
54
|
-
series.forEach((seriesData, seriesIndex)=>{
|
|
55
|
-
const seriesId = `${chartId}${seriesData.name}${seriesIndex}${queryIndex}`;
|
|
56
|
-
const seriesColor = colorList[queryIndex * series.length + seriesIndex] ?? '#ff0000';
|
|
57
|
-
const seriesItem = {
|
|
58
|
-
id: seriesId,
|
|
59
|
-
value: calculate(seriesData.values) ?? null,
|
|
60
|
-
name: seriesData.formattedName ?? '',
|
|
61
|
-
itemStyle: {
|
|
62
|
-
color: seriesColor
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
pieChartData.push(seriesItem);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
return (0, _utils.sortSeriesData)(pieChartData, sort);
|
|
69
|
-
}, [
|
|
70
|
-
calculation,
|
|
71
|
-
chartId,
|
|
72
|
-
colorList,
|
|
73
|
-
queryResults,
|
|
74
|
-
sort
|
|
75
|
-
]);
|
|
76
|
-
const { legendItems, legendColumns } = (0, _react.useMemo)(()=>{
|
|
77
|
-
const pieChartLegendMapper = pieChartLegend?.mode === 'table' ? new _utils.PieChartTableLegendMapper() : new _utils.PieChartListLegendMapper();
|
|
78
|
-
const values = pieChartLegend?.values;
|
|
79
|
-
const legendItems = pieChartLegendMapper.mapToLegendItems(pieChartData, values);
|
|
80
|
-
const legendColumns = pieChartLegendMapper.mapToLegendColumns(values, formatOptions);
|
|
81
|
-
return {
|
|
82
|
-
legendItems,
|
|
83
|
-
legendColumns
|
|
84
|
-
};
|
|
85
|
-
}, [
|
|
86
|
-
formatOptions,
|
|
87
|
-
pieChartData,
|
|
88
|
-
pieChartLegend?.mode,
|
|
89
|
-
pieChartLegend?.values
|
|
90
|
-
]);
|
|
91
|
-
const contentPadding = chartsTheme.container.padding.default;
|
|
92
|
-
const adjustedContentDimensions = contentDimensions ? {
|
|
93
|
-
width: contentDimensions.width - contentPadding * 2,
|
|
94
|
-
height: contentDimensions.height - contentPadding * 2
|
|
95
|
-
} : undefined;
|
|
96
|
-
const legend = (0, _react.useMemo)(()=>{
|
|
97
|
-
return props.spec.legend && (0, _pluginsystem.validateLegendSpec)(props.spec.legend) ? (0, _merge.default)({}, _components.DEFAULT_LEGEND, props.spec.legend) : undefined;
|
|
98
|
-
}, [
|
|
99
|
-
props.spec.legend
|
|
100
|
-
]);
|
|
101
|
-
const [selectedLegendItems, setSelectedLegendItems] = (0, _react.useState)('ALL');
|
|
102
|
-
const [legendSorting, setLegendSorting] = (0, _react.useState)();
|
|
103
|
-
const chartRef = (0, _react.useRef)(null);
|
|
104
|
-
// ensures there are fallbacks for unset properties since most
|
|
105
|
-
// users should not need to customize visual display
|
|
106
|
-
if (!contentDimensions) return null;
|
|
107
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
108
|
-
sx: {
|
|
109
|
-
padding: `${contentPadding}px`
|
|
110
|
-
},
|
|
111
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ContentWithLegend, {
|
|
112
|
-
width: adjustedContentDimensions?.width ?? 400,
|
|
113
|
-
height: adjustedContentDimensions?.height ?? 1000,
|
|
114
|
-
// Making this small enough that the medium size doesn't get
|
|
115
|
-
// responsive-handling-ed away when in the panel options editor.
|
|
116
|
-
minChildrenHeight: 50,
|
|
117
|
-
legendSize: legend?.size,
|
|
118
|
-
legendProps: legend && {
|
|
119
|
-
options: legend,
|
|
120
|
-
data: legendItems,
|
|
121
|
-
selectedItems: selectedLegendItems,
|
|
122
|
-
onSelectedItemsChange: setSelectedLegendItems,
|
|
123
|
-
tableProps: {
|
|
124
|
-
columns: legendColumns,
|
|
125
|
-
sorting: legendSorting,
|
|
126
|
-
onSortingChange: setLegendSorting
|
|
127
|
-
},
|
|
128
|
-
onItemMouseOver: (e, { id })=>{
|
|
129
|
-
chartRef.current?.highlightSeries({
|
|
130
|
-
name: id
|
|
131
|
-
});
|
|
132
|
-
},
|
|
133
|
-
onItemMouseOut: ()=>{
|
|
134
|
-
chartRef.current?.clearHighlightedSeries();
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
children: ({ height, width })=>{
|
|
138
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
139
|
-
style: {
|
|
140
|
-
height,
|
|
141
|
-
width
|
|
142
|
-
},
|
|
143
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PieChartBase.PieChartBase, {
|
|
144
|
-
data: pieChartData,
|
|
145
|
-
width: width,
|
|
146
|
-
height: height,
|
|
147
|
-
mode: mode,
|
|
148
|
-
formatOptions: formatOptions,
|
|
149
|
-
showLabels: Boolean(props.spec.showLabels)
|
|
150
|
-
})
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
})
|
|
154
|
-
});
|
|
155
|
-
}
|
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/colors.js
DELETED
|
@@ -1,207 +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 generateGradientColor () {
|
|
25
|
-
return generateGradientColor;
|
|
26
|
-
},
|
|
27
|
-
get getAutoPaletteColor () {
|
|
28
|
-
return getAutoPaletteColor;
|
|
29
|
-
},
|
|
30
|
-
get getColor () {
|
|
31
|
-
return getColor;
|
|
32
|
-
},
|
|
33
|
-
get getConsistentColor () {
|
|
34
|
-
return getConsistentColor;
|
|
35
|
-
},
|
|
36
|
-
get getConsistentSeriesNameColor () {
|
|
37
|
-
return getConsistentSeriesNameColor;
|
|
38
|
-
},
|
|
39
|
-
get getDefaultSeriesColor () {
|
|
40
|
-
return getDefaultSeriesColor;
|
|
41
|
-
},
|
|
42
|
-
get getSeriesColor () {
|
|
43
|
-
return getSeriesColor;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const _colorhash = /*#__PURE__*/ _interop_require_default(require("color-hash"));
|
|
47
|
-
function _interop_require_default(obj) {
|
|
48
|
-
return obj && obj.__esModule ? obj : {
|
|
49
|
-
default: obj
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.
|
|
53
|
-
// More info: https://github.com/zenozeng/color-hash#custom-hue
|
|
54
|
-
// Picked min of 20 and max of 360 to exclude common threshold colors (red).
|
|
55
|
-
// Items with "error" in them will always be generated as red.
|
|
56
|
-
const ERROR_HUE_CUTOFF = 20;
|
|
57
|
-
const colorGenerator = new _colorhash.default({
|
|
58
|
-
hue: {
|
|
59
|
-
min: ERROR_HUE_CUTOFF,
|
|
60
|
-
max: 360
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
const redColorGenerator = new _colorhash.default({
|
|
64
|
-
hue: {
|
|
65
|
-
min: 0,
|
|
66
|
-
max: ERROR_HUE_CUTOFF
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
// Color utility functions
|
|
70
|
-
/**
|
|
71
|
-
* Converts a number to a 2-digit hex string
|
|
72
|
-
*/ function toHex(n) {
|
|
73
|
-
const hex = n.toString(16);
|
|
74
|
-
return hex.length === 1 ? '0' + hex : hex;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Converts a hex color string to RGB values
|
|
78
|
-
*/ function hexToRgb(hex) {
|
|
79
|
-
const cleanHex = hex.replace('#', '');
|
|
80
|
-
return {
|
|
81
|
-
r: parseInt(cleanHex.substring(0, 2), 16),
|
|
82
|
-
g: parseInt(cleanHex.substring(2, 4), 16),
|
|
83
|
-
b: parseInt(cleanHex.substring(4, 6), 16)
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Returns a deterministic number between 0 and 1 for a given string
|
|
88
|
-
*/ function stringToSeed(str) {
|
|
89
|
-
let hash = 0;
|
|
90
|
-
for(let i = 0; i < str.length; i++){
|
|
91
|
-
const char = str.charCodeAt(i);
|
|
92
|
-
hash = (hash << 5) - hash + char;
|
|
93
|
-
hash = hash & hash; // Convert to 32-bit integer
|
|
94
|
-
}
|
|
95
|
-
// Convert to positive number and normalize to 0-1 range
|
|
96
|
-
return Math.abs(hash) / 2147483647;
|
|
97
|
-
}
|
|
98
|
-
function generateGradientColor(baseColor, factor) {
|
|
99
|
-
// Convert hex color to RGB
|
|
100
|
-
const { r, g, b } = hexToRgb(baseColor);
|
|
101
|
-
const newR = Math.round(r * factor);
|
|
102
|
-
const newG = Math.round(g * factor);
|
|
103
|
-
const newB = Math.round(b * factor);
|
|
104
|
-
return `#${toHex(newR)}${toHex(newG)}${toHex(newB)}`;
|
|
105
|
-
}
|
|
106
|
-
function getSeriesColor(seriesNames, colorPalette) {
|
|
107
|
-
const totalSeries = seriesNames.length;
|
|
108
|
-
if (totalSeries <= 0) {
|
|
109
|
-
return [];
|
|
110
|
-
}
|
|
111
|
-
const colors = [];
|
|
112
|
-
// undefined palette - default
|
|
113
|
-
if (colorPalette === undefined) {
|
|
114
|
-
for(let nameIndex = 0; nameIndex < seriesNames.length; nameIndex++){
|
|
115
|
-
const seriesColor = getDefaultSeriesColor({
|
|
116
|
-
categoricalPalette: [
|
|
117
|
-
'#ff0000'
|
|
118
|
-
],
|
|
119
|
-
muiPrimaryColor: '#ff0000',
|
|
120
|
-
seriesName: seriesNames[nameIndex] || ''
|
|
121
|
-
});
|
|
122
|
-
colors.push(seriesColor);
|
|
123
|
-
}
|
|
124
|
-
return colors;
|
|
125
|
-
}
|
|
126
|
-
// single color palette - generate gradients from that color
|
|
127
|
-
if (colorPalette.length === 1) {
|
|
128
|
-
const baseColor = colorPalette[0] ?? '#ff0000';
|
|
129
|
-
for(let i = 0; i < totalSeries; i++){
|
|
130
|
-
if (i === 0) {
|
|
131
|
-
colors.push(baseColor);
|
|
132
|
-
} else {
|
|
133
|
-
const gradientFactor = 1 * ((totalSeries - i) / totalSeries);
|
|
134
|
-
colors.push(generateGradientColor(baseColor, gradientFactor));
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return colors.sort((a, b)=>{
|
|
138
|
-
const seedA = stringToSeed(seriesNames[colors.indexOf(a)] || 'fallback');
|
|
139
|
-
const seedB = stringToSeed(seriesNames[colors.indexOf(b)] || 'fallback');
|
|
140
|
-
return seedA - seedB;
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
// multi color palette - loops through colors and adds gradient when palette is exhausted
|
|
144
|
-
for(let i = 0; i < totalSeries; i++){
|
|
145
|
-
const color = getColor(colorPalette, i);
|
|
146
|
-
colors.push(color);
|
|
147
|
-
}
|
|
148
|
-
if (totalSeries > colorPalette.length) {
|
|
149
|
-
return colors.sort((a, b)=>{
|
|
150
|
-
const seedA = stringToSeed(seriesNames[colors.indexOf(a)] || 'fallback');
|
|
151
|
-
const seedB = stringToSeed(seriesNames[colors.indexOf(b)] || 'fallback');
|
|
152
|
-
return seedA - seedB;
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
return colors;
|
|
156
|
-
}
|
|
157
|
-
function getColor(palette, seriesIndex) {
|
|
158
|
-
// Handle undefined or empty palette
|
|
159
|
-
if (!palette || palette.length === 0) {
|
|
160
|
-
return '#ff0000';
|
|
161
|
-
}
|
|
162
|
-
const paletteTotalColors = palette.length;
|
|
163
|
-
const paletteIndex = seriesIndex % paletteTotalColors;
|
|
164
|
-
const baseColor = palette[paletteIndex] ?? '#ff0000';
|
|
165
|
-
// If we haven't exhausted the palette yet, use the original color
|
|
166
|
-
if (seriesIndex < paletteTotalColors) {
|
|
167
|
-
return baseColor;
|
|
168
|
-
}
|
|
169
|
-
// Calculate which "cycle" we're in (0 = first repeat, 1 = second repeat, etc.)
|
|
170
|
-
const cycleNumber = Math.floor(seriesIndex / paletteTotalColors);
|
|
171
|
-
// Apply gradient based on cycle number to create visual distinction
|
|
172
|
-
const gradientFactor = Math.min(1 - cycleNumber * 0.2, 1);
|
|
173
|
-
return generateGradientColor(baseColor, gradientFactor);
|
|
174
|
-
}
|
|
175
|
-
function computeConsistentColor(name, error) {
|
|
176
|
-
const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);
|
|
177
|
-
const saturationPercent = `${(saturation * 100).toFixed(0)}%`;
|
|
178
|
-
const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;
|
|
179
|
-
return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;
|
|
180
|
-
}
|
|
181
|
-
// To check whether a color has already been generated for a given string.
|
|
182
|
-
// TODO: Predefined color aliases will be defined here
|
|
183
|
-
const colorLookup = {};
|
|
184
|
-
function getConsistentColor(name, error) {
|
|
185
|
-
const key = `${name}_____${error}`;
|
|
186
|
-
let value = colorLookup[key];
|
|
187
|
-
if (!value) {
|
|
188
|
-
value = computeConsistentColor(name, error);
|
|
189
|
-
colorLookup[key] = value;
|
|
190
|
-
}
|
|
191
|
-
return value;
|
|
192
|
-
}
|
|
193
|
-
function getConsistentSeriesNameColor(inputString) {
|
|
194
|
-
return getConsistentColor(inputString, inputString.toLowerCase().includes('error'));
|
|
195
|
-
}
|
|
196
|
-
function getDefaultSeriesColor(props) {
|
|
197
|
-
const { categoricalPalette, muiPrimaryColor, seriesName } = props;
|
|
198
|
-
// Fallback is unlikely to set unless echarts theme palette in charts theme provider is undefined.
|
|
199
|
-
const fallbackColor = Array.isArray(categoricalPalette) && categoricalPalette[0] ? categoricalPalette[0] // Needed since echarts color property isn't always an array.
|
|
200
|
-
: muiPrimaryColor;
|
|
201
|
-
return getAutoPaletteColor(seriesName, fallbackColor);
|
|
202
|
-
}
|
|
203
|
-
function getAutoPaletteColor(name, fallbackColor) {
|
|
204
|
-
// corresponds to 'Auto' in palette.kind for generative color palette
|
|
205
|
-
const generatedColor = getConsistentSeriesNameColor(name);
|
|
206
|
-
return generatedColor ?? fallbackColor;
|
|
207
|
-
}
|
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";
|