@perses-dev/components 0.53.1 → 0.54.0-beta.1

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 (232) hide show
  1. package/dist/ContentWithLegend/ContentWithLegend.js +1 -1
  2. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  3. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +1 -1
  4. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
  5. package/dist/ContentWithLegend/model/content-with-legend-model.js +1 -1
  6. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
  7. package/dist/FormEditor/FormActions.d.ts +1 -1
  8. package/dist/FormEditor/FormActions.d.ts.map +1 -1
  9. package/dist/FormEditor/FormActions.js.map +1 -1
  10. package/dist/FormatControls/FormatControls.d.ts +1 -1
  11. package/dist/FormatControls/FormatControls.d.ts.map +1 -1
  12. package/dist/FormatControls/FormatControls.js +1 -1
  13. package/dist/FormatControls/FormatControls.js.map +1 -1
  14. package/dist/FormatControls/UnitSelector.d.ts +1 -1
  15. package/dist/FormatControls/UnitSelector.d.ts.map +1 -1
  16. package/dist/FormatControls/UnitSelector.js +1 -1
  17. package/dist/FormatControls/UnitSelector.js.map +1 -1
  18. package/dist/Legend/Legend.js +1 -1
  19. package/dist/Legend/Legend.js.map +1 -1
  20. package/dist/Legend/legend-model.d.ts +1 -1
  21. package/dist/Legend/legend-model.d.ts.map +1 -1
  22. package/dist/Legend/legend-model.js.map +1 -1
  23. package/dist/LinksEditor/LinksEditor.d.ts +1 -1
  24. package/dist/LinksEditor/LinksEditor.js.map +1 -1
  25. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.d.ts +1 -1
  26. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  27. package/dist/Table/Table.d.ts +1 -1
  28. package/dist/Table/Table.d.ts.map +1 -1
  29. package/dist/Table/Table.js +26 -6
  30. package/dist/Table/Table.js.map +1 -1
  31. package/dist/Table/TableToolbar.d.ts +34 -0
  32. package/dist/Table/TableToolbar.d.ts.map +1 -0
  33. package/dist/Table/TableToolbar.js +127 -0
  34. package/dist/Table/TableToolbar.js.map +1 -0
  35. package/dist/Table/VirtualizedTable.d.ts +3 -1
  36. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  37. package/dist/Table/VirtualizedTable.js +128 -117
  38. package/dist/Table/VirtualizedTable.js.map +1 -1
  39. package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -1
  40. package/dist/Table/VirtualizedTableContainer.js +5 -1
  41. package/dist/Table/VirtualizedTableContainer.js.map +1 -1
  42. package/dist/Table/hooks/useFuzzySearch.d.ts +12 -0
  43. package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -0
  44. package/dist/Table/hooks/useFuzzySearch.js +43 -0
  45. package/dist/Table/hooks/useFuzzySearch.js.map +1 -0
  46. package/dist/Table/model/table-model.d.ts +38 -4
  47. package/dist/Table/model/table-model.d.ts.map +1 -1
  48. package/dist/Table/model/table-model.js.map +1 -1
  49. package/dist/ThresholdsEditor/ThresholdInput.d.ts +1 -1
  50. package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -1
  51. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  52. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts +1 -1
  53. package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
  54. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  55. package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts +2 -3
  56. package/dist/TimeRangeSelector/DateTimeRangePicker.d.ts.map +1 -1
  57. package/dist/TimeRangeSelector/DateTimeRangePicker.js +2 -0
  58. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  59. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +1 -1
  60. package/dist/TimeRangeSelector/TimeRangeSelector.js +1 -1
  61. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  62. package/dist/TimeRangeSelector/utils.d.ts +1 -1
  63. package/dist/TimeRangeSelector/utils.js +1 -1
  64. package/dist/TimeRangeSelector/utils.js.map +1 -1
  65. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +2 -2
  66. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  67. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  68. package/dist/TimeSeriesTooltip/nearby-series.d.ts +2 -2
  69. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  70. package/dist/TimeSeriesTooltip/nearby-series.js +1 -2
  71. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  72. package/dist/TransformsEditor/TransformEditor.d.ts +1 -1
  73. package/dist/TransformsEditor/TransformEditor.d.ts.map +1 -1
  74. package/dist/TransformsEditor/TransformEditor.js.map +1 -1
  75. package/dist/TransformsEditor/TransformEditorContainer.d.ts.map +1 -1
  76. package/dist/TransformsEditor/TransformEditorContainer.js +1 -1
  77. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  78. package/dist/TransformsEditor/TransformsEditor.d.ts +1 -1
  79. package/dist/TransformsEditor/TransformsEditor.d.ts.map +1 -1
  80. package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
  81. package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
  82. package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -1
  83. package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
  84. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +2 -2
  85. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +2 -2
  86. package/dist/cjs/FormatControls/FormatControls.js +4 -4
  87. package/dist/cjs/FormatControls/UnitSelector.js +3 -3
  88. package/dist/cjs/Legend/Legend.js +2 -2
  89. package/dist/cjs/Table/Table.js +24 -4
  90. package/dist/cjs/Table/TableToolbar.js +140 -0
  91. package/dist/cjs/Table/VirtualizedTable.js +126 -115
  92. package/dist/cjs/Table/VirtualizedTableContainer.js +5 -1
  93. package/dist/cjs/Table/hooks/useFuzzySearch.js +48 -0
  94. package/dist/cjs/TimeRangeSelector/DateTimeRangePicker.js +2 -0
  95. package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +3 -3
  96. package/dist/cjs/TimeRangeSelector/utils.js +2 -2
  97. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +2 -3
  98. package/dist/cjs/TransformsEditor/TransformEditorContainer.js +2 -2
  99. package/dist/cjs/model/action.js +43 -0
  100. package/dist/cjs/model/bits.js +113 -0
  101. package/dist/cjs/model/bytes.js +115 -0
  102. package/dist/cjs/model/constants.js +23 -0
  103. package/dist/cjs/model/currency.js +126 -0
  104. package/dist/cjs/model/date.js +297 -0
  105. package/dist/cjs/model/decimal.js +72 -0
  106. package/dist/cjs/model/formatterCache.js +120 -0
  107. package/dist/cjs/model/index.js +16 -0
  108. package/dist/cjs/model/legend.js +101 -0
  109. package/dist/cjs/model/percent.js +82 -0
  110. package/dist/cjs/model/temperature.js +72 -0
  111. package/dist/cjs/model/thresholds.js +16 -0
  112. package/dist/cjs/model/throughput.js +161 -0
  113. package/dist/cjs/model/time.js +178 -0
  114. package/dist/cjs/model/timeOption.js +2 -2
  115. package/dist/cjs/model/transforms.js +29 -0
  116. package/dist/cjs/model/types.js +16 -0
  117. package/dist/cjs/model/units.js +186 -0
  118. package/dist/cjs/model/utils.js +48 -0
  119. package/dist/cjs/theme/theme.js +44 -29
  120. package/dist/cjs/theme/typography.js +8 -7
  121. package/dist/cjs/utils/axis.js +5 -5
  122. package/dist/cjs/utils/index.js +1 -0
  123. package/dist/cjs/utils/request-interpolation.js +49 -0
  124. package/dist/model/action.d.ts +4 -0
  125. package/dist/model/action.d.ts.map +1 -0
  126. package/dist/model/action.js +27 -0
  127. package/dist/model/action.js.map +1 -0
  128. package/dist/model/bits.d.ts +12 -0
  129. package/dist/model/bits.d.ts.map +1 -0
  130. package/dist/model/bits.js +89 -0
  131. package/dist/model/bits.js.map +1 -0
  132. package/dist/model/bytes.d.ts +12 -0
  133. package/dist/model/bytes.d.ts.map +1 -0
  134. package/dist/model/bytes.js +91 -0
  135. package/dist/model/bytes.js.map +1 -0
  136. package/dist/model/constants.d.ts +2 -0
  137. package/dist/model/constants.d.ts.map +1 -0
  138. package/dist/model/constants.js +15 -0
  139. package/dist/model/constants.js.map +1 -0
  140. package/dist/model/currency.d.ts +11 -0
  141. package/dist/model/currency.d.ts.map +1 -0
  142. package/dist/model/currency.js +107 -0
  143. package/dist/model/currency.js.map +1 -0
  144. package/dist/model/date.d.ts +28 -0
  145. package/dist/model/date.d.ts.map +1 -0
  146. package/dist/model/date.js +278 -0
  147. package/dist/model/date.js.map +1 -0
  148. package/dist/model/decimal.d.ts +12 -0
  149. package/dist/model/decimal.d.ts.map +1 -0
  150. package/dist/model/decimal.js +53 -0
  151. package/dist/model/decimal.js.map +1 -0
  152. package/dist/model/formatterCache.d.ts +11 -0
  153. package/dist/model/formatterCache.d.ts.map +1 -0
  154. package/dist/model/formatterCache.js +104 -0
  155. package/dist/model/formatterCache.js.map +1 -0
  156. package/dist/model/graph.d.ts +1 -1
  157. package/dist/model/graph.js.map +1 -1
  158. package/dist/model/index.d.ts +16 -0
  159. package/dist/model/index.d.ts.map +1 -1
  160. package/dist/model/index.js +16 -0
  161. package/dist/model/index.js.map +1 -1
  162. package/dist/model/legend.d.ts +19 -0
  163. package/dist/model/legend.d.ts.map +1 -0
  164. package/dist/model/legend.js +61 -0
  165. package/dist/model/legend.js.map +1 -0
  166. package/dist/model/percent.d.ts +11 -0
  167. package/dist/model/percent.d.ts.map +1 -0
  168. package/dist/model/percent.js +63 -0
  169. package/dist/model/percent.js.map +1 -0
  170. package/dist/model/temperature.d.ts +11 -0
  171. package/dist/model/temperature.d.ts.map +1 -0
  172. package/dist/model/temperature.js +53 -0
  173. package/dist/model/temperature.js.map +1 -0
  174. package/dist/model/theme.d.ts +1 -1
  175. package/dist/model/theme.d.ts.map +1 -1
  176. package/dist/model/theme.js.map +1 -1
  177. package/dist/model/thresholds.d.ts +16 -0
  178. package/dist/model/thresholds.d.ts.map +1 -0
  179. package/dist/model/thresholds.js +15 -0
  180. package/dist/model/thresholds.js.map +1 -0
  181. package/dist/model/throughput.d.ts +12 -0
  182. package/dist/model/throughput.d.ts.map +1 -0
  183. package/dist/model/throughput.js +142 -0
  184. package/dist/model/throughput.js.map +1 -0
  185. package/dist/model/time.d.ts +23 -0
  186. package/dist/model/time.d.ts.map +1 -0
  187. package/dist/model/time.js +158 -0
  188. package/dist/model/time.js.map +1 -0
  189. package/dist/model/timeOption.d.ts +1 -1
  190. package/dist/model/timeOption.js +1 -1
  191. package/dist/model/timeOption.js.map +1 -1
  192. package/dist/model/transforms.d.ts +43 -0
  193. package/dist/model/transforms.d.ts.map +1 -0
  194. package/dist/model/transforms.js +22 -0
  195. package/dist/model/transforms.js.map +1 -0
  196. package/dist/model/types.d.ts +56 -0
  197. package/dist/model/types.d.ts.map +1 -0
  198. package/dist/model/types.js +15 -0
  199. package/dist/model/types.js.map +1 -0
  200. package/dist/model/units.d.ts +105 -0
  201. package/dist/model/units.d.ts.map +1 -0
  202. package/dist/model/units.js +132 -0
  203. package/dist/model/units.js.map +1 -0
  204. package/dist/model/utils.d.ts +4 -0
  205. package/dist/model/utils.d.ts.map +1 -0
  206. package/dist/model/utils.js +32 -0
  207. package/dist/model/utils.js.map +1 -0
  208. package/dist/theme/theme.d.ts +3 -1
  209. package/dist/theme/theme.d.ts.map +1 -1
  210. package/dist/theme/theme.js +46 -29
  211. package/dist/theme/theme.js.map +1 -1
  212. package/dist/theme/typography.d.ts +6 -4
  213. package/dist/theme/typography.d.ts.map +1 -1
  214. package/dist/theme/typography.js +8 -7
  215. package/dist/theme/typography.js.map +1 -1
  216. package/dist/utils/axis.d.ts +1 -1
  217. package/dist/utils/axis.d.ts.map +1 -1
  218. package/dist/utils/axis.js +1 -1
  219. package/dist/utils/axis.js.map +1 -1
  220. package/dist/utils/chart-actions.d.ts +1 -1
  221. package/dist/utils/chart-actions.js.map +1 -1
  222. package/dist/utils/index.d.ts +1 -0
  223. package/dist/utils/index.d.ts.map +1 -1
  224. package/dist/utils/index.js +1 -0
  225. package/dist/utils/index.js.map +1 -1
  226. package/dist/utils/request-interpolation.d.ts +6 -0
  227. package/dist/utils/request-interpolation.d.ts.map +1 -0
  228. package/dist/utils/request-interpolation.js +33 -0
  229. package/dist/utils/request-interpolation.js.map +1 -0
  230. package/dist/utils/variable-interpolation.d.ts +1 -1
  231. package/dist/utils/variable-interpolation.js.map +1 -1
  232. package/package.json +6 -2
