@perses-dev/pie-chart-plugin 0.13.0-rc.0 → 0.13.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 (59) hide show
  1. package/__mf/js/{PieChart.1d330862.js → PieChart.cf3c31fc.js} +3 -3
  2. package/__mf/js/async/390.99d822cd.js +7 -0
  3. package/__mf/js/async/392.2780a75e.js +2 -0
  4. package/__mf/js/async/{941.ca6b716b.js → 634.282182cd.js} +3 -3
  5. package/__mf/js/async/648.924b8cfc.js +22 -0
  6. package/__mf/js/async/{322.e2f8adf7.js → 941.4ea66ef3.js} +2 -2
  7. package/__mf/js/async/{__federation_expose_PieChart.3cc122de.js → __federation_expose_PieChart.329ca150.js} +1 -1
  8. package/__mf/js/async/lib-router.48213c49.js +2 -0
  9. package/__mf/js/async/{lib-router.34969c19.js.LICENSE.txt → lib-router.48213c49.js.LICENSE.txt} +3 -3
  10. package/__mf/js/{main.fe65156a.js → main.2fa79bb4.js} +3 -3
  11. package/lib/PieChart.js +1 -1
  12. package/lib/PieChart.js.map +1 -1
  13. package/lib/PieChartBase.js +1 -1
  14. package/lib/PieChartBase.js.map +1 -1
  15. package/lib/PieChartOptionsEditorSettings.js +1 -1
  16. package/lib/PieChartOptionsEditorSettings.js.map +1 -1
  17. package/lib/bootstrap.js +1 -1
  18. package/lib/bootstrap.js.map +1 -1
  19. package/lib/cjs/PieChart.js +1 -1
  20. package/lib/cjs/PieChartBase.js +1 -1
  21. package/lib/cjs/PieChartOptionsEditorSettings.js +1 -1
  22. package/lib/cjs/bootstrap.js +1 -1
  23. package/lib/cjs/colors.js +1 -1
  24. package/lib/cjs/env.d.js +1 -1
  25. package/lib/cjs/getPluginModule.js +12 -0
  26. package/lib/cjs/index-federation.js +1 -1
  27. package/lib/cjs/index.js +12 -0
  28. package/lib/cjs/pie-chart-model.js +1 -1
  29. package/lib/cjs/setup-tests.js +1 -1
  30. package/lib/cjs/utils.js +1 -1
  31. package/lib/colors.js +1 -1
  32. package/lib/colors.js.map +1 -1
  33. package/lib/env.d.js +1 -1
  34. package/lib/env.d.js.map +1 -1
  35. package/lib/getPluginModule.d.ts.map +1 -1
  36. package/lib/getPluginModule.js +12 -0
  37. package/lib/getPluginModule.js.map +1 -1
  38. package/lib/index-federation.js +1 -1
  39. package/lib/index-federation.js.map +1 -1
  40. package/lib/index.d.ts.map +1 -1
  41. package/lib/index.js +12 -0
  42. package/lib/index.js.map +1 -1
  43. package/lib/pie-chart-model.js +1 -1
  44. package/lib/pie-chart-model.js.map +1 -1
  45. package/lib/setup-tests.js +1 -1
  46. package/lib/setup-tests.js.map +1 -1
  47. package/lib/utils.js +1 -1
  48. package/lib/utils.js.map +1 -1
  49. package/mf-manifest.json +13 -13
  50. package/mf-stats.json +13 -13
  51. package/package.json +4 -4
  52. package/__mf/js/async/252.48b65470.js +0 -22
  53. package/__mf/js/async/308.830d2130.js +0 -7
  54. package/__mf/js/async/392.4e64389c.js +0 -2
  55. package/__mf/js/async/lib-router.34969c19.js +0 -2
  56. /package/__mf/js/async/{308.830d2130.js.LICENSE.txt → 390.99d822cd.js.LICENSE.txt} +0 -0
  57. /package/__mf/js/async/{392.4e64389c.js.LICENSE.txt → 392.2780a75e.js.LICENSE.txt} +0 -0
  58. /package/__mf/js/async/{252.48b65470.js.LICENSE.txt → 648.924b8cfc.js.LICENSE.txt} +0 -0
  59. /package/__mf/js/async/{322.e2f8adf7.js.LICENSE.txt → 941.4ea66ef3.js.LICENSE.txt} +0 -0
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
package/lib/cjs/colors.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
package/lib/cjs/env.d.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,3 +1,15 @@
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.
1
13
  "use strict";
2
14
  Object.defineProperty(exports, "__esModule", {
3
15
  value: true
@@ -40,7 +40,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
40
40
  }
41
41
  return newObj;
42
42
  }
43
- // Copyright 2024 The Perses Authors
43
+ // Copyright The Perses Authors
44
44
  // Licensed under the Apache License, Version 2.0 (the "License");
45
45
  // you may not use this file except in compliance with the License.
46
46
  // You may obtain a copy of the License at
package/lib/cjs/index.js CHANGED
@@ -1,3 +1,15 @@
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.
1
13
  "use strict";
