@perses-dev/gauge-chart-plugin 0.13.0 → 0.14.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.
Files changed (131) hide show
  1. package/__mf/js/GaugeChart.d0898a25.js +7 -0
  2. package/__mf/js/async/121.923647b2.js +2 -0
  3. package/__mf/js/async/192.66cc8639.js +1 -0
  4. package/__mf/js/async/208.1dc9d791.js +74 -0
  5. package/__mf/js/async/235.3d14b76d.js +1 -0
  6. package/__mf/js/async/274.481c2cff.js +2 -0
  7. package/__mf/js/async/356.81432231.js +1 -0
  8. package/__mf/js/async/377.5ac59bcd.js +1 -0
  9. package/__mf/js/async/392.589be345.js +2 -0
  10. package/__mf/js/async/403.f63f0b01.js +2 -0
  11. package/__mf/js/async/407.549724e8.js +4 -0
  12. package/__mf/js/async/407.549724e8.js.LICENSE.txt +9 -0
  13. package/__mf/js/async/410.41a2ea21.js +1 -0
  14. package/__mf/js/async/458.c3d7080e.js +1 -0
  15. package/__mf/js/async/463.1623acc4.js +7 -0
  16. package/__mf/js/async/{700.e028a93e.js.LICENSE.txt → 463.1623acc4.js.LICENSE.txt} +41 -1
  17. package/__mf/js/async/470.a5788e56.js +2 -0
  18. package/__mf/js/async/496.ddfbee86.js +1 -0
  19. package/__mf/js/async/587.b53469e7.js +1 -0
  20. package/__mf/js/async/588.231edddc.js +1 -0
  21. package/__mf/js/async/616.56af3d9a.js +1 -0
  22. package/__mf/js/async/71.5c044eb7.js +1 -0
  23. package/__mf/js/async/710.63c7c633.js +29 -0
  24. package/__mf/js/async/77.84340477.js +1 -0
  25. package/__mf/js/async/823.ed9ab057.js +10 -0
  26. package/__mf/js/async/844.8884c953.js +37 -0
  27. package/__mf/js/async/854.23201b26.js +1 -0
  28. package/__mf/js/async/873.828ee17a.js +1 -0
  29. package/__mf/js/async/941.f2b7612e.js +2 -0
  30. package/__mf/js/async/963.8f8fc110.js +1 -0
  31. package/__mf/js/async/968.fbee556d.js +1 -0
  32. package/__mf/js/async/978.75bd4607.js +1 -0
  33. package/__mf/js/async/__federation_expose_GaugeChart.a608d5e4.js +1 -0
  34. package/__mf/js/async/lib-router.a426c87f.js +2 -0
  35. package/__mf/js/main.7041202d.js +7 -0
  36. package/lib/GaugeChart.d.ts +3 -3
  37. package/lib/GaugeChart.d.ts.map +1 -1
  38. package/lib/GaugeChart.js +3 -3
  39. package/lib/GaugeChart.js.map +1 -1
  40. package/lib/GaugeChartBase.d.ts +3 -3
  41. package/lib/GaugeChartBase.d.ts.map +1 -1
  42. package/lib/GaugeChartBase.js +7 -7
  43. package/lib/GaugeChartBase.js.map +1 -1
  44. package/lib/GaugeChartOptionsEditorSettings.d.ts +2 -2
  45. package/lib/GaugeChartOptionsEditorSettings.d.ts.map +1 -1
  46. package/lib/GaugeChartOptionsEditorSettings.js +7 -7
  47. package/lib/GaugeChartOptionsEditorSettings.js.map +1 -1
  48. package/lib/GaugeChartPanel.d.ts +4 -4
  49. package/lib/GaugeChartPanel.d.ts.map +1 -1
  50. package/lib/GaugeChartPanel.js +8 -8
  51. package/lib/GaugeChartPanel.js.map +1 -1
  52. package/lib/bootstrap.js +2 -2
  53. package/lib/gauge-chart-model.d.ts +3 -3
  54. package/lib/gauge-chart-model.d.ts.map +1 -1
  55. package/lib/gauge-chart-model.js.map +1 -1
  56. package/lib/getPluginModule.d.ts +1 -1
  57. package/lib/getPluginModule.d.ts.map +1 -1
  58. package/lib/getPluginModule.js +3 -1
  59. package/lib/getPluginModule.js.map +1 -1
  60. package/lib/index-federation.js +1 -1
  61. package/lib/index.js +6 -6
  62. package/lib/index.js.map +1 -1
  63. package/lib/setup-tests.d.ts +1 -1
  64. package/lib/setup-tests.d.ts.map +1 -1
  65. package/lib/setup-tests.js +2 -2
  66. package/lib/setup-tests.js.map +1 -1
  67. package/lib/thresholds.d.ts +1 -1
  68. package/lib/thresholds.d.ts.map +1 -1
  69. package/lib/thresholds.js +1 -1
  70. package/lib/thresholds.js.map +1 -1
  71. package/mf-manifest.json +39 -40
  72. package/mf-stats.json +39 -40
  73. package/package.json +10 -10
  74. package/__mf/js/GaugeChart.7e331b64.js +0 -7
  75. package/__mf/js/async/121.4c5f5798.js +0 -2
  76. package/__mf/js/async/172.afec864d.js +0 -110
  77. package/__mf/js/async/177.2e554778.js +0 -1
  78. package/__mf/js/async/187.ba6fd686.js +0 -7
  79. package/__mf/js/async/187.ba6fd686.js.LICENSE.txt +0 -39
  80. package/__mf/js/async/192.fb5cd927.js +0 -1
  81. package/__mf/js/async/235.b918db36.js +0 -1
  82. package/__mf/js/async/274.9badab92.js +0 -2
  83. package/__mf/js/async/356.c7cf4f79.js +0 -1
  84. package/__mf/js/async/377.06309086.js +0 -1
  85. package/__mf/js/async/392.4807325b.js +0 -2
  86. package/__mf/js/async/403.9db35877.js +0 -2
  87. package/__mf/js/async/410.4043d582.js +0 -1
  88. package/__mf/js/async/458.0f5bc9ee.js +0 -1
  89. package/__mf/js/async/470.9e955be3.js +0 -2
  90. package/__mf/js/async/496.dc9e951b.js +0 -1
  91. package/__mf/js/async/546.7850a553.js +0 -24
  92. package/__mf/js/async/546.7850a553.js.LICENSE.txt +0 -19
  93. package/__mf/js/async/558.9e9f2911.js +0 -1
  94. package/__mf/js/async/587.2649e50b.js +0 -1
  95. package/__mf/js/async/588.f25e2591.js +0 -1
  96. package/__mf/js/async/616.0741833f.js +0 -1
  97. package/__mf/js/async/700.e028a93e.js +0 -30
  98. package/__mf/js/async/71.57cf30f3.js +0 -1
  99. package/__mf/js/async/756.cbb57779.js +0 -1
  100. package/__mf/js/async/77.629e7e49.js +0 -1
  101. package/__mf/js/async/823.488b0ae9.js +0 -10
  102. package/__mf/js/async/854.d052322d.js +0 -1
  103. package/__mf/js/async/873.650a20f9.js +0 -1
  104. package/__mf/js/async/941.c6518e38.js +0 -2
  105. package/__mf/js/async/963.ab063f73.js +0 -1
  106. package/__mf/js/async/968.5b4a4f18.js +0 -1
  107. package/__mf/js/async/978.8aa2a024.js +0 -1
  108. package/__mf/js/async/__federation_expose_GaugeChart.b9c57db4.js +0 -1
  109. package/__mf/js/async/lib-router.f8568e8a.js +0 -2
  110. package/__mf/js/main.c44733a6.js +0 -7
  111. package/lib/cjs/GaugeChart.js +0 -39
  112. package/lib/cjs/GaugeChartBase.js +0 -196
  113. package/lib/cjs/GaugeChartOptionsEditorSettings.js +0 -120
  114. package/lib/cjs/GaugeChartPanel.js +0 -195
  115. package/lib/cjs/bootstrap.js +0 -26
  116. package/lib/cjs/env.d.js +0 -14
  117. package/lib/cjs/gauge-chart-model.js +0 -57
  118. package/lib/cjs/getPluginModule.js +0 -39
  119. package/lib/cjs/index-federation.js +0 -55
  120. package/lib/cjs/index.js +0 -41
  121. package/lib/cjs/setup-tests.js +0 -19
  122. package/lib/cjs/thresholds.js +0 -77
  123. /package/__mf/css/async/{187.85c2cbf6.css → 463.85c2cbf6.css} +0 -0
  124. /package/__mf/js/async/{121.4c5f5798.js.LICENSE.txt → 121.923647b2.js.LICENSE.txt} +0 -0
  125. /package/__mf/js/async/{274.9badab92.js.LICENSE.txt → 274.481c2cff.js.LICENSE.txt} +0 -0
  126. /package/__mf/js/async/{392.4807325b.js.LICENSE.txt → 392.589be345.js.LICENSE.txt} +0 -0
  127. /package/__mf/js/async/{403.9db35877.js.LICENSE.txt → 403.f63f0b01.js.LICENSE.txt} +0 -0
  128. /package/__mf/js/async/{470.9e955be3.js.LICENSE.txt → 470.a5788e56.js.LICENSE.txt} +0 -0
  129. /package/__mf/js/async/{823.488b0ae9.js.LICENSE.txt → 823.ed9ab057.js.LICENSE.txt} +0 -0
  130. /package/__mf/js/async/{941.c6518e38.js.LICENSE.txt → 941.f2b7612e.js.LICENSE.txt} +0 -0
  131. /package/__mf/js/async/{lib-router.f8568e8a.js.LICENSE.txt → lib-router.a426c87f.js.LICENSE.txt} +0 -0