@@ -0,0 +1,120 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get getFormatterFromCache () {
25
+ return getFormatterFromCache;
26
+ },
27
+ get getFormatterStats () {
28
+ return getFormatterStats;
29
+ }
30
+ });
31
+ /**
32
+ * REASONING FOR CLUSTERING (Map-of-Maps):
33
+ *
34
+ * 1. PERSISTENCE & REUSE: Intl.NumberFormat instantiation is CPU-heavy due to
35
+ * locale/data lookups. Clustering allows 100x faster reuse via caching.
36
+ *
37
+ *
38
+ * 2. LOOKUP PERFORMANCE: Smaller, specialized Maps reduce the risk of hash
39
+ * collisions, ensuring O(1) retrieval time remains consistent even as
40
+ * the total number of formatters across the app grows.
41
+ *
42
+ * 3. GARBAGE COLLECTION & STATS: Categorization allows for targeted memory
43
+ * monitoring and easier debugging of which specific data types are
44
+ * consuming the most resources.
45
+ */ const TIME_FORMATTER_CACHE = new Map();
46
+ const DECIMAL_FORMATTER_CACHE = new Map();
47
+ const BITS_FORMATTER_CACHE = new Map();
48
+ const BYTES_FORMATTER_CACHE = new Map();
49
+ const CURRENCY_FORMATTER_CACHE = new Map();
50
+ const PERCENT_FORMATTER_CACHE = new Map();
51
+ const TEMPERATURE_FORMATTER_CACHE = new Map();
52
+ const THROUGHPUT_FORMATTER_CACHE = new Map();
53
+ const ALL_FORMATTERS = new Map([
54
+ [
55
+ 'time',
56
+ TIME_FORMATTER_CACHE
57
+ ],
58
+ [
59
+ 'decimal',
60
+ DECIMAL_FORMATTER_CACHE
61
+ ],
62
+ [
63
+ 'bits',
64
+ BITS_FORMATTER_CACHE
65
+ ],
66
+ [
67
+ 'bytes',
68
+ BYTES_FORMATTER_CACHE
69
+ ],
70
+ [
71
+ 'currency',
72
+ CURRENCY_FORMATTER_CACHE
73
+ ],
74
+ [
75
+ 'percent',
76
+ PERCENT_FORMATTER_CACHE
77
+ ],
78
+ [
79
+ 'temperature',
80
+ TEMPERATURE_FORMATTER_CACHE
81
+ ],
82
+ [
83
+ 'throughput',
84
+ THROUGHPUT_FORMATTER_CACHE
85
+ ]
86
+ ]);
87
+ function getFormatterFromCache(key, inputType, formatterOptions, locals = 'en-US') {
88
+ const compoundKey = `${key.filter((k)=>![
89
+ undefined,
90
+ null,
91
+ '',
92
+ NaN
93
+ ].includes(k)).join('|')}|${locals}`;
94
+ const inputTypeFormatters = ALL_FORMATTERS.get(inputType);
95
+ if (!inputTypeFormatters) throw new Error('No formatter found for the input type');
96
+ const formatter = inputTypeFormatters.get(compoundKey);
97
+ if (formatter) {
98
+ return formatter.format;
99
+ }
100
+ const newFormatter = Intl.NumberFormat(locals, formatterOptions);
101
+ inputTypeFormatters?.set(`${compoundKey}`, newFormatter);
102
+ return newFormatter.format;
103
+ }
104
+ const getFormatterStats = ()=>{
105
+ const countCacheItems = (inputType)=>{
106
+ if (inputType !== 'all') {
107
+ return ALL_FORMATTERS.get(inputType)?.size ?? 0;
108
+ }
109
+ return Array.from(ALL_FORMATTERS.values()).reduce((acc, map)=>acc + (map?.size ?? 0), 0);
110
+ };
111
+ const getKeys = (inputType)=>{
112
+ return [
113
+ ...ALL_FORMATTERS.get(inputType)?.keys() || []
114
+ ];
115
+ };
116
+ return {
117
+ countCacheItems,
118
+ getKeys
119
+ };
120
+ };
@@ -18,6 +18,22 @@ _export_star(require("./graph"), exports);
18
18
  _export_star(require("./theme"), exports);
