@perses-dev/pie-chart-plugin 0.6.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.
Files changed (129) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +41 -0
  3. package/__mf/css/async/263.80005a4a.css +1 -0
  4. package/__mf/css/async/341.80005a4a.css +1 -0
  5. package/__mf/css/async/759.80005a4a.css +1 -0
  6. package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
  7. package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
  8. package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
  9. package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
  10. package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
  11. package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
  12. package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
  13. package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
  14. package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
  15. package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
  16. package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
  17. package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
  18. package/__mf/js/693.77ca36d8.js +5 -0
  19. package/__mf/js/PieChart.9e5c2bf5.js +5 -0
  20. package/__mf/js/async/162.668ea958.js +73 -0
  21. package/__mf/js/async/162.668ea958.js.LICENSE.txt +19 -0
  22. package/__mf/js/async/173.ee70b493.js +2 -0
  23. package/__mf/js/async/173.ee70b493.js.LICENSE.txt +19 -0
  24. package/__mf/js/async/214.df2e7807.js +1 -0
  25. package/__mf/js/async/224.dbeed4db.js +1 -0
  26. package/__mf/js/async/238.5287310b.js +1 -0
  27. package/__mf/js/async/292.f278784e.js +1 -0
  28. package/__mf/js/async/331.a0d6355f.js +2 -0
  29. package/__mf/js/async/331.a0d6355f.js.LICENSE.txt +21 -0
  30. package/__mf/js/async/36.ac56ec70.js +38 -0
  31. package/__mf/js/async/360.fdc4e499.js +29 -0
  32. package/__mf/js/async/360.fdc4e499.js.LICENSE.txt +37 -0
  33. package/__mf/js/async/488.0fc5dcbb.js +1 -0
  34. package/__mf/js/async/610.8c8cf7f2.js +1 -0
  35. package/__mf/js/async/620.9a73a66b.js +2 -0
  36. package/__mf/js/async/620.9a73a66b.js.LICENSE.txt +9 -0
  37. package/__mf/js/async/651.a1042e18.js +1 -0
  38. package/__mf/js/async/656.5efccb26.js +1 -0
  39. package/__mf/js/async/694.b227b636.js +1 -0
  40. package/__mf/js/async/707.55fda5d1.js +1 -0
  41. package/__mf/js/async/738.4ac98841.js +1 -0
  42. package/__mf/js/async/740.b86dfa00.js +1 -0
  43. package/__mf/js/async/75.905151a5.js +1 -0
  44. package/__mf/js/async/770.93415255.js +1 -0
  45. package/__mf/js/async/960.208437e1.js +2 -0
  46. package/__mf/js/async/960.208437e1.js.LICENSE.txt +8 -0
  47. package/__mf/js/async/964.6df60c3e.js +2 -0
  48. package/__mf/js/async/964.6df60c3e.js.LICENSE.txt +9 -0
  49. package/__mf/js/async/973.74031340.js +110 -0
  50. package/__mf/js/async/973.74031340.js.LICENSE.txt +27 -0
  51. package/__mf/js/async/981.3ecbf5ea.js +2 -0
  52. package/__mf/js/async/981.3ecbf5ea.js.LICENSE.txt +8 -0
  53. package/__mf/js/async/996.9e160813.js +2 -0
  54. package/__mf/js/async/996.9e160813.js.LICENSE.txt +24 -0
  55. package/__mf/js/async/__federation_expose_PieChart.f03b1180.js +1 -0
  56. package/__mf/js/async/lib-router.d29f3ef0.js +2 -0
  57. package/__mf/js/async/lib-router.d29f3ef0.js.LICENSE.txt +32 -0
  58. package/__mf/js/main.518abb8d.js +1 -0
  59. package/lib/PieChart.d.ts +8 -0
  60. package/lib/PieChart.d.ts.map +1 -0
  61. package/lib/PieChart.js +32 -0
  62. package/lib/PieChart.js.map +1 -0
  63. package/lib/PieChartOptionsEditorSettings.d.ts +4 -0
  64. package/lib/PieChartOptionsEditorSettings.d.ts.map +1 -0
  65. package/lib/PieChartOptionsEditorSettings.js +104 -0
  66. package/lib/PieChartOptionsEditorSettings.js.map +1 -0
  67. package/lib/PieChartPanel.d.ts +7 -0
  68. package/lib/PieChartPanel.d.ts.map +1 -0
  69. package/lib/PieChartPanel.js +164 -0
  70. package/lib/PieChartPanel.js.map +1 -0
  71. package/lib/bootstrap.d.ts +2 -0
  72. package/lib/bootstrap.d.ts.map +1 -0
  73. package/lib/bootstrap.js +19 -0
  74. package/lib/bootstrap.js.map +1 -0
  75. package/lib/cjs/PieChart.js +38 -0
  76. package/lib/cjs/PieChartOptionsEditorSettings.js +117 -0
  77. package/lib/cjs/PieChartPanel.js +177 -0
  78. package/lib/cjs/bootstrap.js +26 -0
  79. package/lib/cjs/env.d.js +14 -0
  80. package/lib/cjs/getPluginModule.js +27 -0
  81. package/lib/cjs/index-federation.js +55 -0
  82. package/lib/cjs/index.js +31 -0
  83. package/lib/cjs/model.js +16 -0
  84. package/lib/cjs/palette-gen.js +75 -0
  85. package/lib/cjs/palette.js +83 -0
  86. package/lib/cjs/pie-chart-model.js +114 -0
  87. package/lib/cjs/setup-tests.js +19 -0
  88. package/lib/cjs/utils.js +72 -0
  89. package/lib/env.d.js +15 -0
  90. package/lib/env.d.js.map +1 -0
  91. package/lib/getPluginModule.d.ts +6 -0
  92. package/lib/getPluginModule.d.ts.map +1 -0
  93. package/lib/getPluginModule.js +16 -0
  94. package/lib/getPluginModule.js.map +1 -0
  95. package/lib/index-federation.d.ts +1 -0
  96. package/lib/index-federation.d.ts.map +1 -0
  97. package/lib/index-federation.js +15 -0
  98. package/lib/index-federation.js.map +1 -0
  99. package/lib/index.d.ts +9 -0
  100. package/lib/index.d.ts.map +1 -0
  101. package/lib/index.js +10 -0
  102. package/lib/index.js.map +1 -0
  103. package/lib/model.d.ts +20 -0
  104. package/lib/model.d.ts.map +1 -0
  105. package/lib/model.js +15 -0
  106. package/lib/model.js.map +1 -0
  107. package/lib/palette-gen.d.ts +25 -0
  108. package/lib/palette-gen.d.ts.map +1 -0
  109. package/lib/palette-gen.js +62 -0
  110. package/lib/palette-gen.js.map +1 -0
  111. package/lib/palette.d.ts +6 -0
  112. package/lib/palette.d.ts.map +1 -0
  113. package/lib/palette.js +64 -0
  114. package/lib/palette.js.map +1 -0
  115. package/lib/pie-chart-model.d.ts +71 -0
  116. package/lib/pie-chart-model.d.ts.map +1 -0
  117. package/lib/pie-chart-model.js +71 -0
  118. package/lib/pie-chart-model.js.map +1 -0
  119. package/lib/setup-tests.d.ts +2 -0
  120. package/lib/setup-tests.d.ts.map +1 -0
  121. package/lib/setup-tests.js +17 -0
  122. package/lib/setup-tests.js.map +1 -0
  123. package/lib/utils.d.ts +7 -0
  124. package/lib/utils.d.ts.map +1 -0
  125. package/lib/utils.js +56 -0
  126. package/lib/utils.js.map +1 -0
  127. package/mf-manifest.json +321 -0
  128. package/mf-stats.json +366 -0
  129. package/package.json +53 -0