@@ -1,120 +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, "GaugeChartOptionsEditorSettings", {
18
- enumerable: true,
19
- get: function() {
20
- return GaugeChartOptionsEditorSettings;
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 _gaugechartmodel = require("./gauge-chart-model");
30
- function _interop_require_default(obj) {
31
- return obj && obj.__esModule ? obj : {
32
- default: obj
33
- };
34
- }
35
- function GaugeChartOptionsEditorSettings(props) {
36
- const { onChange, value } = props;
37
- /* If legend setting doesn't exist (because it is optional), the legend should show by default
38
- This is for the records before the legend option was added
39
- */ const showLegend = value?.legend?.show ?? true;
40
- const handleCalculationChange = (newCalculation)=>{
41
- onChange((0, _immer.produce)(value, (draft)=>{
42
- draft.calculation = newCalculation;
43
- }));
44
- };
45
- const handleUnitChange = (newFormat)=>{
46
- onChange((0, _immer.produce)(value, (draft)=>{
47
- draft.format = newFormat;
48
- }));
49
- };
50
- // ensures decimalPlaces defaults to correct value
51
- const format = (0, _merge.default)({}, _gaugechartmodel.DEFAULT_FORMAT, value.format);
52
- // max only needs to be set explicitly for units other than percent and percent-decimal
53
- let maxPlaceholder = 'Enter value';
54
- if (format.unit === 'percent') {
55
- maxPlaceholder = _gaugechartmodel.DEFAULT_MAX_PERCENT.toString();
56
- } else if (format.unit === 'percent-decimal') {
57
- maxPlaceholder = _gaugechartmodel.DEFAULT_MAX_PERCENT_DECIMAL.toString();
58
- }
59
- const handleThresholdsChange = (thresholds)=>{
60
- onChange((0, _immer.produce)(value, (draft)=>{
61
- draft.thresholds = thresholds;
62
- }));
63
- };
64
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGrid, {
65
- children: [
66
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
67
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
68
- title: "Misc",
69
- children: [
70
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormatControls, {
71
- value: format,
72
- onChange: handleUnitChange
73
- }),
74
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.CalculationSelector, {
75
- value: value.calculation,
76
- onChange: handleCalculationChange
77
- }),
78
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
79
- label: "Max",
80
- control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
81
- type: "number",
82
- value: value.max ?? '',
83
- onChange: (e)=>{
84
- // ensure empty value resets to undef to allow chart to calculate max
85
- const newValue = e.target.value ? Number(e.target.value) : undefined;
86
- onChange((0, _immer.produce)(value, (draft)=>{
87
- draft.max = newValue;
88
- }));
89
- },
90
- placeholder: maxPlaceholder
91
- })
92
- })
93
- ]
94
- })
95
- }),
96
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorColumn, {
97
- children: [
98
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ThresholdsEditor, {
99
- thresholds: value.thresholds,
100
- onChange: handleThresholdsChange
101
- }),
102
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
103
- label: "Show legend",
104
- control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
105
- onChange: ()=>{
106
- onChange((0, _immer.produce)(value, (draft)=>{
107
- draft.legend = {
108
- ...draft.legend,
109
- show: !showLegend
110
- };
111
- }));
112
- },
113
- checked: showLegend
114
- })
115
- })
116
- ]
117
- })
118
- ]
119
- });
120
- }
@@ -1,195 +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 GaugeChartLoading () {
25
- return GaugeChartLoading;
26
- },
27
- get GaugeChartPanel () {
28
- return GaugeChartPanel;
29
- }
30
- });
31
- const _jsxruntime = require("react/jsx-runtime");
32
- const _material = require("@mui/material");
33
- const _components = require("@perses-dev/components");
34
- const _pluginsystem = require("@perses-dev/plugin-system");
35
- const _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
36
- const _react = require("react");
37
- const _gaugechartmodel = require("./gauge-chart-model");
38
- const _thresholds = require("./thresholds");
39
- const _GaugeChartBase = require("./GaugeChartBase");
40
- function _interop_require_default(obj) {
41
- return obj && obj.__esModule ? obj : {
42
- default: obj
43
- };
44
- }
45
- const EMPTY_GAUGE_SERIES = {
46
- label: '',
47
- value: undefined
48
- };
49
- const GAUGE_MIN_WIDTH = 90;
50
- const PANEL_PADDING_OFFSET = 20;
51
- /**
52
- * Calculate responsive progress width based on panel dimensions
53
- */ function getResponsiveProgressWidth(width, height) {
54
- const MIN_WIDTH = 10;
55
- const MAX_WIDTH = 48;
56
- const RATIO = 0.1; // 10% of the smaller dimension
57
- const minSize = Math.min(width, height);
58
- // Use RATIO of the smaller dimension as base, with reasonable min/max bounds
59
- return Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, Math.round(minSize * RATIO)));
60
- }
61
- /**
62
- * Responsive font size depending on number of characters and panel dimensions.
63
- * Uses clamp to ensure the text never overflows and scales appropriately with panel size.
64
- * (Value refers to the main number value displayed inside the gauge)
65
- */ function getResponsiveValueFontSize(value, format, width, height) {
66
- const MIN_SIZE = 8;
67
- const MAX_SIZE = 64;
68
- const formattedValue = typeof value === 'number' ? (0, _components.formatValue)(value, format) : `${value}`;
69
- const valueTextLength = Math.max(formattedValue.length, 6); // Ensure a minimum length to avoid overly large text for short values
70
- const availableSpace = Math.min(width, height);
71
- const fontSize = availableSpace / valueTextLength;
72
- return `clamp(${MIN_SIZE}px, ${fontSize}px, ${MAX_SIZE}px)`;
73
- }
74
- /**
75
- * Calculate responsive title font size based on panel dimensions
76
- * (Title refers to the text displayed below the gauge as a legend)
77
- */ function getResponsiveTitleFontSize(width, height) {
78
- const MIN_SIZE = 10;
79
- const MAX_SIZE = 16;
80
- const RATIO = 0.06; // Use 6% of the smaller dimension as base
81
- const size = Math.round(Math.min(width, height) * RATIO);
82
- // Scale based on panel size, with reasonable min/max bounds
83
- return Math.max(MIN_SIZE, Math.min(MAX_SIZE, size));
84
- }
85
- function GaugeChartPanel(props) {
86
- const { spec: pluginSpec, contentDimensions, queryResults } = props;
87
- const { calculation, max, legend } = pluginSpec;
88
- const { thresholds: thresholdsColors } = (0, _components.useChartsTheme)();
89
- /* Legend setting just added to the cue schema
90
- This line assures that if legend setting doesn't exist (for old gauge setting records),
91
- The legend shows normally as before. If it exists, then it checks the show property.
92
- */ const showLegend = legend?.show ?? true;
93
- // ensures all default format properties set if undef
94
- const format = (0, _merge.default)({}, _gaugechartmodel.DEFAULT_FORMAT, pluginSpec.format);
95
- const thresholds = pluginSpec.thresholds ?? _thresholds.defaultThresholdInput;
96
- const gaugeData = (0, _react.useMemo)(()=>{
97
- const seriesData = [];
98
- if (!_pluginsystem.CalculationsMap[calculation]) {
99
- console.warn(`Invalid GaugeChart panel calculation ${calculation}, fallback to ${_pluginsystem.DEFAULT_CALCULATION}`);
100
- }
101
- const calculate = _pluginsystem.CalculationsMap[calculation] ?? _pluginsystem.CalculationsMap[_pluginsystem.DEFAULT_CALCULATION];
102
- for (const result of queryResults){
103
- for (const timeSeries of result.data.series){
104
- seriesData.push({
105
- value: calculate(timeSeries.values),
106
- label: showLegend ? timeSeries.formattedName ?? '' : ''
107
- });
108
- }
109
- }
110
- return seriesData;
111
- }, [
112
- queryResults,
113
- calculation,
114
- showLegend
115
- ]);
116
- if (!contentDimensions) return null;
117
- // needed for end value of last threshold color segment
118
- let thresholdMax = max;
119
- if (thresholdMax === undefined) {
120
- thresholdMax = format.unit === 'percent' ? _gaugechartmodel.DEFAULT_MAX_PERCENT : _gaugechartmodel.DEFAULT_MAX_PERCENT_DECIMAL;
121
- }
122
- const axisLineColors = (0, _thresholds.convertThresholds)(thresholds, format, thresholdMax, thresholdsColors);
123
- // accounts for showing a separate chart for each time series
124
- let chartWidth = contentDimensions.width / gaugeData.length - PANEL_PADDING_OFFSET;
125
- if (chartWidth < GAUGE_MIN_WIDTH && gaugeData.length > 1) {
126
- // enables horizontal scroll when charts overflow outside of panel
127
- chartWidth = GAUGE_MIN_WIDTH;
128
- }
129
- // Calculate responsive values based on chart dimensions
130
- const progressWidth = getResponsiveProgressWidth(chartWidth, contentDimensions.height);
131
- const axisLineWidth = Math.round(progressWidth * 0.2); // Axis line width is 20% of progress width
132
- const titleFontSize = getResponsiveTitleFontSize(chartWidth, contentDimensions.height);
133
- const axisLine = {
134
- show: true,
135
- lineStyle: {
136
- width: axisLineWidth,
137
- color: axisLineColors
138
- }
139
- };
140
- // no data message handled inside chart component
141
- if (!gaugeData.length) {
142
- const emptyValueFontSize = getResponsiveValueFontSize(null, format, contentDimensions.width, contentDimensions.height);
143
- const emptyProgressWidth = getResponsiveProgressWidth(contentDimensions.width, contentDimensions.height);
144
- const emptyTitleFontSize = getResponsiveTitleFontSize(contentDimensions.width, contentDimensions.height);
145
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_GaugeChartBase.GaugeChartBase, {
146
- width: contentDimensions.width,
147
- height: contentDimensions.height,
148
- data: EMPTY_GAUGE_SERIES,
149
- format: format,
150
- axisLine: axisLine,
151
- max: thresholdMax,
152
- valueFontSize: emptyValueFontSize,
153
- progressWidth: emptyProgressWidth,
154
- titleFontSize: emptyTitleFontSize
155
- });
156
- }
157
- const hasMultipleCharts = gaugeData.length > 1;
158
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
159
- direction: "row",
160
- spacing: hasMultipleCharts ? 2 : 0,
161
- justifyContent: hasMultipleCharts ? 'left' : 'center',
162
- alignItems: "center",
163
- sx: {
164
- // so scrollbar only shows when necessary
165
- overflowX: gaugeData.length > 1 ? 'scroll' : 'auto'
166
- },
167
- children: gaugeData.map((series, seriesIndex)=>{
168
- const fontSize = getResponsiveValueFontSize(series.value ?? null, format, chartWidth, contentDimensions.height);
169
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
170
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_GaugeChartBase.GaugeChartBase, {
171
- width: chartWidth,
172
- height: contentDimensions.height,
173
- data: series,
174
- format: format,
175
- axisLine: axisLine,
176
- max: thresholdMax,
177
- valueFontSize: fontSize,
178
- progressWidth: progressWidth,
179
- titleFontSize: titleFontSize
180
- })
181
- }, `gauge-series-${seriesIndex}`);
182
- })
183
- });
184
- }
185
- function GaugeChartLoading({ contentDimensions }) {
186
- if (!contentDimensions) return null;
187
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Skeleton, {
188
- sx: {
189
- margin: '0 auto'
190
- },
191
- variant: "circular",
192
- width: contentDimensions.width > contentDimensions.height ? contentDimensions.height : contentDimensions.width,
193
- height: contentDimensions.height
194
- });
195
- }
@@ -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,57 +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 DEFAULT_FORMAT () {
25
- return DEFAULT_FORMAT;
26
- },
27
- get DEFAULT_MAX_PERCENT () {
28
- return DEFAULT_MAX_PERCENT;
29
- },
30
- get DEFAULT_MAX_PERCENT_DECIMAL () {
31
- return DEFAULT_MAX_PERCENT_DECIMAL;
32
- },
33
- get createInitialGaugeChartOptions () {
34
- return createInitialGaugeChartOptions;
35
- }
36
- });
37
- const DEFAULT_FORMAT = {
38
- unit: 'percent-decimal'
39
- };
40
- const DEFAULT_MAX_PERCENT = 100;
41
- const DEFAULT_MAX_PERCENT_DECIMAL = 1;
42
- function createInitialGaugeChartOptions() {
43
- return {
44
- calculation: 'last-number',
45
- format: DEFAULT_FORMAT,
46
- thresholds: {
47
- steps: [
48
- {
49
- value: 0.8
50
- },
51
- {
52
- value: 0.9
53
- }
54
- ]
55
- }
56
- };
57
- }
@@ -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,41 +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
- _export_star(require("./gauge-chart-model"), exports);
24
- _export_star(require("./GaugeChart"), exports);
25
- _export_star(require("./GaugeChartOptionsEditorSettings"), exports);
26
- _export_star(require("./GaugeChartPanel"), exports);
27
- const _getPluginModule = require("./getPluginModule");
28
- _export_star(require("./thresholds"), exports);
29
- function _export_star(from, to) {
30
- Object.keys(from).forEach(function(k) {
31
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
32
- Object.defineProperty(to, k, {
33
- enumerable: true,
34
- get: function() {
35
- return from[k];
36
- }
37
- });
38
- }
39
- });
40
- return from;
41
- }
@@ -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,77 +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 convertThresholds () {
25
- return convertThresholds;
26
- },
27
- get defaultThresholdInput () {
28
- return defaultThresholdInput;
29
- }
30
- });
31
- const _zip = /*#__PURE__*/ _interop_require_default(require("lodash/zip"));
32
- function _interop_require_default(obj) {
33
- return obj && obj.__esModule ? obj : {
34
- default: obj
35
- };
36
- }
37
- const defaultThresholdInput = {
38
- steps: [
39
- {
40
- value: 0
41
- }
42
- ]
43
- };
44
- function convertThresholds(thresholds, unit, max, palette) {
45
- const defaultThresholdColor = thresholds.defaultColor ?? palette.defaultColor;
46
- const defaultThresholdSteps = [
47
- [
48
- 0,
49
- defaultThresholdColor
50
- ]
51
- ];
52
- if (thresholds.steps !== undefined) {
53
- // https://echarts.apache.org/en/option.html#series-gauge.axisLine.lineStyle.color
54
- // color segments must be decimal between 0 and 1
55
- const segmentMax = 1;
56
- const valuesArr = thresholds.steps.map((step)=>{
57
- if (thresholds.mode === 'percent') {
58
- return step.value / 100;
59
- }
60
- return step.value / max;
61
- });
62
- valuesArr.push(segmentMax);
63
- const colorsArr = thresholds.steps.map((step, index)=>step.color ?? palette.palette[index]);
64
- colorsArr.unshift(defaultThresholdColor);
65
- const zippedArr = (0, _zip.default)(valuesArr, colorsArr);
66
- return zippedArr.map((elem)=>{
67
- const convertedValues = elem[0] ?? segmentMax;
68
- const convertedColors = elem[1] ?? defaultThresholdColor;
69
- return [
70
- convertedValues,
71
- convertedColors
72
- ];
73
- });
74
- } else {
75
- return defaultThresholdSteps;
76
- }
77
- }