@perses-dev/bar-chart-plugin 0.13.0 → 0.14.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/__mf/js/BarChart.777a5fe9.js +7 -0
  2. package/__mf/js/async/121.0dfa8a56.js +2 -0
  3. package/__mf/js/async/138.a47c7fc8.js +2 -0
  4. package/__mf/js/async/192.e523747d.js +1 -0
  5. package/__mf/js/async/235.5bb676bf.js +1 -0
  6. package/__mf/js/async/274.becf0c4e.js +2 -0
  7. package/__mf/js/async/319.a1a08706.js +1 -0
  8. package/__mf/js/async/356.4a2d6a5d.js +1 -0
  9. package/__mf/js/async/377.6b67c9b8.js +1 -0
  10. package/__mf/js/async/392.ce5748af.js +2 -0
  11. package/__mf/js/async/407.f9cff9c5.js +4 -0
  12. package/__mf/js/async/407.f9cff9c5.js.LICENSE.txt +9 -0
  13. package/__mf/js/async/435.4802f945.js +1 -0
  14. package/__mf/js/async/458.dd052408.js +1 -0
  15. package/__mf/js/async/470.6bd33fa1.js +2 -0
  16. package/__mf/js/async/496.46cf1305.js +1 -0
  17. package/__mf/js/async/587.e4d2ed78.js +1 -0
  18. package/__mf/js/async/588.ca7f0375.js +1 -0
  19. package/__mf/js/async/603.6e4d4c2a.js +1 -0
  20. package/__mf/js/async/616.6263efeb.js +1 -0
  21. package/__mf/js/async/71.5f1bab20.js +1 -0
  22. package/__mf/js/async/720.e068b3e4.js +101 -0
  23. package/__mf/js/async/77.d762eaa0.js +1 -0
  24. package/__mf/js/async/788.e72a42a8.js +43 -0
  25. package/__mf/js/async/{815.60db8972.js.LICENSE.txt → 788.e72a42a8.js.LICENSE.txt} +41 -1
  26. package/__mf/js/async/823.2a2b516e.js +10 -0
  27. package/__mf/js/async/854.49d186a1.js +1 -0
  28. package/__mf/js/async/873.9b3f6f36.js +1 -0
  29. package/__mf/js/async/934.04010fe7.js +2 -0
  30. package/__mf/js/async/941.88203ba1.js +2 -0
  31. package/__mf/js/async/963.36fb71d2.js +1 -0
  32. package/__mf/js/async/968.66f07975.js +1 -0
  33. package/__mf/js/async/977.b3f21ee5.js +1 -0
  34. package/__mf/js/async/978.d27fe59a.js +1 -0
  35. package/__mf/js/async/__federation_expose_BarChart.07c26459.js +1 -0
  36. package/__mf/js/async/lib-router.a4768e7d.js +2 -0
  37. package/__mf/js/main.e614feb4.js +7 -0
  38. package/lib/BarChart.d.ts +3 -3
  39. package/lib/BarChart.d.ts.map +1 -1
  40. package/lib/BarChart.js +4 -4
  41. package/lib/BarChart.js.map +1 -1
  42. package/lib/BarChartBase.d.ts +4 -2
  43. package/lib/BarChartBase.d.ts.map +1 -1
  44. package/lib/BarChartBase.js +34 -15
  45. package/lib/BarChartBase.js.map +1 -1
  46. package/lib/BarChartExportAction.d.ts +1 -1
  47. package/lib/BarChartExportAction.d.ts.map +1 -1
  48. package/lib/BarChartExportAction.js +5 -5
  49. package/lib/BarChartExportAction.js.map +1 -1
  50. package/lib/BarChartOptionsEditorSettings.d.ts +2 -2
  51. package/lib/BarChartOptionsEditorSettings.d.ts.map +1 -1
  52. package/lib/BarChartOptionsEditorSettings.js +87 -16
  53. package/lib/BarChartOptionsEditorSettings.js.map +1 -1
  54. package/lib/BarChartPanel.d.ts +4 -4
  55. package/lib/BarChartPanel.d.ts.map +1 -1
  56. package/lib/BarChartPanel.js +11 -10
  57. package/lib/BarChartPanel.js.map +1 -1
  58. package/lib/bar-chart-model.d.ts +18 -3
  59. package/lib/bar-chart-model.d.ts.map +1 -1
  60. package/lib/bar-chart-model.js +4 -2
  61. package/lib/bar-chart-model.js.map +1 -1
  62. package/lib/bootstrap.js +2 -2
  63. package/lib/getPluginModule.d.ts +1 -1
  64. package/lib/getPluginModule.d.ts.map +1 -1
  65. package/lib/getPluginModule.js +3 -1
  66. package/lib/getPluginModule.js.map +1 -1
  67. package/lib/index-federation.js +1 -1
  68. package/lib/index.js +5 -5
  69. package/lib/index.js.map +1 -1
  70. package/lib/setup-tests.d.ts +1 -1
  71. package/lib/setup-tests.d.ts.map +1 -1
  72. package/lib/setup-tests.js +2 -2
  73. package/lib/setup-tests.js.map +1 -1
  74. package/lib/tresholds.d.ts +1 -1
  75. package/lib/tresholds.d.ts.map +1 -1
  76. package/lib/tresholds.js +1 -1
  77. package/lib/tresholds.js.map +1 -1
  78. package/lib/utils.d.ts +8 -2
  79. package/lib/utils.d.ts.map +1 -1
  80. package/lib/utils.js +22 -3
  81. package/lib/utils.js.map +1 -1
  82. package/mf-manifest.json +40 -41
  83. package/mf-stats.json +40 -41
  84. package/package.json +10 -10
  85. package/__mf/js/BarChart.9e1e78c7.js +0 -7
  86. package/__mf/js/async/121.473596c1.js +0 -2
  87. package/__mf/js/async/177.3e3ea369.js +0 -1
  88. package/__mf/js/async/187.0c10a71e.js +0 -7
  89. package/__mf/js/async/187.0c10a71e.js.LICENSE.txt +0 -39
  90. package/__mf/js/async/192.d5754c56.js +0 -1
  91. package/__mf/js/async/235.b9e83b0f.js +0 -1
  92. package/__mf/js/async/274.3b869914.js +0 -2
  93. package/__mf/js/async/356.4b7b13a4.js +0 -1
  94. package/__mf/js/async/377.1e6cd99f.js +0 -1
  95. package/__mf/js/async/392.43a49d02.js +0 -2
  96. package/__mf/js/async/435.7b8a2474.js +0 -1
  97. package/__mf/js/async/458.e0bfe246.js +0 -1
  98. package/__mf/js/async/46.822ac417.js +0 -101
  99. package/__mf/js/async/470.bbaeb6f6.js +0 -2
  100. package/__mf/js/async/496.b1d86a71.js +0 -1
  101. package/__mf/js/async/546.966246a4.js +0 -24
  102. package/__mf/js/async/546.966246a4.js.LICENSE.txt +0 -19
  103. package/__mf/js/async/568.93423f6b.js +0 -1
  104. package/__mf/js/async/587.19607cd0.js +0 -1
  105. package/__mf/js/async/588.3e2e88e6.js +0 -1
  106. package/__mf/js/async/603.73790c72.js +0 -1
  107. package/__mf/js/async/616.673776b4.js +0 -1
  108. package/__mf/js/async/71.8dde0897.js +0 -1
  109. package/__mf/js/async/77.64992029.js +0 -1
  110. package/__mf/js/async/815.60db8972.js +0 -39
  111. package/__mf/js/async/823.55761759.js +0 -10
  112. package/__mf/js/async/854.8910fbf0.js +0 -1
  113. package/__mf/js/async/873.2961fe42.js +0 -1
  114. package/__mf/js/async/934.e8708047.js +0 -2
  115. package/__mf/js/async/941.b9c9bdfe.js +0 -2
  116. package/__mf/js/async/963.e557410b.js +0 -1
  117. package/__mf/js/async/968.0da0003e.js +0 -1
  118. package/__mf/js/async/977.4f77cf46.js +0 -1
  119. package/__mf/js/async/978.83c86840.js +0 -1
  120. package/__mf/js/async/__federation_expose_BarChart.cf3b83b6.js +0 -1
  121. package/__mf/js/async/lib-router.9c050a7f.js +0 -2
  122. package/__mf/js/main.8c45ef82.js +0 -7
  123. package/lib/cjs/BarChart.js +0 -45
  124. package/lib/cjs/BarChartBase.js +0 -232
  125. package/lib/cjs/BarChartExportAction.js +0 -124
  126. package/lib/cjs/BarChartOptionsEditorSettings.js +0 -180
  127. package/lib/cjs/BarChartPanel.js +0 -138
  128. package/lib/cjs/bar-chart-model.js +0 -66
  129. package/lib/cjs/bootstrap.js +0 -26
  130. package/lib/cjs/env.d.js +0 -14
  131. package/lib/cjs/getPluginModule.js +0 -39
  132. package/lib/cjs/index-federation.js +0 -55
  133. package/lib/cjs/index.js +0 -40
  134. package/lib/cjs/setup-tests.js +0 -19
  135. package/lib/cjs/tresholds.js +0 -77
  136. package/lib/cjs/utils.js +0 -72
  137. /package/__mf/css/async/{187.85c2cbf6.css → 788.85c2cbf6.css} +0 -0
  138. /package/__mf/js/async/{121.473596c1.js.LICENSE.txt → 121.0dfa8a56.js.LICENSE.txt} +0 -0
  139. /package/__mf/js/async/{274.3b869914.js.LICENSE.txt → 274.becf0c4e.js.LICENSE.txt} +0 -0
  140. /package/__mf/js/async/{392.43a49d02.js.LICENSE.txt → 392.ce5748af.js.LICENSE.txt} +0 -0
  141. /package/__mf/js/async/{470.bbaeb6f6.js.LICENSE.txt → 470.6bd33fa1.js.LICENSE.txt} +0 -0
  142. /package/__mf/js/async/{823.55761759.js.LICENSE.txt → 823.2a2b516e.js.LICENSE.txt} +0 -0
  143. /package/__mf/js/async/{934.e8708047.js.LICENSE.txt → 934.04010fe7.js.LICENSE.txt} +0 -0
  144. /package/__mf/js/async/{941.b9c9bdfe.js.LICENSE.txt → 941.88203ba1.js.LICENSE.txt} +0 -0
  145. /package/__mf/js/async/{lib-router.9c050a7f.js.LICENSE.txt → lib-router.a4768e7d.js.LICENSE.txt} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/BarChartExportAction.tsx"],"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 React, { useCallback, useMemo } from 'react';\nimport { exportDataAsCSV, extractExportableData, isExportableData, sanitizeFilename } from '@perses-dev/plugin-system';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { IconButton } from '@mui/material';\nimport DownloadIcon from 'mdi-material-ui/Download';\nimport { BarChartPanelProps } from './BarChartPanel';\n\nexport const BarChartExportAction: React.FC<BarChartPanelProps> = ({ queryResults, definition }) => {\n const exportableData = useMemo(() => {\n return extractExportableData(queryResults);\n }, [queryResults]);\n\n const canExport = useMemo(() => {\n return isExportableData(exportableData);\n }, [exportableData]);\n\n const handleExport = useCallback(() => {\n if (!exportableData || !canExport) return;\n\n try {\n const title = definition?.spec?.display?.name || 'Time Series Data';\n\n const csvBlob = exportDataAsCSV({\n data: exportableData,\n });\n\n const baseFilename = sanitizeFilename(title);\n const filename = `${baseFilename}_data.csv`;\n\n const link = document.createElement('a');\n link.href = URL.createObjectURL(csvBlob);\n link.download = filename;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(link.href);\n } catch (error) {\n console.error('Time series export failed:', error);\n }\n }, [exportableData, canExport, definition]);\n\n if (!canExport) {\n return null;\n }\n\n return (\n <InfoTooltip description=\"Export as CSV\">\n <IconButton size=\"small\" onClick={handleExport} aria-label=\"Export time series data as CSV\">\n <DownloadIcon fontSize=\"inherit\" />\n </IconButton>\n </InfoTooltip>\n );\n};\n"],"names":["React","useCallback","useMemo","exportDataAsCSV","extractExportableData","isExportableData","sanitizeFilename","InfoTooltip","IconButton","DownloadIcon","BarChartExportAction","queryResults","definition","exportableData","canExport","handleExport","title","spec","display","name","csvBlob","data","baseFilename","filename","link","document","createElement","href","URL","createObjectURL","download","body","appendChild","click","removeChild","revokeObjectURL","error","console","description","size","onClick","aria-label","fontSize"],"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,SAASC,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AACpD,SAASC,eAAe,EAAEC,qBAAqB,EAAEC,gBAAgB,EAAEC,gBAAgB,QAAQ,4BAA4B;AACvH,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,OAAOC,kBAAkB,2BAA2B;AAGpD,OAAO,MAAMC,uBAAqD,CAAC,EAAEC,YAAY,EAAEC,UAAU,EAAE;IAC7F,MAAMC,iBAAiBX,QAAQ;QAC7B,OAAOE,sBAAsBO;IAC/B,GAAG;QAACA;KAAa;IAEjB,MAAMG,YAAYZ,QAAQ;QACxB,OAAOG,iBAAiBQ;IAC1B,GAAG;QAACA;KAAe;IAEnB,MAAME,eAAed,YAAY;QAC/B,IAAI,CAACY,kBAAkB,CAACC,WAAW;QAEnC,IAAI;YACF,MAAME,QAAQJ,YAAYK,MAAMC,SAASC,QAAQ;YAEjD,MAAMC,UAAUjB,gBAAgB;gBAC9BkB,MAAMR;YACR;YAEA,MAAMS,eAAehB,iBAAiBU;YACtC,MAAMO,WAAW,GAAGD,aAAa,SAAS,CAAC;YAE3C,MAAME,OAAOC,SAASC,aAAa,CAAC;YACpCF,KAAKG,IAAI,GAAGC,IAAIC,eAAe,CAACT;YAChCI,KAAKM,QAAQ,GAAGP;YAChBE,SAASM,IAAI,CAACC,WAAW,CAACR;YAC1BA,KAAKS,KAAK;YACVR,SAASM,IAAI,CAACG,WAAW,CAACV;YAC1BI,IAAIO,eAAe,CAACX,KAAKG,IAAI;QAC/B,EAAE,OAAOS,OAAO;YACdC,QAAQD,KAAK,CAAC,8BAA8BA;QAC9C;IACF,GAAG;QAACvB;QAAgBC;QAAWF;KAAW;IAE1C,IAAI,CAACE,WAAW;QACd,OAAO;IACT;IAEA,qBACE,KAACP;QAAY+B,aAAY;kBACvB,cAAA,KAAC9B;YAAW+B,MAAK;YAAQC,SAASzB;YAAc0B,cAAW;sBACzD,cAAA,KAAChC;gBAAaiC,UAAS;;;;AAI/B,EAAE"}
