@perses-dev/bar-chart-plugin 0.11.1 → 0.13.0-beta.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/__mf/css/async/236.85c2cbf6.css +1 -0
- package/__mf/font/inter-cyrillic-300-normal.432f2b21.woff +0 -0
- package/__mf/font/inter-cyrillic-300-normal.9da91009.woff2 +0 -0
- package/__mf/font/inter-cyrillic-400-normal.372704ff.woff2 +0 -0
- package/__mf/font/inter-cyrillic-400-normal.a6b6ef6f.woff +0 -0
- package/__mf/font/inter-cyrillic-500-normal.7c15bba8.woff2 +0 -0
- package/__mf/font/inter-cyrillic-500-normal.b9f8c929.woff +0 -0
- package/__mf/font/inter-cyrillic-600-normal.2f42892a.woff2 +0 -0
- package/__mf/font/inter-cyrillic-600-normal.c3987adc.woff +0 -0
- package/__mf/font/inter-cyrillic-700-normal.93eba3c3.woff +0 -0
- package/__mf/font/inter-cyrillic-700-normal.e9e5b2dc.woff2 +0 -0
- package/__mf/font/inter-cyrillic-900-normal.f285bd7a.woff2 +0 -0
- package/__mf/font/inter-cyrillic-900-normal.ffbd8a3a.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-300-normal.95bb9038.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-300-normal.cfc143a9.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-400-normal.2a31c04b.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-400-normal.f572b170.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-500-normal.5a6bb1da.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-500-normal.fe0d9b14.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-600-normal.ecbdecad.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-600-normal.f7b3c15b.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-700-normal.4b4022a6.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-700-normal.74b516d2.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-900-normal.9970ddb5.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-900-normal.a0d59adc.woff2 +0 -0
- package/__mf/font/inter-greek-300-normal.0d7be683.woff2 +0 -0
- package/__mf/font/inter-greek-300-normal.8f0b988e.woff +0 -0
- package/__mf/font/inter-greek-400-normal.cc58c11b.woff +0 -0
- package/__mf/font/inter-greek-400-normal.d7020e3c.woff2 +0 -0
- package/__mf/font/inter-greek-500-normal.d9a33207.woff +0 -0
- package/__mf/font/inter-greek-500-normal.f41f43db.woff2 +0 -0
- package/__mf/font/inter-greek-600-normal.4ec0c1c1.woff +0 -0
- package/__mf/font/inter-greek-600-normal.cc532937.woff2 +0 -0
- package/__mf/font/inter-greek-700-normal.5ec6c758.woff +0 -0
- package/__mf/font/inter-greek-700-normal.97f0eeeb.woff2 +0 -0
- package/__mf/font/inter-greek-900-normal.46b66369.woff2 +0 -0
- package/__mf/font/inter-greek-900-normal.9ae3a3c5.woff +0 -0
- package/__mf/font/inter-greek-ext-300-normal.10247a66.woff2 +0 -0
- package/__mf/font/inter-greek-ext-300-normal.4668e5cb.woff +0 -0
- package/__mf/font/inter-greek-ext-400-normal.4ce1df5d.woff2 +0 -0
- package/__mf/font/inter-greek-ext-400-normal.88ede1ea.woff +0 -0
- package/__mf/font/inter-greek-ext-500-normal.7a4aa726.woff +0 -0
- package/__mf/font/inter-greek-ext-500-normal.cbd51e2d.woff2 +0 -0
- package/__mf/font/inter-greek-ext-600-normal.089a95ee.woff +0 -0
- package/__mf/font/inter-greek-ext-600-normal.1f33d317.woff2 +0 -0
- package/__mf/font/inter-greek-ext-700-normal.31f1075d.woff +0 -0
- package/__mf/font/inter-greek-ext-700-normal.827cd618.woff2 +0 -0
- package/__mf/font/inter-greek-ext-900-normal.531bcee7.woff +0 -0
- package/__mf/font/inter-greek-ext-900-normal.8a9b36b9.woff2 +0 -0
- package/__mf/font/inter-latin-300-normal.15fb600d.woff2 +0 -0
- package/__mf/font/inter-latin-300-normal.6f95f590.woff +0 -0
- package/__mf/font/inter-latin-400-normal.2c7a775c.woff +0 -0
- package/__mf/font/inter-latin-400-normal.ef6d3f52.woff2 +0 -0
- package/__mf/font/inter-latin-500-normal.b7b43ace.woff2 +0 -0
- package/__mf/font/inter-latin-500-normal.cb4c8ceb.woff +0 -0
- package/__mf/font/inter-latin-600-normal.8fb1a964.woff2 +0 -0
- package/__mf/font/inter-latin-600-normal.ce0f5f43.woff +0 -0
- package/__mf/font/inter-latin-700-normal.953b7aa5.woff2 +0 -0
- package/__mf/font/inter-latin-700-normal.9c21d4dc.woff +0 -0
- package/__mf/font/inter-latin-900-normal.2a8028ec.woff2 +0 -0
- package/__mf/font/inter-latin-900-normal.fa252135.woff +0 -0
- package/__mf/font/inter-latin-ext-300-normal.167cc8c9.woff2 +0 -0
- package/__mf/font/inter-latin-ext-300-normal.f695be66.woff +0 -0
- package/__mf/font/inter-latin-ext-400-normal.32a25442.woff2 +0 -0
- package/__mf/font/inter-latin-ext-400-normal.4edcaace.woff +0 -0
- package/__mf/font/inter-latin-ext-500-normal.a19a84a6.woff +0 -0
- package/__mf/font/inter-latin-ext-500-normal.d9b491de.woff2 +0 -0
- package/__mf/font/inter-latin-ext-600-normal.38b075d8.woff2 +0 -0
- package/__mf/font/inter-latin-ext-600-normal.49faa47a.woff +0 -0
- package/__mf/font/inter-latin-ext-700-normal.93534b50.woff +0 -0
- package/__mf/font/inter-latin-ext-700-normal.b63daa1a.woff2 +0 -0
- package/__mf/font/inter-latin-ext-900-normal.0efdb307.woff +0 -0
- package/__mf/font/inter-latin-ext-900-normal.9c0fc2c7.woff2 +0 -0
- package/__mf/font/inter-vietnamese-300-normal.aad496d8.woff +0 -0
- package/__mf/font/inter-vietnamese-300-normal.ad9ef503.woff2 +0 -0
- package/__mf/font/inter-vietnamese-400-normal.a9dd2faf.woff +0 -0
- package/__mf/font/inter-vietnamese-400-normal.de4fc44f.woff2 +0 -0
- package/__mf/font/inter-vietnamese-500-normal.7c0a695f.woff2 +0 -0
- package/__mf/font/inter-vietnamese-500-normal.a3a73b95.woff +0 -0
- package/__mf/font/inter-vietnamese-600-normal.9d518599.woff2 +0 -0
- package/__mf/font/inter-vietnamese-600-normal.c5ce3fcb.woff +0 -0
- package/__mf/font/inter-vietnamese-700-normal.bc68b199.woff +0 -0
- package/__mf/font/inter-vietnamese-700-normal.faf12809.woff2 +0 -0
- package/__mf/font/inter-vietnamese-900-normal.2b782045.woff +0 -0
- package/__mf/font/inter-vietnamese-900-normal.e639b65a.woff2 +0 -0
- package/__mf/js/BarChart.684cf4ee.js +7 -0
- package/__mf/js/async/121.697325de.js +2 -0
- package/__mf/js/async/177.83b4a0c7.js +1 -0
- package/__mf/js/async/187.dce780a3.js +24 -0
- package/__mf/js/async/{634.c4642701.js.LICENSE.txt → 187.dce780a3.js.LICENSE.txt} +0 -16
- package/__mf/js/async/192.978ad416.js +1 -0
- package/__mf/js/async/235.dcb2a938.js +1 -0
- package/__mf/js/async/236.1e90c5b6.js +7 -0
- package/__mf/js/async/{901.1c784bfb.js.LICENSE.txt → 236.1e90c5b6.js.LICENSE.txt} +19 -1
- package/__mf/js/async/274.48038fad.js +2 -0
- package/__mf/js/async/356.3310d2e7.js +1 -0
- package/__mf/js/async/377.fbdc975f.js +1 -0
- package/__mf/js/async/392.2095dbb3.js +2 -0
- package/__mf/js/async/435.dc0a9a8a.js +1 -0
- package/__mf/js/async/{77.f584b802.js → 458.8fe7d3e6.js} +1 -1
- package/__mf/js/async/46.f0465d0c.js +101 -0
- package/__mf/js/async/470.306558f6.js +2 -0
- package/__mf/js/async/496.1c041ac9.js +1 -0
- package/__mf/js/async/568.0c8cf5cf.js +1 -0
- package/__mf/js/async/587.f983bd0d.js +1 -0
- package/__mf/js/async/588.c5433cac.js +1 -0
- package/__mf/js/async/616.3805dee7.js +1 -0
- package/__mf/js/async/71.63183692.js +1 -0
- package/__mf/js/async/721.497b5f27.js +1 -0
- package/__mf/js/async/77.317669de.js +1 -0
- package/__mf/js/async/823.d7e96856.js +10 -0
- package/__mf/js/async/{204.9eb9aa47.js.LICENSE.txt → 823.d7e96856.js.LICENSE.txt} +1 -1
- package/__mf/js/async/854.c97a2bb3.js +1 -0
- package/__mf/js/async/873.be346a58.js +1 -0
- package/__mf/js/async/934.ffdb04e7.js +2 -0
- package/__mf/js/async/941.4dad52d6.js +2 -0
- package/__mf/js/async/958.30e78b21.js +39 -0
- package/__mf/js/async/{705.790ed4c5.js.LICENSE.txt → 958.30e78b21.js.LICENSE.txt} +17 -1
- package/__mf/js/async/963.2293b290.js +1 -0
- package/__mf/js/async/968.fc1dd4a5.js +1 -0
- package/__mf/js/async/978.fd94d741.js +1 -0
- package/__mf/js/async/__federation_expose_BarChart.44843c4d.js +1 -0
- package/__mf/js/async/lib-router.354c6b86.js +2 -0
- package/__mf/js/main.2ce2f26b.js +7 -0
- package/lib/BarChartBase.d.ts +12 -2
- package/lib/BarChartBase.d.ts.map +1 -1
- package/lib/BarChartBase.js +104 -12
- package/lib/BarChartBase.js.map +1 -1
- package/lib/BarChartOptionsEditorSettings.d.ts.map +1 -1
- package/lib/BarChartOptionsEditorSettings.js +98 -29
- package/lib/BarChartOptionsEditorSettings.js.map +1 -1
- package/lib/BarChartPanel.d.ts +1 -1
- package/lib/BarChartPanel.d.ts.map +1 -1
- package/lib/BarChartPanel.js +71 -4
- package/lib/BarChartPanel.js.map +1 -1
- package/lib/bar-chart-model.d.ts +9 -3
- package/lib/bar-chart-model.d.ts.map +1 -1
- package/lib/bar-chart-model.js +8 -2
- package/lib/bar-chart-model.js.map +1 -1
- package/lib/cjs/BarChartBase.js +107 -15
- package/lib/cjs/BarChartOptionsEditorSettings.js +95 -26
- package/lib/cjs/BarChartPanel.js +72 -5
- package/lib/cjs/bar-chart-model.js +18 -3
- package/lib/tresholds.d.ts +1 -1
- package/lib/tresholds.d.ts.map +1 -1
- package/lib/tresholds.js.map +1 -1
- package/mf-manifest.json +76 -62
- package/mf-stats.json +92 -64
- package/package.json +4 -4
- package/__mf/css/async/442.d3010b86.css +0 -1
- package/__mf/css/async/61.d3010b86.css +0 -1
- package/__mf/css/async/823.d3010b86.css +0 -1
- 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/BarChart.685a17f4.js +0 -6
- package/__mf/js/async/102.b7abdc1f.js +0 -1
- package/__mf/js/async/121.517e00e8.js +0 -2
- package/__mf/js/async/160.edce75b3.js +0 -1
- package/__mf/js/async/177.91621efa.js +0 -1
- package/__mf/js/async/192.73182890.js +0 -1
- package/__mf/js/async/204.9eb9aa47.js +0 -10
- package/__mf/js/async/235.b537858d.js +0 -38
- package/__mf/js/async/255.75982caf.js +0 -1
- package/__mf/js/async/274.9bfff28e.js +0 -2
- package/__mf/js/async/356.6146b01c.js +0 -1
- package/__mf/js/async/377.5b9c90dc.js +0 -1
- package/__mf/js/async/392.63dbc9c4.js +0 -2
- package/__mf/js/async/458.cffba90f.js +0 -1
- package/__mf/js/async/470.82e9b967.js +0 -2
- package/__mf/js/async/473.2df10452.js +0 -1
- package/__mf/js/async/496.b35b3a0a.js +0 -1
- package/__mf/js/async/587.bcc920f1.js +0 -1
- package/__mf/js/async/588.680cfad0.js +0 -1
- package/__mf/js/async/616.302bdae0.js +0 -1
- package/__mf/js/async/634.c4642701.js +0 -24
- package/__mf/js/async/703.16dd2eaa.js +0 -2
- package/__mf/js/async/705.790ed4c5.js +0 -102
- package/__mf/js/async/71.dab9ec76.js +0 -1
- package/__mf/js/async/854.7be16fdf.js +0 -1
- package/__mf/js/async/873.daa0c1ab.js +0 -1
- package/__mf/js/async/901.1c784bfb.js +0 -7
- package/__mf/js/async/941.4efdb193.js +0 -2
- package/__mf/js/async/963.85d5346b.js +0 -1
- package/__mf/js/async/968.d562d0d2.js +0 -1
- package/__mf/js/async/978.458b6e7d.js +0 -1
- package/__mf/js/async/__federation_expose_BarChart.8a38ae5e.js +0 -1
- package/__mf/js/async/lib-router.66821436.js +0 -2
- package/__mf/js/main.0490f6dd.js +0 -6
- /package/__mf/js/async/{121.517e00e8.js.LICENSE.txt → 121.697325de.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{274.9bfff28e.js.LICENSE.txt → 274.48038fad.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.63dbc9c4.js.LICENSE.txt → 392.2095dbb3.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{470.82e9b967.js.LICENSE.txt → 470.306558f6.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{703.16dd2eaa.js.LICENSE.txt → 934.ffdb04e7.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.4efdb193.js.LICENSE.txt → 941.4dad52d6.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.66821436.js.LICENSE.txt → lib-router.354c6b86.js.LICENSE.txt} +0 -0
|
@@ -21,9 +21,9 @@ Object.defineProperty(exports, "BarChartOptionsEditorSettings", {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _react = require("react");
|
|
24
25
|
const _material = require("@mui/material");
|
|
25
26
|
const _components = require("@perses-dev/components");
|
|
26
|
-
const _core = require("@perses-dev/core");
|
|
27
27
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
28
28
|
const _immer = require("immer");
|
|
29
29
|
const _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
|
|
@@ -57,40 +57,109 @@ function BarChartOptionsEditorSettings(props) {
|
|
|
57
57
|
};
|
|
58
58
|
const handleResetSettings = ()=>{
|
|
59
59
|
onChange((0, _immer.produce)(value, (draft)=>{
|
|
60
|
-
draft.calculation =
|
|
60
|
+
draft.calculation = _pluginsystem.DEFAULT_CALCULATION;
|
|
61
61
|
draft.format = _barchartmodel.DEFAULT_FORMAT;
|
|
62
62
|
draft.sort = _barchartmodel.DEFAULT_SORT;
|
|
63
63
|
draft.mode = _barchartmodel.DEFAULT_MODE;
|
|
64
|
+
draft.groupBy = _barchartmodel.DEFAULT_GROUP_BY;
|
|
65
|
+
draft.isStacked = _barchartmodel.DEFAULT_IS_STACKED;
|
|
66
|
+
draft.orientation = _barchartmodel.DEFAULT_ORIENTATION;
|
|
64
67
|
}));
|
|
65
68
|
};
|
|
66
69
|
// ensures decimalPlaces defaults to correct value
|
|
67
70
|
const format = (0, _merge.default)({}, _barchartmodel.DEFAULT_FORMAT, value.format);
|
|
71
|
+
const groupBy = value.groupBy ?? _barchartmodel.DEFAULT_GROUP_BY;
|
|
72
|
+
const isStacked = value.isStacked ?? _barchartmodel.DEFAULT_IS_STACKED;
|
|
68
73
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGrid, {
|
|
69
74
|
children: [
|
|
70
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
71
|
-
children:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
75
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorColumn, {
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
|
|
78
|
+
title: "Misc",
|
|
79
|
+
children: [
|
|
80
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormatControls, {
|
|
81
|
+
value: format,
|
|
82
|
+
onChange: handleUnitChange,
|
|
83
|
+
disabled: value.mode === 'percentage'
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.CalculationSelector, {
|
|
86
|
+
value: value.calculation,
|
|
87
|
+
onChange: handleCalculationChange
|
|
88
|
+
}),
|
|
89
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SortSelector, {
|
|
90
|
+
value: value.sort,
|
|
91
|
+
onChange: handleSortChange
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ModeSelector, {
|
|
94
|
+
value: value.mode,
|
|
95
|
+
onChange: handleModeChange,
|
|
96
|
+
disablePercentageMode: (0, _components.isPercentUnit)(format)
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.ToggleButtonGroup, {
|
|
99
|
+
exclusive: true,
|
|
100
|
+
size: "small",
|
|
101
|
+
value: value.orientation ?? 'horizontal',
|
|
102
|
+
onChange: (_, v)=>v && onChange((0, _immer.produce)(value, (draft)=>{
|
|
103
|
+
draft.orientation = v;
|
|
104
|
+
})),
|
|
105
|
+
children: [
|
|
106
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButton, {
|
|
107
|
+
value: "horizontal",
|
|
108
|
+
children: "Horizontal"
|
|
109
|
+
}),
|
|
110
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButton, {
|
|
111
|
+
value: "vertical",
|
|
112
|
+
children: "Vertical"
|
|
113
|
+
})
|
|
114
|
+
]
|
|
115
|
+
})
|
|
116
|
+
]
|
|
117
|
+
}),
|
|
118
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
|
|
119
|
+
title: "Stacking",
|
|
120
|
+
children: [
|
|
121
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Autocomplete, {
|
|
122
|
+
multiple: true,
|
|
123
|
+
freeSolo: true,
|
|
124
|
+
value: groupBy,
|
|
125
|
+
onChange: (_, newValue)=>{
|
|
126
|
+
const filtered = newValue.filter((v)=>v.trim() !== '');
|
|
127
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
128
|
+
draft.groupBy = filtered;
|
|
129
|
+
if (filtered.length === 0) draft.isStacked = false;
|
|
130
|
+
}));
|
|
131
|
+
},
|
|
132
|
+
options: [],
|
|
133
|
+
renderTags: (tagValues, getTagProps)=>tagValues.map((option, index)=>/*#__PURE__*/ (0, _react.createElement)(_material.Chip, {
|
|
134
|
+
size: "small",
|
|
135
|
+
variant: "outlined",
|
|
136
|
+
label: option,
|
|
137
|
+
...getTagProps({
|
|
138
|
+
index
|
|
139
|
+
}),
|
|
140
|
+
key: option
|
|
141
|
+
})),
|
|
142
|
+
renderInput: (params)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
143
|
+
...params,
|
|
144
|
+
size: "small",
|
|
145
|
+
label: "Group By Labels",
|
|
146
|
+
placeholder: "Type label name + Enter"
|
|
147
|
+
})
|
|
148
|
+
}),
|
|
149
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
150
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
151
|
+
size: "small",
|
|
152
|
+
checked: isStacked,
|
|
153
|
+
disabled: groupBy.length === 0,
|
|
154
|
+
onChange: (e)=>onChange((0, _immer.produce)(value, (draft)=>{
|
|
155
|
+
draft.isStacked = e.target.checked;
|
|
156
|
+
}))
|
|
157
|
+
}),
|
|
158
|
+
label: "Stack bars"
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
})
|
|
162
|
+
]
|
|
94
163
|
}),
|
|
95
164
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
|
|
96
165
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorGroup, {
|
package/lib/cjs/BarChartPanel.js
CHANGED
|
@@ -24,15 +24,16 @@ const _jsxruntime = require("react/jsx-runtime");
|
|
|
24
24
|
const _components = require("@perses-dev/components");
|
|
25
25
|
const _material = require("@mui/material");
|
|
26
26
|
const _react = require("react");
|
|
27
|
-
const
|
|
27
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
28
28
|
const _utils = require("./utils");
|
|
29
29
|
const _BarChartBase = require("./BarChartBase");
|
|
30
30
|
function BarChartPanel(props) {
|
|
31
|
-
const { spec: { calculation, format, sort, mode }, contentDimensions, queryResults } = props;
|
|
31
|
+
const { spec: { calculation, format, sort, mode, groupBy = [], isStacked = false, orientation = 'horizontal' }, contentDimensions, queryResults } = props;
|
|
32
32
|
const chartsTheme = (0, _components.useChartsTheme)();
|
|
33
33
|
const PADDING = chartsTheme.container.padding.default;
|
|
34
34
|
const barChartData = (0, _react.useMemo)(()=>{
|
|
35
|
-
|
|
35
|
+
if (groupBy.length > 0) return [];
|
|
36
|
+
const calculate = _pluginsystem.CalculationsMap[calculation];
|
|
36
37
|
const barChartData = [];
|
|
37
38
|
for (const result of queryResults){
|
|
38
39
|
for (const seriesData of result.data.series){
|
|
@@ -53,9 +54,72 @@ function BarChartPanel(props) {
|
|
|
53
54
|
queryResults,
|
|
54
55
|
sort,
|
|
55
56
|
mode,
|
|
57
|
+
calculation,
|
|
58
|
+
groupBy
|
|
59
|
+
]);
|
|
60
|
+
const stackedBarChartData = (0, _react.useMemo)(()=>{
|
|
61
|
+
if (groupBy.length === 0) return null;
|
|
62
|
+
const calculate = _pluginsystem.CalculationsMap[calculation];
|
|
63
|
+
const groupMap = new Map();
|
|
64
|
+
const segmentNamesOrdered = [];
|
|
65
|
+
const segmentNamesSet = new Set();
|
|
66
|
+
for (const queryResult of queryResults){
|
|
67
|
+
for (const seriesData of queryResult.data.series){
|
|
68
|
+
const labels = seriesData.labels ?? {};
|
|
69
|
+
const groupKey = groupBy.map((k)=>labels[k] ?? '').join(' / ');
|
|
70
|
+
const remainingEntries = Object.entries(labels).filter(([k])=>!groupBy.includes(k));
|
|
71
|
+
const segmentName = remainingEntries.length > 0 ? '{' + remainingEntries.map(([k, v])=>`${k}="${v}"`).join(', ') + '}' : seriesData.formattedName ?? seriesData.name;
|
|
72
|
+
if (!groupMap.has(groupKey)) {
|
|
73
|
+
groupMap.set(groupKey, new Map());
|
|
74
|
+
}
|
|
75
|
+
const segMap = groupMap.get(groupKey);
|
|
76
|
+
if (!segMap) continue;
|
|
77
|
+
const value = calculate(seriesData.values) ?? 0;
|
|
78
|
+
segMap.set(segmentName, (segMap.get(segmentName) ?? 0) + value);
|
|
79
|
+
if (!segmentNamesSet.has(segmentName)) {
|
|
80
|
+
segmentNamesSet.add(segmentName);
|
|
81
|
+
segmentNamesOrdered.push(segmentName);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (groupMap.size === 0) return null;
|
|
86
|
+
const getTotalValue = (cat)=>Array.from(groupMap.get(cat)?.values() ?? []).reduce((a, b)=>a + b, 0);
|
|
87
|
+
let categories = Array.from(groupMap.keys());
|
|
88
|
+
if (sort === 'asc') {
|
|
89
|
+
categories = categories.sort((a, b)=>getTotalValue(a) - getTotalValue(b));
|
|
90
|
+
} else if (sort === 'desc') {
|
|
91
|
+
categories = categories.sort((a, b)=>getTotalValue(b) - getTotalValue(a));
|
|
92
|
+
}
|
|
93
|
+
const series = segmentNamesOrdered.map((segName)=>{
|
|
94
|
+
const values = categories.map((cat)=>{
|
|
95
|
+
const rawVal = groupMap.get(cat)?.get(segName) ?? null;
|
|
96
|
+
if (mode === 'percentage' && rawVal !== null) {
|
|
97
|
+
const total = getTotalValue(cat);
|
|
98
|
+
return total > 0 ? rawVal / total * 100 : 0;
|
|
99
|
+
}
|
|
100
|
+
return rawVal;
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
name: segName,
|
|
104
|
+
values
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
categories,
|
|
109
|
+
series
|
|
110
|
+
};
|
|
111
|
+
}, [
|
|
112
|
+
queryResults,
|
|
113
|
+
groupBy,
|
|
114
|
+
sort,
|
|
115
|
+
mode,
|
|
56
116
|
calculation
|
|
57
117
|
]);
|
|
58
118
|
if (contentDimensions === undefined) return null;
|
|
119
|
+
const effectiveFormat = mode === 'percentage' ? {
|
|
120
|
+
unit: 'percent',
|
|
121
|
+
decimalPlaces: format?.decimalPlaces
|
|
122
|
+
} : format;
|
|
59
123
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
60
124
|
sx: {
|
|
61
125
|
padding: `${PADDING}px`
|
|
@@ -64,8 +128,11 @@ function BarChartPanel(props) {
|
|
|
64
128
|
width: contentDimensions.width - PADDING * 2,
|
|
65
129
|
height: contentDimensions.height - PADDING * 2,
|
|
66
130
|
data: barChartData,
|
|
67
|
-
format: format,
|
|
68
|
-
mode: mode
|
|
131
|
+
format: groupBy.length > 0 ? effectiveFormat : format,
|
|
132
|
+
mode: mode,
|
|
133
|
+
groupedData: stackedBarChartData,
|
|
134
|
+
isStacked: isStacked,
|
|
135
|
+
orientation: orientation
|
|
69
136
|
})
|
|
70
137
|
});
|
|
71
138
|
}
|
|
@@ -24,9 +24,18 @@ _export(exports, {
|
|
|
24
24
|
get DEFAULT_FORMAT () {
|
|
25
25
|
return DEFAULT_FORMAT;
|
|
26
26
|
},
|
|
27
|
+
get DEFAULT_GROUP_BY () {
|
|
28
|
+
return DEFAULT_GROUP_BY;
|
|
29
|
+
},
|
|
30
|
+
get DEFAULT_IS_STACKED () {
|
|
31
|
+
return DEFAULT_IS_STACKED;
|
|
32
|
+
},
|
|
27
33
|
get DEFAULT_MODE () {
|
|
28
34
|
return DEFAULT_MODE;
|
|
29
35
|
},
|
|
36
|
+
get DEFAULT_ORIENTATION () {
|
|
37
|
+
return DEFAULT_ORIENTATION;
|
|
38
|
+
},
|
|
30
39
|
get DEFAULT_SORT () {
|
|
31
40
|
return DEFAULT_SORT;
|
|
32
41
|
},
|
|
@@ -34,18 +43,24 @@ _export(exports, {
|
|
|
34
43
|
return createInitialBarChartOptions;
|
|
35
44
|
}
|
|
36
45
|
});
|
|
37
|
-
const
|
|
46
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
38
47
|
const DEFAULT_FORMAT = {
|
|
39
48
|
unit: 'decimal',
|
|
40
49
|
shortValues: true
|
|
41
50
|
};
|
|
42
51
|
const DEFAULT_SORT = 'desc';
|
|
43
52
|
const DEFAULT_MODE = 'value';
|
|
53
|
+
const DEFAULT_ORIENTATION = 'horizontal';
|
|
54
|
+
const DEFAULT_GROUP_BY = [];
|
|
55
|
+
const DEFAULT_IS_STACKED = false;
|
|
44
56
|
function createInitialBarChartOptions() {
|
|
45
57
|
return {
|
|
46
|
-
calculation:
|
|
58
|
+
calculation: _pluginsystem.DEFAULT_CALCULATION,
|
|
47
59
|
format: DEFAULT_FORMAT,
|
|
48
60
|
sort: DEFAULT_SORT,
|
|
49
|
-
mode: DEFAULT_MODE
|
|
61
|
+
mode: DEFAULT_MODE,
|
|
62
|
+
orientation: DEFAULT_ORIENTATION,
|
|
63
|
+
groupBy: DEFAULT_GROUP_BY,
|
|
64
|
+
isStacked: DEFAULT_IS_STACKED
|
|
50
65
|
};
|
|
51
66
|
}
|
package/lib/tresholds.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ThresholdColorPalette, ThresholdOptions
|
|
1
|
+
import { FormatOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components';
|
|
2
2
|
export type GaugeColorStop = [number, string];
|
|
3
3
|
export type EChartsAxisLineColors = GaugeColorStop[];
|
|
4
4
|
export declare const defaultThresholdInput: ThresholdOptions;
|
package/lib/tresholds.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tresholds.d.ts","sourceRoot":"","sources":["../../src/tresholds.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,qBAAqB,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"tresholds.d.ts","sourceRoot":"","sources":["../../src/tresholds.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAe,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG7G,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG,cAAc,EAAE,CAAC;AAErD,eAAO,MAAM,qBAAqB,EAAE,gBAA4C,CAAC;AAEjF,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,aAAa,EACnB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,GAC7B,qBAAqB,CA4BvB"}
|
package/lib/tresholds.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tresholds.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StepOptions, ThresholdColorPalette, ThresholdOptions
|
|
1
|
+
{"version":3,"sources":["../../src/tresholds.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormatOptions, StepOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components';\nimport zip from 'lodash/zip';\n\nexport type GaugeColorStop = [number, string];\n\nexport type EChartsAxisLineColors = GaugeColorStop[];\n\nexport const defaultThresholdInput: ThresholdOptions = { steps: [{ value: 0 }] };\n\nexport function convertThresholds(\n thresholds: ThresholdOptions,\n unit: FormatOptions,\n max: number,\n palette: ThresholdColorPalette\n): EChartsAxisLineColors {\n const defaultThresholdColor = thresholds.defaultColor ?? palette.defaultColor;\n const defaultThresholdSteps: EChartsAxisLineColors = [[0, defaultThresholdColor]];\n\n if (thresholds.steps !== undefined) {\n // https://echarts.apache.org/en/option.html#series-gauge.axisLine.lineStyle.color\n // color segments must be decimal between 0 and 1\n const segmentMax = 1;\n const valuesArr: number[] = thresholds.steps.map((step: StepOptions) => {\n if (thresholds.mode === 'percent') {\n return step.value / 100;\n }\n return step.value / max;\n });\n valuesArr.push(segmentMax);\n\n const colorsArr = thresholds.steps.map((step: StepOptions, index) => step.color ?? palette.palette[index]);\n colorsArr.unshift(defaultThresholdColor);\n\n const zippedArr = zip(valuesArr, colorsArr);\n return zippedArr.map((elem) => {\n const convertedValues = elem[0] ?? segmentMax;\n const convertedColors = elem[1] ?? defaultThresholdColor;\n return [convertedValues, convertedColors];\n });\n } else {\n return defaultThresholdSteps;\n }\n}\n"],"names":["zip","defaultThresholdInput","steps","value","convertThresholds","thresholds","unit","max","palette","defaultThresholdColor","defaultColor","defaultThresholdSteps","undefined","segmentMax","valuesArr","map","step","mode","push","colorsArr","index","color","unshift","zippedArr","elem","convertedValues","convertedColors"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,OAAOA,SAAS,aAAa;AAM7B,OAAO,MAAMC,wBAA0C;IAAEC,OAAO;QAAC;YAAEC,OAAO;QAAE;KAAE;AAAC,EAAE;AAEjF,OAAO,SAASC,kBACdC,UAA4B,EAC5BC,IAAmB,EACnBC,GAAW,EACXC,OAA8B;IAE9B,MAAMC,wBAAwBJ,WAAWK,YAAY,IAAIF,QAAQE,YAAY;IAC7E,MAAMC,wBAA+C;QAAC;YAAC;YAAGF;SAAsB;KAAC;IAEjF,IAAIJ,WAAWH,KAAK,KAAKU,WAAW;QAClC,kFAAkF;QAClF,iDAAiD;QACjD,MAAMC,aAAa;QACnB,MAAMC,YAAsBT,WAAWH,KAAK,CAACa,GAAG,CAAC,CAACC;YAChD,IAAIX,WAAWY,IAAI,KAAK,WAAW;gBACjC,OAAOD,KAAKb,KAAK,GAAG;YACtB;YACA,OAAOa,KAAKb,KAAK,GAAGI;QACtB;QACAO,UAAUI,IAAI,CAACL;QAEf,MAAMM,YAAYd,WAAWH,KAAK,CAACa,GAAG,CAAC,CAACC,MAAmBI,QAAUJ,KAAKK,KAAK,IAAIb,QAAQA,OAAO,CAACY,MAAM;QACzGD,UAAUG,OAAO,CAACb;QAElB,MAAMc,YAAYvB,IAAIc,WAAWK;QACjC,OAAOI,UAAUR,GAAG,CAAC,CAACS;YACpB,MAAMC,kBAAkBD,IAAI,CAAC,EAAE,IAAIX;YACnC,MAAMa,kBAAkBF,IAAI,CAAC,EAAE,IAAIf;YACnC,OAAO;gBAACgB;gBAAiBC;aAAgB;QAC3C;IACF,OAAO;QACL,OAAOf;IACT;AACF"}
|