@perses-dev/components 0.54.0-beta.0 → 0.54.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AlignSelector/AlignSelector.js +1 -1
- package/dist/AlignSelector/AlignSelector.js.map +1 -1
- package/dist/ColorPicker/ColorPicker.js +1 -1
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- 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/Dialog/DiscardChangesConfirmationDialog.js +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/DragAndDrop/DragAndDropList.js +1 -1
- package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
- package/dist/DragAndDrop/DragButton.js +1 -1
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/DragAndDrop/DropIndicator.js +1 -1
- package/dist/DragAndDrop/DropIndicator.js.map +1 -1
- package/dist/Drawer/Drawer.js +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.js +1 -1
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/ErrorAlert.js +1 -1
- package/dist/ErrorAlert.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 +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 +2 -2
- 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/JSONEditor.js +1 -1
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Legend/CompactLegend.js +1 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.js +2 -2
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/LegendColorBadge.js +1 -1
- package/dist/Legend/LegendColorBadge.js.map +1 -1
- package/dist/Legend/ListLegend.js +1 -1
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.js +1 -1
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js +18 -4
- package/dist/Legend/TableLegend.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/LinksEditor/LinkEditorForm.js +1 -1
- package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
- package/dist/LinksEditor/LinksEditor.js +1 -1
- package/dist/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
- package/dist/Overlay/Overlay.js +1 -1
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/SortSelector/SortSelectorButtons.js +1 -1
- package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
- package/dist/Table/InnerTable.js +1 -1
- package/dist/Table/InnerTable.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 +47 -14
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.js +1 -1
- package/dist/Table/TableBody.js.map +1 -1
- package/dist/Table/TableCell.js +1 -1
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.js +1 -1
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableFoot.js +1 -1
- package/dist/Table/TableFoot.js.map +1 -1
- package/dist/Table/TableHead.js +1 -1
- package/dist/Table/TableHead.js.map +1 -1
- package/dist/Table/TableHeaderCell.d.ts +20 -1
- package/dist/Table/TableHeaderCell.d.ts.map +1 -1
- package/dist/Table/TableHeaderCell.js +56 -24
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/TableRow.js +1 -1
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/TableToolbar.d.ts +46 -0
- package/dist/Table/TableToolbar.d.ts.map +1 -0
- package/dist/Table/TableToolbar.js +138 -0
- package/dist/Table/TableToolbar.js.map +1 -0
- package/dist/Table/VirtualizedTable.d.ts +7 -3
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +157 -123
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -1
- package/dist/Table/VirtualizedTableContainer.js +6 -2
- package/dist/Table/VirtualizedTableContainer.js.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.d.ts +14 -0
- package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -0
- package/dist/Table/hooks/useFuzzySearch.js +62 -0
- package/dist/Table/hooks/useFuzzySearch.js.map +1 -0
- package/dist/Table/model/table-model.d.ts +78 -4
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +37 -19
- 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 +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 +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js +25 -2
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.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 +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.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/TimeZoneSelector.js +1 -1
- package/dist/TimeZoneSelector.js.map +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.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 +1 -1
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.d.ts.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +2 -2
- 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 +1 -1
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
- package/dist/YAxisLabel.js +1 -1
- package/dist/YAxisLabel.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/Legend/TableLegend.js +16 -2
- package/dist/cjs/Table/Table.js +44 -11
- package/dist/cjs/Table/TableHeaderCell.js +54 -22
- package/dist/cjs/Table/TableToolbar.js +151 -0
- package/dist/cjs/Table/VirtualizedTable.js +155 -121
- package/dist/cjs/Table/VirtualizedTableContainer.js +5 -1
- package/dist/cjs/Table/hooks/useFuzzySearch.js +67 -0
- package/dist/cjs/Table/model/table-model.js +43 -19
- package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +23 -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 +17 -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/model/value-mapping.js +16 -0
- package/dist/cjs/theme/typography.js +1 -1
- package/dist/cjs/utils/axis.js +5 -5
- package/dist/cjs/utils/format.js +20 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/request-interpolation.js +49 -0
- package/dist/context/ChartsProvider.js +1 -1
- package/dist/context/ChartsProvider.js.map +1 -1
- package/dist/context/ItemActionsProvider.js +1 -1
- package/dist/context/ItemActionsProvider.js.map +1 -1
- package/dist/context/SelectionProvider.js +1 -1
- package/dist/context/SelectionProvider.js.map +1 -1
- package/dist/context/SnackbarProvider.js +1 -1
- package/dist/context/SnackbarProvider.js.map +1 -1
- package/dist/context/TimeZoneProvider.js +1 -1
- package/dist/context/TimeZoneProvider.js.map +1 -1
- package/dist/controls/TextField.js +1 -1
- package/dist/controls/TextField.js.map +1 -1
- 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 +17 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +17 -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/model/value-mapping.d.ts +35 -0
- package/dist/model/value-mapping.d.ts.map +1 -0
- package/dist/model/value-mapping.js +15 -0
- package/dist/model/value-mapping.js.map +1 -0
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/theme/typography.js +1 -1
- package/dist/theme/typography.js.map +1 -1
- 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/format.d.ts +1 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +17 -0
- package/dist/utils/format.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 +4 -2
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
/**
|
|
14
|
+
* REASONING FOR CLUSTERING (Map-of-Maps):
|
|
15
|
+
*
|
|
16
|
+
* 1. PERSISTENCE & REUSE: Intl.NumberFormat instantiation is CPU-heavy due to
|
|
17
|
+
* locale/data lookups. Clustering allows 100x faster reuse via caching.
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
* 2. LOOKUP PERFORMANCE: Smaller, specialized Maps reduce the risk of hash
|
|
21
|
+
* collisions, ensuring O(1) retrieval time remains consistent even as
|
|
22
|
+
* the total number of formatters across the app grows.
|
|
23
|
+
*
|
|
24
|
+
* 3. GARBAGE COLLECTION & STATS: Categorization allows for targeted memory
|
|
25
|
+
* monitoring and easier debugging of which specific data types are
|
|
26
|
+
* consuming the most resources.
|
|
27
|
+
*/ const TIME_FORMATTER_CACHE = new Map();
|
|
28
|
+
const DECIMAL_FORMATTER_CACHE = new Map();
|
|
29
|
+
const BITS_FORMATTER_CACHE = new Map();
|
|
30
|
+
const BYTES_FORMATTER_CACHE = new Map();
|
|
31
|
+
const CURRENCY_FORMATTER_CACHE = new Map();
|
|
32
|
+
const PERCENT_FORMATTER_CACHE = new Map();
|
|
33
|
+
const TEMPERATURE_FORMATTER_CACHE = new Map();
|
|
34
|
+
const THROUGHPUT_FORMATTER_CACHE = new Map();
|
|
35
|
+
const ALL_FORMATTERS = new Map([
|
|
36
|
+
[
|
|
37
|
+
'time',
|
|
38
|
+
TIME_FORMATTER_CACHE
|
|
39
|
+
],
|
|
40
|
+
[
|
|
41
|
+
'decimal',
|
|
42
|
+
DECIMAL_FORMATTER_CACHE
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
'bits',
|
|
46
|
+
BITS_FORMATTER_CACHE
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
'bytes',
|
|
50
|
+
BYTES_FORMATTER_CACHE
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
'currency',
|
|
54
|
+
CURRENCY_FORMATTER_CACHE
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
'percent',
|
|
58
|
+
PERCENT_FORMATTER_CACHE
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
'temperature',
|
|
62
|
+
TEMPERATURE_FORMATTER_CACHE
|
|
63
|
+
],
|
|
64
|
+
[
|
|
65
|
+
'throughput',
|
|
66
|
+
THROUGHPUT_FORMATTER_CACHE
|
|
67
|
+
]
|
|
68
|
+
]);
|
|
69
|
+
export function getFormatterFromCache(key, inputType, formatterOptions, locals = 'en-US') {
|
|
70
|
+
const compoundKey = `${key.filter((k)=>![
|
|
71
|
+
undefined,
|
|
72
|
+
null,
|
|
73
|
+
'',
|
|
74
|
+
NaN
|
|
75
|
+
].includes(k)).join('|')}|${locals}`;
|
|
76
|
+
const inputTypeFormatters = ALL_FORMATTERS.get(inputType);
|
|
77
|
+
if (!inputTypeFormatters) throw new Error('No formatter found for the input type');
|
|
78
|
+
const formatter = inputTypeFormatters.get(compoundKey);
|
|
79
|
+
if (formatter) {
|
|
80
|
+
return formatter.format;
|
|
81
|
+
}
|
|
82
|
+
const newFormatter = Intl.NumberFormat(locals, formatterOptions);
|
|
83
|
+
inputTypeFormatters?.set(`${compoundKey}`, newFormatter);
|
|
84
|
+
return newFormatter.format;
|
|
85
|
+
}
|
|
86
|
+
export const getFormatterStats = ()=>{
|
|
87
|
+
const countCacheItems = (inputType)=>{
|
|
88
|
+
if (inputType !== 'all') {
|
|
89
|
+
return ALL_FORMATTERS.get(inputType)?.size ?? 0;
|
|
90
|
+
}
|
|
91
|
+
return Array.from(ALL_FORMATTERS.values()).reduce((acc, map)=>acc + (map?.size ?? 0), 0);
|
|
92
|
+
};
|
|
93
|
+
const getKeys = (inputType)=>{
|
|
94
|
+
return [
|
|
95
|
+
...ALL_FORMATTERS.get(inputType)?.keys() || []
|
|
96
|
+
];
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
countCacheItems,
|
|
100
|
+
getKeys
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=formatterCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/formatterCache.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\ntype FormatFn = (value: number | bigint) => string;\ntype InputType = 'time' | 'temperature' | 'bytes' | 'bits' | 'decimal' | 'currency' | 'percent' | 'throughput';\ntype Locals = 'en-US' | 'en-GB';\n\n/**\n * REASONING FOR CLUSTERING (Map-of-Maps):\n *\n * 1. PERSISTENCE & REUSE: Intl.NumberFormat instantiation is CPU-heavy due to\n * locale/data lookups. Clustering allows 100x faster reuse via caching.\n *\n *\n * 2. LOOKUP PERFORMANCE: Smaller, specialized Maps reduce the risk of hash\n * collisions, ensuring O(1) retrieval time remains consistent even as\n * the total number of formatters across the app grows.\n *\n * 3. GARBAGE COLLECTION & STATS: Categorization allows for targeted memory\n * monitoring and easier debugging of which specific data types are\n * consuming the most resources.\n */\nconst TIME_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst DECIMAL_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst BITS_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst BYTES_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst CURRENCY_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst PERCENT_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst TEMPERATURE_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst THROUGHPUT_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\n\nconst ALL_FORMATTERS: Map<InputType, Map<string, Intl.NumberFormat>> = new Map([\n ['time', TIME_FORMATTER_CACHE],\n ['decimal', DECIMAL_FORMATTER_CACHE],\n ['bits', BITS_FORMATTER_CACHE],\n ['bytes', BYTES_FORMATTER_CACHE],\n ['currency', CURRENCY_FORMATTER_CACHE],\n ['percent', PERCENT_FORMATTER_CACHE],\n ['temperature', TEMPERATURE_FORMATTER_CACHE],\n ['throughput', THROUGHPUT_FORMATTER_CACHE],\n]);\n\nexport function getFormatterFromCache(\n key: Array<string | number | boolean | undefined>,\n inputType: InputType,\n formatterOptions: Intl.NumberFormatOptions,\n locals: Locals = 'en-US'\n): FormatFn {\n const compoundKey = `${key.filter((k) => !([undefined, null, '', NaN] as unknown[]).includes(k)).join('|')}|${locals}`;\n const inputTypeFormatters = ALL_FORMATTERS.get(inputType);\n if (!inputTypeFormatters) throw new Error('No formatter found for the input type');\n\n const formatter = inputTypeFormatters.get(compoundKey);\n if (formatter) {\n return formatter.format;\n }\n\n const newFormatter = Intl.NumberFormat(locals, formatterOptions);\n inputTypeFormatters?.set(`${compoundKey}`, newFormatter);\n\n return newFormatter.format;\n}\n\n/* This is a small utility for unit tests */\nexport interface IFormatterStats {\n countCacheItems: (inputType: InputType | 'all') => number;\n getKeys: (inputType: InputType) => string[];\n}\n\nexport const getFormatterStats = (): IFormatterStats => {\n const countCacheItems = (inputType: InputType | 'all'): number => {\n if (inputType !== 'all') {\n return ALL_FORMATTERS.get(inputType)?.size ?? 0;\n }\n\n return Array.from(ALL_FORMATTERS.values()).reduce((acc, map) => acc + (map?.size ?? 0), 0);\n };\n\n const getKeys = (inputType: InputType): string[] => {\n return [...(ALL_FORMATTERS.get(inputType)?.keys() || [])];\n };\n\n return { countCacheItems, getKeys };\n};\n"],"names":["TIME_FORMATTER_CACHE","Map","DECIMAL_FORMATTER_CACHE","BITS_FORMATTER_CACHE","BYTES_FORMATTER_CACHE","CURRENCY_FORMATTER_CACHE","PERCENT_FORMATTER_CACHE","TEMPERATURE_FORMATTER_CACHE","THROUGHPUT_FORMATTER_CACHE","ALL_FORMATTERS","getFormatterFromCache","key","inputType","formatterOptions","locals","compoundKey","filter","k","undefined","NaN","includes","join","inputTypeFormatters","get","Error","formatter","format","newFormatter","Intl","NumberFormat","set","getFormatterStats","countCacheItems","size","Array","from","values","reduce","acc","map","getKeys","keys"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAMjC;;;;;;;;;;;;;;CAcC,GACD,MAAMA,uBAAuB,IAAIC;AACjC,MAAMC,0BAA0B,IAAID;AACpC,MAAME,uBAAuB,IAAIF;AACjC,MAAMG,wBAAwB,IAAIH;AAClC,MAAMI,2BAA2B,IAAIJ;AACrC,MAAMK,0BAA0B,IAAIL;AACpC,MAAMM,8BAA8B,IAAIN;AACxC,MAAMO,6BAA6B,IAAIP;AAEvC,MAAMQ,iBAAiE,IAAIR,IAAI;IAC7E;QAAC;QAAQD;KAAqB;IAC9B;QAAC;QAAWE;KAAwB;IACpC;QAAC;QAAQC;KAAqB;IAC9B;QAAC;QAASC;KAAsB;IAChC;QAAC;QAAYC;KAAyB;IACtC;QAAC;QAAWC;KAAwB;IACpC;QAAC;QAAeC;KAA4B;IAC5C;QAAC;QAAcC;KAA2B;CAC3C;AAED,OAAO,SAASE,sBACdC,GAAiD,EACjDC,SAAoB,EACpBC,gBAA0C,EAC1CC,SAAiB,OAAO;IAExB,MAAMC,cAAc,GAAGJ,IAAIK,MAAM,CAAC,CAACC,IAAM,CAAC,AAAC;YAACC;YAAW;YAAM;YAAIC;SAAI,CAAeC,QAAQ,CAACH,IAAII,IAAI,CAAC,KAAK,CAAC,EAAEP,QAAQ;IACtH,MAAMQ,sBAAsBb,eAAec,GAAG,CAACX;IAC/C,IAAI,CAACU,qBAAqB,MAAM,IAAIE,MAAM;IAE1C,MAAMC,YAAYH,oBAAoBC,GAAG,CAACR;IAC1C,IAAIU,WAAW;QACb,OAAOA,UAAUC,MAAM;IACzB;IAEA,MAAMC,eAAeC,KAAKC,YAAY,CAACf,QAAQD;IAC/CS,qBAAqBQ,IAAI,GAAGf,aAAa,EAAEY;IAE3C,OAAOA,aAAaD,MAAM;AAC5B;AAQA,OAAO,MAAMK,oBAAoB;IAC/B,MAAMC,kBAAkB,CAACpB;QACvB,IAAIA,cAAc,OAAO;YACvB,OAAOH,eAAec,GAAG,CAACX,YAAYqB,QAAQ;QAChD;QAEA,OAAOC,MAAMC,IAAI,CAAC1B,eAAe2B,MAAM,IAAIC,MAAM,CAAC,CAACC,KAAKC,MAAQD,MAAOC,CAAAA,KAAKN,QAAQ,CAAA,GAAI;IAC1F;IAEA,MAAMO,UAAU,CAAC5B;QACf,OAAO;eAAKH,eAAec,GAAG,CAACX,YAAY6B,UAAU,EAAE;SAAE;IAC3D;IAEA,OAAO;QAAET;QAAiBQ;IAAQ;AACpC,EAAE"}
|
package/dist/model/index.d.ts
CHANGED
|
@@ -2,4 +2,21 @@ export * from './graph';
|
|
|
2
2
|
export * from './theme';
|
|
3
3
|
export * from './timeOption';
|
|
4
4
|
export * from './timeZoneOption';
|
|
5
|
+
export * from './action';
|
|
6
|
+
export * from './legend';
|
|
7
|
+
export * from './time';
|
|
8
|
+
export * from './bits';
|
|
9
|
+
export * from './bytes';
|
|
10
|
+
export * from './currency';
|
|
11
|
+
export * from './percent';
|
|
12
|
+
export * from './temperature';
|
|
13
|
+
export * from './decimal';
|
|
14
|
+
export * from './throughput';
|
|
15
|
+
export * from './formatterCache';
|
|
16
|
+
export * from './units';
|
|
17
|
+
export * from './utils';
|
|
18
|
+
export * from './types';
|
|
19
|
+
export * from './thresholds';
|
|
20
|
+
export * from './transforms';
|
|
21
|
+
export * from './value-mapping';
|
|
5
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
|
package/dist/model/index.js
CHANGED
|
@@ -14,5 +14,22 @@ export * from './graph';
|
|
|
14
14
|
export * from './theme';
|
|
15
15
|
export * from './timeOption';
|
|
16
16
|
export * from './timeZoneOption';
|
|
17
|
+
export * from './action';
|
|
18
|
+
export * from './legend';
|
|
19
|
+
export * from './time';
|
|
20
|
+
export * from './bits';
|
|
21
|
+
export * from './bytes';
|
|
22
|
+
export * from './currency';
|
|
23
|
+
export * from './percent';
|
|
24
|
+
export * from './temperature';
|
|
25
|
+
export * from './decimal';
|
|
26
|
+
export * from './throughput';
|
|
27
|
+
export * from './formatterCache';
|
|
28
|
+
export * from './units';
|
|
29
|
+
export * from './utils';
|
|
30
|
+
export * from './types';
|
|
31
|
+
export * from './thresholds';
|
|
32
|
+
export * from './transforms';
|
|
33
|
+
export * from './value-mapping';
|
|
17
34
|
|
|
18
35
|
//# sourceMappingURL=index.js.map
|
package/dist/model/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './graph';\nexport * from './theme';\nexport * from './timeOption';\nexport * from './timeZoneOption';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,mBAAmB"}
|
|
1
|
+
{"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './graph';\nexport * from './theme';\nexport * from './timeOption';\nexport * from './timeZoneOption';\nexport * from './action';\nexport * from './legend';\nexport * from './time';\nexport * from './bits';\nexport * from './bytes';\nexport * from './currency';\nexport * from './percent';\nexport * from './temperature';\nexport * from './decimal';\nexport * from './throughput';\nexport * from './formatterCache';\nexport * from './units';\nexport * from './utils';\nexport * from './types';\nexport * from './thresholds';\nexport * from './transforms';\nexport * from './value-mapping';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,mBAAmB;AACjC,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,mBAAmB;AACjC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,eAAe;AAC7B,cAAc,kBAAkB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const legendPositions: readonly ["bottom", "right"];
|
|
2
|
+
export type LegendPositions = (typeof legendPositions)[number];
|
|
3
|
+
export declare const legendModes: readonly ["list", "table"];
|
|
4
|
+
export type LegendMode = (typeof legendModes)[number];
|
|
5
|
+
export declare const legendSizes: readonly ["small", "medium"];
|
|
6
|
+
export type LegendSize = (typeof legendSizes)[number];
|
|
7
|
+
export interface LegendOptionsBase {
|
|
8
|
+
position: LegendPositions;
|
|
9
|
+
mode?: LegendMode;
|
|
10
|
+
size?: LegendSize;
|
|
11
|
+
}
|
|
12
|
+
export declare function isValidLegendPosition(position: LegendPositions): boolean;
|
|
13
|
+
export declare function isValidLegendMode(mode: LegendMode): boolean;
|
|
14
|
+
export declare function isValidLegendSize(size: LegendSize): boolean;
|
|
15
|
+
export declare const DEFAULT_LEGEND: Required<LegendOptionsBase>;
|
|
16
|
+
export declare function getLegendPosition(position?: LegendPositions): 'bottom' | 'right';
|
|
17
|
+
export declare function getLegendMode(mode?: LegendMode): 'list' | 'table';
|
|
18
|
+
export declare function getLegendSize(size?: LegendSize): 'small' | 'medium';
|
|
19
|
+
//# sourceMappingURL=legend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/model/legend.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,eAAe,8BAA+B,CAAC;AAC5D,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,eAAO,MAAM,WAAW,4BAA6B,CAAC;AACtD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD,eAAO,MAAM,WAAW,8BAA+B,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAGtD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAExE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAE3D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAE3D;AAED,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,iBAAiB,CAItD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,eAAe,GAAG,QAAQ,GAAG,OAAO,CAQhF;AAED,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAMjE;AAED,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAMnE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
export const legendPositions = [
|
|
14
|
+
'bottom',
|
|
15
|
+
'right'
|
|
16
|
+
];
|
|
17
|
+
export const legendModes = [
|
|
18
|
+
'list',
|
|
19
|
+
'table'
|
|
20
|
+
];
|
|
21
|
+
export const legendSizes = [
|
|
22
|
+
'small',
|
|
23
|
+
'medium'
|
|
24
|
+
];
|
|
25
|
+
export function isValidLegendPosition(position) {
|
|
26
|
+
return legendPositions.includes(position);
|
|
27
|
+
}
|
|
28
|
+
export function isValidLegendMode(mode) {
|
|
29
|
+
return legendModes.includes(mode);
|
|
30
|
+
}
|
|
31
|
+
export function isValidLegendSize(size) {
|
|
32
|
+
return legendSizes.includes(size);
|
|
33
|
+
}
|
|
34
|
+
export const DEFAULT_LEGEND = {
|
|
35
|
+
position: 'bottom',
|
|
36
|
+
mode: 'list',
|
|
37
|
+
size: 'medium'
|
|
38
|
+
};
|
|
39
|
+
export function getLegendPosition(position) {
|
|
40
|
+
if (position === undefined) {
|
|
41
|
+
return DEFAULT_LEGEND.position;
|
|
42
|
+
}
|
|
43
|
+
if (isValidLegendPosition(position)) {
|
|
44
|
+
return position;
|
|
45
|
+
}
|
|
46
|
+
return DEFAULT_LEGEND.position;
|
|
47
|
+
}
|
|
48
|
+
export function getLegendMode(mode) {
|
|
49
|
+
if (!mode || !isValidLegendMode(mode)) {
|
|
50
|
+
return DEFAULT_LEGEND.mode;
|
|
51
|
+
}
|
|
52
|
+
return mode;
|
|
53
|
+
}
|
|
54
|
+
export function getLegendSize(size) {
|
|
55
|
+
if (!size || !isValidLegendSize(size)) {
|
|
56
|
+
return DEFAULT_LEGEND.size;
|
|
57
|
+
}
|
|
58
|
+
return size;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=legend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/legend.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport const legendPositions = ['bottom', 'right'] as const;\nexport type LegendPositions = (typeof legendPositions)[number];\n\nexport const legendModes = ['list', 'table'] as const;\nexport type LegendMode = (typeof legendModes)[number];\n\nexport const legendSizes = ['small', 'medium'] as const;\nexport type LegendSize = (typeof legendSizes)[number];\n\n// Common legend options used across some UI components and panel specifications\nexport interface LegendOptionsBase {\n position: LegendPositions;\n mode?: LegendMode;\n size?: LegendSize;\n}\n\nexport function isValidLegendPosition(position: LegendPositions): boolean {\n return (legendPositions as readonly string[]).includes(position);\n}\n\nexport function isValidLegendMode(mode: LegendMode): boolean {\n return (legendModes as readonly string[]).includes(mode);\n}\n\nexport function isValidLegendSize(size: LegendSize): boolean {\n return (legendSizes as readonly string[]).includes(size);\n}\n\nexport const DEFAULT_LEGEND: Required<LegendOptionsBase> = {\n position: 'bottom',\n mode: 'list',\n size: 'medium',\n};\n\nexport function getLegendPosition(position?: LegendPositions): 'bottom' | 'right' {\n if (position === undefined) {\n return DEFAULT_LEGEND.position;\n }\n if (isValidLegendPosition(position)) {\n return position;\n }\n return DEFAULT_LEGEND.position;\n}\n\nexport function getLegendMode(mode?: LegendMode): 'list' | 'table' {\n if (!mode || !isValidLegendMode(mode)) {\n return DEFAULT_LEGEND.mode;\n }\n\n return mode;\n}\n\nexport function getLegendSize(size?: LegendSize): 'small' | 'medium' {\n if (!size || !isValidLegendSize(size)) {\n return DEFAULT_LEGEND.size;\n }\n\n return size;\n}\n"],"names":["legendPositions","legendModes","legendSizes","isValidLegendPosition","position","includes","isValidLegendMode","mode","isValidLegendSize","size","DEFAULT_LEGEND","getLegendPosition","undefined","getLegendMode","getLegendSize"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,MAAMA,kBAAkB;IAAC;IAAU;CAAQ,CAAU;AAG5D,OAAO,MAAMC,cAAc;IAAC;IAAQ;CAAQ,CAAU;AAGtD,OAAO,MAAMC,cAAc;IAAC;IAAS;CAAS,CAAU;AAUxD,OAAO,SAASC,sBAAsBC,QAAyB;IAC7D,OAAO,AAACJ,gBAAsCK,QAAQ,CAACD;AACzD;AAEA,OAAO,SAASE,kBAAkBC,IAAgB;IAChD,OAAO,AAACN,YAAkCI,QAAQ,CAACE;AACrD;AAEA,OAAO,SAASC,kBAAkBC,IAAgB;IAChD,OAAO,AAACP,YAAkCG,QAAQ,CAACI;AACrD;AAEA,OAAO,MAAMC,iBAA8C;IACzDN,UAAU;IACVG,MAAM;IACNE,MAAM;AACR,EAAE;AAEF,OAAO,SAASE,kBAAkBP,QAA0B;IAC1D,IAAIA,aAAaQ,WAAW;QAC1B,OAAOF,eAAeN,QAAQ;IAChC;IACA,IAAID,sBAAsBC,WAAW;QACnC,OAAOA;IACT;IACA,OAAOM,eAAeN,QAAQ;AAChC;AAEA,OAAO,SAASS,cAAcN,IAAiB;IAC7C,IAAI,CAACA,QAAQ,CAACD,kBAAkBC,OAAO;QACrC,OAAOG,eAAeH,IAAI;IAC5B;IAEA,OAAOA;AACT;AAEA,OAAO,SAASO,cAAcL,IAAiB;IAC7C,IAAI,CAACA,QAAQ,CAACD,kBAAkBC,OAAO;QACrC,OAAOC,eAAeD,IAAI;IAC5B;IAEA,OAAOA;AACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UnitGroupConfig, UnitConfig } from './types';
|
|
2
|
+
type PercentUnit = 'percent' | 'percent-decimal' | '%';
|
|
3
|
+
export type PercentFormatOptions = {
|
|
4
|
+
unit?: PercentUnit;
|
|
5
|
+
decimalPlaces?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const PERCENT_GROUP_CONFIG: UnitGroupConfig;
|
|
8
|
+
export declare const PERCENT_UNIT_CONFIG: Readonly<Record<PercentUnit, UnitConfig>>;
|
|
9
|
+
export declare function formatPercent(value: number, { unit, decimalPlaces }: PercentFormatOptions): string;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=percent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"percent.d.ts","sourceRoot":"","sources":["../../src/model/percent.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGtD,KAAK,WAAW,GAAG,SAAS,GAAG,iBAAiB,GAAG,GAAG,CAAC;AACvD,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AACF,eAAO,MAAM,oBAAoB,EAAE,eAGlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,CAgBzE,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,oBAAoB,GAAG,MAAM,CA2BlG"}
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
import { MAX_SIGNIFICANT_DIGITS } from './constants';
|
|
14
|
+
import { getFormatterFromCache } from './formatterCache';
|
|
15
|
+
import { hasDecimalPlaces, limitDecimalPlaces } from './utils';
|
|
16
|
+
export const PERCENT_GROUP_CONFIG = {
|
|
17
|
+
label: 'percent',
|
|
18
|
+
decimalPlaces: true
|
|
19
|
+
};
|
|
20
|
+
const PERCENT_GROUP = 'Percent';
|
|
21
|
+
export const PERCENT_UNIT_CONFIG = {
|
|
22
|
+
percent: {
|
|
23
|
+
group: PERCENT_GROUP,
|
|
24
|
+
label: 'Percent (0-100)'
|
|
25
|
+
},
|
|
26
|
+
'percent-decimal': {
|
|
27
|
+
group: PERCENT_GROUP,
|
|
28
|
+
label: 'Percent (0.0-1.0)'
|
|
29
|
+
},
|
|
30
|
+
'%': {
|
|
31
|
+
// This option is not shown in the selector because it is a shorthand
|
|
32
|
+
// duplicate of `Percent`.
|
|
33
|
+
disableSelectorOption: true,
|
|
34
|
+
group: PERCENT_GROUP,
|
|
35
|
+
label: '%'
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export function formatPercent(value, { unit, decimalPlaces }) {
|
|
39
|
+
const formatterOptions = {
|
|
40
|
+
style: 'percent',
|
|
41
|
+
useGrouping: true
|
|
42
|
+
};
|
|
43
|
+
if (hasDecimalPlaces(decimalPlaces)) {
|
|
44
|
+
formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);
|
|
45
|
+
formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);
|
|
46
|
+
} else {
|
|
47
|
+
formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;
|
|
48
|
+
}
|
|
49
|
+
// Intl.NumberFormat translates 0 -> 0%, 0.5 -> 50%, 1 -> 100%, etc.
|
|
50
|
+
if (unit === 'percent') {
|
|
51
|
+
value = value / 100;
|
|
52
|
+
}
|
|
53
|
+
const key = [
|
|
54
|
+
formatterOptions.style,
|
|
55
|
+
formatterOptions.useGrouping,
|
|
56
|
+
formatterOptions.maximumSignificantDigits,
|
|
57
|
+
decimalPlaces,
|
|
58
|
+
unit
|
|
59
|
+
];
|
|
60
|
+
return getFormatterFromCache(key, 'percent', formatterOptions, 'en-US')(value);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=percent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/percent.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { getFormatterFromCache } from './formatterCache';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\ntype PercentUnit = 'percent' | 'percent-decimal' | '%';\nexport type PercentFormatOptions = {\n unit?: PercentUnit;\n decimalPlaces?: number;\n};\nexport const PERCENT_GROUP_CONFIG: UnitGroupConfig = {\n label: 'percent',\n decimalPlaces: true,\n};\nconst PERCENT_GROUP = 'Percent';\nexport const PERCENT_UNIT_CONFIG: Readonly<Record<PercentUnit, UnitConfig>> = {\n percent: {\n group: PERCENT_GROUP,\n label: 'Percent (0-100)',\n },\n 'percent-decimal': {\n group: PERCENT_GROUP,\n label: 'Percent (0.0-1.0)',\n },\n '%': {\n // This option is not shown in the selector because it is a shorthand\n // duplicate of `Percent`.\n disableSelectorOption: true,\n group: PERCENT_GROUP,\n label: '%',\n },\n};\n\nexport function formatPercent(value: number, { unit, decimalPlaces }: PercentFormatOptions): string {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'percent',\n useGrouping: true,\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n // Intl.NumberFormat translates 0 -> 0%, 0.5 -> 50%, 1 -> 100%, etc.\n if (unit === 'percent') {\n value = value / 100;\n }\n\n const key = [\n formatterOptions.style,\n formatterOptions.useGrouping,\n formatterOptions.maximumSignificantDigits,\n decimalPlaces,\n unit,\n ];\n\n return getFormatterFromCache(key, 'percent', formatterOptions, 'en-US')(value);\n}\n"],"names":["MAX_SIGNIFICANT_DIGITS","getFormatterFromCache","hasDecimalPlaces","limitDecimalPlaces","PERCENT_GROUP_CONFIG","label","decimalPlaces","PERCENT_GROUP","PERCENT_UNIT_CONFIG","percent","group","disableSelectorOption","formatPercent","value","unit","formatterOptions","style","useGrouping","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","key"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,sBAAsB,QAAQ,cAAc;AACrD,SAASC,qBAAqB,QAAQ,mBAAmB;AAEzD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,UAAU;AAO/D,OAAO,MAAMC,uBAAwC;IACnDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,MAAMC,gBAAgB;AACtB,OAAO,MAAMC,sBAAiE;IAC5EC,SAAS;QACPC,OAAOH;QACPF,OAAO;IACT;IACA,mBAAmB;QACjBK,OAAOH;QACPF,OAAO;IACT;IACA,KAAK;QACH,qEAAqE;QACrE,0BAA0B;QAC1BM,uBAAuB;QACvBD,OAAOH;QACPF,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASO,cAAcC,KAAa,EAAE,EAAEC,IAAI,EAAER,aAAa,EAAwB;IACxF,MAAMS,mBAA6C;QACjDC,OAAO;QACPC,aAAa;IACf;IAEA,IAAIf,iBAAiBI,gBAAgB;QACnCS,iBAAiBG,qBAAqB,GAAGf,mBAAmBG;QAC5DS,iBAAiBI,qBAAqB,GAAGhB,mBAAmBG;IAC9D,OAAO;QACLS,iBAAiBK,wBAAwB,GAAGpB;IAC9C;IAEA,oEAAoE;IACpE,IAAIc,SAAS,WAAW;QACtBD,QAAQA,QAAQ;IAClB;IAEA,MAAMQ,MAAM;QACVN,iBAAiBC,KAAK;QACtBD,iBAAiBE,WAAW;QAC5BF,iBAAiBK,wBAAwB;QACzCd;QACAQ;KACD;IAED,OAAOb,sBAAsBoB,KAAK,WAAWN,kBAAkB,SAASF;AAC1E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UnitConfig, UnitGroupConfig } from './types';
|
|
2
|
+
type TemperatureUnits = 'celsius' | 'fahrenheit';
|
|
3
|
+
export type TemperatureFormatOptions = {
|
|
4
|
+
unit: TemperatureUnits;
|
|
5
|
+
decimalPlaces?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const TEMPERATURE_GROUP_CONFIG: UnitGroupConfig;
|
|
8
|
+
export declare const TEMPERATURE_UNIT_CONFIG: Readonly<Record<TemperatureUnits, UnitConfig>>;
|
|
9
|
+
export declare const formatTemperature: (value: number, { unit, decimalPlaces }: TemperatureFormatOptions) => string;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=temperature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temperature.d.ts","sourceRoot":"","sources":["../../src/model/temperature.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAKtD,KAAK,gBAAgB,GAAG,SAAS,GAAG,YAAY,CAAC;AAEjD,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,gBAAgB,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,eAGtC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,UAAU,CAAC,CASlF,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAAW,MAAM,2BAA2B,wBAAwB,KAAG,MAwBpG,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
import { MAX_SIGNIFICANT_DIGITS } from './constants';
|
|
14
|
+
import { getFormatterFromCache } from './formatterCache';
|
|
15
|
+
import { hasDecimalPlaces, limitDecimalPlaces } from './utils';
|
|
16
|
+
const TEMPERATURE_GROUP = 'Temperature';
|
|
17
|
+
export const TEMPERATURE_GROUP_CONFIG = {
|
|
18
|
+
label: TEMPERATURE_GROUP,
|
|
19
|
+
decimalPlaces: true
|
|
20
|
+
};
|
|
21
|
+
export const TEMPERATURE_UNIT_CONFIG = {
|
|
22
|
+
celsius: {
|
|
23
|
+
group: TEMPERATURE_GROUP,
|
|
24
|
+
label: 'Celsius (°C)'
|
|
25
|
+
},
|
|
26
|
+
fahrenheit: {
|
|
27
|
+
group: TEMPERATURE_GROUP,
|
|
28
|
+
label: 'Fahrenheit (°F)'
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export const formatTemperature = (value, { unit, decimalPlaces })=>{
|
|
32
|
+
const formatterOptions = {
|
|
33
|
+
unit,
|
|
34
|
+
style: 'unit'
|
|
35
|
+
};
|
|
36
|
+
if (hasDecimalPlaces(decimalPlaces)) {
|
|
37
|
+
formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);
|
|
38
|
+
formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);
|
|
39
|
+
} else {
|
|
40
|
+
formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;
|
|
41
|
+
}
|
|
42
|
+
const locals = unit === 'celsius' ? 'en-GB' : 'en-US';
|
|
43
|
+
const key = [
|
|
44
|
+
formatterOptions.style,
|
|
45
|
+
formatterOptions.unit,
|
|
46
|
+
formatterOptions.maximumSignificantDigits,
|
|
47
|
+
decimalPlaces,
|
|
48
|
+
locals
|
|
49
|
+
];
|
|
50
|
+
return getFormatterFromCache(key, 'temperature', formatterOptions, locals)(value);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=temperature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/temperature.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { getFormatterFromCache } from './formatterCache';\nimport { UnitConfig, UnitGroupConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\nconst TEMPERATURE_GROUP = 'Temperature';\n\ntype TemperatureUnits = 'celsius' | 'fahrenheit';\n\nexport type TemperatureFormatOptions = {\n unit: TemperatureUnits;\n decimalPlaces?: number;\n};\n\nexport const TEMPERATURE_GROUP_CONFIG: UnitGroupConfig = {\n label: TEMPERATURE_GROUP,\n decimalPlaces: true,\n};\n\nexport const TEMPERATURE_UNIT_CONFIG: Readonly<Record<TemperatureUnits, UnitConfig>> = {\n celsius: {\n group: TEMPERATURE_GROUP,\n label: 'Celsius (°C)',\n },\n fahrenheit: {\n group: TEMPERATURE_GROUP,\n label: 'Fahrenheit (°F)',\n },\n};\n\nexport const formatTemperature = (value: number, { unit, decimalPlaces }: TemperatureFormatOptions): string => {\n const formatterOptions: Intl.NumberFormatOptions = {\n unit,\n style: 'unit',\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n const locals = unit === 'celsius' ? 'en-GB' : 'en-US';\n\n const key = [\n formatterOptions.style,\n formatterOptions.unit,\n formatterOptions.maximumSignificantDigits,\n decimalPlaces,\n locals,\n ];\n\n return getFormatterFromCache(key, 'temperature', formatterOptions, locals)(value);\n};\n"],"names":["MAX_SIGNIFICANT_DIGITS","getFormatterFromCache","hasDecimalPlaces","limitDecimalPlaces","TEMPERATURE_GROUP","TEMPERATURE_GROUP_CONFIG","label","decimalPlaces","TEMPERATURE_UNIT_CONFIG","celsius","group","fahrenheit","formatTemperature","value","unit","formatterOptions","style","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","locals","key"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,sBAAsB,QAAQ,cAAc;AACrD,SAASC,qBAAqB,QAAQ,mBAAmB;AAEzD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,UAAU;AAE/D,MAAMC,oBAAoB;AAS1B,OAAO,MAAMC,2BAA4C;IACvDC,OAAOF;IACPG,eAAe;AACjB,EAAE;AAEF,OAAO,MAAMC,0BAA0E;IACrFC,SAAS;QACPC,OAAON;QACPE,OAAO;IACT;IACAK,YAAY;QACVD,OAAON;QACPE,OAAO;IACT;AACF,EAAE;AAEF,OAAO,MAAMM,oBAAoB,CAACC,OAAe,EAAEC,IAAI,EAAEP,aAAa,EAA4B;IAChG,MAAMQ,mBAA6C;QACjDD;QACAE,OAAO;IACT;IAEA,IAAId,iBAAiBK,gBAAgB;QACnCQ,iBAAiBE,qBAAqB,GAAGd,mBAAmBI;QAC5DQ,iBAAiBG,qBAAqB,GAAGf,mBAAmBI;IAC9D,OAAO;QACLQ,iBAAiBI,wBAAwB,GAAGnB;IAC9C;IAEA,MAAMoB,SAASN,SAAS,YAAY,UAAU;IAE9C,MAAMO,MAAM;QACVN,iBAAiBC,KAAK;QACtBD,iBAAiBD,IAAI;QACrBC,iBAAiBI,wBAAwB;QACzCZ;QACAa;KACD;IAED,OAAOnB,sBAAsBoB,KAAK,eAAeN,kBAAkBK,QAAQP;AAC7E,EAAE"}
|
package/dist/model/theme.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ThresholdColorPalette } from '@perses-dev/core';
|
|
2
1
|
import type { EChartsOption, BarSeriesOption, LineSeriesOption, GaugeSeriesOption, TitleComponentOption, ComposeOption, XAXisComponentOption, YAXisComponentOption } from 'echarts';
|
|
2
|
+
import { ThresholdColorPalette } from './thresholds';
|
|
3
3
|
export interface PersesChartsTheme {
|
|
4
4
|
echartsTheme: EChartsTheme;
|
|
5
5
|
noDataOption: NoDataOption;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/model/theme.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/model/theme.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF;;OAEG;IACH,SAAS,EAAE;QACT;;WAEG;QACH,OAAO,EAAE;YACP,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;IACF,UAAU,EAAE,qBAAqB,CAAC;IAClC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAGD,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC,oBAAoB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC,CAAC"}
|
package/dist/model/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/theme.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/model/theme.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {\n EChartsOption,\n BarSeriesOption,\n LineSeriesOption,\n GaugeSeriesOption,\n TitleComponentOption,\n ComposeOption,\n XAXisComponentOption,\n YAXisComponentOption,\n} from 'echarts';\nimport { ThresholdColorPalette } from './thresholds';\n\nexport interface PersesChartsTheme {\n echartsTheme: EChartsTheme;\n noDataOption: NoDataOption;\n sparkline: {\n width: number;\n color: string;\n areaOpacity: number;\n };\n /**\n * Theming for the container that wraps a chart.\n */\n container: {\n /**\n * Padding in pixels.\n */\n padding: {\n default: number;\n };\n };\n thresholds: ThresholdColorPalette;\n /**\n * The id of the container that will have the chart tooltip appended to it.\n * By default, chart tooltip uses the body of the top-level document object.\n */\n tooltipPortalContainerId?: string;\n}\n\n// https://github.com/apache/echarts/issues/12489#issuecomment-643185207\nexport interface EChartsTheme extends EChartsOption {\n bar?: BarSeriesOption;\n line?: LineSeriesOption;\n gauge?: GaugeSeriesOption;\n}\n\nexport type NoDataOption = ComposeOption<TitleComponentOption | XAXisComponentOption | YAXisComponentOption>;\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAgDjC,WAA6G"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface StepOptions {
|
|
2
|
+
value: number;
|
|
3
|
+
color?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ThresholdOptions {
|
|
7
|
+
mode?: 'percent' | 'absolute';
|
|
8
|
+
defaultColor?: string;
|
|
9
|
+
max?: number;
|
|
10
|
+
steps?: StepOptions[];
|
|
11
|
+
}
|
|
12
|
+
export interface ThresholdColorPalette {
|
|
13
|
+
defaultColor: string;
|
|
14
|
+
palette: string[];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=thresholds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thresholds.d.ts","sourceRoot":"","sources":["../../src/model/thresholds.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export { };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=thresholds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/thresholds.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport interface StepOptions {\n value: number;\n color?: string;\n name?: string;\n}\n\nexport interface ThresholdOptions {\n mode?: 'percent' | 'absolute';\n defaultColor?: string;\n max?: number; // is this same as the max in GaugeChartOptions? can we remove?\n steps?: StepOptions[];\n}\n\nexport interface ThresholdColorPalette {\n defaultColor: string;\n palette: string[];\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAejC,WAGC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UnitGroupConfig, UnitConfig } from './types';
|
|
2
|
+
type ThroughputUnit = 'bits/sec' | 'decbits/sec' | 'bytes/sec' | 'decbytes/sec' | 'counts/sec' | 'events/sec' | 'messages/sec' | 'ops/sec' | 'packets/sec' | 'reads/sec' | 'records/sec' | 'requests/sec' | 'rows/sec' | 'writes/sec';
|
|
3
|
+
export type ThroughputFormatOptions = {
|
|
4
|
+
unit?: ThroughputUnit;
|
|
5
|
+
decimalPlaces?: number;
|
|
6
|
+
shortValues?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const THROUGHPUT_GROUP_CONFIG: UnitGroupConfig;
|
|
9
|
+
export declare const THROUGHPUT_UNIT_CONFIG: Readonly<Record<ThroughputUnit, UnitConfig>>;
|
|
10
|
+
export declare function formatThroughput(value: number, { unit, shortValues, decimalPlaces }: ThroughputFormatOptions): string;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=throughput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throughput.d.ts","sourceRoot":"","sources":["../../src/model/throughput.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAItD,KAAK,cAAc,GACf,UAAU,GACV,aAAa,GACb,WAAW,GACX,cAAc,GACd,YAAY,GACZ,YAAY,GACZ,cAAc,GACd,SAAS,GACT,aAAa,GACb,WAAW,GACX,aAAa,GACb,cAAc,GACd,UAAU,GACV,YAAY,CAAC;AACjB,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AACF,eAAO,MAAM,uBAAuB,EAAE,eAGrC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CA0D/E,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,uBAAuB,GAAG,MAAM,CAmDrH"}
|