1
+ {"version":3,"sources":["../../src/BarChartExportAction.tsx"],"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 { IconButton } from '@mui/material';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { exportDataAsCSV, extractExportableData, isExportableData, sanitizeFilename } from '@perses-dev/plugin-system';\nimport DownloadIcon from 'mdi-material-ui/Download';\nimport React, { useCallback, useMemo } from 'react';\n\nimport type { BarChartPanelProps } from './BarChartPanel';\n\nexport const BarChartExportAction: React.FC<BarChartPanelProps> = ({ queryResults, definition }) => {\n const exportableData = useMemo(() => {\n return extractExportableData(queryResults);\n }, [queryResults]);\n\n const canExport = useMemo(() => {\n return isExportableData(exportableData);\n }, [exportableData]);\n\n const handleExport = useCallback(() => {\n if (!exportableData || !canExport) return;\n\n try {\n const title = definition?.spec?.display?.name || 'Time Series Data';\n\n const csvBlob = exportDataAsCSV({\n data: exportableData,\n });\n\n const baseFilename = sanitizeFilename(title);\n const filename = `${baseFilename}_data.csv`;\n\n const link = document.createElement('a');\n link.href = URL.createObjectURL(csvBlob);\n link.download = filename;\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(link.href);\n } catch (error) {\n console.error('Time series export failed:', error);\n }\n }, [exportableData, canExport, definition]);\n\n if (!canExport) {\n return null;\n }\n\n return (\n <InfoTooltip description=\"Export as CSV\">\n <IconButton size=\"small\" onClick={handleExport} aria-label=\"Export time series data as CSV\">\n <DownloadIcon fontSize=\"inherit\" />\n </IconButton>\n </InfoTooltip>\n );\n};\n"],"names":["IconButton","InfoTooltip","exportDataAsCSV","extractExportableData","isExportableData","sanitizeFilename","DownloadIcon","React","useCallback","useMemo","BarChartExportAction","queryResults","definition","exportableData","canExport","handleExport","title","spec","display","name","csvBlob","data","baseFilename","filename","link","document","createElement","href","URL","createObjectURL","download","body","appendChild","click","removeChild","revokeObjectURL","error","console","description","size","onClick","aria-label","fontSize"],"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,SAASA,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,eAAe,EAAEC,qBAAqB,EAAEC,gBAAgB,EAAEC,gBAAgB,QAAQ,4BAA4B;AACvH,OAAOC,kBAAkB,2BAA2B;AACpD,OAAOC,SAASC,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AAIpD,OAAO,MAAMC,uBAAqD,CAAC,EAAEC,YAAY,EAAEC,UAAU,EAAE;IAC7F,MAAMC,iBAAiBJ,QAAQ;QAC7B,OAAON,sBAAsBQ;IAC/B,GAAG;QAACA;KAAa;IAEjB,MAAMG,YAAYL,QAAQ;QACxB,OAAOL,iBAAiBS;IAC1B,GAAG;QAACA;KAAe;IAEnB,MAAME,eAAeP,YAAY;QAC/B,IAAI,CAACK,kBAAkB,CAACC,WAAW;QAEnC,IAAI;YACF,MAAME,QAAQJ,YAAYK,MAAMC,SAASC,QAAQ;YAEjD,MAAMC,UAAUlB,gBAAgB;gBAC9BmB,MAAMR;YACR;YAEA,MAAMS,eAAejB,iBAAiBW;YACtC,MAAMO,WAAW,GAAGD,aAAa,SAAS,CAAC;YAE3C,MAAME,OAAOC,SAASC,aAAa,CAAC;YACpCF,KAAKG,IAAI,GAAGC,IAAIC,eAAe,CAACT;YAChCI,KAAKM,QAAQ,GAAGP;YAChBE,SAASM,IAAI,CAACC,WAAW,CAACR;YAC1BA,KAAKS,KAAK;YACVR,SAASM,IAAI,CAACG,WAAW,CAACV;YAC1BI,IAAIO,eAAe,CAACX,KAAKG,IAAI;QAC/B,EAAE,OAAOS,OAAO;YACdC,QAAQD,KAAK,CAAC,8BAA8BA;QAC9C;IACF,GAAG;QAACvB;QAAgBC;QAAWF;KAAW;IAE1C,IAAI,CAACE,WAAW;QACd,OAAO;IACT;IAEA,qBACE,KAACb;QAAYqC,aAAY;kBACvB,cAAA,KAACtC;YAAWuC,MAAK;YAAQC,SAASzB;YAAc0B,cAAW;sBACzD,cAAA,KAACnC;gBAAaoC,UAAS;;;;AAI/B,EAAE"}
@@ -1,4 +1,4 @@
1
- import { ReactElement } from 'react';
2
- import { BarChartOptionsEditorProps } from './bar-chart-model';
1
+ import type { ReactElement } from 'react';
2
+ import type { BarChartOptionsEditorProps } from './bar-chart-model';
3
3
  export declare function BarChartOptionsEditorSettings(props: BarChartOptionsEditorProps): ReactElement;
4
4
  //# sourceMappingURL=BarChartOptionsEditorSettings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BarChartOptionsEditorSettings.d.ts","sourceRoot":"","sources":["../../src/BarChartOptionsEditorSettings.tsx"],"names":[],"mappings":"AAgDA,OAAO,EAAqB,YAAY,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,EAEL,0BAA0B,EAO3B,MAAM,mBAAmB,CAAC;AAE3B,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,0BAA0B,GAAG,YAAY,CAuI7F"}