19
19
  _export_star(require("./timeOption"), exports);
20
20
  _export_star(require("./timeZoneOption"), exports);
21
+ _export_star(require("./action"), exports);
22
+ _export_star(require("./legend"), exports);
23
+ _export_star(require("./time"), exports);
24
+ _export_star(require("./bits"), exports);
25
+ _export_star(require("./bytes"), exports);
26
+ _export_star(require("./currency"), exports);
27
+ _export_star(require("./percent"), exports);
28
+ _export_star(require("./temperature"), exports);
29
+ _export_star(require("./decimal"), exports);
30
+ _export_star(require("./throughput"), exports);
31
+ _export_star(require("./formatterCache"), exports);
32
+ _export_star(require("./units"), exports);
33
+ _export_star(require("./utils"), exports);
34
+ _export_star(require("./types"), exports);
35
+ _export_star(require("./thresholds"), exports);
36
+ _export_star(require("./transforms"), exports);
21
37
  function _export_star(from, to) {
22
38
  Object.keys(from).forEach(function(k) {
23
39
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -0,0 +1,101 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get DEFAULT_LEGEND () {
25
+ return DEFAULT_LEGEND;
26
+ },
27
+ get getLegendMode () {
28
+ return getLegendMode;
29
+ },
30
+ get getLegendPosition () {
31
+ return getLegendPosition;
32
+ },
33
+ get getLegendSize () {
34
+ return getLegendSize;
35
+ },
36
+ get isValidLegendMode () {
37
+ return isValidLegendMode;
38
+ },
39
+ get isValidLegendPosition () {
40
+ return isValidLegendPosition;
41
+ },
42
+ get isValidLegendSize () {
43
+ return isValidLegendSize;
44
+ },
45
+ get legendModes () {
46
+ return legendModes;
47
+ },
48
+ get legendPositions () {
49
+ return legendPositions;
50
+ },
51
+ get legendSizes () {
52
+ return legendSizes;
53
+ }
54
+ });
55
+ const legendPositions = [
56
+ 'bottom',
57
+ 'right'
58
+ ];
59
+ const legendModes = [
60
+ 'list',
61
+ 'table'
62
+ ];
63
+ const legendSizes = [
64
+ 'small',
65
+ 'medium'
66
+ ];
67
+ function isValidLegendPosition(position) {
68
+ return legendPositions.includes(position);
69
+ }
70
+ function isValidLegendMode(mode) {
71
+ return legendModes.includes(mode);
72
+ }
73
+ function isValidLegendSize(size) {
74
+ return legendSizes.includes(size);
75
+ }
76
+ const DEFAULT_LEGEND = {
77
+ position: 'bottom',
78
+ mode: 'list',
79
+ size: 'medium'
80
+ };
81
+ function getLegendPosition(position) {
82
+ if (position === undefined) {
83
+ return DEFAULT_LEGEND.position;
84
+ }
85
+ if (isValidLegendPosition(position)) {
86
+ return position;
87
+ }
88
+ return DEFAULT_LEGEND.position;
89
+ }
90
+ function getLegendMode(mode) {
91
+ if (!mode || !isValidLegendMode(mode)) {
92
+ return DEFAULT_LEGEND.mode;
93
+ }
94
+ return mode;
95
+ }
96
+ function getLegendSize(size) {
97
+ if (!size || !isValidLegendSize(size)) {
98
+ return DEFAULT_LEGEND.size;
99
+ }
100
+ return size;
101
+ }
@@ -0,0 +1,82 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get PERCENT_GROUP_CONFIG () {
25
+ return PERCENT_GROUP_CONFIG;
26
+ },
27
+ get PERCENT_UNIT_CONFIG () {
28
+ return PERCENT_UNIT_CONFIG;
29
+ },
30
+ get formatPercent () {
31
+ return formatPercent;
32
+ }
33
+ });
34
+ const _constants = require("./constants");
35
+ const _formatterCache = require("./formatterCache");
36
+ const _utils = require("./utils");
37
+ const PERCENT_GROUP_CONFIG = {
38
+ label: 'percent',
39
+ decimalPlaces: true
40
+ };
41
+ const PERCENT_GROUP = 'Percent';
42
+ const PERCENT_UNIT_CONFIG = {
43
+ percent: {
44
+ group: PERCENT_GROUP,
45
+ label: 'Percent (0-100)'
46
+ },
47
+ 'percent-decimal': {
48
+ group: PERCENT_GROUP,
49
+ label: 'Percent (0.0-1.0)'
50
+ },
51
+ '%': {
52
+ // This option is not shown in the selector because it is a shorthand
53
+ // duplicate of `Percent`.
54
+ disableSelectorOption: true,
55
+ group: PERCENT_GROUP,
56
+ label: '%'
57
+ }
58
+ };
59
+ function formatPercent(value, { unit, decimalPlaces }) {
60
+ const formatterOptions = {
61
+ style: 'percent',
62
+ useGrouping: true
63
+ };
64
+ if ((0, _utils.hasDecimalPlaces)(decimalPlaces)) {
65
+ formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
66
+ formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
67
+ } else {
68
+ formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
69
+ }
70
+ // Intl.NumberFormat translates 0 -> 0%, 0.5 -> 50%, 1 -> 100%, etc.
71
+ if (unit === 'percent') {
72
+ value = value / 100;
73
+ }
74
+ const key = [
75
+ formatterOptions.style,
76
+ formatterOptions.useGrouping,
77
+ formatterOptions.maximumSignificantDigits,
78
+ decimalPlaces,
79
+ unit
80
+ ];
81
+ return (0, _formatterCache.getFormatterFromCache)(key, 'percent', formatterOptions, 'en-US')(value);
82
+ }
@@ -0,0 +1,72 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get TEMPERATURE_GROUP_CONFIG () {
25
+ return TEMPERATURE_GROUP_CONFIG;
26
+ },
27
+ get TEMPERATURE_UNIT_CONFIG () {
28
+ return TEMPERATURE_UNIT_CONFIG;
29
+ },
30
+ get formatTemperature () {
31
+ return formatTemperature;
32
+ }
33
+ });
34
+ const _constants = require("./constants");
35
+ const _formatterCache = require("./formatterCache");
36
+ const _utils = require("./utils");
37
+ const TEMPERATURE_GROUP = 'Temperature';
38
+ const TEMPERATURE_GROUP_CONFIG = {
39
+ label: TEMPERATURE_GROUP,
40
+ decimalPlaces: true
41
+ };
42
+ const TEMPERATURE_UNIT_CONFIG = {
43
+ celsius: {
44
+ group: TEMPERATURE_GROUP,
45
+ label: 'Celsius (°C)'
46
+ },
47
+ fahrenheit: {
48
+ group: TEMPERATURE_GROUP,
49
+ label: 'Fahrenheit (°F)'
50
+ }
51
+ };
52
+ const formatTemperature = (value, { unit, decimalPlaces })=>{
53
+ const formatterOptions = {
54
+ unit,
55
+ style: 'unit'
56
+ };
57
+ if ((0, _utils.hasDecimalPlaces)(decimalPlaces)) {
58
+ formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
59
+ formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
60
+ } else {
61
+ formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
62
+ }
63
+ const locals = unit === 'celsius' ? 'en-GB' : 'en-US';
64
+ const key = [
65
+ formatterOptions.style,
66
+ formatterOptions.unit,
67
+ formatterOptions.maximumSignificantDigits,
68
+ decimalPlaces,
69
+ locals
70
+ ];
71
+ return (0, _formatterCache.getFormatterFromCache)(key, 'temperature', formatterOptions, locals)(value);
72
+ };
@@ -0,0 +1,16 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
@@ -0,0 +1,161 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get THROUGHPUT_GROUP_CONFIG () {
25
+ return THROUGHPUT_GROUP_CONFIG;
26
+ },
27
+ get THROUGHPUT_UNIT_CONFIG () {
28
+ return THROUGHPUT_UNIT_CONFIG;
29
+ },
30
+ get formatThroughput () {
31
+ return formatThroughput;
32
+ }
33
+ });
34
+ const _bytes = require("./bytes");
35
+ const _bits = require("./bits");
36
+ const _constants = require("./constants");
37
+ const _utils = require("./utils");
38
+ const _formatterCache = require("./formatterCache");
39
+ const THROUGHPUT_GROUP_CONFIG = {
40
+ label: 'Throughput',
41
+ decimalPlaces: true
42
+ };
43
+ const THROUGHPUT_GROUP = 'Throughput';
44
+ const THROUGHPUT_UNIT_CONFIG = {
45
+ 'bits/sec': {
46
+ group: THROUGHPUT_GROUP,
47
+ label: 'Bits/sec (IEC)'
48
+ },
49
+ 'decbits/sec': {
50
+ group: THROUGHPUT_GROUP,
51
+ label: 'Bits/sec (SI)'
52
+ },
53
+ 'bytes/sec': {
54
+ group: THROUGHPUT_GROUP,
55
+ label: 'Bytes/sec (IEC)'
56
+ },
57
+ 'decbytes/sec': {
58
+ group: THROUGHPUT_GROUP,
59
+ label: 'Bytes/sec (SI)'
60
+ },
61
+ 'counts/sec': {
62
+ group: THROUGHPUT_GROUP,
63
+ label: 'Counts/sec'
64
+ },
65
+ 'events/sec': {
66
+ group: THROUGHPUT_GROUP,
67
+ label: 'Events/sec'
68
+ },
69
+ 'messages/sec': {
70
+ group: THROUGHPUT_GROUP,
71
+ label: 'Messages/sec'
72
+ },
73
+ 'ops/sec': {
74
+ group: THROUGHPUT_GROUP,
75
+ label: 'Ops/sec'
76
+ },
77
+ 'packets/sec': {
78
+ group: THROUGHPUT_GROUP,
79
+ label: 'Packets/sec'
80
+ },
81
+ 'reads/sec': {
82
+ group: THROUGHPUT_GROUP,
83
+ label: 'Reads/sec'
84
+ },
85
+ 'requests/sec': {
86
+ group: THROUGHPUT_GROUP,
87
+ label: 'Requests/sec'
88
+ },
89
+ 'records/sec': {
90
+ group: THROUGHPUT_GROUP,
91
+ label: 'Records/sec'
92
+ },
93
+ 'rows/sec': {
94
+ group: THROUGHPUT_GROUP,
95
+ label: 'Rows/sec'
96
+ },
97
+ 'writes/sec': {
98
+ group: THROUGHPUT_GROUP,
99
+ label: 'Writes/sec'
100
+ }
101
+ };
102
+ function formatThroughput(value, { unit, shortValues, decimalPlaces }) {
103
+ // special case for data throughput
104
+ if (unit === 'bits/sec') {
105
+ const denominator = Math.abs(value) < 1024 ? 'sec' : 's';
106
+ return (0, _bits.formatBits)(value, {
107
+ unit: 'bits',
108
+ shortValues,
109
+ decimalPlaces
110
+ }) + '/' + denominator;
111
+ }
112
+ if (unit === 'decbits/sec') {
113
+ const denominator = Math.abs(value) < 1000 ? 'sec' : 's';
114
+ return (0, _bits.formatBits)(value, {
115
+ unit: 'decbits',
116
+ shortValues,
117
+ decimalPlaces
118
+ }) + '/' + denominator;
119
+ }
120
+ if (unit === 'decbytes/sec') {
121
+ const denominator = Math.abs(value) < 1000 ? 'sec' : 's';
122
+ return (0, _bytes.formatBytes)(value, {
123
+ unit: 'decbytes',
124
+ shortValues,
125
+ decimalPlaces
126
+ }) + '/' + denominator;
127
+ }
128
+ if (unit === 'bytes/sec') {
129
+ const denominator = Math.abs(value) < 1024 ? 'sec' : 's';
130
+ return (0, _bytes.formatBytes)(value, {
131
+ unit: 'bytes',
132
+ shortValues,
133
+ decimalPlaces
134
+ }) + '/' + denominator;
135
+ }
136
+ const formatterOptions = {
137
+ style: 'decimal',
138
+ useGrouping: true
139
+ };
140
+ if ((0, _utils.shouldShortenValues)(shortValues)) {
141
+ formatterOptions.notation = 'compact';
142
+ }
143
+ if ((0, _utils.hasDecimalPlaces)(decimalPlaces)) {
144
+ formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
145
+ formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
146
+ } else {
147
+ if ((0, _utils.shouldShortenValues)(shortValues)) {
148
+ formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
149
+ }
150
+ }
151
+ const key = [
152
+ formatterOptions.style,
153
+ formatterOptions.useGrouping,
154
+ formatterOptions.notation,
155
+ formatterOptions.maximumSignificantDigits,
156
+ decimalPlaces,
157
+ shortValues,
158
+ unit
159
+ ];
160
+ return `${(0, _formatterCache.getFormatterFromCache)(key, 'throughput', formatterOptions, 'en-US')(value)} ${unit}`;
161
+ }