@perses-dev/components 0.0.0-snapshot-explorer-plugin-c4a7621 → 0.0.0-snapshot-profile-8090608

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 (187) hide show
  1. package/README.md +1 -4
  2. package/dist/ColorPicker/ColorPicker.js.map +1 -1
  3. package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
  4. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  5. package/dist/DragAndDrop/DragButton.d.ts +2 -2
  6. package/dist/DragAndDrop/DragButton.d.ts.map +1 -1
  7. package/dist/DragAndDrop/DragButton.js +5 -3
  8. package/dist/DragAndDrop/DragButton.js.map +1 -1
  9. package/dist/DragAndDrop/DropIndicator.js.map +1 -1
  10. package/dist/Drawer/Drawer.js.map +1 -1
  11. package/dist/EChart/EChart.d.ts +3 -2
  12. package/dist/EChart/EChart.d.ts.map +1 -1
  13. package/dist/EChart/EChart.js +26 -4
  14. package/dist/EChart/EChart.js.map +1 -1
  15. package/dist/InfoTooltip/InfoTooltip.js +2 -1
  16. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  17. package/dist/JSONEditor.d.ts.map +1 -1
  18. package/dist/JSONEditor.js +5 -6
  19. package/dist/JSONEditor.js.map +1 -1
  20. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  21. package/dist/Overlay/Overlay.js +1 -1
  22. package/dist/Overlay/Overlay.js.map +1 -1
  23. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  24. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  25. package/dist/Table/Table.d.ts +1 -1
  26. package/dist/Table/Table.d.ts.map +1 -1
  27. package/dist/Table/Table.js +15 -4
  28. package/dist/Table/Table.js.map +1 -1
  29. package/dist/Table/TableCell.d.ts +2 -1
  30. package/dist/Table/TableCell.d.ts.map +1 -1
  31. package/dist/Table/TableCell.js +4 -2
  32. package/dist/Table/TableCell.js.map +1 -1
  33. package/dist/Table/TableFoot.d.ts +4 -0
  34. package/dist/Table/TableFoot.d.ts.map +1 -0
  35. package/dist/{BarChart/index.js → Table/TableFoot.js} +11 -3
  36. package/dist/Table/TableFoot.js.map +1 -0
  37. package/dist/Table/TableHeaderCell.js.map +1 -1
  38. package/dist/Table/VirtualizedTable.d.ts +3 -2
  39. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  40. package/dist/Table/VirtualizedTable.js +33 -2
  41. package/dist/Table/VirtualizedTable.js.map +1 -1
  42. package/dist/Table/model/table-model.d.ts +18 -2
  43. package/dist/Table/model/table-model.d.ts.map +1 -1
  44. package/dist/Table/model/table-model.js +4 -2
  45. package/dist/Table/model/table-model.js.map +1 -1
  46. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  47. package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -1
  48. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  49. package/dist/TimeChart/TimeChart.d.ts.map +1 -1
  50. package/dist/TimeChart/TimeChart.js +6 -6
  51. package/dist/TimeChart/TimeChart.js.map +1 -1
  52. package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
  53. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  54. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +1 -1
  55. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  56. package/dist/TimeRangeSelector/utils.js.map +1 -1
  57. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -1
  58. package/dist/TimeSeriesTooltip/LineChartTooltip.js +2 -5
  59. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
  60. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  61. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
  62. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  63. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +2 -5
  64. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  65. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +1 -8
  66. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  67. package/dist/TimeSeriesTooltip/tooltip-model.js +6 -16
  68. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  69. package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
  70. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  71. package/dist/TimeSeriesTooltip/utils.js +27 -23
  72. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  73. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  74. package/dist/cjs/DragAndDrop/DragButton.js +4 -2
  75. package/dist/cjs/EChart/EChart.js +25 -3
  76. package/dist/cjs/InfoTooltip/InfoTooltip.js +2 -1
  77. package/dist/cjs/JSONEditor.js +4 -5
  78. package/dist/cjs/Overlay/Overlay.js +1 -1
  79. package/dist/cjs/Table/Table.js +14 -3
  80. package/dist/cjs/Table/TableCell.js +4 -2
  81. package/dist/cjs/{StatChart/utils/formatStatChartValue.js → Table/TableFoot.js} +12 -15
  82. package/dist/cjs/Table/VirtualizedTable.js +32 -1
  83. package/dist/cjs/Table/model/table-model.js +7 -2
  84. package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +9 -9
  85. package/dist/cjs/TimeChart/TimeChart.js +5 -5
  86. package/dist/cjs/TimeRangeSelector/DateTimeRangePicker.js +2 -2
  87. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +1 -4
  88. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +1 -4
  89. package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +6 -25
  90. package/dist/cjs/TimeSeriesTooltip/utils.js +26 -22
  91. package/dist/cjs/context/ChartsProvider.js +3 -1
  92. package/dist/cjs/index.js +0 -5
  93. package/dist/cjs/test-utils/theme.js +1 -0
  94. package/dist/context/ChartsProvider.d.ts +2 -0
  95. package/dist/context/ChartsProvider.d.ts.map +1 -1
  96. package/dist/context/ChartsProvider.js +3 -1
  97. package/dist/context/ChartsProvider.js.map +1 -1
  98. package/dist/context/SnackbarProvider.js.map +1 -1
  99. package/dist/index.d.ts +0 -5
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +0 -5
  102. package/dist/index.js.map +1 -1
  103. package/dist/model/timeOption.js.map +1 -1
  104. package/dist/test-utils/theme.d.ts.map +1 -1
  105. package/dist/test-utils/theme.js +1 -0
  106. package/dist/test-utils/theme.js.map +1 -1
  107. package/dist/theme/component-overrides/alert.js.map +1 -1
  108. package/dist/utils/component-ids.js.map +1 -1
  109. package/package.json +6 -11
  110. package/dist/BarChart/BarChart.d.ts +0 -16
  111. package/dist/BarChart/BarChart.d.ts.map +0 -1
  112. package/dist/BarChart/BarChart.js +0 -134
  113. package/dist/BarChart/BarChart.js.map +0 -1
  114. package/dist/BarChart/index.d.ts +0 -2
  115. package/dist/BarChart/index.d.ts.map +0 -1
  116. package/dist/BarChart/index.js.map +0 -1
  117. package/dist/GaugeChart/GaugeChart.d.ts +0 -23
  118. package/dist/GaugeChart/GaugeChart.d.ts.map +0 -1
  119. package/dist/GaugeChart/GaugeChart.js +0 -214
  120. package/dist/GaugeChart/GaugeChart.js.map +0 -1
  121. package/dist/GaugeChart/index.d.ts +0 -2
  122. package/dist/GaugeChart/index.d.ts.map +0 -1
  123. package/dist/GaugeChart/index.js +0 -15
  124. package/dist/GaugeChart/index.js.map +0 -1
  125. package/dist/PieChart/PieChart.d.ts +0 -14
  126. package/dist/PieChart/PieChart.d.ts.map +0 -1
  127. package/dist/PieChart/PieChart.js +0 -92
  128. package/dist/PieChart/PieChart.js.map +0 -1
  129. package/dist/PieChart/index.d.ts +0 -2
  130. package/dist/PieChart/index.d.ts.map +0 -1
  131. package/dist/PieChart/index.js +0 -15
  132. package/dist/PieChart/index.js.map +0 -1
  133. package/dist/StatChart/StatChart.d.ts +0 -21
  134. package/dist/StatChart/StatChart.d.ts.map +0 -1
  135. package/dist/StatChart/StatChart.js +0 -185
  136. package/dist/StatChart/StatChart.js.map +0 -1
  137. package/dist/StatChart/calculateFontSize.d.ts +0 -16
  138. package/dist/StatChart/calculateFontSize.d.ts.map +0 -1
  139. package/dist/StatChart/calculateFontSize.js +0 -49
  140. package/dist/StatChart/calculateFontSize.js.map +0 -1
  141. package/dist/StatChart/index.d.ts +0 -2
  142. package/dist/StatChart/index.d.ts.map +0 -1
  143. package/dist/StatChart/index.js +0 -15
  144. package/dist/StatChart/index.js.map +0 -1
  145. package/dist/StatChart/utils/formatStatChartValue.d.ts +0 -3
  146. package/dist/StatChart/utils/formatStatChartValue.d.ts.map +0 -1
  147. package/dist/StatChart/utils/formatStatChartValue.js +0 -26
  148. package/dist/StatChart/utils/formatStatChartValue.js.map +0 -1
  149. package/dist/StatusHistoryChart/StatusHistoryChart.d.ts +0 -27
  150. package/dist/StatusHistoryChart/StatusHistoryChart.d.ts.map +0 -1
  151. package/dist/StatusHistoryChart/StatusHistoryChart.js +0 -132
  152. package/dist/StatusHistoryChart/StatusHistoryChart.js.map +0 -1
  153. package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts +0 -13
  154. package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts.map +0 -1
  155. package/dist/StatusHistoryChart/StatusHistoryTooltip.js +0 -47
  156. package/dist/StatusHistoryChart/StatusHistoryTooltip.js.map +0 -1
  157. package/dist/StatusHistoryChart/get-formatted-axis-label.d.ts +0 -2
  158. package/dist/StatusHistoryChart/get-formatted-axis-label.d.ts.map +0 -1
  159. package/dist/StatusHistoryChart/get-formatted-axis-label.js +0 -41
  160. package/dist/StatusHistoryChart/get-formatted-axis-label.js.map +0 -1
  161. package/dist/StatusHistoryChart/index.d.ts +0 -3
  162. package/dist/StatusHistoryChart/index.d.ts.map +0 -1
  163. package/dist/StatusHistoryChart/index.js +0 -16
  164. package/dist/StatusHistoryChart/index.js.map +0 -1
  165. package/dist/StatusHistoryChart/utils/get-color.d.ts +0 -6
  166. package/dist/StatusHistoryChart/utils/get-color.d.ts.map +0 -1
  167. package/dist/StatusHistoryChart/utils/get-color.js +0 -100
  168. package/dist/StatusHistoryChart/utils/get-color.js.map +0 -1
  169. package/dist/StatusHistoryChart/utils/get-tooltip-position.d.ts +0 -3
  170. package/dist/StatusHistoryChart/utils/get-tooltip-position.d.ts.map +0 -1
  171. package/dist/StatusHistoryChart/utils/get-tooltip-position.js +0 -27
  172. package/dist/StatusHistoryChart/utils/get-tooltip-position.js.map +0 -1
  173. package/dist/cjs/BarChart/BarChart.js +0 -142
  174. package/dist/cjs/BarChart/index.js +0 -30
  175. package/dist/cjs/GaugeChart/GaugeChart.js +0 -227
  176. package/dist/cjs/GaugeChart/index.js +0 -30
  177. package/dist/cjs/PieChart/PieChart.js +0 -100
  178. package/dist/cjs/PieChart/index.js +0 -30
  179. package/dist/cjs/StatChart/StatChart.js +0 -198
  180. package/dist/cjs/StatChart/calculateFontSize.js +0 -55
  181. package/dist/cjs/StatChart/index.js +0 -30
  182. package/dist/cjs/StatusHistoryChart/StatusHistoryChart.js +0 -140
  183. package/dist/cjs/StatusHistoryChart/StatusHistoryTooltip.js +0 -55
  184. package/dist/cjs/StatusHistoryChart/get-formatted-axis-label.js +0 -48
  185. package/dist/cjs/StatusHistoryChart/index.js +0 -31
  186. package/dist/cjs/StatusHistoryChart/utils/get-color.js +0 -125
  187. package/dist/cjs/StatusHistoryChart/utils/get-tooltip-position.js +0 -35