1
+ {"version":3,"file":"BarChartOptionsEditorSettings.d.ts","sourceRoot":"","sources":["../../src/BarChartOptionsEditorSettings.tsx"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAqB,YAAY,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAmB,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAarF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,0BAA0B,GAAG,YAAY,CAqM7F"}
@@ -12,13 +12,16 @@ import { createElement as _createElement } from "react";
12
12
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
- import { Autocomplete, Button, Chip, FormControlLabel, Switch, TextField, ToggleButton, ToggleButtonGroup } from '@mui/material';
16
- import { FormatControls, isPercentUnit, isUnitWithShortValues, ModeSelector, OptionsEditorColumn, OptionsEditorGrid, OptionsEditorGroup, SortSelector } from '@perses-dev/components';
17
- import { CalculationSelector, DEFAULT_CALCULATION } from '@perses-dev/plugin-system';
18
- import { produce } from 'immer';
19
- import merge from 'lodash/merge';
20
- import omit from 'lodash/omit';
21
- import { DEFAULT_FORMAT, DEFAULT_MODE, DEFAULT_ORIENTATION, DEFAULT_SORT, DEFAULT_IS_STACKED, DEFAULT_GROUP_BY } from './bar-chart-model';
15
+ import { Autocomplete, Button, Chip, FormControlLabel, IconButton, Stack, Switch, TextField, ToggleButton, ToggleButtonGroup } from "@mui/material";
16
+ import { FormatControls, isPercentUnit, isUnitWithShortValues, ModeSelector, OptionsColorPicker, OptionsEditorColumn, OptionsEditorGrid, OptionsEditorGroup, SortSelector } from "@perses-dev/components";
17
+ import { CalculationSelector, DEFAULT_CALCULATION } from "@perses-dev/plugin-system";
18
+ import { produce } from "immer";
19
+ import merge from "lodash/merge";
20
+ import omit from "lodash/omit";
21
+ import DeleteIcon from "mdi-material-ui/DeleteOutline";
22
+ import AddIcon from "mdi-material-ui/Plus";
23
+ import { DEFAULT_FORMAT, DEFAULT_MODE, DEFAULT_ORIENTATION, DEFAULT_SORT, DEFAULT_IS_STACKED, DEFAULT_GROUP_BY, DEFAULT_VISUAL } from "./bar-chart-model.js";
24
+ const DEFAULT_COLOR_VALUE = '#555';
22
25
  export function BarChartOptionsEditorSettings(props) {
23
26
  const { onChange, value } = props;
24
27
  const handleCalculationChange = (newCalculation)=>{
@@ -50,6 +53,34 @@ export function BarChartOptionsEditorSettings(props) {
50
53
  draft.groupBy = DEFAULT_GROUP_BY;
51
54
  draft.isStacked = DEFAULT_IS_STACKED;
52
55
  draft.orientation = DEFAULT_ORIENTATION;
56
+ draft.visual = DEFAULT_VISUAL;
57
+ }));
58
+ };
59
+ const handleAddColorOverride = ()=>{
60
+ onChange(produce(value, (draft)=>{
61
+ if (!draft.visual) draft.visual = {};
62
+ if (!draft.visual.colorOverrides) draft.visual.colorOverrides = [];
63
+ draft.visual.colorOverrides.push({
64
+ regex: '',
65
+ color: DEFAULT_COLOR_VALUE
66
+ });
67
+ }));
68
+ };
69
+ const handleRemoveColorOverride = (index)=>{
70
+ onChange(produce(value, (draft)=>{
71
+ draft.visual?.colorOverrides?.splice(index, 1);
72
+ }));
73
+ };
74
+ const handleColorOverrideRegexChange = (index, regex)=>{
75
+ onChange(produce(value, (draft)=>{
76
+ const override = draft.visual?.colorOverrides?.[index];
77
+ if (override) override.regex = regex;
78
+ }));
79
+ };
80
+ const handleColorOverrideColorChange = (index, color)=>{
81
+ onChange(produce(value, (draft)=>{
82
+ const override = draft.visual?.colorOverrides?.[index];
83
+ if (override) override.color = color;
53
84
  }));
54
85
  };
55
86
  // ensures decimalPlaces defaults to correct value
@@ -58,6 +89,7 @@ export function BarChartOptionsEditorSettings(props) {
58
89
  ]), value.format);
59
90
  const groupBy = value.groupBy ?? DEFAULT_GROUP_BY;
60
91
  const isStacked = value.isStacked ?? DEFAULT_IS_STACKED;