2
14
  Object.defineProperty(exports, "__esModule", {
3
15
  value: true
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
package/lib/cjs/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
package/lib/colors.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
package/lib/colors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/colors.ts"],"sourcesContent":["// Copyright 2025 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 ColorHash from 'color-hash';\n\n// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.\n// More info: https://github.com/zenozeng/color-hash#custom-hue\n// Picked min of 20 and max of 360 to exclude common threshold colors (red).\n// Items with \"error\" in them will always be generated as red.\nconst ERROR_HUE_CUTOFF = 20;\nconst colorGenerator = new ColorHash({ hue: { min: ERROR_HUE_CUTOFF, max: 360 } });\nconst redColorGenerator = new ColorHash({ hue: { min: 0, max: ERROR_HUE_CUTOFF } });\n\nexport interface SeriesColorProps {\n categoricalPalette: string[];\n muiPrimaryColor: string;\n seriesName: string;\n}\n\n// Color utility functions\n/**\n * Converts a number to a 2-digit hex string\n */\nfunction toHex(n: number): string {\n const hex = n.toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n}\n\n/**\n * Converts a hex color string to RGB values\n */\nfunction hexToRgb(hex: string): { r: number; g: number; b: number } {\n const cleanHex = hex.replace('#', '');\n return {\n r: parseInt(cleanHex.substring(0, 2), 16),\n g: parseInt(cleanHex.substring(2, 4), 16),\n b: parseInt(cleanHex.substring(4, 6), 16),\n };\n}\n\n/**\n * Returns a deterministic number between 0 and 1 for a given string\n */\nfunction stringToSeed(str: string): number {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash; // Convert to 32-bit integer\n }\n // Convert to positive number and normalize to 0-1 range\n return Math.abs(hash) / 2147483647;\n}\n\n/**\n * Helper function to generate gradient colors for series within a query\n */\nexport function generateGradientColor(baseColor: string, factor: number): string {\n // Convert hex color to RGB\n const { r, g, b } = hexToRgb(baseColor);\n\n const newR = Math.round(r * factor);\n const newG = Math.round(g * factor);\n const newB = Math.round(b * factor);\n\n return `#${toHex(newR)}${toHex(newG)}${toHex(newB)}`;\n}\n\n/**\n * Generates a list of color strings for a given number of series using a categorical palette.\n * When the number of series exceeds the palette size, it cycles through the palette\n * and applies gradients to create visual distinction.\n * @param totalSeries - The total number of series that need colors\n * @param colorPalette - Array of color strings to use as the base palette\n * @returns Array of color strings, one for each series\n */\nexport function getSeriesColor(seriesNames: string[], colorPalette?: string[]): string[] {\n const totalSeries = seriesNames.length;\n\n if (totalSeries <= 0) {\n return [];\n }\n\n const colors: string[] = [];\n\n // undefined palette - default\n if (colorPalette === undefined) {\n for (let nameIndex = 0; nameIndex < seriesNames.length; nameIndex++) {\n const seriesColor = getDefaultSeriesColor({\n categoricalPalette: ['#ff0000'],\n muiPrimaryColor: '#ff0000',\n seriesName: seriesNames[nameIndex] || '',\n });\n colors.push(seriesColor);\n }\n return colors;\n }\n\n // single color palette - generate gradients from that color\n if (colorPalette.length === 1) {\n const baseColor = colorPalette[0] ?? '#ff0000';\n for (let i = 0; i < totalSeries; i++) {\n if (i === 0) {\n colors.push(baseColor);\n } else {\n const gradientFactor = 1 * ((totalSeries - i) / totalSeries);\n colors.push(generateGradientColor(baseColor, gradientFactor));\n }\n }\n return colors.sort((a, b) => {\n const seedA = stringToSeed(seriesNames[colors.indexOf(a)] || 'fallback');\n const seedB = stringToSeed(seriesNames[colors.indexOf(b)] || 'fallback');\n return seedA - seedB;\n });\n }\n\n // multi color palette - loops through colors and adds gradient when palette is exhausted\n for (let i = 0; i < totalSeries; i++) {\n const color = getColor(colorPalette, i);\n colors.push(color);\n }\n\n if (totalSeries > colorPalette.length) {\n return colors.sort((a, b) => {\n const seedA = stringToSeed(seriesNames[colors.indexOf(a)] || 'fallback');\n const seedB = stringToSeed(seriesNames[colors.indexOf(b)] || 'fallback');\n return seedA - seedB;\n });\n }\n return colors;\n}\n\n/**\n * Default classical qualitative palette that cycles through the colors array by index.\n * When colors start repeating (after exhausting the palette), applies gradients for distinction.\n */\nexport function getColor(palette: string[], seriesIndex: number): string {\n // Handle undefined or empty palette\n if (!palette || palette.length === 0) {\n return '#ff0000';\n }\n\n const paletteTotalColors = palette.length;\n const paletteIndex = seriesIndex % paletteTotalColors;\n const baseColor = palette[paletteIndex] ?? '#ff0000';\n\n // If we haven't exhausted the palette yet, use the original color\n if (seriesIndex < paletteTotalColors) {\n return baseColor;\n }\n\n // Calculate which \"cycle\" we're in (0 = first repeat, 1 = second repeat, etc.)\n const cycleNumber = Math.floor(seriesIndex / paletteTotalColors);\n\n // Apply gradient based on cycle number to create visual distinction\n const gradientFactor = Math.min(1 - cycleNumber * 0.2, 1);\n return generateGradientColor(baseColor, gradientFactor);\n}\n\nfunction computeConsistentColor(name: string, error: boolean): string {\n const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);\n const saturationPercent = `${(saturation * 100).toFixed(0)}%`;\n const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;\n return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;\n}\n\n// To check whether a color has already been generated for a given string.\n// TODO: Predefined color aliases will be defined here\nconst colorLookup: Record<string, string> = {};\n\n/**\n * Return a consistent color for (name, error) tuple\n */\nexport function getConsistentColor(name: string, error: boolean): string {\n const key = `${name}_____${error}`;\n let value = colorLookup[key];\n if (!value) {\n value = computeConsistentColor(name, error);\n colorLookup[key] = value;\n }\n return value;\n}\n\n/*\n * Generate a consistent series name color (if series name includes 'error', it will have a red hue).\n */\nexport function getConsistentSeriesNameColor(inputString: string): string {\n return getConsistentColor(inputString, inputString.toLowerCase().includes('error'));\n}\n\n/**\n * Get line color as well as color for tooltip and legend, account for whether palette is 'categorical' or 'auto' aka generative\n */\nexport function getDefaultSeriesColor(props: SeriesColorProps): string {\n const { categoricalPalette, muiPrimaryColor, seriesName } = props;\n\n // Fallback is unlikely to set unless echarts theme palette in charts theme provider is undefined.\n const fallbackColor =\n Array.isArray(categoricalPalette) && categoricalPalette[0]\n ? (categoricalPalette[0] as string) // Needed since echarts color property isn't always an array.\n : muiPrimaryColor;\n\n return getAutoPaletteColor(seriesName, fallbackColor);\n}\n\n/**\n * Get color from generative color palette, this approaches uses series name as the seed and\n * allows for consistent colors across panels (when all panels use this approach).\n */\nexport function getAutoPaletteColor(name: string, fallbackColor: string): string {\n // corresponds to 'Auto' in palette.kind for generative color palette\n const generatedColor = getConsistentSeriesNameColor(name);\n return generatedColor ?? fallbackColor;\n}\n"],"names":["ColorHash","ERROR_HUE_CUTOFF","colorGenerator","hue","min","max","redColorGenerator","toHex","n","hex","toString","length","hexToRgb","cleanHex","replace","r","parseInt","substring","g","b","stringToSeed","str","hash","i","char","charCodeAt","Math","abs","generateGradientColor","baseColor","factor","newR","round","newG","newB","getSeriesColor","seriesNames","colorPalette","totalSeries","colors","undefined","nameIndex","seriesColor","getDefaultSeriesColor","categoricalPalette","muiPrimaryColor","seriesName","push","gradientFactor","sort","a","seedA","indexOf","seedB","color","getColor","palette","seriesIndex","paletteTotalColors","paletteIndex","cycleNumber","floor","computeConsistentColor","name","error","saturation","lightness","hsl","saturationPercent","toFixed","lightnessPercent","colorLookup","getConsistentColor","key","value","getConsistentSeriesNameColor","inputString","toLowerCase","includes","props","fallbackColor","Array","isArray","getAutoPaletteColor","generatedColor"],"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,OAAOA,eAAe,aAAa;AAEnC,qFAAqF;AACrF,+DAA+D;AAC/D,4EAA4E;AAC5E,8DAA8D;AAC9D,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB,IAAIF,UAAU;IAAEG,KAAK;QAAEC,KAAKH;QAAkBI,KAAK;IAAI;AAAE;AAChF,MAAMC,oBAAoB,IAAIN,UAAU;IAAEG,KAAK;QAAEC,KAAK;QAAGC,KAAKJ;I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AC7D,MAAMS,MAAM,GAAGV,KAAK,KAAK,EAAEC,OAAO;IAClC,IAAIU,QAAQH,WAAW,CAACE,IAAI;IAC5B,IAAI,CAACC,OAAO;QACVA,QAAQZ,uBAAuBC,MAAMC;QACrCO,WAAW,CAACE,IAAI,GAAGC;IACrB;IACA,OAAOA;AACT;AAEA;;CAEC,GACD,OAAO,SAASC,6BAA6BC,WAAmB;IAC9D,OAAOJ,mBAAmBI,aAAaA,YAAYC,WAAW,GAAGC,QAAQ,CAAC;AAC5E;AAEA;;CAEC,GACD,OAAO,SAASnC,sBAAsBoC,KAAuB;IAC3D,MAAM,EAAEnC,kBAAkB,EAAEC,eAAe,EAAEC,UAAU,EAAE,GAAGiC;IAE5D,kGAAkG;IAClG,MAAMC,gBACJC,MAAMC,OAAO,CAACtC,uBAAuBA,kBAAkB,CAAC,EAAE,GACrDA,kBAAkB,CAAC,EAAE,CAAY,6DAA6D;OAC/FC;IAEN,OAAOsC,oBAAoBrC,YAAYkC;AACzC;AAEA;;;CAGC,GACD,OAAO,SAASG,oBAAoBpB,IAAY,EAAEiB,aAAqB;IACrE,qEAAqE;IACrE,MAAMI,iBAAiBT,6BAA6BZ;IACpD,OAAOqB,kBAAkBJ;AAC3B"}
1
+ {"version":3,"sources":["../../src/colors.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 ColorHash from 'color-hash';\n\n// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.\n// More info: https://github.com/zenozeng/color-hash#custom-hue\n// Picked min of 20 and max of 360 to exclude common threshold colors (red).\n// Items with \"error\" in them will always be generated as red.\nconst ERROR_HUE_CUTOFF = 20;\nconst colorGenerator = new ColorHash({ hue: { min: ERROR_HUE_CUTOFF, max: 360 } });\nconst redColorGenerator = new ColorHash({ hue: { min: 0, max: ERROR_HUE_CUTOFF } });\n\nexport interface SeriesColorProps {\n categoricalPalette: string[];\n muiPrimaryColor: string;\n seriesName: string;\n}\n\n// Color utility functions\n/**\n * Converts a number to a 2-digit hex string\n */\nfunction toHex(n: number): string {\n const hex = n.toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n}\n\n/**\n * Converts a hex color string to RGB values\n */\nfunction hexToRgb(hex: string): { r: number; g: number; b: number } {\n const cleanHex = hex.replace('#', '');\n return {\n r: parseInt(cleanHex.substring(0, 2), 16),\n g: parseInt(cleanHex.substring(2, 4), 16),\n b: parseInt(cleanHex.substring(4, 6), 16),\n };\n}\n\n/**\n * Returns a deterministic number between 0 and 1 for a given string\n */\nfunction stringToSeed(str: string): number {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash; // Convert to 32-bit integer\n }\n // Convert to positive number and normalize to 0-1 range\n return Math.abs(hash) / 2147483647;\n}\n\n/**\n * Helper function to generate gradient colors for series within a query\n */\nexport function generateGradientColor(baseColor: string, factor: number): string {\n // Convert hex color to RGB\n const { r, g, b } = hexToRgb(baseColor);\n\n const newR = Math.round(r * factor);\n const newG = Math.round(g * factor);\n const newB = Math.round(b * factor);\n\n return `#${toHex(newR)}${toHex(newG)}${toHex(newB)}`;\n}\n\n/**\n * Generates a list of color strings for a given number of series using a categorical palette.\n * When the number of series exceeds the palette size, it cycles through the palette\n * and applies gradients to create visual distinction.\n * @param totalSeries - The total number of series that need colors\n * @param colorPalette - Array of color strings to use as the base palette\n * @returns Array of color strings, one for each series\n */\nexport function getSeriesColor(seriesNames: string[], colorPalette?: string[]): string[] {\n const totalSeries = seriesNames.length;\n\n if (totalSeries <= 0) {\n return [];\n }\n\n const colors: string[] = [];\n\n // undefined palette - default\n if (colorPalette === undefined) {\n for (let nameIndex = 0; nameIndex < seriesNames.length; nameIndex++) {\n const seriesColor = getDefaultSeriesColor({\n categoricalPalette: ['#ff0000'],\n muiPrimaryColor: '#ff0000',\n seriesName: seriesNames[nameIndex] || '',\n });\n colors.push(seriesColor);\n }\n return colors;\n }\n\n // single color palette - generate gradients from that color\n if (colorPalette.length === 1) {\n const baseColor = colorPalette[0] ?? '#ff0000';\n for (let i = 0; i < totalSeries; i++) {\n if (i === 0) {\n colors.push(baseColor);\n } else {\n const gradientFactor = 1 * ((totalSeries - i) / totalSeries);\n colors.push(generateGradientColor(baseColor, gradientFactor));\n }\n }\n return colors.sort((a, b) => {\n const seedA = stringToSeed(seriesNames[colors.indexOf(a)] || 'fallback');\n const seedB = stringToSeed(seriesNames[colors.indexOf(b)] || 'fallback');\n return seedA - seedB;\n });\n }\n\n // multi color palette - loops through colors and adds gradient when palette is exhausted\n for (let i = 0; i < totalSeries; i++) {\n const color = getColor(colorPalette, i);\n colors.push(color);\n }\n\n if (totalSeries > colorPalette.length) {\n return colors.sort((a, b) => {\n const seedA = stringToSeed(seriesNames[colors.indexOf(a)] || 'fallback');\n const seedB = stringToSeed(seriesNames[colors.indexOf(b)] || 'fallback');\n return seedA - seedB;\n });\n }\n return colors;\n}\n\n/**\n * Default classical qualitative palette that cycles through the colors array by index.\n * When colors start repeating (after exhausting the palette), applies gradients for distinction.\n */\nexport function getColor(palette: string[], seriesIndex: number): string {\n // Handle undefined or empty palette\n if (!palette || palette.length === 0) {\n return '#ff0000';\n }\n\n const paletteTotalColors = palette.length;\n const paletteIndex = seriesIndex % paletteTotalColors;\n const baseColor = palette[paletteIndex] ?? '#ff0000';\n\n // If we haven't exhausted the palette yet, use the original color\n if (seriesIndex < paletteTotalColors) {\n return baseColor;\n }\n\n // Calculate which \"cycle\" we're in (0 = first repeat, 1 = second repeat, etc.)\n const cycleNumber = Math.floor(seriesIndex / paletteTotalColors);\n\n // Apply gradient based on cycle number to create visual distinction\n const gradientFactor = Math.min(1 - cycleNumber * 0.2, 1);\n return generateGradientColor(baseColor, gradientFactor);\n}\n\nfunction computeConsistentColor(name: string, error: boolean): string {\n const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);\n const saturationPercent = `${(saturation * 100).toFixed(0)}%`;\n const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;\n return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;\n}\n\n// To check whether a color has already been generated for a given string.\n// TODO: Predefined color aliases will be defined here\nconst colorLookup: Record<string, string> = {};\n\n/**\n * Return a consistent color for (name, error) tuple\n */\nexport function getConsistentColor(name: string, error: boolean): string {\n const key = `${name}_____${error}`;\n let value = colorLookup[key];\n if (!value) {\n value = computeConsistentColor(name, error);\n colorLookup[key] = value;\n }\n return value;\n}\n\n/*\n * Generate a consistent series name color (if series name includes 'error', it will have a red hue).\n */\nexport function getConsistentSeriesNameColor(inputString: string): string {\n return getConsistentColor(inputString, inputString.toLowerCase().includes('error'));\n}\n\n/**\n * Get line color as well as color for tooltip and legend, account for whether palette is 'categorical' or 'auto' aka generative\n */\nexport function getDefaultSeriesColor(props: SeriesColorProps): string {\n const { categoricalPalette, muiPrimaryColor, seriesName } = props;\n\n // Fallback is unlikely to set unless echarts theme palette in charts theme provider is undefined.\n const fallbackColor =\n Array.isArray(categoricalPalette) && categoricalPalette[0]\n ? (categoricalPalette[0] as string) // Needed since echarts color property isn't always an array.\n : muiPrimaryColor;\n\n return getAutoPaletteColor(seriesName, fallbackColor);\n}\n\n/**\n * Get color from generative color palette, this approaches uses series name as the seed and\n * allows for consistent colors across panels (when all panels use this approach).\n */\nexport function getAutoPaletteColor(name: string, fallbackColor: string): string {\n // corresponds to 'Auto' in palette.kind for generative color palette\n const generatedColor = getConsistentSeriesNameColor(name);\n return generatedColor ?? fallbackColor;\n}\n"],"names":["ColorHash","ERROR_HUE_CUTOFF","colorGenerator","hue","min","max","redColorGenerator","toHex","n","hex","toString","length","hexToRgb","cleanHex","replace","r","parseInt","substring","g","b","stringToSeed","str","hash","i","char","charCodeAt","Math","abs","generateGradientColor","baseColor","factor","newR","round","newG","newB","getSeriesColor","seriesNames","colorPalette","totalSeries","colors","undefined","nameIndex","seriesColor","getDefaultSeriesColor","categoricalPalette","muiPrimaryColor","seriesName","push","gradientFactor","sort","a","seedA","indexOf","seedB","color","getColor","palette","seriesIndex","paletteTotalColors","paletteIndex","cycleNumber","floor","computeConsistentColor","name","error","saturation","lightness","hsl","saturationPercent","toFixed","lightnessPercent","colorLookup","getConsistentColor","key","value","getConsistentSeriesNameColor","inputString","toLowerCase","includes","props","fallbackColor","Array","isArray","getAutoPaletteColor","generatedColor"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,eAAe,aAAa;AAEnC,qFAAqF;AACrF,+DAA+D;AAC/D,4EAA4E;AAC5E,8DAA8D;AAC9D,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB,IAAIF,UAAU;IAAEG,KAAK;QAAEC,KAAKH;QAAkBI,KAAK;IAAI;AAAE;AAChF,MAAMC,oBAAoB,IAAIN,UAAU;IAAEG,KAAK;QAAEC,KAAK;QAAGC,KAAKJ;IAAiB;AAAE;AAQjF,0BAA0B;AAC1B;;CAEC,GACD,SAASM,MAAMC,CAAS;IACtB,MAAMC,MAAMD,EAAEE,QAAQ,CAAC;IACvB,OAAOD,IAAIE,MAAM,KAAK,IAAI,MAAMF,MAAMA;AACxC;AAEA;;CAEC,GACD,SAASG,SAASH,GAAW;IAC3B,MAAMI,WAAWJ,IAAIK,OAAO,CAAC,KAAK;IAClC,OAAO;QACLC,GAAGC,SAASH,SAASI,SAAS,CAAC,GAAG,IAAI;QACtCC,GAAG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AEA;;CAEC,GACD,OAAO,SAASnC,sBAAsBoC,KAAuB;IAC3D,MAAM,EAAEnC,kBAAkB,EAAEC,eAAe,EAAEC,UAAU,EAAE,GAAGiC;IAE5D,kGAAkG;IAClG,MAAMC,gBACJC,MAAMC,OAAO,CAACtC,uBAAuBA,kBAAkB,CAAC,EAAE,GACrDA,kBAAkB,CAAC,EAAE,CAAY,6DAA6D;OAC/FC;IAEN,OAAOsC,oBAAoBrC,YAAYkC;AACzC;AAEA;;;CAGC,GACD,OAAO,SAASG,oBAAoBpB,IAAY,EAAEiB,aAAqB;IACrE,qEAAqE;IACrE,MAAMI,iBAAiBT,6BAA6BZ;IACpD,OAAOqB,kBAAkBJ;AAC3B"}
package/lib/env.d.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
package/lib/env.d.js.map CHANGED
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/env.d.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\n/// <reference types=\"@rsbuild/core/types\" />\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6CAA6C"}
@@ -1 +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"}
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"}
@@ -1,3 +1,15 @@
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.
1
13
  import packageJson from '../package.json';
2
14
  /**
3
15
  * Returns the plugin module information from package.json
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/getPluginModule.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 { 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":"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,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"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/index-federation.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('./bootstrap');\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,iCAAiC,CAAC"}
package/lib/index.js CHANGED
@@ -1,3 +1,15 @@
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.
1
13
  export * from './PieChartPanel';
2
14
  export { getPluginModule } from './getPluginModule';
3
15
  export * from './colors';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './PieChartPanel';\nexport { getPluginModule } from './getPluginModule';\nexport * from './colors';\nexport * from './pie-chart-model';\nexport * from './PieChart';\nexport * from './PieChartOptionsEditorSettings';\n"],"names":["getPluginModule"],"mappings":"AAAA,cAAc,kBAAkB;AAChC,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,WAAW;AACzB,cAAc,oBAAoB;AAClC,cAAc,aAAa;AAC3B,cAAc,kCAAkC"}
1
+ {"version":3,"sources":["../../src/index.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\nexport * from './PieChartPanel';\nexport { getPluginModule } from './getPluginModule';\nexport * from './colors';\nexport * from './pie-chart-model';\nexport * from './PieChart';\nexport * from './PieChartOptionsEditorSettings';\n"],"names":["getPluginModule"],"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;AAEjC,cAAc,kBAAkB;AAChC,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,WAAW;AACzB,cAAc,oBAAoB;AAClC,cAAc,aAAa;AAC3B,cAAc,kCAAkC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/pie-chart-model.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 { ModeOption, SortOption } from '@perses-dev/components';\nimport { CalculationType, DEFAULT_CALCULATION, Definition, FormatOptions } from '@perses-dev/core';\nimport { LegendSpecOptions, OptionsEditorProps } from '@perses-dev/plugin-system';\n\nexport const DEFAULT_FORMAT: FormatOptions = { unit: 'decimal', shortValues: true };\nexport const DEFAULT_SORT: SortOption = 'desc';\nexport const DEFAULT_MODE: ModeOption = 'value';\n\nexport interface BarChartDefinition extends Definition<PieChartOptions> {\n kind: 'PieChart';\n}\n\nexport interface PieChartOptions {\n calculation: CalculationType;\n format?: FormatOptions;\n colorPalette?: string[];\n legend?: LegendSpecOptions;\n mode?: ModeOption;\n radius: number;\n showLabels?: boolean;\n sort?: SortOption;\n}\n\nexport type PieChartOptionsEditorProps = OptionsEditorProps<PieChartOptions>;\n\nexport function createInitialPieChartOptions(): PieChartOptions {\n return {\n calculation: DEFAULT_CALCULATION,\n format: DEFAULT_FORMAT,\n mode: DEFAULT_MODE,\n radius: 50,\n showLabels: false,\n sort: DEFAULT_SORT,\n };\n}\n"],"names":["DEFAULT_CALCULATION","DEFAULT_FORMAT","unit","shortValues","DEFAULT_SORT","DEFAULT_MODE","createInitialPieChartOptions","calculation","format","mode","radius","showLabels","sort"],"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;AAGjC,SAA0BA,mBAAmB,QAAmC,mBAAmB;AAGnG,OAAO,MAAMC,iBAAgC;IAAEC,MAAM;IAAWC,aAAa;AAAK,EAAE;AACpF,OAAO,MAAMC,eAA2B,OAAO;AAC/C,OAAO,MAAMC,eAA2B,QAAQ;AAmBhD,OAAO,SAASC;IACd,OAAO;QACLC,aAAaP;QACbQ,QAAQP;QACRQ,MAAMJ;QACNK,QAAQ;QACRC,YAAY;QACZC,MAAMR;IACR;AACF"}
1
+ {"version":3,"sources":["../../src/pie-chart-model.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 { ModeOption, SortOption } from '@perses-dev/components';\nimport { CalculationType, DEFAULT_CALCULATION, Definition, FormatOptions } from '@perses-dev/core';\nimport { LegendSpecOptions, OptionsEditorProps } from '@perses-dev/plugin-system';\n\nexport const DEFAULT_FORMAT: FormatOptions = { unit: 'decimal', shortValues: true };\nexport const DEFAULT_SORT: SortOption = 'desc';\nexport const DEFAULT_MODE: ModeOption = 'value';\n\nexport interface BarChartDefinition extends Definition<PieChartOptions> {\n kind: 'PieChart';\n}\n\nexport interface PieChartOptions {\n calculation: CalculationType;\n format?: FormatOptions;\n colorPalette?: string[];\n legend?: LegendSpecOptions;\n mode?: ModeOption;\n radius: number;\n showLabels?: boolean;\n sort?: SortOption;\n}\n\nexport type PieChartOptionsEditorProps = OptionsEditorProps<PieChartOptions>;\n\nexport function createInitialPieChartOptions(): PieChartOptions {\n return {\n calculation: DEFAULT_CALCULATION,\n format: DEFAULT_FORMAT,\n mode: DEFAULT_MODE,\n radius: 50,\n showLabels: false,\n sort: DEFAULT_SORT,\n };\n}\n"],"names":["DEFAULT_CALCULATION","DEFAULT_FORMAT","unit","shortValues","DEFAULT_SORT","DEFAULT_MODE","createInitialPieChartOptions","calculation","format","mode","radius","showLabels","sort"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAA0BA,mBAAmB,QAAmC,mBAAmB;AAGnG,OAAO,MAAMC,iBAAgC;IAAEC,MAAM;IAAWC,aAAa;AAAK,EAAE;AACpF,OAAO,MAAMC,eAA2B,OAAO;AAC/C,OAAO,MAAMC,eAA2B,QAAQ;AAmBhD,OAAO,SAASC;IACd,OAAO;QACLC,aAAaP;QACbQ,QAAQP;QACRQ,MAAMJ;QACNK,QAAQ;QACRC,YAAY;QACZC,MAAMR;IACR;AACF"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/setup-tests.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\nimport '@testing-library/jest-dom';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n"],"names":["jest","mock"],"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,OAAO,4BAA4B;AAEnC,iFAAiF;AACjFA,KAAKC,IAAI,CAAC"}
1
+ {"version":3,"sources":["../../src/setup-tests.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 '@testing-library/jest-dom';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n"],"names":["jest","mock"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,4BAA4B;AAEnC,iFAAiF;AACjFA,KAAKC,IAAI,CAAC"}
package/lib/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils.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 { SortOption } from '@perses-dev/components';\nimport { DEFAULT_SORT } from './pie-chart-model';\nimport { PieChartData } from './PieChartBase';\n\nexport function calculatePercentages(data: PieChartData[]): Array<{ id?: string; name: string; value: number }> {\n const sum = data.reduce((accumulator, { value }) => accumulator + (value ?? 0), 0);\n return data.map((seriesData) => {\n const percentage = ((seriesData.value ?? 0) / sum) * 100;\n return {\n ...seriesData,\n value: Number(percentage.toFixed(2)),\n };\n });\n}\n\nexport function sortSeriesData(data: PieChartData[], sortOrder: SortOption = DEFAULT_SORT): PieChartData[] {\n return data.sort((a, b) => {\n // Handle null values - push them to the end regardless of sort order\n if (a.value === null && b.value === null) return 0;\n if (a.value === null) return 1;\n if (b.value === null) return -1;\n\n // Sort by value\n const diff = (a.value ?? 0) - (b.value ?? 0);\n return sortOrder === 'asc' ? diff : -diff;\n });\n}\n"],"names":["DEFAULT_SORT","calculatePercentages","data","sum","reduce","accumulator","value","map","seriesData","percentage","Number","toFixed","sortSeriesData","sortOrder","sort","a","b","diff"],"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;AAGjC,SAASA,YAAY,QAAQ,oBAAoB;AAGjD,OAAO,SAASC,qBAAqBC,IAAoB;IACvD,MAAMC,MAAMD,KAAKE,MAAM,CAAC,CAACC,aAAa,EAAEC,KAAK,EAAE,GAAKD,cAAeC,CAAAA,SAAS,CAAA,GAAI;IAChF,OAAOJ,KAAKK,GAAG,CAAC,CAACC;QACf,MAAMC,aAAa,AAAED,CAAAA,WAAWF,KAAK,IAAI,CAAA,IAAKH,MAAO;QACrD,OAAO;YACL,GAAGK,UAAU;YACbF,OAAOI,OAAOD,WAAWE,OAAO,CAAC;QACnC;IACF;AACF;AAEA,OAAO,SAASC,eAAeV,IAAoB,EAAEW,YAAwBb,YAAY;IACvF,OAAOE,KAAKY,IAAI,CAAC,CAACC,GAAGC;QACnB,qEAAqE;QACrE,IAAID,EAAET,KAAK,KAAK,QAAQU,EAAEV,KAAK,KAAK,MAAM,OAAO;QACjD,IAAIS,EAAET,KAAK,KAAK,MAAM,OAAO;QAC7B,IAAIU,EAAEV,KAAK,KAAK,MAAM,OAAO,CAAC;QAE9B,gBAAgB;QAChB,MAAMW,OAAO,AAACF,CAAAA,EAAET,KAAK,IAAI,CAAA,IAAMU,CAAAA,EAAEV,KAAK,IAAI,CAAA;QAC1C,OAAOO,cAAc,QAAQI,OAAO,CAACA;IACvC;AACF"}
1
+ {"version":3,"sources":["../../src/utils.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 { SortOption } from '@perses-dev/components';\nimport { DEFAULT_SORT } from './pie-chart-model';\nimport { PieChartData } from './PieChartBase';\n\nexport function calculatePercentages(data: PieChartData[]): Array<{ id?: string; name: string; value: number }> {\n const sum = data.reduce((accumulator, { value }) => accumulator + (value ?? 0), 0);\n return data.map((seriesData) => {\n const percentage = ((seriesData.value ?? 0) / sum) * 100;\n return {\n ...seriesData,\n value: Number(percentage.toFixed(2)),\n };\n });\n}\n\nexport function sortSeriesData(data: PieChartData[], sortOrder: SortOption = DEFAULT_SORT): PieChartData[] {\n return data.sort((a, b) => {\n // Handle null values - push them to the end regardless of sort order\n if (a.value === null && b.value === null) return 0;\n if (a.value === null) return 1;\n if (b.value === null) return -1;\n\n // Sort by value\n const diff = (a.value ?? 0) - (b.value ?? 0);\n return sortOrder === 'asc' ? diff : -diff;\n });\n}\n"],"names":["DEFAULT_SORT","calculatePercentages","data","sum","reduce","accumulator","value","map","seriesData","percentage","Number","toFixed","sortSeriesData","sortOrder","sort","a","b","diff"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,YAAY,QAAQ,oBAAoB;AAGjD,OAAO,SAASC,qBAAqBC,IAAoB;IACvD,MAAMC,MAAMD,KAAKE,MAAM,CAAC,CAACC,aAAa,EAAEC,KAAK,EAAE,GAAKD,cAAeC,CAAAA,SAAS,CAAA,GAAI;IAChF,OAAOJ,KAAKK,GAAG,CAAC,CAACC;QACf,MAAMC,aAAa,AAAED,CAAAA,WAAWF,KAAK,IAAI,CAAA,IAAKH,MAAO;QACrD,OAAO;YACL,GAAGK,UAAU;YACbF,OAAOI,OAAOD,WAAWE,OAAO,CAAC;QACnC;IACF;AACF;AAEA,OAAO,SAASC,eAAeV,IAAoB,EAAEW,YAAwBb,YAAY;IACvF,OAAOE,KAAKY,IAAI,CAAC,CAACC,GAAGC;QACnB,qEAAqE;QACrE,IAAID,EAAET,KAAK,KAAK,QAAQU,EAAEV,KAAK,KAAK,MAAM,OAAO;QACjD,IAAIS,EAAET,KAAK,KAAK,MAAM,OAAO;QAC7B,IAAIU,EAAEV,KAAK,KAAK,MAAM,OAAO,CAAC;QAE9B,gBAAgB;QAChB,MAAMW,OAAO,AAACF,CAAAA,EAAET,KAAK,IAAI,CAAA,IAAMU,CAAAA,EAAEV,KAAK,IAAI,CAAA;QAC1C,OAAOO,cAAc,QAAQI,OAAO,CAACA;IACvC;AACF"}
package/mf-manifest.json CHANGED
@@ -5,11 +5,11 @@
5
5
  "name": "PieChart",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "0.13.0-rc.0",
8
+ "buildVersion": "0.13.0",
9
9
  "buildName": "@perses-dev/pie-chart-plugin"
10
10
  },
11
11
  "remoteEntry": {
12
- "name": "__mf/js/PieChart.1d330862.js",
12
+ "name": "__mf/js/PieChart.cf3c31fc.js",
13
13
  "path": "",
14
14
  "type": "global"
15
15
  },
@@ -87,14 +87,14 @@
87
87
  {
88
88
  "id": "PieChart:@perses-dev/components",
89
89
  "name": "@perses-dev/components",
90
- "version": "0.53.0-rc.1",
90
+ "version": "0.53.0",
91
91
  "singleton": true,
92
- "requiredVersion": "^0.53.0-rc.1",
92
+ "requiredVersion": "^0.53.0",
93
93
  "assets": {
94
94
  "js": {
95
95
  "async": [],
96
96
  "sync": [
97
- "__mf/js/async/308.830d2130.js"
97
+ "__mf/js/async/390.99d822cd.js"
98
98
  ]
99
99
  },
100
100
  "css": {
@@ -106,14 +106,14 @@
106
106
  {
107
107
  "id": "PieChart:@perses-dev/plugin-system",
108
108
  "name": "@perses-dev/plugin-system",
109
- "version": "0.53.0-rc.1",
109
+ "version": "0.53.0",
110
110
  "singleton": true,
111
- "requiredVersion": "^0.53.0-rc.1",
111
+ "requiredVersion": "^0.53.0",
112
112
  "assets": {
113
113
  "js": {
114
114
  "async": [],
115
115
  "sync": [
116
- "__mf/js/async/252.48b65470.js"
116
+ "__mf/js/async/648.924b8cfc.js"
117
117
  ]
118
118
  },
119
119
  "css": {
@@ -163,14 +163,14 @@
163
163
  {
164
164
  "id": "PieChart:lodash",
165
165
  "name": "lodash",
166
- "version": "4.17.21",
166
+ "version": "4.17.23",
167
167
  "singleton": true,
168
168
  "requiredVersion": "^4.17.21",
169
169
  "assets": {
170
170
  "js": {
171
171
  "async": [],
172
172
  "sync": [
173
- "__mf/js/async/392.4e64389c.js"
173
+ "__mf/js/async/392.2780a75e.js"
174
174
  ]
175
175
  },
176
176
  "css": {
@@ -230,12 +230,12 @@
230
230
  "__mf/js/async/67.5bf7fff1.js",
231
231
  "__mf/js/async/721.8dc45583.js",
232
232
  "__mf/js/async/337.13482c5c.js",
233
- "__mf/js/async/__federation_expose_PieChart.3cc122de.js"
233
+ "__mf/js/async/__federation_expose_PieChart.329ca150.js"
234
234
  ],
235
235
  "async": [
236
- "__mf/js/async/lib-router.34969c19.js",
236
+ "__mf/js/async/lib-router.48213c49.js",
237
237
  "__mf/js/async/356.75a8af4c.js",
238
- "__mf/js/async/941.ca6b716b.js",
238
+ "__mf/js/async/634.282182cd.js",
239
239
  "__mf/js/async/177.c83badab.js",
240
240
  "__mf/js/async/469.e52e96c4.js",
241
241
  "__mf/js/async/663.c0629798.js"
package/mf-stats.json CHANGED
@@ -5,11 +5,11 @@
5
5
  "name": "PieChart",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "0.13.0-rc.0",
8
+ "buildVersion": "0.13.0",
9
9
  "buildName": "@perses-dev/pie-chart-plugin"
10
10
  },
11
11
  "remoteEntry": {
12
- "name": "__mf/js/PieChart.1d330862.js",
12
+ "name": "__mf/js/PieChart.cf3c31fc.js",
13
13
  "path": "",
14
14
  "type": "global"
15
15
  },
@@ -95,17 +95,17 @@
95
95
  },
96
96
  {
97
97
  "singleton": true,
98
- "requiredVersion": "^0.53.0-rc.1",
98
+ "requiredVersion": "^0.53.0",
99
99
  "shareScope": "default",
100
100
  "name": "@perses-dev/components",
101
- "version": "0.53.0-rc.1",
101
+ "version": "0.53.0",
102
102
  "eager": false,
103
103
  "id": "PieChart:@perses-dev/components",
104
104
  "assets": {
105
105
  "js": {
106
106
  "async": [],
107
107
  "sync": [
108
- "__mf/js/async/308.830d2130.js"
108
+ "__mf/js/async/390.99d822cd.js"
109
109
  ]
110
110
  },
111
111
  "css": {
@@ -119,17 +119,17 @@
119
119
  },
120
120
  {
121
121
  "singleton": true,
122
- "requiredVersion": "^0.53.0-rc.1",
122
+ "requiredVersion": "^0.53.0",
123
123
  "shareScope": "default",
124
124
  "name": "@perses-dev/plugin-system",
125
- "version": "0.53.0-rc.1",
125
+ "version": "0.53.0",
126
126
  "eager": false,
127
127
  "id": "PieChart:@perses-dev/plugin-system",
128
128
  "assets": {
129
129
  "js": {
130
130
  "async": [],
131
131
  "sync": [
132
- "__mf/js/async/252.48b65470.js"
132
+ "__mf/js/async/648.924b8cfc.js"
133
133
  ]
134
134
  },
135
135
  "css": {
@@ -190,14 +190,14 @@
190
190
  "requiredVersion": "^4.17.21",
191
191
  "shareScope": "default",
192
192
  "name": "lodash",
193
- "version": "4.17.21",
193
+ "version": "4.17.23",
194
194
  "eager": false,
195
195
  "id": "PieChart:lodash",
196
196
  "assets": {
197
197
  "js": {
198
198
  "async": [],
199
199
  "sync": [
200
- "__mf/js/async/392.4e64389c.js"
200
+ "__mf/js/async/392.2780a75e.js"
201
201
  ]
202
202
  },
203
203
  "css": {
@@ -273,12 +273,12 @@
273
273
  "__mf/js/async/67.5bf7fff1.js",
274
274
  "__mf/js/async/721.8dc45583.js",
275
275
  "__mf/js/async/337.13482c5c.js",
276
- "__mf/js/async/__federation_expose_PieChart.3cc122de.js"
276
+ "__mf/js/async/__federation_expose_PieChart.329ca150.js"
277
277
  ],
278
278
  "async": [
279
- "__mf/js/async/lib-router.34969c19.js",
279
+ "__mf/js/async/lib-router.48213c49.js",
280
280
  "__mf/js/async/356.75a8af4c.js",
281
- "__mf/js/async/941.ca6b716b.js",
281
+ "__mf/js/async/634.282182cd.js",
282
282
  "__mf/js/async/177.c83badab.js",
283
283
  "__mf/js/async/469.e52e96c4.js",
284
284
  "__mf/js/async/663.c0629798.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/pie-chart-plugin",
3
- "version": "0.13.0-rc.0",
3
+ "version": "0.13.0",
4
4
  "homepage": "https://github.com/perses/plugins/blob/main/README.md",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,9 +27,9 @@
27
27
  "@emotion/react": "^11.7.1",
28
28
  "@emotion/styled": "^11.6.0",
29
29
  "@hookform/resolvers": "^3.2.0",
30
- "@perses-dev/components": "^0.53.0-rc.1",
31
- "@perses-dev/core": "^0.53.0-beta.4",
32
- "@perses-dev/plugin-system": "^0.53.0-rc.1",
30
+ "@perses-dev/components": "^0.53.0",
31
+ "@perses-dev/core": "^0.53.0-rc.2",
32
+ "@perses-dev/plugin-system": "^0.53.0",
33
33
  "date-fns": "^4.1.0",
34
34
  "date-fns-tz": "^3.2.0",
35
35
  "echarts": "5.5.0",