@@ -1,100 +0,0 @@
1
- // Copyright 2024 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- export const FALLBACK_COLOR = '#1f77b4';
14
- export function getColorForValue(value, baseColor) {
15
- // Validate base color
16
- if (!baseColor.match(/^#[0-9A-Fa-f]{6}$/)) {
17
- baseColor = FALLBACK_COLOR;
18
- }
19
- try {
20
- const [baseH, baseS, baseL] = hexToHSL(baseColor);
21
- // Ensure numeric values are valid
22
- if (isNaN(baseH) || isNaN(baseS) || isNaN(baseL)) {
23
- throw new Error('Invalid HSL values');
24
- }
25
- // Create deterministic hash
26
- const hash = String(value).split('').reduce((acc, char)=>acc + char.charCodeAt(0), 0);
27
- const hueStep = 60;
28
- const lightnessVariation = 15;
29
- const hueOffset = hash % 6 * hueStep; // 6 segments of 60° each
30
- const newH = (baseH + hueOffset) % 360;
31
- const newL = baseL + (hash % 2 ? lightnessVariation : -lightnessVariation);
32
- // Keep saturation high for better distinction
33
- const newS = Math.min(baseS + 10, 90);
34
- const color = hslToHex(Math.abs(newH), Math.min(Math.max(newS, 50), 90), Math.min(Math.max(newL, 30), 70) // Keep lightness 30-70%
35
- );
36
- // Validate generated color
37
- if (!color.match(/^#[0-9A-Fa-f]{6}$/)) {
38
- throw new Error('Invalid generated color');
39
- }
40
- return color;
41
- } catch (_) {
42
- return FALLBACK_COLOR;
43
- }
44
- }
45
- export function getColorsForValues(uniqueValues, themeColors) {
46
- // If we have enough theme colors, use them
47
- if (themeColors.length >= uniqueValues.length) {
48
- return themeColors.slice(0, uniqueValues.length);
49
- }
50
- // Use theme colors first, then generate additional ones
51
- return uniqueValues.map((value, index)=>{
52
- if (index < themeColors.length) {
53
- return themeColors[index] || FALLBACK_COLOR;
54
- }
55
- return getColorForValue(value, themeColors[0] || FALLBACK_COLOR);
56
- });
57
- }
58
- export function hexToHSL(hex) {
59
- const r = parseInt(hex.slice(1, 3), 16) / 255;
60
- const g = parseInt(hex.slice(3, 5), 16) / 255;
61
- const b = parseInt(hex.slice(5, 7), 16) / 255;
62
- const max = Math.max(r, g, b);
63
- const min = Math.min(r, g, b);
64
- let h = 0;
65
- let s = 0;
66
- const l = (max + min) / 2;
67
- if (max !== min) {
68
- const d = max - min;
69
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
70
- switch(max){
71
- case r:
72
- h = (g - b) / d + (g < b ? 6 : 0);
73
- break;
74
- case g:
75
- h = (b - r) / d + 2;
76
- break;
77
- case b:
78
- h = (r - g) / d + 4;
79
- break;
80
- }
81
- h /= 6;
82
- }
83
- return [
84
- h * 360,
85
- s * 100,
86
- l * 100
87
- ];
88
- }
89
- export function hslToHex(h, s, l) {
90
- l /= 100;
91
- const a = s * Math.min(l, 1 - l) / 100;
92
- const f = (n)=>{
93
- const k = (n + h / 30) % 12;
94
- const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
95
- return Math.round(255 * color).toString(16).padStart(2, '0');
96
- };
97
- return `#${f(0)}${f(8)}${f(4)}`;
98
- }
99
-
100
- //# sourceMappingURL=get-color.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/StatusHistoryChart/utils/get-color.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\nexport const FALLBACK_COLOR = '#1f77b4';\n\nexport function getColorForValue(value: number | string, baseColor: string): string {\n // Validate base color\n if (!baseColor.match(/^#[0-9A-Fa-f]{6}$/)) {\n baseColor = FALLBACK_COLOR;\n }\n\n try {\n const [baseH, baseS, baseL] = hexToHSL(baseColor);\n\n // Ensure numeric values are valid\n if (isNaN(baseH) || isNaN(baseS) || isNaN(baseL)) {\n throw new Error('Invalid HSL values');\n }\n\n // Create deterministic hash\n const hash = String(value)\n .split('')\n .reduce((acc, char) => acc + char.charCodeAt(0), 0);\n\n const hueStep = 60;\n const lightnessVariation = 15;\n\n const hueOffset = (hash % 6) * hueStep; // 6 segments of 60° each\n const newH = (baseH + hueOffset) % 360;\n const newL = baseL + (hash % 2 ? lightnessVariation : -lightnessVariation);\n\n // Keep saturation high for better distinction\n const newS = Math.min(baseS + 10, 90);\n const color = hslToHex(\n Math.abs(newH),\n Math.min(Math.max(newS, 50), 90), // Keep saturation 50-90%\n Math.min(Math.max(newL, 30), 70) // Keep lightness 30-70%\n );\n\n // Validate generated color\n if (!color.match(/^#[0-9A-Fa-f]{6}$/)) {\n throw new Error('Invalid generated color');\n }\n\n return color;\n } catch (_) {\n return FALLBACK_COLOR;\n }\n}\n\nexport function getColorsForValues(uniqueValues: Array<number | string>, themeColors: string[]): string[] {\n // If we have enough theme colors, use them\n if (themeColors.length >= uniqueValues.length) {\n return themeColors.slice(0, uniqueValues.length);\n }\n\n // Use theme colors first, then generate additional ones\n return uniqueValues.map((value, index) => {\n if (index < themeColors.length) {\n return themeColors[index] || FALLBACK_COLOR;\n }\n return getColorForValue(value, themeColors[0] || FALLBACK_COLOR);\n });\n}\n\nexport function hexToHSL(hex: string): [number, number, number] {\n const r = parseInt(hex.slice(1, 3), 16) / 255;\n const g = parseInt(hex.slice(3, 5), 16) / 255;\n const b = parseInt(hex.slice(5, 7), 16) / 255;\n\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h = 0;\n let s = 0;\n const l = (max + min) / 2;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n return [h * 360, s * 100, l * 100];\n}\n\nexport function hslToHex(h: number, s: number, l: number): string {\n l /= 100;\n const a = (s * Math.min(l, 1 - l)) / 100;\n const f = (n: number): string => {\n const k = (n + h / 30) % 12;\n const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);\n return Math.round(255 * color)\n .toString(16)\n .padStart(2, '0');\n };\n return `#${f(0)}${f(8)}${f(4)}`;\n}\n"],"names":["FALLBACK_COLOR","getColorForValue","value","baseColor","match","baseH","baseS","baseL","hexToHSL","isNaN","Error","hash","String","split","reduce","acc","char","charCodeAt","hueStep","lightnessVariation","hueOffset","newH","newL","newS","Math","min","color","hslToHex","abs","max","_","getColorsForValues","uniqueValues","themeColors","length","slice","map","index","hex","r","parseInt","g","b","h","s","l","d","a","f","n","k","round","toString","padStart"],"mappings":"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"}
@@ -1,3 +0,0 @@
1
- import { TooltipComponentOption } from 'echarts';
2
- export declare const getTooltipPosition: TooltipComponentOption['position'];
3
- //# sourceMappingURL=get-tooltip-position.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-tooltip-position.d.ts","sourceRoot":"","sources":["../../../src/StatusHistoryChart/utils/get-tooltip-position.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,eAAO,MAAM,kBAAkB,EAAE,sBAAsB,CAAC,UAAU,CAYjE,CAAC"}
@@ -1,27 +0,0 @@
1
- // Copyright 2024 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- export const getTooltipPosition = (...data)=>{
14
- const point = data[0];
15
- const size = data[4];
16
- // calculate the position to avoid overflow
17
- const [x, y] = point;
18
- const { contentSize, viewSize } = size;
19
- const posX = x + contentSize[0] > viewSize[0] ? x - contentSize[0] : x;
20
- const posY = y + contentSize[1] > viewSize[1] ? y - contentSize[1] : y;
21
- return [
22
- posX,
23
- posY
24
- ];
25
- };
26
-
27
- //# sourceMappingURL=get-tooltip-position.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/StatusHistoryChart/utils/get-tooltip-position.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 { TooltipComponentOption } from 'echarts';\n\nexport const getTooltipPosition: TooltipComponentOption['position'] = (...data) => {\n const point = data[0];\n const size = data[4];\n\n // calculate the position to avoid overflow\n const [x, y] = point;\n const { contentSize, viewSize } = size;\n\n const posX = x + contentSize[0] > viewSize[0] ? x - contentSize[0] : x;\n const posY = y + contentSize[1] > viewSize[1] ? y - contentSize[1] : y;\n\n return [posX, posY];\n};\n"],"names":["getTooltipPosition","data","point","size","x","y","contentSize","viewSize","posX","posY"],"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;AAIjC,OAAO,MAAMA,qBAAyD,CAAC,GAAGC;IACxE,MAAMC,QAAQD,IAAI,CAAC,EAAE;IACrB,MAAME,OAAOF,IAAI,CAAC,EAAE;IAEpB,2CAA2C;IAC3C,MAAM,CAACG,GAAGC,EAAE,GAAGH;IACf,MAAM,EAAEI,WAAW,EAAEC,QAAQ,EAAE,GAAGJ;IAElC,MAAMK,OAAOJ,IAAIE,WAAW,CAAC,EAAE,GAAGC,QAAQ,CAAC,EAAE,GAAGH,IAAIE,WAAW,CAAC,EAAE,GAAGF;IACrE,MAAMK,OAAOJ,IAAIC,WAAW,CAAC,EAAE,GAAGC,QAAQ,CAAC,EAAE,GAAGF,IAAIC,WAAW,CAAC,EAAE,GAAGD;IAErE,OAAO;QAACG;QAAMC;KAAK;AACrB,EAAE"}
@@ -1,142 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "BarChart", {
18
- enumerable: true,
19
- get: function() {
20
- return BarChart;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _react = require("react");
25
- const _core = require("@perses-dev/core");
26
- const _core1 = require("echarts/core");
27
- const _charts = require("echarts/charts");
28
- const _components = require("echarts/components");
29
- const _renderers = require("echarts/renderers");
30
- const _material = require("@mui/material");
31
- const _context = require("../context");
32
- const _EChart = require("../EChart");
33
- const _utils = require("../utils");
34
- (0, _core1.use)([
35
- _charts.BarChart,
36
- _components.GridComponent,
37
- _components.DatasetComponent,
38
- _components.TitleComponent,
39
- _components.TooltipComponent,
40
- _renderers.CanvasRenderer
41
- ]);
42
- const BAR_WIN_WIDTH = 14;
43
- const BAR_GAP = 6;
44
- function BarChart(props) {
45
- const { width, height, data, format = {
46
- unit: 'decimal'
47
- }, mode = 'value' } = props;
48
- const chartsTheme = (0, _context.useChartsTheme)();
49
- const option = (0, _react.useMemo)(()=>{
50
- if (!data || !data.length) return chartsTheme.noDataOption;
51
- const source = [];
52
- data.map((d)=>{
53
- source.push([
54
- d.label,
55
- d.value
56
- ]);
57
- });
58
- return {
59
- title: {
60
- show: false
61
- },
62
- dataset: [
63
- {
64
- dimensions: [
65
- 'label',
66
- 'value'
67
- ],
68
- source: source
69
- }
70
- ],
71
- xAxis: (0, _utils.getFormattedAxis)({}, format),
72
- yAxis: {
73
- type: 'category',
74
- splitLine: {
75
- show: false
76
- },
77
- axisLabel: {
78
- overflow: 'truncate',
79
- width: width / 3
80
- }
81
- },
82
- series: {
83
- type: 'bar',
84
- label: {
85
- show: true,
86
- position: 'right',
87
- formatter: (params)=>{
88
- if (!params.data[1]) {
89
- return undefined;
90
- }
91
- if (mode === 'percentage') {
92
- return (0, _core.formatValue)(params.data[1], {
93
- unit: 'percent',
94
- decimalPlaces: format.decimalPlaces
95
- });
96
- }
97
- return (0, _core.formatValue)(params.data[1], format);
98
- },
99
- barMinWidth: BAR_WIN_WIDTH,
100
- barCategoryGap: BAR_GAP
101
- },
102
- itemStyle: {
103
- borderRadius: 4,
104
- color: chartsTheme.echartsTheme[0]
105
- }
106
- },
107
- tooltip: {
108
- appendToBody: true,
109
- confine: true,
110
- formatter: (params)=>params.data[1] && `<b>${params.name}</b> &emsp; ${(0, _core.formatValue)(params.data[1], format)}`
111
- },
112
- // increase distance between grid and container to prevent y axis labels from getting cut off
113
- grid: {
114
- left: '5%',
115
- right: '5%'
116
- }
117
- };
118
- }, [
119
- data,
120
- chartsTheme,
121
- width,
122
- mode,
123
- format
124
- ]);
125
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
126
- style: {
127
- width: width,
128
- height: height
129
- },
130
- sx: {
131
- overflow: 'auto'
132
- },
133
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_EChart.EChart, {
134
- sx: {
135
- minHeight: height,
136
- height: data ? data.length * (BAR_WIN_WIDTH + BAR_GAP) : '100%'
137
- },
138
- option: option,
139
- theme: chartsTheme.echartsTheme
140
- })
141
- });
142
- }
@@ -1,30 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- _export_star(require("./BarChart"), exports);
18
- function _export_star(from, to) {
19
- Object.keys(from).forEach(function(k) {
20
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
- Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
27
- }
28
- });
29
- return from;
30
- }
@@ -1,227 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- GaugeChart: function() {
25
- return GaugeChart;
26
- },
27
- getResponsiveValueSize: function() {
28
- return getResponsiveValueSize;
29
- }
30
- });
31
- const _jsxruntime = require("react/jsx-runtime");
32
- const _core = require("@perses-dev/core");
33
- const _core1 = require("echarts/core");
34
- const _charts = require("echarts/charts");
35
- const _components = require("echarts/components");
36
- const _renderers = require("echarts/renderers");
37
- const _context = require("../context");
38
- const _EChart = require("../EChart");
39
- (0, _core1.use)([
40
- _charts.GaugeChart,
41
- _components.GridComponent,
42
- _components.TitleComponent,
43
- _components.TooltipComponent,
44
- _renderers.CanvasRenderer
45
- ]);
46
- const PROGRESS_WIDTH = 16;
47
- // adjusts when to show pointer icon
48
- const GAUGE_SMALL_BREAKPOINT = 170;
49
- function GaugeChart(props) {
50
- const { width, height, data, format, axisLine, max } = props;
51
- const chartsTheme = (0, _context.useChartsTheme)();
52
- // useDeepMemo ensures value size util does not rerun everytime you hover on the chart
53
- const option = (0, _core.useDeepMemo)(()=>{
54
- if (data.value === undefined) return chartsTheme.noDataOption;
55
- // adjusts fontSize depending on number of characters
56
- const valueSizeClamp = getResponsiveValueSize(data.value, format, width, height);
57
- return {
58
- title: {
59
- show: false
60
- },
61
- tooltip: {
62
- show: false
63
- },
64
- series: [
65
- {
66
- type: 'gauge',
67
- center: [
68
- '50%',
69
- '65%'
70
- ],
71
- radius: '86%',
72
- startAngle: 200,
73
- endAngle: -20,
74
- min: 0,
75
- max,
76
- silent: true,
77
- progress: {
78
- show: true,
79
- width: PROGRESS_WIDTH,
80
- itemStyle: {
81
- color: 'auto'
82
- }
83
- },
84
- pointer: {
85
- show: false
86
- },
87
- axisLine: {
88
- lineStyle: {
89
- color: [
90
- [
91
- 1,
92
- 'rgba(127,127,127,0.35)'
93
- ]
94
- ],
95
- width: PROGRESS_WIDTH
96
- }
97
- },
98
- axisTick: {
99
- show: false,
100
- distance: 0
101
- },
102
- splitLine: {
103
- show: false
104
- },
105
- axisLabel: {
106
- show: false,
107
- distance: -18,
108
- color: '#999',
109
- fontSize: 12
110
- },
111
- anchor: {
112
- show: false
113
- },
114
- title: {
115
- show: false
116
- },
117
- detail: {
118
- show: false
119
- },
120
- data: [
121
- {
122
- value: data.value
123
- }
124
- ]
125
- },
126
- {
127
- type: 'gauge',
128
- center: [
129
- '50%',
130
- '65%'
131
- ],
132
- radius: '100%',
133
- startAngle: 200,
134
- endAngle: -20,
135
- min: 0,
136
- max,
137
- pointer: {
138
- show: true,
139
- // pointer hidden for small panels, path taken from ex: https://echarts.apache.org/examples/en/editor.html?c=gauge-grade
140
- icon: width > GAUGE_SMALL_BREAKPOINT ? 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z' : 'none',
141
- length: 10,
142
- width: 5,
143
- offsetCenter: [
144
- 0,
145
- '-49%'
146
- ],
147
- itemStyle: {
148
- color: 'auto'
149
- }
150
- },
151
- axisLine,
152
- axisTick: {
153
- show: false
154
- },
155
- splitLine: {
156
- show: false
157
- },
158
- axisLabel: {
159
- show: false
160
- },
161
- detail: {
162
- show: true,
163
- width: '60%',
164
- borderRadius: 8,
165
- offsetCenter: [
166
- 0,
167
- '-9%'
168
- ],
169
- color: 'inherit',
170
- fontSize: valueSizeClamp,
171
- formatter: data.value === null ? // at this level because the `formatter` function argument is `NaN`
172
- // when the value is `null`, making it difficult to differentiate
173
- // `null` from a true `NaN` case.
174
- ()=>'null' : (value)=>{
175
- return (0, _core.formatValue)(value, format);
176
- }
177
- },
178
- data: [
179
- {
180
- value: data.value,
181
- name: data.label,
182
- // TODO: new UX for series names, create separate React component or reuse ListLegendItem
183
- // https://echarts.apache.org/en/option.html#series-gauge.data.title
184
- title: {
185
- show: true,
186
- color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit',
187
- offsetCenter: [
188
- 0,
189
- '55%'
190
- ],
191
- overflow: 'truncate',
192
- fontSize: 12,
193
- width: width * 0.8
194
- }
195
- }
196
- ]
197
- }
198
- ]
199
- };
200
- }, [
201
- data,
202
- width,
203
- height,
204
- chartsTheme,
205
- format,
206
- axisLine,
207
- max
208
- ]);
209
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_EChart.EChart, {
210
- sx: {
211
- width: width,
212
- height: height,
213
- padding: `${chartsTheme.container.padding.default}px`
214
- },
215
- option: option,
216
- theme: chartsTheme.echartsTheme
217
- });
218
- }
219
- function getResponsiveValueSize(value, format, width, height) {
220
- const MIN_SIZE = 3;
221
- const MAX_SIZE = 24;
222
- const SIZE_MULTIPLIER = 0.7;
223
- const formattedValue = typeof value === 'number' ? (0, _core.formatValue)(value, format) : `${value}`;
224
- const valueCharacters = formattedValue.length ?? 2;
225
- const valueSize = Math.min(width, height) / valueCharacters * SIZE_MULTIPLIER;
226
- return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;
227
- }
@@ -1,30 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- _export_star(require("./GaugeChart"), exports);
18
- function _export_star(from, to) {
19
- Object.keys(from).forEach(function(k) {
20
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
- Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
27
- }
28
- });
29
- return from;
30
- }