92
+ const colorOverrides = value.visual?.colorOverrides ?? [];
61
93
  return /*#__PURE__*/ _jsxs(OptionsEditorGrid, {
62
94
  children: [
63
95
  /*#__PURE__*/ _jsxs(OptionsEditorColumn, {
@@ -149,16 +181,55 @@ export function BarChartOptionsEditorSettings(props) {
149
181
  })
150
182
  ]
151
183
  }),
152
- /*#__PURE__*/ _jsx(OptionsEditorColumn, {
153
- children: /*#__PURE__*/ _jsx(OptionsEditorGroup, {
154
- title: "Reset Settings",
155
- children: /*#__PURE__*/ _jsx(Button, {
156
- variant: "outlined",
157
- color: "secondary",
158
- onClick: handleResetSettings,
159
- children: "Reset To Defaults"
184
+ /*#__PURE__*/ _jsxs(OptionsEditorColumn, {
185
+ children: [
186
+ /*#__PURE__*/ _jsxs(OptionsEditorGroup, {
187
+ title: "Color Overrides",
188
+ children: [
189
+ colorOverrides.map((override, i)=>/*#__PURE__*/ _jsxs(Stack, {
190
+ direction: "row",
191
+ alignItems: "center",
192
+ spacing: 1,
193
+ children: [
194
+ /*#__PURE__*/ _jsx(TextField, {
195
+ size: "small",
196
+ label: "Regex",
197
+ value: override.regex,
198
+ onChange: (e)=>handleColorOverrideRegexChange(i, e.target.value),
199
+ sx: {
200
+ flexGrow: 1
201
+ }
202
+ }),
203
+ /*#__PURE__*/ _jsx(OptionsColorPicker, {
204
+ label: override.regex || `Color override n°${i + 1}`,
205
+ color: override.color || DEFAULT_COLOR_VALUE,
206
+ onColorChange: (color)=>handleColorOverrideColorChange(i, color)
207
+ }),
208
+ /*#__PURE__*/ _jsx(IconButton, {
209
+ "aria-label": `delete color override n°${i + 1}`,
210
+ onClick: ()=>handleRemoveColorOverride(i),
211
+ children: /*#__PURE__*/ _jsx(DeleteIcon, {})
212
+ })
213
+ ]
214
+ }, i)),
215
+ /*#__PURE__*/ _jsx(Button, {
216
+ variant: "outlined",
217
+ startIcon: /*#__PURE__*/ _jsx(AddIcon, {}),
218
+ onClick: handleAddColorOverride,
219
+ children: "Add Color Override"
220
+ })
221
+ ]
222
+ }),
223
+ /*#__PURE__*/ _jsx(OptionsEditorGroup, {
224
+ title: "Reset Settings",
225
+ children: /*#__PURE__*/ _jsx(Button, {
226
+ variant: "outlined",
227
+ color: "secondary",
228
+ onClick: handleResetSettings,
229
+ children: "Reset To Defaults"
230
+ })
160
231
  })
161
- })
232
+ ]
162
233
  })
163
234
  ]
164
235
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/BarChartOptionsEditorSettings.tsx"],"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 {\n Autocomplete,\n Button,\n Chip,\n FormControlLabel,\n Switch,\n TextField,\n ToggleButton,\n ToggleButtonGroup,\n} from '@mui/material';\nimport {\n FormatControls,\n FormatControlsProps,\n FormatOptions,\n isPercentUnit,\n isUnitWithShortValues,\n ModeOption,\n ModeSelector,\n ModeSelectorProps,\n OptionsEditorColumn,\n OptionsEditorGrid,\n OptionsEditorGroup,\n SortOption,\n SortSelector,\n SortSelectorProps,\n} from '@perses-dev/components';\nimport {\n CalculationSelector,\n CalculationSelectorProps,\n CalculationType,\n DEFAULT_CALCULATION,\n} from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport merge from 'lodash/merge';\nimport omit from 'lodash/omit';\nimport { MouseEventHandler, ReactElement } from 'react';\nimport {\n BarChartOptions,\n BarChartOptionsEditorProps,\n DEFAULT_FORMAT,\n DEFAULT_MODE,\n DEFAULT_ORIENTATION,\n DEFAULT_SORT,\n DEFAULT_IS_STACKED,\n DEFAULT_GROUP_BY,\n} from './bar-chart-model';\n\nexport function BarChartOptionsEditorSettings(props: BarChartOptionsEditorProps): ReactElement {\n const { onChange, value } = props;\n\n const handleCalculationChange: CalculationSelectorProps['onChange'] = (newCalculation: CalculationType) => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.calculation = newCalculation;\n })\n );\n };\n\n const handleUnitChange: FormatControlsProps['onChange'] = (newFormat: FormatOptions) => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.format = newFormat;\n })\n );\n };\n\n const handleSortChange: SortSelectorProps['onChange'] = (newSort: SortOption) => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.sort = newSort;\n })\n );\n };\n\n const handleModeChange: ModeSelectorProps['onChange'] = (newMode: ModeOption) => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.mode = newMode;\n })\n );\n };\n\n const handleResetSettings: MouseEventHandler<HTMLButtonElement> = () => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.calculation = DEFAULT_CALCULATION;\n draft.format = DEFAULT_FORMAT;\n draft.sort = DEFAULT_SORT;\n draft.mode = DEFAULT_MODE;\n draft.groupBy = DEFAULT_GROUP_BY;\n draft.isStacked = DEFAULT_IS_STACKED;\n draft.orientation = DEFAULT_ORIENTATION;\n })\n );\n };\n\n // ensures decimalPlaces defaults to correct value\n const format = merge(\n {},\n !value.format || isUnitWithShortValues(value.format) ? DEFAULT_FORMAT : omit(DEFAULT_FORMAT, ['shortValues']),\n value.format\n );\n const groupBy = value.groupBy ?? DEFAULT_GROUP_BY;\n const isStacked = value.isStacked ?? DEFAULT_IS_STACKED;\n\n return (\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Misc\">\n <FormatControls value={format} onChange={handleUnitChange} disabled={value.mode === 'percentage'} />\n <CalculationSelector value={value.calculation} onChange={handleCalculationChange} />\n <SortSelector value={value.sort} onChange={handleSortChange} />\n <ModeSelector value={value.mode} onChange={handleModeChange} disablePercentageMode={isPercentUnit(format)} />\n <ToggleButtonGroup\n exclusive\n size=\"small\"\n value={value.orientation ?? 'horizontal'}\n onChange={(_, v) =>\n v &&\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.orientation = v;\n })\n )\n }\n >\n <ToggleButton value=\"horizontal\">Horizontal</ToggleButton>\n <ToggleButton value=\"vertical\">Vertical</ToggleButton>\n </ToggleButtonGroup>\n </OptionsEditorGroup>\n <OptionsEditorGroup title=\"Stacking\">\n <Autocomplete\n multiple\n freeSolo\n value={groupBy}\n onChange={(_, newValue) => {\n const filtered = (newValue as string[]).filter((v) => v.trim() !== '');\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.groupBy = filtered;\n if (filtered.length === 0) draft.isStacked = false;\n })\n );\n }}\n options={[]}\n renderTags={(tagValues, getTagProps) =>\n tagValues.map((option, index) => (\n <Chip size=\"small\" variant=\"outlined\" label={option} {...getTagProps({ index })} key={option} />\n ))\n }\n renderInput={(params) => (\n <TextField {...params} size=\"small\" label=\"Group By Labels\" placeholder=\"Type label name + Enter\" />\n )}\n />\n <FormControlLabel\n control={\n <Switch\n size=\"small\"\n checked={isStacked}\n disabled={groupBy.length === 0}\n onChange={(e) =>\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.isStacked = e.target.checked;\n })\n )\n }\n />\n }\n label=\"Stack bars\"\n />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Reset Settings\">\n <Button variant=\"outlined\" color=\"secondary\" onClick={handleResetSettings}>\n Reset To Defaults\n </Button>\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n );\n}\n"],"names":["Autocomplete","Button","Chip","FormControlLabel","Switch","TextField","ToggleButton","ToggleButtonGroup","FormatControls","isPercentUnit","isUnitWithShortValues","ModeSelector","OptionsEditorColumn","OptionsEditorGrid","OptionsEditorGroup","SortSelector","CalculationSelector","DEFAULT_CALCULATION","produce","merge","omit","DEFAULT_FORMAT","DEFAULT_MODE","DEFAULT_ORIENTATION","DEFAULT_SORT","DEFAULT_IS_STACKED","DEFAULT_GROUP_BY","BarChartOptionsEditorSettings","props","onChange","value","handleCalculationChange","newCalculation","draft","calculation","handleUnitChange","newFormat","format","handleSortChange","newSort","sort","handleModeChange","newMode","mode","handleResetSettings","groupBy","isStacked","orientation","title","disabled","disablePercentageMode","exclusive","size","_","v","multiple","freeSolo","newValue","filtered","filter","trim","length","options","renderTags","tagValues","getTagProps","map","option","index","variant","label","key","renderInput","params","placeholder","control","checked","e","target","color","onClick"],"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,SACEA,YAAY,EACZC,MAAM,EACNC,IAAI,EACJC,gBAAgB,EAChBC,MAAM,EACNC,SAAS,EACTC,YAAY,EACZC,iBAAiB,QACZ,gBAAgB;AACvB,SACEC,cAAc,EAGdC,aAAa,EACbC,qBAAqB,EAErBC,YAAY,EAEZC,mBAAmB,EACnBC,iBAAiB,EACjBC,kBAAkB,EAElBC,YAAY,QAEP,yBAAyB;AAChC,SACEC,mBAAmB,EAGnBC,mBAAmB,QACd,4BAA4B;AACnC,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,WAAW,eAAe;AACjC,OAAOC,U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wB,SAAS9B;oCACTG,UAAUJ,QAAQgB,MAAM,KAAK;oCAC7BhC,UAAU,CAACgD,IACThD,SACEX,QAAQY,OAAO,CAACG;4CACdA,MAAMa,SAAS,GAAG+B,EAAEC,MAAM,CAACF,OAAO;wCACpC;;gCAKRN,OAAM;;;;;;0BAIZ,KAAC1D;0BACC,cAAA,KAACE;oBAAmBkC,OAAM;8BACxB,cAAA,KAAC/C;wBAAOoE,SAAQ;wBAAWU,OAAM;wBAAYC,SAASpC;kCAAqB;;;;;;AAOrF"}
1
+ {"version":3,"sources":["../../src/BarChartOptionsEditorSettings.tsx"],"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 {\n Autocomplete,\n Button,\n Chip,\n FormControlLabel,\n IconButton,\n Stack,\n Switch,\n TextField,\n ToggleButton,\n ToggleButtonGroup,\n} from '@mui/material';\nimport type {\n FormatControlsProps,\n FormatOptions,\n ModeOption,\n ModeSelectorProps,\n SortOption,\n SortSelectorProps,\n} from '@perses-dev/components';\nimport {\n FormatControls,\n isPercentUnit,\n isUnitWithShortValues,\n ModeSelector,\n OptionsColorPicker,\n OptionsEditorColumn,\n OptionsEditorGrid,\n OptionsEditorGroup,\n SortSelector,\n} from '@perses-dev/components';\nimport type { CalculationSelectorProps, CalculationType } from '@perses-dev/plugin-system';\nimport { CalculationSelector, DEFAULT_CALCULATION } from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport merge from 'lodash/merge';\nimport omit from 'lodash/omit';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport type { MouseEventHandler, ReactElement } from 'react';\n\nimport type { BarChartOptions, BarChartOptionsEditorProps } from './bar-chart-model';\nimport {\n DEFAULT_FORMAT,\n DEFAULT_MODE,\n DEFAULT_ORIENTATION,\n DEFAULT_SORT,\n DEFAULT_IS_STACKED,\n DEFAULT_GROUP_BY,\n DEFAULT_VISUAL,\n} from './bar-chart-model';\n\nconst DEFAULT_COLOR_VALUE = '#555';\n\nexport function BarChartOptionsEditorSettings(props: BarChartOptionsEditorProps): ReactElement {\n const { onChange, value } = props;\n\n const handleCalculationChange: CalculationSelectorProps['onChange'] = (newCalculation: CalculationType) => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.calculation = newCalculation;\n }),\n );\n };\n\n const handleUnitChange: FormatControlsProps['onChange'] = (newFormat: FormatOptions) => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.format = newFormat;\n }),\n );\n };\n\n const handleSortChange: SortSelectorProps['onChange'] = (newSort: SortOption) => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.sort = newSort;\n }),\n );\n };\n\n const handleModeChange: ModeSelectorProps['onChange'] = (newMode: ModeOption) => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.mode = newMode;\n }),\n );\n };\n\n const handleResetSettings: MouseEventHandler<HTMLButtonElement> = () => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.calculation = DEFAULT_CALCULATION;\n draft.format = DEFAULT_FORMAT;\n draft.sort = DEFAULT_SORT;\n draft.mode = DEFAULT_MODE;\n draft.groupBy = DEFAULT_GROUP_BY;\n draft.isStacked = DEFAULT_IS_STACKED;\n draft.orientation = DEFAULT_ORIENTATION;\n draft.visual = DEFAULT_VISUAL;\n }),\n );\n };\n\n const handleAddColorOverride = (): void => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n if (!draft.visual) draft.visual = {};\n if (!draft.visual.colorOverrides) draft.visual.colorOverrides = [];\n draft.visual.colorOverrides.push({ regex: '', color: DEFAULT_COLOR_VALUE });\n }),\n );\n };\n\n const handleRemoveColorOverride = (index: number): void => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.visual?.colorOverrides?.splice(index, 1);\n }),\n );\n };\n\n const handleColorOverrideRegexChange = (index: number, regex: string): void => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n const override = draft.visual?.colorOverrides?.[index];\n if (override) override.regex = regex;\n }),\n );\n };\n\n const handleColorOverrideColorChange = (index: number, color: string): void => {\n onChange(\n produce(value, (draft: BarChartOptions) => {\n const override = draft.visual?.colorOverrides?.[index];\n if (override) override.color = color;\n }),\n );\n };\n\n // ensures decimalPlaces defaults to correct value\n const format = merge(\n {},\n !value.format || isUnitWithShortValues(value.format) ? DEFAULT_FORMAT : omit(DEFAULT_FORMAT, ['shortValues']),\n value.format,\n );\n const groupBy = value.groupBy ?? DEFAULT_GROUP_BY;\n const isStacked = value.isStacked ?? DEFAULT_IS_STACKED;\n const colorOverrides = value.visual?.colorOverrides ?? [];\n\n return (\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Misc\">\n <FormatControls value={format} onChange={handleUnitChange} disabled={value.mode === 'percentage'} />\n <CalculationSelector value={value.calculation} onChange={handleCalculationChange} />\n <SortSelector value={value.sort} onChange={handleSortChange} />\n <ModeSelector value={value.mode} onChange={handleModeChange} disablePercentageMode={isPercentUnit(format)} />\n <ToggleButtonGroup\n exclusive\n size=\"small\"\n value={value.orientation ?? 'horizontal'}\n onChange={(_, v) =>\n v &&\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.orientation = v;\n }),\n )\n }\n >\n <ToggleButton value=\"horizontal\">Horizontal</ToggleButton>\n <ToggleButton value=\"vertical\">Vertical</ToggleButton>\n </ToggleButtonGroup>\n </OptionsEditorGroup>\n <OptionsEditorGroup title=\"Stacking\">\n <Autocomplete\n multiple\n freeSolo\n value={groupBy}\n onChange={(_, newValue) => {\n const filtered = (newValue as string[]).filter((v) => v.trim() !== '');\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.groupBy = filtered;\n if (filtered.length === 0) draft.isStacked = false;\n }),\n );\n }}\n options={[]}\n renderTags={(tagValues, getTagProps) =>\n tagValues.map((option, index) => (\n <Chip size=\"small\" variant=\"outlined\" label={option} {...getTagProps({ index })} key={option} />\n ))\n }\n renderInput={(params) => (\n <TextField {...params} size=\"small\" label=\"Group By Labels\" placeholder=\"Type label name + Enter\" />\n )}\n />\n <FormControlLabel\n control={\n <Switch\n size=\"small\"\n checked={isStacked}\n disabled={groupBy.length === 0}\n onChange={(e) =>\n onChange(\n produce(value, (draft: BarChartOptions) => {\n draft.isStacked = e.target.checked;\n }),\n )\n }\n />\n }\n label=\"Stack bars\"\n />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Color Overrides\">\n {colorOverrides.map((override, i) => (\n <Stack key={i} direction=\"row\" alignItems=\"center\" spacing={1}>\n <TextField\n size=\"small\"\n label=\"Regex\"\n value={override.regex}\n onChange={(e) => handleColorOverrideRegexChange(i, e.target.value)}\n sx={{ flexGrow: 1 }}\n />\n <OptionsColorPicker\n label={override.regex || `Color override n°${i + 1}`}\n color={override.color || DEFAULT_COLOR_VALUE}\n onColorChange={(color) => handleColorOverrideColorChange(i, color)}\n />\n <IconButton aria-label={`delete color override n°${i + 1}`} onClick={() => handleRemoveColorOverride(i)}>\n <DeleteIcon />\n </IconButton>\n </Stack>\n ))}\n <Button variant=\"outlined\" startIcon={<AddIcon />} onClick={handleAddColorOverride}>\n Add Color Override\n </Button>\n </OptionsEditorGroup>\n <OptionsEditorGroup title=\"Reset Settings\">\n <Button variant=\"outlined\" color=\"secondary\" onClick={handleResetSettings}>\n Reset To Defaults\n </Button>\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n );\n}\n"],"names":["Autocomplete","Button","Chip","FormControlLabel","IconButton","Stack","Switch","TextField","ToggleButton","ToggleButtonGroup","FormatControls","isPercentUnit","isUnitWithShortValues","ModeSelector","OptionsColorPicker","OptionsEditorColumn","OptionsEditorGrid","OptionsEditorGroup","SortSelector","CalculationSelector","DEFAULT_CALCULATION","produce","merge","omit","DeleteIcon","AddIcon","DEFAULT_FORMAT","DEFAULT_MODE","DEFAULT_ORIENTATION","DEFAULT_SORT","DEFAULT_IS_STACKED","DEFAULT_GROUP_BY","DEFAULT_VISUAL","DEFAULT_COLOR_VALUE","BarChartOptionsEditorSettings","props","onChange","value","handleCalculationChange","newCalculation","draft","calculation","handleUnitChange","newFormat","format","handleSortChange","newSort","sort","handleModeChange","newMode","mode","handleResetSettings","groupBy","isStacked","orientation","visual","handleAddColorOverride","colorOverrides","push","regex","color","handleRemoveColorOverride","index","splice","handleColorOverrideRegexChange","override","handleColorOverrideColorChange","title","disabled","disablePercentageMode","exclusive","size","_","v","multiple","freeSolo","newValue","filtered","filter","trim","length","options","renderTags","tagValues","getTagProps","map","option","variant","label","key","renderInput","params","placeholder","control","checked","e","target","i","direction","alignItems","spacing","sx","flexGrow","onColorChange","aria-label","onClick","startIcon"],"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,SACEA,YAAY,EACZC,MAAM,EACNC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,YAAY,EACZC,iBAAiB,QACZ,gBAAgB;AASvB,SACEC,cAAc,EACdC,aAAa,EACbC,qBAAqB,EACrBC,YAAY,EACZC,kBAAkB,EAClBC,mBAAmB,EACnBC,iBAAiB,EACjBC,kBAAkB,EAClBC,YAAY,QACP,yBAAyB;AAEhC,SAASC,mBAAmB,EAAEC,mBAAmB,QAAQ,4BAA4B;AACrF,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC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;;;0BAIZ,MAACzE;;kCACC,MAACE;wBAAmBkD,OAAM;;4BACvBV,eAAe4B,GAAG,CAAC,CAACpB,UAAUgC,kBAC7B,MAAC5F;oCAAc6F,WAAU;oCAAMC,YAAW;oCAASC,SAAS;;sDAC1D,KAAC7F;4CACCgE,MAAK;4CACLiB,OAAM;4CACNnD,OAAO4B,SAASN,KAAK;4CACrBvB,UAAU,CAAC2D,IAAM/B,+BAA+BiC,GAAGF,EAAEC,MAAM,CAAC3D,KAAK;4CACjEgE,IAAI;gDAAEC,UAAU;4CAAE;;sDAEpB,KAACxF;4CACC0E,OAAOvB,SAASN,KAAK,IAAI,CAAC,iBAAiB,EAAEsC,IAAI,GAAG;4CACpDrC,OAAOK,SAASL,KAAK,IAAI3B;4CACzBsE,eAAe,CAAC3C,QAAUM,+BAA+B+B,GAAGrC;;sDAE9D,KAACxD;4CAAWoG,cAAY,CAAC,wBAAwB,EAAEP,IAAI,GAAG;4CAAEQ,SAAS,IAAM5C,0BAA0BoC;sDACnG,cAAA,KAACzE;;;mCAdOyE;0CAkBd,KAAChG;gCAAOsF,SAAQ;gCAAWmB,yBAAW,KAACjF;gCAAYgF,SAASjD;0CAAwB;;;;kCAItF,KAACvC;wBAAmBkD,OAAM;kCACxB,cAAA,KAAClE;4BAAOsF,SAAQ;4BAAW3B,OAAM;4BAAY6C,SAAStD;sCAAqB;;;;;;;AAOrF"}
@@ -1,7 +1,7 @@
1
- import { ReactElement } from 'react';
2
- import { PanelProps } from '@perses-dev/plugin-system';
3
- import { TimeSeriesData } from '@perses-dev/spec';
4
- import { BarChartOptions } from './bar-chart-model';
1
+ import type { PanelProps } from '@perses-dev/plugin-system';
2
+ import type { TimeSeriesData } from '@perses-dev/spec';
3
+ import type { ReactElement } from 'react';
4
+ import type { BarChartOptions } from './bar-chart-model';
5
5
  export type BarChartPanelProps = PanelProps<BarChartOptions, TimeSeriesData>;