@@ -0,0 +1,55 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ function _getRequireWildcardCache(nodeInterop) {
15
+ if (typeof WeakMap !== "function") return null;
16
+ var cacheBabelInterop = new WeakMap();
17
+ var cacheNodeInterop = new WeakMap();
18
+ return (_getRequireWildcardCache = function(nodeInterop) {
19
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
20
+ })(nodeInterop);
21
+ }
22
+ function _interop_require_wildcard(obj, nodeInterop) {
23
+ if (!nodeInterop && obj && obj.__esModule) {
24
+ return obj;
25
+ }
26
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
27
+ return {
28
+ default: obj
29
+ };
30
+ }
31
+ var cache = _getRequireWildcardCache(nodeInterop);
32
+ if (cache && cache.has(obj)) {
33
+ return cache.get(obj);
34
+ }
35
+ var newObj = {
36
+ __proto__: null
37
+ };
38
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
39
+ for(var key in obj){
40
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
41
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
42
+ if (desc && (desc.get || desc.set)) {
43
+ Object.defineProperty(newObj, key, desc);
44
+ } else {
45
+ newObj[key] = obj[key];
46
+ }
47
+ }
48
+ }
49
+ newObj.default = obj;
50
+ if (cache) {
51
+ cache.set(obj, newObj);
52
+ }
53
+ return newObj;
54
+ }
55
+ Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bootstrap")));
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getPluginModule", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _getPluginModule.getPluginModule;
9
+ }
10
+ });
11
+ _export_star(require(".//PieChartPanel"), exports);
12
+ const _getPluginModule = require("./getPluginModule");
13
+ _export_star(require("./model"), exports);
14
+ _export_star(require("./palette"), exports);
15
+ _export_star(require("./palette-gen"), exports);
16
+ _export_star(require("./pie-chart-model"), exports);
17
+ _export_star(require("./PieChart"), exports);
18
+ _export_star(require("./PieChartOptionsEditorSettings"), exports);
19
+ function _export_star(from, to) {
20
+ Object.keys(from).forEach(function(k) {
21
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
22
+ Object.defineProperty(to, k, {
23
+ enumerable: true,
24
+ get: function() {
25
+ return from[k];
26
+ }
27
+ });
28
+ }
29
+ });
30
+ return from;
31
+ }
@@ -0,0 +1,16 @@
1
+ // Copyright 2023 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
+ });
@@ -0,0 +1,75 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ getAutoPaletteColor: function() {
25
+ return getAutoPaletteColor;
26
+ },
27
+ getCategoricalPaletteColor: function() {
28
+ return getCategoricalPaletteColor;
29
+ },
30
+ getConsistentSeriesNameColor: function() {
31
+ return getConsistentSeriesNameColor;
32
+ },
33
+ getSeriesColor: function() {
34
+ return getSeriesColor;
35
+ }
36
+ });
37
+ const _palette = require("./palette");
38
+ function getSeriesColor(props) {
39
+ const { categoricalPalette, visual, muiPrimaryColor, seriesName, seriesIndex, querySettings, queryHasMultipleResults } = props;
40
+ // Use color overrides defined in query settings in priority, if applicable
41
+ if (querySettings) {
42
+ if (querySettings.colorMode === 'fixed') {
43
+ return querySettings.colorValue;
44
+ } else if (querySettings.colorMode === 'fixed-single' && !queryHasMultipleResults) {
45
+ return querySettings.colorValue;
46
+ }
47
+ }
48
+ // Fallback is unlikely to set unless echarts theme palette in charts theme provider is undefined.
49
+ const fallbackColor = Array.isArray(categoricalPalette) && categoricalPalette[0] ? categoricalPalette[0] // Needed since echarts color property isn't always an array.
50
+ : muiPrimaryColor;
51
+ // Explicit way to always cycle through classical palette instead of changing when based on number of series.
52
+ if (visual.palette?.mode === 'categorical') {
53
+ return getCategoricalPaletteColor(categoricalPalette, seriesIndex, fallbackColor);
54
+ }
55
+ return getAutoPaletteColor(seriesName, fallbackColor);
56
+ }
57
+ function getAutoPaletteColor(name, fallbackColor) {
58
+ // corresponds to 'Auto' in palette.kind for generative color palette
59
+ const generatedColor = getConsistentSeriesNameColor(name);
60
+ return generatedColor ?? fallbackColor;
61
+ }
62
+ function getCategoricalPaletteColor(palette, seriesIndex, fallbackColor) {
63
+ if (palette === undefined) {
64
+ return fallbackColor;
65
+ }
66
+ // Loop through predefined static color palette
67
+ const paletteTotalColors = palette.length ?? 1;
68
+ const paletteIndex = seriesIndex % paletteTotalColors;
69
+ // fallback color comes from echarts theme
70
+ const seriesColor = palette[paletteIndex] ?? fallbackColor;
71
+ return seriesColor;
72
+ }
73
+ function getConsistentSeriesNameColor(inputString) {
74
+ return (0, _palette.getConsistentColor)(inputString, inputString.toLowerCase().includes('error'));
75
+ }
@@ -0,0 +1,83 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ getConsistentCategoricalColor: function() {
25
+ return getConsistentCategoricalColor;
26
+ },
27
+ getConsistentColor: function() {
28
+ return getConsistentColor;
29
+ }
30
+ });
31
+ const _colorhash = /*#__PURE__*/ _interop_require_default(require("color-hash"));
32
+ function _interop_require_default(obj) {
33
+ return obj && obj.__esModule ? obj : {
34
+ default: obj
35
+ };
36
+ }
37
+ // Valid hue values are 0 to 360 and can be adjusted to control the generated colors.
38
+ // More info: https://github.com/zenozeng/color-hash#custom-hue
39
+ // Picked min of 20 and max of 360 to exclude common threshold colors (red).
40
+ // Items with "error" in them will always be generated as red.
41
+ const ERROR_HUE_CUTOFF = 20;
42
+ const colorGenerator = new _colorhash.default({
43
+ hue: {
44
+ min: ERROR_HUE_CUTOFF,
45
+ max: 360
46
+ }
47
+ });
48
+ const redColorGenerator = new _colorhash.default({
49
+ hue: {
50
+ min: 0,
51
+ max: ERROR_HUE_CUTOFF
52
+ }
53
+ });
54
+ function computeConsistentColor(name, error) {
55
+ const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);
56
+ const saturationPercent = `${(saturation * 100).toFixed(0)}%`;
57
+ const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;
58
+ return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;
59
+ }
60
+ // To check whether a color has already been generated for a given string.
61
+ // TODO: Predefined color aliases will be defined here
62
+ const colorLookup = {};
63
+ function getConsistentColor(name, error) {
64
+ const key = `${name}_____${error}`;
65
+ let value = colorLookup[key];
66
+ if (!value) {
67
+ value = computeConsistentColor(name, error);
68
+ colorLookup[key] = value;
69
+ }
70
+ return value;
71
+ }
72
+ function getConsistentCategoricalColor(name, error, categoricalPalette, errorPalette) {
73
+ const palette = error ? errorPalette : categoricalPalette;
74
+ if (palette.length === 0) {
75
+ console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');
76
+ return '#000';
77
+ }
78
+ let hash = 0;
79
+ for(let i = 0; i < name.length; i++){
80
+ hash = name.charCodeAt(i) + ((hash << 5) - hash);
81
+ }
82
+ return palette[Math.abs(hash) % palette.length] ?? '#000';
83
+ }
@@ -0,0 +1,114 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ DEFAULT_AREA_OPACITY: function() {
25
+ return DEFAULT_AREA_OPACITY;
26
+ },
27
+ DEFAULT_CONNECT_NULLS: function() {
28
+ return DEFAULT_CONNECT_NULLS;
29
+ },
30
+ DEFAULT_FORMAT: function() {
31
+ return DEFAULT_FORMAT;
32
+ },
33
+ DEFAULT_LINE_WIDTH: function() {
34
+ return DEFAULT_LINE_WIDTH;
35
+ },
36
+ DEFAULT_MODE: function() {
37
+ return DEFAULT_MODE;
38
+ },
39
+ DEFAULT_POINT_RADIUS: function() {
40
+ return DEFAULT_POINT_RADIUS;
41
+ },
42
+ DEFAULT_SORT: function() {
43
+ return DEFAULT_SORT;
44
+ },
45
+ DEFAULT_VISUAL: function() {
46
+ return DEFAULT_VISUAL;
47
+ },
48
+ POINT_SIZE_OFFSET: function() {
49
+ return POINT_SIZE_OFFSET;
50
+ },
51
+ VISUAL_CONFIG: function() {
52
+ return VISUAL_CONFIG;
53
+ },
54
+ createInitialPieChartOptions: function() {
55
+ return createInitialPieChartOptions;
56
+ }
57
+ });
58
+ const _core = require("@perses-dev/core");
59
+ const DEFAULT_CONNECT_NULLS = false;
60
+ const POINT_SIZE_OFFSET = 1.5;
61
+ const DEFAULT_FORMAT = {
62
+ unit: 'decimal',
63
+ shortValues: true
64
+ };
65
+ const DEFAULT_SORT = 'desc';
66
+ const DEFAULT_MODE = 'value';
67
+ const DEFAULT_LINE_WIDTH = 1.25;
68
+ const DEFAULT_AREA_OPACITY = 0;
69
+ const DEFAULT_POINT_RADIUS = DEFAULT_LINE_WIDTH + POINT_SIZE_OFFSET;
70
+ const VISUAL_CONFIG = {
71
+ lineWidth: {
72
+ label: 'Line Width',
73
+ testId: 'slider-line-width',
74
+ min: 0.25,
75
+ max: 3,
76
+ step: 0.25
77
+ },
78
+ pointRadius: {
79
+ label: 'Point Radius',
80
+ testId: 'slider-point-radius',
81
+ min: 0,
82
+ max: 6,
83
+ step: 0.25
84
+ },
85
+ areaOpacity: {
86
+ label: 'Area Opacity',
87
+ testId: 'slider-area-opacity',
88
+ min: 0,
89
+ max: 1,
90
+ step: 0.05
91
+ },
92
+ stack: {
93
+ label: 'Stack Series'
94
+ },
95
+ connectNulls: {
96
+ label: 'Connect Nulls'
97
+ }
98
+ };
99
+ const DEFAULT_VISUAL = {
100
+ lineWidth: DEFAULT_LINE_WIDTH,
101
+ areaOpacity: DEFAULT_AREA_OPACITY,
102
+ pointRadius: DEFAULT_POINT_RADIUS,
103
+ connectNulls: DEFAULT_CONNECT_NULLS
104
+ };
105
+ function createInitialPieChartOptions() {
106
+ return {
107
+ calculation: _core.DEFAULT_CALCULATION,
108
+ format: DEFAULT_FORMAT,
109
+ radius: 50,
110
+ sort: DEFAULT_SORT,
111
+ mode: DEFAULT_MODE,
112
+ visual: DEFAULT_VISUAL
113
+ };
114
+ }
@@ -0,0 +1,19 @@
1
+ // Copyright 2023 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');
@@ -0,0 +1,72 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ calculatePercentages: function() {
25
+ return calculatePercentages;
26
+ },
27
+ sortSeriesData: function() {
28
+ return sortSeriesData;
29
+ }
30
+ });
31
+ const _piechartmodel = require("./pie-chart-model");
32
+ function calculatePercentages(data) {
33
+ const sum = data.reduce((accumulator, { value })=>accumulator + (value ?? 0), 0);
34
+ return data.map((seriesData)=>{
35
+ const percentage = (seriesData.value ?? 0) / sum * 100;
36
+ return {
37
+ ...seriesData,
38
+ value: percentage
39
+ };
40
+ });
41
+ }
42
+ function sortSeriesData(data, sortOrder = _piechartmodel.DEFAULT_SORT) {
43
+ if (sortOrder === 'asc') {
44
+ // sort in ascending order by value
45
+ return data.sort((a, b)=>{
46
+ if (a.value === null) {
47
+ return 1;
48
+ }
49
+ if (b.value === null) {
50
+ return -1;
51
+ }
52
+ if (a.value === b.value) {
53
+ return 0;
54
+ }
55
+ return a.value < b.value ? 1 : -1;
56
+ });
57
+ } else {
58
+ // sort in descending order by value
59
+ return data.sort((a, b)=>{
60
+ if (a.value === null) {
61
+ return -1;
62
+ }
63
+ if (b.value === null) {
64
+ return 1;
65
+ }
66
+ if (a.value === b.value) {
67
+ return 0;
68
+ }
69
+ return a.value < b.value ? -1 : 1;
70
+ });
71
+ }
72
+ }
package/lib/env.d.js ADDED
@@ -0,0 +1,15 @@
1
+ // Copyright 2024 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
+
15
+ //# sourceMappingURL=env.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/env.d.ts"],"sourcesContent":["// Copyright 2024 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\n/// <reference types=\"@rsbuild/core/types\" />\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6CAA6C"}
@@ -0,0 +1,6 @@
1
+ import { PluginModuleResource } from '@perses-dev/plugin-system';
2
+ /**
3
+ * Returns the plugin module information from package.json
4
+ */
5
+ export declare function getPluginModule(): PluginModuleResource;
6
+ //# sourceMappingURL=getPluginModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAGnF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}
@@ -0,0 +1,16 @@
1
+ import packageJson from '../package.json';
2
+ /**
3
+ * Returns the plugin module information from package.json
4
+ */ export function getPluginModule() {
5
+ const { name, version, perses } = packageJson;
6
+ return {
7
+ kind: 'PluginModule',
8
+ metadata: {
9
+ name,
10
+ version
11
+ },
12
+ spec: perses
13
+ };
14
+ }
15
+
16
+ //# sourceMappingURL=getPluginModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/getPluginModule.ts"],"sourcesContent":["import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\nimport packageJson from '../package.json';\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AACA,OAAOA,iBAAiB,kBAAkB;AAE1C;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGJ;IAClC,OAAO;QACLK,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index-federation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-federation.d.ts","sourceRoot":"","sources":["../../src/index-federation.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ // Copyright 2024 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
+ import('./bootstrap');
14
+
15
+ //# sourceMappingURL=index-federation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index-federation.ts"],"sourcesContent":["// Copyright 2024 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('./bootstrap');\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export * from './/PieChartPanel';
2
+ export { getPluginModule } from './getPluginModule';
3
+ export * from './model';
4
+ export * from './palette';
5
+ export * from './palette-gen';
6
+ export * from './pie-chart-model';
7
+ export * from './PieChart';
8
+ export * from './PieChartOptionsEditorSettings';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,iCAAiC,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export * from './/PieChartPanel';
2
+ export { getPluginModule } from './getPluginModule';
3
+ export * from './model';
4
+ export * from './palette';
5
+ export * from './palette-gen';
6
+ export * from './pie-chart-model';
7
+ export * from './PieChart';
8
+ export * from './PieChartOptionsEditorSettings';
9
+
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './/PieChartPanel';\nexport { getPluginModule } from './getPluginModule';\nexport * from './model';\nexport * from './palette';\nexport * from './palette-gen';\nexport * from './pie-chart-model';\nexport * from './PieChart';\nexport * from './PieChartOptionsEditorSettings';\n"],"names":["getPluginModule"],"mappings":"AAAA,cAAc,mBAAmB;AACjC,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,aAAa;AAC3B,cAAc,kCAAkC"}
package/lib/model.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export interface QuerySettingsOptions {
2
+ queryIndex: number;
3
+ colorMode: 'fixed' | 'fixed-single';
4
+ colorValue: string;
5
+ }
6
+ export interface ChartPaletteOptions {
7
+ mode: 'auto' | 'categorical';
8
+ }
9
+ export type StackOptions = 'none' | 'all';
10
+ export type ChartVisualOptions = {
11
+ display?: 'line' | 'bar';
12
+ lineWidth?: number;
13
+ areaOpacity?: number;
14
+ showPoints?: 'auto' | 'always';
15
+ palette?: ChartPaletteOptions;
16
+ pointRadius?: number;
17
+ stack?: StackOptions;
18
+ connectNulls?: boolean;
19
+ };
20
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,GAAG,cAAc,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC;CAC9B;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC;AAE1C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC/B,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC"}
package/lib/model.js ADDED
@@ -0,0 +1,15 @@
1
+ // Copyright 2023 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
+ export { };
14
+
15
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model.ts"],"sourcesContent":["// Copyright 2023 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\nexport interface QuerySettingsOptions {\n queryIndex: number;\n colorMode: 'fixed' | 'fixed-single';\n colorValue: string;\n}\n\nexport interface ChartPaletteOptions {\n mode: 'auto' | 'categorical';\n}\n\nexport type StackOptions = 'none' | 'all';\n\nexport type ChartVisualOptions = {\n display?: 'line' | 'bar';\n lineWidth?: number;\n areaOpacity?: number;\n showPoints?: 'auto' | 'always';\n palette?: ChartPaletteOptions;\n pointRadius?: number;\n stack?: StackOptions;\n connectNulls?: boolean;\n};\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAcjC,WASE"}
@@ -0,0 +1,25 @@
1
+ import { ChartVisualOptions, QuerySettingsOptions } from './model';
2
+ export interface SeriesColorProps {
3
+ categoricalPalette: string[];
4
+ visual: ChartVisualOptions;
5
+ muiPrimaryColor: string;
6
+ seriesName: string;
7
+ seriesIndex: number;
8
+ querySettings?: QuerySettingsOptions;
9
+ queryHasMultipleResults?: boolean;
10
+ }
11
+ /**
12
+ * Get line color as well as color for tooltip and legend, account for whether palette is 'categorical' or 'auto' aka generative
13
+ */
14
+ export declare function getSeriesColor(props: SeriesColorProps): string;
15
+ /**
16
+ * Get color from generative color palette, this approaches uses series name as the seed and
17
+ * allows for consistent colors across panels (when all panels use this approach).
18
+ */
19
+ export declare function getAutoPaletteColor(name: string, fallbackColor: string): string;
20
+ /**
21
+ * Default classical qualitative palette that cycles through the colors array by index.
22
+ */
23
+ export declare function getCategoricalPaletteColor(palette: string[], seriesIndex: number, fallbackColor: string): string;
24
+ export declare function getConsistentSeriesNameColor(inputString: string): string;
25
+ //# sourceMappingURL=palette-gen.d.ts.map