@perses-dev/components 0.54.0-beta.0 → 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.
- package/dist/ContentWithLegend/ContentWithLegend.js +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.d.ts.map +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js +1 -1
- package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
- package/dist/FormEditor/FormActions.d.ts +1 -1
- package/dist/FormEditor/FormActions.d.ts.map +1 -1
- package/dist/FormEditor/FormActions.js.map +1 -1
- package/dist/FormatControls/FormatControls.d.ts +1 -1
- package/dist/FormatControls/FormatControls.d.ts.map +1 -1
- package/dist/FormatControls/FormatControls.js +1 -1
- package/dist/FormatControls/FormatControls.js.map +1 -1
- package/dist/FormatControls/UnitSelector.d.ts +1 -1
- package/dist/FormatControls/UnitSelector.d.ts.map +1 -1
- package/dist/FormatControls/UnitSelector.js +1 -1
- package/dist/FormatControls/UnitSelector.js.map +1 -1
- package/dist/Legend/Legend.js +1 -1
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/legend-model.d.ts +1 -1
- package/dist/Legend/legend-model.d.ts.map +1 -1
- package/dist/Legend/legend-model.js.map +1 -1
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +26 -6
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableToolbar.d.ts +34 -0
- package/dist/Table/TableToolbar.d.ts.map +1 -0
- package/dist/Table/TableToolbar.js +127 -0
- package/dist/Table/TableToolbar.js.map +1 -0
- package/dist/Table/VirtualizedTable.d.ts +3 -1
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +128 -117
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -1
- package/dist/Table/VirtualizedTableContainer.js +5 -1
- package/dist/Table/VirtualizedTableContainer.js.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.d.ts +12 -0
- package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -0
- package/dist/Table/hooks/useFuzzySearch.js +43 -0
- package/dist/Table/hooks/useFuzzySearch.js.map +1 -0
- package/dist/Table/model/table-model.d.ts +37 -3
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.d.ts +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.d.ts.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.d.ts.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +1 -2
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +2 -2
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +1 -2
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.d.ts +1 -1
- package/dist/TransformsEditor/TransformEditor.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.d.ts +1 -1
- package/dist/TransformsEditor/TransformsEditor.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/cjs/ContentWithLegend/ContentWithLegend.js +2 -2
- package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +2 -2
- package/dist/cjs/FormatControls/FormatControls.js +4 -4
- package/dist/cjs/FormatControls/UnitSelector.js +3 -3
- package/dist/cjs/Legend/Legend.js +2 -2
- package/dist/cjs/Table/Table.js +24 -4
- package/dist/cjs/Table/TableToolbar.js +140 -0
- package/dist/cjs/Table/VirtualizedTable.js +126 -115
- package/dist/cjs/Table/VirtualizedTableContainer.js +5 -1
- package/dist/cjs/Table/hooks/useFuzzySearch.js +48 -0
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +2 -3
- package/dist/cjs/TransformsEditor/TransformEditorContainer.js +2 -2
- package/dist/cjs/model/action.js +43 -0
- package/dist/cjs/model/bits.js +113 -0
- package/dist/cjs/model/bytes.js +115 -0
- package/dist/cjs/model/constants.js +23 -0
- package/dist/cjs/model/currency.js +126 -0
- package/dist/cjs/model/date.js +297 -0
- package/dist/cjs/model/decimal.js +72 -0
- package/dist/cjs/model/formatterCache.js +120 -0
- package/dist/cjs/model/index.js +16 -0
- package/dist/cjs/model/legend.js +101 -0
- package/dist/cjs/model/percent.js +82 -0
- package/dist/cjs/model/temperature.js +72 -0
- package/dist/cjs/model/thresholds.js +16 -0
- package/dist/cjs/model/throughput.js +161 -0
- package/dist/cjs/model/time.js +178 -0
- package/dist/cjs/model/transforms.js +29 -0
- package/dist/cjs/model/types.js +16 -0
- package/dist/cjs/model/units.js +186 -0
- package/dist/cjs/model/utils.js +48 -0
- package/dist/cjs/utils/axis.js +5 -5
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/request-interpolation.js +49 -0
- package/dist/model/action.d.ts +4 -0
- package/dist/model/action.d.ts.map +1 -0
- package/dist/model/action.js +27 -0
- package/dist/model/action.js.map +1 -0
- package/dist/model/bits.d.ts +12 -0
- package/dist/model/bits.d.ts.map +1 -0
- package/dist/model/bits.js +89 -0
- package/dist/model/bits.js.map +1 -0
- package/dist/model/bytes.d.ts +12 -0
- package/dist/model/bytes.d.ts.map +1 -0
- package/dist/model/bytes.js +91 -0
- package/dist/model/bytes.js.map +1 -0
- package/dist/model/constants.d.ts +2 -0
- package/dist/model/constants.d.ts.map +1 -0
- package/dist/model/constants.js +15 -0
- package/dist/model/constants.js.map +1 -0
- package/dist/model/currency.d.ts +11 -0
- package/dist/model/currency.d.ts.map +1 -0
- package/dist/model/currency.js +107 -0
- package/dist/model/currency.js.map +1 -0
- package/dist/model/date.d.ts +28 -0
- package/dist/model/date.d.ts.map +1 -0
- package/dist/model/date.js +278 -0
- package/dist/model/date.js.map +1 -0
- package/dist/model/decimal.d.ts +12 -0
- package/dist/model/decimal.d.ts.map +1 -0
- package/dist/model/decimal.js +53 -0
- package/dist/model/decimal.js.map +1 -0
- package/dist/model/formatterCache.d.ts +11 -0
- package/dist/model/formatterCache.d.ts.map +1 -0
- package/dist/model/formatterCache.js +104 -0
- package/dist/model/formatterCache.js.map +1 -0
- package/dist/model/index.d.ts +16 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +16 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/legend.d.ts +19 -0
- package/dist/model/legend.d.ts.map +1 -0
- package/dist/model/legend.js +61 -0
- package/dist/model/legend.js.map +1 -0
- package/dist/model/percent.d.ts +11 -0
- package/dist/model/percent.d.ts.map +1 -0
- package/dist/model/percent.js +63 -0
- package/dist/model/percent.js.map +1 -0
- package/dist/model/temperature.d.ts +11 -0
- package/dist/model/temperature.d.ts.map +1 -0
- package/dist/model/temperature.js +53 -0
- package/dist/model/temperature.js.map +1 -0
- package/dist/model/theme.d.ts +1 -1
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/model/thresholds.d.ts +16 -0
- package/dist/model/thresholds.d.ts.map +1 -0
- package/dist/model/thresholds.js +15 -0
- package/dist/model/thresholds.js.map +1 -0
- package/dist/model/throughput.d.ts +12 -0
- package/dist/model/throughput.d.ts.map +1 -0
- package/dist/model/throughput.js +142 -0
- package/dist/model/throughput.js.map +1 -0
- package/dist/model/time.d.ts +23 -0
- package/dist/model/time.d.ts.map +1 -0
- package/dist/model/time.js +158 -0
- package/dist/model/time.js.map +1 -0
- package/dist/model/transforms.d.ts +43 -0
- package/dist/model/transforms.d.ts.map +1 -0
- package/dist/model/transforms.js +22 -0
- package/dist/model/transforms.js.map +1 -0
- package/dist/model/types.d.ts +56 -0
- package/dist/model/types.d.ts.map +1 -0
- package/dist/model/types.js +15 -0
- package/dist/model/types.js.map +1 -0
- package/dist/model/units.d.ts +105 -0
- package/dist/model/units.d.ts.map +1 -0
- package/dist/model/units.js +132 -0
- package/dist/model/units.js.map +1 -0
- package/dist/model/utils.d.ts +4 -0
- package/dist/model/utils.d.ts.map +1 -0
- package/dist/model/utils.js +32 -0
- package/dist/model/utils.js.map +1 -0
- package/dist/utils/axis.d.ts +1 -1
- package/dist/utils/axis.d.ts.map +1 -1
- package/dist/utils/axis.js +1 -1
- package/dist/utils/axis.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/request-interpolation.d.ts +6 -0
- package/dist/utils/request-interpolation.d.ts.map +1 -0
- package/dist/utils/request-interpolation.js +33 -0
- package/dist/utils/request-interpolation.js.map +1 -0
- package/package.json +2 -1
|
@@ -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 DECIMAL_GROUP_CONFIG () {
|
|
25
|
+
return DECIMAL_GROUP_CONFIG;
|
|
26
|
+
},
|
|
27
|
+
get DECIMAL_UNIT_CONFIG () {
|
|
28
|
+
return DECIMAL_UNIT_CONFIG;
|
|
29
|
+
},
|
|
30
|
+
get formatDecimal () {
|
|
31
|
+
return formatDecimal;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const _constants = require("./constants");
|
|
35
|
+
const _formatterCache = require("./formatterCache");
|
|
36
|
+
const _utils = require("./utils");
|
|
37
|
+
const DECIMAL_GROUP_CONFIG = {
|
|
38
|
+
label: 'Decimal',
|
|
39
|
+
decimalPlaces: true,
|
|
40
|
+
shortValues: true
|
|
41
|
+
};
|
|
42
|
+
const DECIMAL_UNIT_CONFIG = {
|
|
43
|
+
decimal: {
|
|
44
|
+
group: 'Decimal',
|
|
45
|
+
label: 'Decimal'
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function formatDecimal(value, { shortValues, decimalPlaces }) {
|
|
49
|
+
const formatterOptions = {
|
|
50
|
+
style: 'decimal',
|
|
51
|
+
useGrouping: true
|
|
52
|
+
};
|
|
53
|
+
if ((0, _utils.shouldShortenValues)(shortValues)) {
|
|
54
|
+
formatterOptions.notation = 'compact';
|
|
55
|
+
}
|
|
56
|
+
if ((0, _utils.hasDecimalPlaces)(decimalPlaces)) {
|
|
57
|
+
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
|
|
58
|
+
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
|
|
59
|
+
} else {
|
|
60
|
+
if ((0, _utils.shouldShortenValues)(shortValues)) {
|
|
61
|
+
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const key = [
|
|
65
|
+
formatterOptions.style,
|
|
66
|
+
formatterOptions.useGrouping,
|
|
67
|
+
formatterOptions.notation,
|
|
68
|
+
formatterOptions.maximumSignificantDigits,
|
|
69
|
+
decimalPlaces
|
|
70
|
+
];
|
|
71
|
+
return (0, _formatterCache.getFormatterFromCache)(key, 'decimal', formatterOptions, 'en-US')(value);
|
|
72
|
+
}
|
|
@@ -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
|
+
};
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -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
|
+
}
|