6
6
  export declare function BarChartPanel(props: BarChartPanelProps): ReactElement | null;
7
7
  //# sourceMappingURL=BarChartPanel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BarChartPanel.d.ts","sourceRoot":"","sources":["../../src/BarChartPanel.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAoC,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIpD,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;AAE7E,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,GAAG,IAAI,CAiH5E"}
1
+ {"version":3,"file":"BarChartPanel.d.ts","sourceRoot":"","sources":["../../src/BarChartPanel.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAmB,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKzD,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;AAE7E,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,GAAG,IAAI,CAkH5E"}
@@ -11,14 +11,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import { useChartsTheme } from '@perses-dev/components';
15
- import { Box } from '@mui/material';
16
- import { useMemo } from 'react';
17
- import { CalculationsMap } from '@perses-dev/plugin-system';
18
- import { calculatePercentages, sortSeriesData } from './utils';
19
- import { BarChartBase } from './BarChartBase';
14
+ import { Box } from "@mui/material";
15
+ import { useChartsTheme } from "@perses-dev/components";
16
+ import { CalculationsMap } from "@perses-dev/plugin-system";
17
+ import { useMemo } from "react";
18
+ import { BarChartBase } from "./BarChartBase.js";
19
+ import { calculatePercentages, sortSeriesData } from "./utils.js";
20
20
  export function BarChartPanel(props) {
21
- const { spec: { calculation, format, sort, mode, groupBy = [], isStacked = false, orientation = 'horizontal' }, contentDimensions, queryResults } = props;
21
+ const { spec: { calculation, format, sort, mode, groupBy = [], isStacked = false, orientation = 'horizontal', visual }, contentDimensions, queryResults } = props;
22
22
  const chartsTheme = useChartsTheme();
23
23
  const PADDING = chartsTheme.container.padding.default;
24
24
  const barChartData = useMemo(()=>{
@@ -76,9 +76,9 @@ export function BarChartPanel(props) {
76
76
  const getTotalValue = (cat)=>Array.from(groupMap.get(cat)?.values() ?? []).reduce((a, b)=>a + b, 0);
77
77
  let categories = Array.from(groupMap.keys());
78
78
  if (sort === 'asc') {
79
- categories = categories.sort((a, b)=>getTotalValue(a) - getTotalValue(b));
79
+ categories = categories.toSorted((a, b)=>getTotalValue(a) - getTotalValue(b));
80
80
  } else if (sort === 'desc') {
81
- categories = categories.sort((a, b)=>getTotalValue(b) - getTotalValue(a));
81
+ categories = categories.toSorted((a, b)=>getTotalValue(b) - getTotalValue(a));
82
82
  }
83
83
  const series = segmentNamesOrdered.map((segName)=>{
84
84
  const values = categories.map((cat)=>{
@@ -122,7 +122,8 @@ export function BarChartPanel(props) {
122
122
  mode: mode,
123
123
  groupedData: stackedBarChartData,
124
124
  isStacked: isStacked,
125
- orientation: orientation
125
+ orientation: orientation,
126
+ colorOverrides: visual?.colorOverrides
126
127
  })
127
128
  });
128
129
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/BarChartPanel.tsx"],"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 { useChartsTheme } from '@perses-dev/components';\nimport { Box } from '@mui/material';\nimport { ReactElement, useMemo } from 'react';\nimport { CalculationsMap, CalculationType, PanelProps } from '@perses-dev/plugin-system';\nimport { TimeSeriesData } from '@perses-dev/spec';\nimport { BarChartOptions } from './bar-chart-model';\nimport { calculatePercentages, sortSeriesData } from './utils';\nimport { BarChartBase, BarChartData, StackedBarChartData, StackedBarChartSeries } from './BarChartBase';\n\nexport type BarChartPanelProps = PanelProps<BarChartOptions, TimeSeriesData>;\n\nexport function BarChartPanel(props: BarChartPanelProps): ReactElement | null {\n const {\n spec: { calculation, format, sort, mode, groupBy = [], isStacked = false, orientation = 'horizontal' },\n contentDimensions,\n queryResults,\n } = props;\n\n const chartsTheme = useChartsTheme();\n const PADDING = chartsTheme.container.padding.default;\n\n const barChartData: BarChartData[] = useMemo(() => {\n if (groupBy.length > 0) return [];\n\n const calculate = CalculationsMap[calculation as CalculationType];\n const barChartData: BarChartData[] = [];\n for (const result of queryResults) {\n for (const seriesData of result.data.series) {\n const series = {\n value: calculate(seriesData.values) ?? null,\n label: seriesData.formattedName ?? '',\n };\n barChartData.push(series);\n }\n }\n\n const sortedBarChartData = sortSeriesData(barChartData, sort);\n if (mode === 'percentage') {\n return calculatePercentages(sortedBarChartData);\n } else {\n return sortedBarChartData;\n }\n }, [queryResults, sort, mode, calculation, groupBy]);\n\n const stackedBarChartData: StackedBarChartData | null = useMemo(() => {\n if (groupBy.length === 0) return null;\n\n const calculate = CalculationsMap[calculation as CalculationType];\n const groupMap = new Map<string, Map<string, number>>();\n const segmentNamesOrdered: string[] = [];\n const segmentNamesSet = new Set<string>();\n\n for (const queryResult of queryResults) {\n for (const seriesData of queryResult.data.series) {\n const labels = seriesData.labels ?? {};\n\n const groupKey = groupBy.map((k) => labels[k] ?? '').join(' / ');\n\n const remainingEntries = Object.entries(labels).filter(([k]) => !groupBy.includes(k));\n const segmentName =\n remainingEntries.length > 0\n ? '{' + remainingEntries.map(([k, v]) => `${k}=\"${v}\"`).join(', ') + '}'\n : (seriesData.formattedName ?? seriesData.name);\n\n if (!groupMap.has(groupKey)) {\n groupMap.set(groupKey, new Map());\n }\n const segMap = groupMap.get(groupKey);\n if (!segMap) continue;\n const value = calculate(seriesData.values) ?? 0;\n segMap.set(segmentName, (segMap.get(segmentName) ?? 0) + value);\n\n if (!segmentNamesSet.has(segmentName)) {\n segmentNamesSet.add(segmentName);\n segmentNamesOrdered.push(segmentName);\n }\n }\n }\n\n if (groupMap.size === 0) return null;\n const getTotalValue = (cat: string): number =>\n Array.from(groupMap.get(cat)?.values() ?? []).reduce((a, b) => a + b, 0);\n\n let categories = Array.from(groupMap.keys());\n if (sort === 'asc') {\n categories = categories.sort((a, b) => getTotalValue(a) - getTotalValue(b));\n } else if (sort === 'desc') {\n categories = categories.sort((a, b) => getTotalValue(b) - getTotalValue(a));\n }\n\n const series: StackedBarChartSeries[] = segmentNamesOrdered.map((segName) => {\n const values = categories.map((cat) => {\n const rawVal = groupMap.get(cat)?.get(segName) ?? null;\n if (mode === 'percentage' && rawVal !== null) {\n const total = getTotalValue(cat);\n return total > 0 ? (rawVal / total) * 100 : 0;\n }\n return rawVal;\n });\n return { name: segName, values };\n });\n\n return { categories, series };\n }, [queryResults, groupBy, sort, mode, calculation]);\n\n if (contentDimensions === undefined) return null;\n\n const effectiveFormat =\n mode === 'percentage' ? { unit: 'percent' as const, decimalPlaces: format?.decimalPlaces } : format;\n\n return (\n <Box sx={{ padding: `${PADDING}px` }}>\n <BarChartBase\n width={contentDimensions.width - PADDING * 2}\n height={contentDimensions.height - PADDING * 2}\n data={barChartData}\n format={groupBy.length > 0 ? effectiveFormat : format}\n mode={mode}\n groupedData={stackedBarChartData}\n isStacked={isStacked}\n orientation={orientation}\n />\n </Box>\n );\n}\n"],"names":["useChartsTheme","Box","useMemo","CalculationsMap","calculatePercentages","sortSeriesData","BarChartBase","BarChartPanel","props","spec","calculation","format","sort","mode","groupBy","isStacked","orientation","contentDimensions","queryResults","chartsTheme","PADDING","container","padding","default","barChartData","length","calculate","result","seriesData","data","series","value","values","label","formattedName","push","sortedBarChartData","stackedBarChartData","groupMap","Map","segmentNamesOrdered","segmentNamesSet","Set","queryResult","labels","groupKey","map","k","join","remainingEntries","Object","entries","filter","includes","segmentName","v","name","has","set","segMap","get","add","size","getTotalValue","cat","Array","from","reduce","a","b","categories","keys","segName","rawVal","total","undefined","effectiveFormat","unit","decimalPlaces","sx","width","height","groupedData"],"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,SAASA,cAAc,QAAQ,yBAAyB;AACxD,SAASC,GAAG,QAAQ,gBAAgB;AACpC,SAAuBC,OAAO,QAAQ,QAAQ;AAC9C,SAASC,eAAe,QAAqC,4BAA4B;AAGzF,SAASC,oBAAoB,EAAEC,cAAc,QAAQ,UAAU;AAC/D,SAASC,YAAY,QAAkE,iBAAiB;AAIxG,OAAO,SAASC,cAAcC,KAAyB;IACrD,MAAM,EACJC,MAAM,EAAEC,WAAW,EAAEC,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,UAAU,EAAE,EAAEC,YAAY,KAAK,EAAEC,cAAc,YAAY,EAAE,EACtGC,iBAAiB,EACjBC,YAAY,EACb,GAAGV;IAEJ,MAAMW,cAAcnB;IACpB,MAAMoB,UAAUD,YAAYE,SAAS,CAACC,OAAO,CAACC,OAAO;IAErD,MAAMC,eAA+BtB,QAAQ;QAC3C,IAAIY,QAAQW,MAAM,GAAG,GAAG,OAAO,EA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C,QAAS,MAAM;gBAC9C;gBACA,OAAOD;YACT;YACA,OAAO;gBAAEjB,MAAMgB;gBAASxC;YAAO;QACjC;QAEA,OAAO;YAAEsC;YAAYxC;QAAO;IAC9B,GAAG;QAACZ;QAAcJ;QAASF;QAAMC;QAAMH;KAAY;IAEnD,IAAIO,sBAAsB0D,WAAW,OAAO;IAE5C,MAAMC,kBACJ/D,SAAS,eAAe;QAAEgE,MAAM;QAAoBC,eAAenE,QAAQmE;IAAc,IAAInE;IAE/F,qBACE,KAACV;QAAI8E,IAAI;YAAEzD,SAAS,GAAGF,QAAQ,EAAE,CAAC;QAAC;kBACjC,cAAA,KAACd;YACC0E,OAAO/D,kBAAkB+D,KAAK,GAAG5D,UAAU;YAC3C6D,QAAQhE,kBAAkBgE,MAAM,GAAG7D,UAAU;YAC7CS,MAAML;YACNb,QAAQG,QAAQW,MAAM,GAAG,IAAImD,kBAAkBjE;YAC/CE,MAAMA;YACNqE,aAAa7C;YACbtB,WAAWA;YACXC,aAAaA;;;AAIrB"}
1
+ {"version":3,"sources":["../../src/BarChartPanel.tsx"],"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 { Box } from '@mui/material';\nimport { useChartsTheme } from '@perses-dev/components';\nimport type { CalculationType, PanelProps } from '@perses-dev/plugin-system';\nimport { CalculationsMap } from '@perses-dev/plugin-system';\nimport type { TimeSeriesData } from '@perses-dev/spec';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport type { BarChartOptions } from './bar-chart-model';\nimport type { BarChartData, StackedBarChartData, StackedBarChartSeries } from './BarChartBase';\nimport { BarChartBase } from './BarChartBase';\nimport { calculatePercentages, sortSeriesData } from './utils';\n\nexport type BarChartPanelProps = PanelProps<BarChartOptions, TimeSeriesData>;\n\nexport function BarChartPanel(props: BarChartPanelProps): ReactElement | null {\n const {\n spec: { calculation, format, sort, mode, groupBy = [], isStacked = false, orientation = 'horizontal', visual },\n contentDimensions,\n queryResults,\n } = props;\n\n const chartsTheme = useChartsTheme();\n const PADDING = chartsTheme.container.padding.default;\n\n const barChartData: BarChartData[] = useMemo(() => {\n if (groupBy.length > 0) return [];\n\n const calculate = CalculationsMap[calculation as CalculationType];\n const barChartData: BarChartData[] = [];\n for (const result of queryResults) {\n for (const seriesData of result.data.series) {\n const series = {\n value: calculate(seriesData.values) ?? null,\n label: seriesData.formattedName ?? '',\n };\n barChartData.push(series);\n }\n }\n\n const sortedBarChartData = sortSeriesData(barChartData, sort);\n if (mode === 'percentage') {\n return calculatePercentages(sortedBarChartData);\n } else {\n return sortedBarChartData;\n }\n }, [queryResults, sort, mode, calculation, groupBy]);\n\n const stackedBarChartData: StackedBarChartData | null = useMemo(() => {\n if (groupBy.length === 0) return null;\n\n const calculate = CalculationsMap[calculation as CalculationType];\n const groupMap = new Map<string, Map<string, number>>();\n const segmentNamesOrdered: string[] = [];\n const segmentNamesSet = new Set<string>();\n\n for (const queryResult of queryResults) {\n for (const seriesData of queryResult.data.series) {\n const labels = seriesData.labels ?? {};\n\n const groupKey = groupBy.map((k) => labels[k] ?? '').join(' / ');\n\n const remainingEntries = Object.entries(labels).filter(([k]) => !groupBy.includes(k));\n const segmentName =\n remainingEntries.length > 0\n ? '{' + remainingEntries.map(([k, v]) => `${k}=\"${v}\"`).join(', ') + '}'\n : (seriesData.formattedName ?? seriesData.name);\n\n if (!groupMap.has(groupKey)) {\n groupMap.set(groupKey, new Map());\n }\n const segMap = groupMap.get(groupKey);\n if (!segMap) continue;\n const value = calculate(seriesData.values) ?? 0;\n segMap.set(segmentName, (segMap.get(segmentName) ?? 0) + value);\n\n if (!segmentNamesSet.has(segmentName)) {\n segmentNamesSet.add(segmentName);\n segmentNamesOrdered.push(segmentName);\n }\n }\n }\n\n if (groupMap.size === 0) return null;\n const getTotalValue = (cat: string): number =>\n Array.from(groupMap.get(cat)?.values() ?? []).reduce((a, b) => a + b, 0);\n\n let categories = Array.from(groupMap.keys());\n if (sort === 'asc') {\n categories = categories.toSorted((a, b) => getTotalValue(a) - getTotalValue(b));\n } else if (sort === 'desc') {\n categories = categories.toSorted((a, b) => getTotalValue(b) - getTotalValue(a));\n }\n\n const series: StackedBarChartSeries[] = segmentNamesOrdered.map((segName) => {\n const values = categories.map((cat) => {\n const rawVal = groupMap.get(cat)?.get(segName) ?? null;\n if (mode === 'percentage' && rawVal !== null) {\n const total = getTotalValue(cat);\n return total > 0 ? (rawVal / total) * 100 : 0;\n }\n return rawVal;\n });\n return { name: segName, values };\n });\n\n return { categories, series };\n }, [queryResults, groupBy, sort, mode, calculation]);\n\n if (contentDimensions === undefined) return null;\n\n const effectiveFormat =\n mode === 'percentage' ? { unit: 'percent' as const, decimalPlaces: format?.decimalPlaces } : format;\n\n return (\n <Box sx={{ padding: `${PADDING}px` }}>\n <BarChartBase\n width={contentDimensions.width - PADDING * 2}\n height={contentDimensions.height - PADDING * 2}\n data={barChartData}\n format={groupBy.length > 0 ? effectiveFormat : format}\n mode={mode}\n groupedData={stackedBarChartData}\n isStacked={isStacked}\n orientation={orientation}\n colorOverrides={visual?.colorOverrides}\n />\n </Box>\n );\n}\n"],"names":["Box","useChartsTheme","CalculationsMap","useMemo","BarChartBase","calculatePercentages","sortSeriesData","BarChartPanel","props","spec","calculation","format","sort","mode","groupBy","isStacked","orientation","visual","contentDimensions","queryResults","chartsTheme","PADDING","container","padding","default","barChartData","length","calculate","result","seriesData","data","series","value","values","label","formattedName","push","sortedBarChartData","stackedBarChartData","groupMap","Map","segmentNamesOrdered","segmentNamesSet","Set","queryResult","labels","groupKey","map","k","join","remainingEntries","Object","entries","filter","includes","segmentName","v","name","has","set","segMap","get","add","size","getTotalValue","cat","Array","from","reduce","a","b","categories","keys","toSorted","segName","rawVal","total","undefined","effectiveFormat","unit","decimalPlaces","sx","width","height","groupedData","colorOverrides"],"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,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,cAAc,QAAQ,yBAAyB;AAExD,SAASC,eAAe,QAAQ,4BAA4B;AAG5D,SAASC,OAAO,QAAQ,QAAQ;AAIhC,SAASC,YAAY,QAAQ,oBAAiB;AAC9C,SAASC,oBAAoB,EAAEC,cAAc,QAAQ,aAAU;AAI/D,OAAO,SAASC,cAAcC,KAAyB;IACrD,MAAM,EACJC,MAAM,EAAEC,WAAW,EAAEC,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,UAAU,EAAE,EAAEC,YAAY,KAAK,EAAEC,cAAc,YAAY,EAAEC,MAAM,EAAE,EAC9GC,iBAAiB,EACjBC,YAAY,EACb,GAAGX;IAEJ,MAAMY,cAAcnB;IACpB,MAAMoB,UAAUD,YAAYE,SAAS,CAACC,OAAO,CAACC,OAAO;IAErD,MAAMC,eAA+BtB,QAAQ;QAC3C,IAAIW,QAAQY,MAAM,GAAG,GAAG,OAAO,EAAE;QAEjC,MAAMC,YAAYzB,eAAe,CAACQ,YAA+B;QACjE,MAAMe,eAA+B,EAAE;QACvC,KAAK,MAAMG,UAAUT,aAAc;YACjC,KAAK,MAAMU,cAAcD,OAAOE,IAAI,CAACC,MAAM,CAAE;gBAC3C,MAAMA,SAAS;oBACbC,OAAOL,UAAUE,WAAWI,MAAM,KAAK;oBACvCC,OAAOL,WAAWM,aAAa,IAAI;gBACrC;gBACAV,aAAaW,IAAI,CAACL;YACpB;QACF;QAEA,MAAMM,qBAAqB/B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AIiF,IAAI;YAAE1D,SAAS,GAAGF,QAAQ,EAAE,CAAC;QAAC;kBACjC,cAAA,KAACjB;YACC8E,OAAOhE,kBAAkBgE,KAAK,GAAG7D,UAAU;YAC3C8D,QAAQjE,kBAAkBiE,MAAM,GAAG9D,UAAU;YAC7CS,MAAML;YACNd,QAAQG,QAAQY,MAAM,GAAG,IAAIoD,kBAAkBnE;YAC/CE,MAAMA;YACNuE,aAAa9C;YACbvB,WAAWA;YACXC,aAAaA;YACbqE,gBAAgBpE,QAAQoE;;;AAIhC"}
@@ -1,12 +1,26 @@
1
- import { FormatOptions, ModeOption, SortOption } from '@perses-dev/components';
2
- import { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';
3
- import { Definition } from '@perses-dev/spec';
1
+ import type { FormatOptions, ModeOption, SortOption } from '@perses-dev/components';
2
+ import type { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';
3
+ import type { Definition } from '@perses-dev/spec';
4
4
  export declare const DEFAULT_FORMAT: FormatOptions;
5
5
  export declare const DEFAULT_SORT: SortOption;
6
6
  export declare const DEFAULT_MODE: ModeOption;
7
7
  export declare const DEFAULT_ORIENTATION: 'horizontal' | 'vertical';
8
8
  export declare const DEFAULT_GROUP_BY: string[];
9
9
  export declare const DEFAULT_IS_STACKED = false;
10
+ export declare const DEFAULT_VISUAL: BarChartVisual;
11
+ /**
12
+ * A regex-based color override for a series/bar.
13
+ */
14
+ export interface ColorOverride {
15
+ regex: string;
16
+ color: string;
17
+ }
18
+ /**
19
+ * Visual display options for a BarChart panel.
20
+ */
21
+ export interface BarChartVisual {
22
+ colorOverrides?: ColorOverride[];
23
+ }
10
24
  /**
11
25
  * The schema for a BarChart panel.
12
26
  */
@@ -24,6 +38,7 @@ export interface BarChartOptions {
24
38
  orientation?: 'horizontal' | 'vertical';
25
39
  groupBy?: string[];
26
40
  isStacked?: boolean;
41
+ visual?: BarChartVisual;
27
42
  }
28
43
  export type BarChartOptionsEditorProps = OptionsEditorProps<BarChartOptions>;
29
44
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"bar-chart-model.d.ts","sourceRoot":"","sources":["../../src/bar-chart-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAuB,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACrG,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,eAAO,MAAM,cAAc,EAAE,aAAsD,CAAC;AACpF,eAAO,MAAM,YAAY,EAAE,UAAmB,CAAC;AAC/C,eAAO,MAAM,YAAY,EAAE,UAAoB,CAAC;AAChD,eAAO,MAAM,mBAAmB,EAAE,YAAY,GAAG,UAAyB,CAAC;AAC3E,eAAO,MAAM,gBAAgB,EAAE,MAAM,EAAO,CAAC;AAC7C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,UAAU,CAAC,eAAe,CAAC;IACrE,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,eAAe,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,0BAA0B,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;AAE7E;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,eAAe,CAU9D"}
1
+ {"version":3,"file":"bar-chart-model.d.ts","sourceRoot":"","sources":["../../src/bar-chart-model.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa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4BAA4B,IAAI,eAAe,CAW9D"}
@@ -10,7 +10,7 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { DEFAULT_CALCULATION } from '@perses-dev/plugin-system';
13
+ import { DEFAULT_CALCULATION } from "@perses-dev/plugin-system";
14
14
  export const DEFAULT_FORMAT = {
15
15
  unit: 'decimal',
16
16
  shortValues: true
@@ -20,6 +20,7 @@ export const DEFAULT_MODE = 'value';
20
20
  export const DEFAULT_ORIENTATION = 'horizontal';
21
21
  export const DEFAULT_GROUP_BY = [];
22
22
  export const DEFAULT_IS_STACKED = false;
23
+ export const DEFAULT_VISUAL = {};
23
24
  /**
24
25
  * Creates the initial/empty options for a BarChart panel.
25
26
  */ export function createInitialBarChartOptions() {
@@ -30,7 +31,8 @@ export const DEFAULT_IS_STACKED = false;
30
31
  mode: DEFAULT_MODE,
31
32
  orientation: DEFAULT_ORIENTATION,
32
33
  groupBy: DEFAULT_GROUP_BY,
33
- isStacked: DEFAULT_IS_STACKED
34
+ isStacked: DEFAULT_IS_STACKED,
35
+ visual: DEFAULT_VISUAL
34
36
  };
35
37
  }
36
38
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bar-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 { FormatOptions, ModeOption, SortOption } from '@perses-dev/components';\nimport { CalculationType, DEFAULT_CALCULATION, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { Definition } from '@perses-dev/spec';\n\nexport const DEFAULT_FORMAT: FormatOptions = { unit: 'decimal', shortValues: true };\nexport const DEFAULT_SORT: SortOption = 'desc';\nexport const DEFAULT_MODE: ModeOption = 'value';\nexport const DEFAULT_ORIENTATION: 'horizontal' | 'vertical' = 'horizontal';\nexport const DEFAULT_GROUP_BY: string[] = [];\nexport const DEFAULT_IS_STACKED = false;\n\n/**\n * The schema for a BarChart panel.\n */\nexport interface BarChartDefinition extends Definition<BarChartOptions> {\n kind: 'BarChart';\n}\n\n/**\n * The Options object type supported by the BarChart panel plugin.\n */\nexport interface BarChartOptions {\n calculation: CalculationType;\n format?: FormatOptions;\n sort?: SortOption;\n mode?: ModeOption;\n orientation?: 'horizontal' | 'vertical';\n groupBy?: string[];\n isStacked?: boolean;\n}\n\nexport type BarChartOptionsEditorProps = OptionsEditorProps<BarChartOptions>;\n\n/**\n * Creates the initial/empty options for a BarChart panel.\n */\nexport function createInitialBarChartOptions(): BarChartOptions {\n return {\n calculation: DEFAULT_CALCULATION,\n format: DEFAULT_FORMAT,\n sort: DEFAULT_SORT,\n mode: DEFAULT_MODE,\n orientation: DEFAULT_ORIENTATION,\n groupBy: DEFAULT_GROUP_BY,\n isStacked: DEFAULT_IS_STACKED,\n };\n}\n"],"names":["DEFAULT_CALCULATION","DEFAULT_FORMAT","unit","shortValues","DEFAULT_SORT","DEFAULT_MODE","DEFAULT_ORIENTATION","DEFAULT_GROUP_BY","DEFAULT_IS_STACKED","createInitialBarChartOptions","calculation","format","sort","mode","orientation","groupBy","isStacked"],"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,QAA4B,4BAA4B;AAGrG,OAAO,MAAMC,iBAAgC;IAAEC,MAAM;IAAWC,aAAa;AAAK,EAAE;AACpF,OAAO,MAAMC,eAA2B,OAAO;AAC/C,OAAO,MAAMC,eAA2B,QAAQ;AAChD,OAAO,MAAMC,sBAAiD,aAAa;AAC3E,OAAO,MAAMC,mBAA6B,EAAE,CAAC;AAC7C,OAAO,MAAMC,qBAAqB,MAAM;AAwBxC;;CAEC,GACD,OAAO,SAASC;IACd,OAAO;QACLC,aAAaV;QACbW,QAAQV;QACRW,MAAMR;QACNS,MAAMR;QACNS,aAAaR;QACbS,SAASR;QACTS,WAAWR;IACb;AACF"}
1
+ {"version":3,"sources":["../../src/bar-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 type { FormatOptions, ModeOption, SortOption } from '@perses-dev/components';\nimport type { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { DEFAULT_CALCULATION } from '@perses-dev/plugin-system';\nimport type { Definition } from '@perses-dev/spec';\n\nexport const DEFAULT_FORMAT: FormatOptions = { unit: 'decimal', shortValues: true };\nexport const DEFAULT_SORT: SortOption = 'desc';\nexport const DEFAULT_MODE: ModeOption = 'value';\nexport const DEFAULT_ORIENTATION: 'horizontal' | 'vertical' = 'horizontal';\nexport const DEFAULT_GROUP_BY: string[] = [];\nexport const DEFAULT_IS_STACKED = false;\nexport const DEFAULT_VISUAL: BarChartVisual = {};\n\n/**\n * A regex-based color override for a series/bar.\n */\nexport interface ColorOverride {\n regex: string;\n color: string;\n}\n\n/**\n * Visual display options for a BarChart panel.\n */\nexport interface BarChartVisual {\n colorOverrides?: ColorOverride[];\n}\n\n/**\n * The schema for a BarChart panel.\n */\nexport interface BarChartDefinition extends Definition<BarChartOptions> {\n kind: 'BarChart';\n}\n\n/**\n * The Options object type supported by the BarChart panel plugin.\n */\nexport interface BarChartOptions {\n calculation: CalculationType;\n format?: FormatOptions;\n sort?: SortOption;\n mode?: ModeOption;\n orientation?: 'horizontal' | 'vertical';\n groupBy?: string[];\n isStacked?: boolean;\n visual?: BarChartVisual;\n}\n\nexport type BarChartOptionsEditorProps = OptionsEditorProps<BarChartOptions>;\n\n/**\n * Creates the initial/empty options for a BarChart panel.\n */\nexport function createInitialBarChartOptions(): BarChartOptions {\n return {\n calculation: DEFAULT_CALCULATION,\n format: DEFAULT_FORMAT,\n sort: DEFAULT_SORT,\n mode: DEFAULT_MODE,\n orientation: DEFAULT_ORIENTATION,\n groupBy: DEFAULT_GROUP_BY,\n isStacked: DEFAULT_IS_STACKED,\n visual: DEFAULT_VISUAL,\n };\n}\n"],"names":["DEFAULT_CALCULATION","DEFAULT_FORMAT","unit","shortValues","DEFAULT_SORT","DEFAULT_MODE","DEFAULT_ORIENTATION","DEFAULT_GROUP_BY","DEFAULT_IS_STACKED","DEFAULT_VISUAL","createInitialBarChartOptions","calculation","format","sort","mode","orientation","groupBy","isStacked","visual"],"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;AAIjC,SAASA,mBAAmB,QAAQ,4BAA4B;AAGhE,OAAO,MAAMC,iBAAgC;IAAEC,MAAM;IAAWC,aAAa;AAAK,EAAE;AACpF,OAAO,MAAMC,eAA2B,OAAO;AAC/C,OAAO,MAAMC,eAA2B,QAAQ;AAChD,OAAO,MAAMC,sBAAiD,aAAa;AAC3E,OAAO,MAAMC,mBAA6B,EAAE,CAAC;AAC7C,OAAO,MAAMC,qBAAqB,MAAM;AACxC,OAAO,MAAMC,iBAAiC,CAAC,EAAE;AAwCjD;;CAEC,GACD,OAAO,SAASC;IACd,OAAO;QACLC,aAAaX;QACbY,QAAQX;QACRY,MAAMT;QACNU,MAAMT;QACNU,aAAaT;QACbU,SAAST;QACTU,WAAWT;QACXU,QAAQT;IACV;AACF"}
package/lib/bootstrap.js CHANGED
@@ -11,8 +11,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import React from 'react';
15
- import ReactDOM from 'react-dom/client';
14
+ import React from "react";
15
+ import ReactDOM from "react-dom/client";
16
16
  const root = ReactDOM.createRoot(document.getElementById('root'));
17
17
  root.render(/*#__PURE__*/ _jsx(React.StrictMode, {}));
18
18
 
@@ -1,4 +1,4 @@
1
- import { PluginModuleResource } from '@perses-dev/plugin-system';
1
+ import type { PluginModuleResource } from '@perses-dev/plugin-system';
2
2
  /**
3
3
  * Returns the plugin module information from package.json
4
4
  */
@@ -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,KAAK,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAIxF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}
@@ -10,7 +10,9 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import packageJson from '../package.json';
13
+ import packageJson from "../package.json" with {
14
+ type: 'json'
15
+ };
14
16
  /**
15
17
  * Returns the plugin module information from package.json
16
18
  */ export function getPluginModule() {
@@ -1 +1 @@
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
+ {"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 type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\n\nimport packageJson from '../package.json' with { type: '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","type","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;AAIjC,OAAOA,iBAAiB,uBAAuB;IAAEC,MAAM;AAAO,EAAE;AAEhE;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGL;IAClC,OAAO;QACLM,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
@@ -10,6 +10,6 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import('./bootstrap');
13
+ import("./bootstrap.js");
14
14
 
15
15
  //# sourceMappingURL=index-federation.js.map
package/lib/index.js CHANGED
@@ -10,10 +10,10 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- export * from './bar-chart-model';
14
- export * from './BarChart';
15
- export * from './BarChartOptionsEditorSettings';
16
- export { getPluginModule } from './getPluginModule';
17
- export * from './utils';
13
+ export * from "./bar-chart-model.js";
14
+ export * from "./BarChart.js";
15
+ export * from "./BarChartOptionsEditorSettings.js";
16
+ export { getPluginModule } from "./getPluginModule.js";
17
+ export * from "./utils.js";
18
18
 
19
19
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
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 './bar-chart-model';\nexport * from './BarChart';\nexport * from './BarChartOptionsEditorSettings';\nexport { getPluginModule } from './getPluginModule';\nexport * from './utils';\n"],"names":["getPluginModule"],"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,cAAc,oBAAoB;AAClC,cAAc,aAAa;AAC3B,cAAc,kCAAkC;AAChD,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,UAAU"}
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 './bar-chart-model';\nexport * from './BarChart';\nexport * from './BarChartOptionsEditorSettings';\nexport { getPluginModule } from './getPluginModule';\nexport * from './utils';\n"],"names":["getPluginModule"],"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,cAAc,uBAAoB;AAClC,cAAc,gBAAa;AAC3B,cAAc,qCAAkC;AAChD,SAASA,eAAe,QAAQ,uBAAoB;AACpD,cAAc,aAAU"}
@@ -1,2 +1,2 @@
1
- import '@testing-library/jest-dom';
1
+ import '@testing-library/jest-dom/vitest';
2
2
  //# sourceMappingURL=setup-tests.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,2BAA2B,CAAC"}
1
+ {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,kCAAkC,CAAC"}
@@ -10,8 +10,8 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import '@testing-library/jest-dom';
13
+ import "@testing-library/jest-dom/vitest";
14
14
  // Always mock e-charts during tests since we don't have a proper canvas in jsdom
15
- jest.mock('echarts/core');
15
+ vi.mock('echarts/core');
16
16
 
17
17
  //# sourceMappingURL=setup-tests.js.map
@@ -1 +1 @@
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"}
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/vitest';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\nvi.mock('echarts/core');\n"],"names":["vi","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,mCAAmC;AAE1C,iFAAiF;AACjFA,GAAGC,IAAI,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FormatOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components';
1
+ import type { FormatOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components';
2
2
  export type GaugeColorStop = [number, string];
3
3
  export type EChartsAxisLineColors = GaugeColorStop[];
4
4
  export declare const defaultThresholdInput: ThresholdOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"tresholds.d.ts","sourceRoot":"","sources":["../../src/tresholds.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAe,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG7G,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG,cAAc,EAAE,CAAC;AAErD,eAAO,MAAM,qBAAqB,EAAE,gBAA4C,CAAC;AAEjF,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,aAAa,EACnB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,GAC7B,qBAAqB,CA4BvB"}
1
+ {"version":3,"file":"tresholds.d.ts","sourceRoot":"","sources":["../../src/tresholds.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAe,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAGlH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG,cAAc,EAAE,CAAC;AAErD,eAAO,MAAM,qBAAqB,EAAE,gBAA4C,CAAC;AAEjF,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,aAAa,EACnB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,GAC7B,qBAAqB,CA4BvB"}