@perses-dev/components 0.36.2 → 0.37.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/FontSizeSelector/FontSizeSelector.d.ts +8 -0
- package/dist/FontSizeSelector/FontSizeSelector.d.ts.map +1 -0
- package/dist/FontSizeSelector/FontSizeSelector.js +124 -0
- package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -0
- package/dist/FontSizeSelector/index.d.ts +2 -0
- package/dist/FontSizeSelector/index.d.ts.map +1 -0
- package/dist/FontSizeSelector/index.js +15 -0
- package/dist/FontSizeSelector/index.js.map +1 -0
- package/dist/LineChart/LineChart.d.ts +5 -25
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +6 -6
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/LineChart/index.d.ts +0 -1
- package/dist/LineChart/index.d.ts.map +1 -1
- package/dist/LineChart/index.js +0 -1
- package/dist/LineChart/index.js.map +1 -1
- package/dist/StatChart/StatChart.d.ts +2 -0
- package/dist/StatChart/StatChart.d.ts.map +1 -1
- package/dist/StatChart/StatChart.js +7 -5
- package/dist/StatChart/StatChart.js.map +1 -1
- package/dist/StatChart/calculateFontSize.d.ts +3 -1
- package/dist/StatChart/calculateFontSize.d.ts.map +1 -1
- package/dist/StatChart/calculateFontSize.js +5 -1
- package/dist/StatChart/calculateFontSize.js.map +1 -1
- package/dist/TimeChart/TimeChart.d.ts +23 -0
- package/dist/TimeChart/TimeChart.d.ts.map +1 -0
- package/dist/TimeChart/TimeChart.js +317 -0
- package/dist/TimeChart/TimeChart.js.map +1 -0
- package/dist/TimeChart/index.d.ts +2 -0
- package/dist/TimeChart/index.d.ts.map +1 -0
- package/dist/TimeChart/index.js +15 -0
- package/dist/TimeChart/index.js.map +1 -0
- package/dist/TimeSeriesTooltip/{TimeSeriesTooltip.d.ts → LineChartTooltip.d.ts} +2 -2
- package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -0
- package/dist/TimeSeriesTooltip/{TimeSeriesTooltip.js → LineChartTooltip.js} +4 -4
- package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -0
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +21 -0
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -0
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +78 -0
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -0
- package/dist/TimeSeriesTooltip/TooltipHeader.js +6 -9
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/index.d.ts +2 -1
- package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/index.js +2 -1
- package/dist/TimeSeriesTooltip/index.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +23 -5
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +166 -4
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +4 -0
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts +26 -1
- package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js +41 -5
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/cjs/FontSizeSelector/FontSizeSelector.js +130 -0
- package/dist/cjs/FontSizeSelector/index.js +28 -0
- package/dist/cjs/LineChart/LineChart.js +5 -44
- package/dist/cjs/LineChart/index.js +0 -1
- package/dist/cjs/StatChart/StatChart.js +7 -5
- package/dist/cjs/StatChart/calculateFontSize.js +5 -1
- package/dist/cjs/TimeChart/TimeChart.js +323 -0
- package/dist/cjs/TimeChart/index.js +28 -0
- package/dist/cjs/TimeSeriesTooltip/{TimeSeriesTooltip.js → LineChartTooltip.js} +4 -4
- package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +89 -0
- package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +6 -9
- package/dist/cjs/TimeSeriesTooltip/index.js +2 -1
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +162 -4
- package/dist/cjs/TimeSeriesTooltip/utils.js +47 -7
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/utils/axis.js +58 -0
- package/dist/cjs/{LineChart/utils.js → utils/chart-actions.js} +0 -54
- package/dist/cjs/utils/format.js +47 -1
- package/dist/cjs/utils/index.js +3 -1
- package/dist/cjs/utils/theme-gen.js +42 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/model/graph.d.ts +19 -2
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/graph.js.map +1 -1
- package/dist/model/theme.d.ts +5 -0
- package/dist/model/theme.d.ts.map +1 -1
- package/dist/model/theme.js.map +1 -1
- package/dist/utils/axis.d.ts +14 -0
- package/dist/utils/axis.d.ts.map +1 -0
- package/dist/utils/axis.js +45 -0
- package/dist/utils/axis.js.map +1 -0
- package/dist/utils/chart-actions.d.ts +18 -0
- package/dist/utils/chart-actions.d.ts.map +1 -0
- package/dist/utils/chart-actions.js +52 -0
- package/dist/utils/chart-actions.js.map +1 -0
- package/dist/utils/format.d.ts +6 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +47 -0
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/theme-gen.d.ts +6 -1
- package/dist/utils/theme-gen.d.ts.map +1 -1
- package/dist/utils/theme-gen.js +42 -1
- package/dist/utils/theme-gen.js.map +1 -1
- package/package.json +3 -3
- package/dist/LineChart/utils.d.ts +0 -31
- package/dist/LineChart/utils.d.ts.map +0 -1
- package/dist/LineChart/utils.js +0 -103
- package/dist/LineChart/utils.js.map +0 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +0 -1
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
import { Theme } from '@mui/material';
|
|
1
2
|
import { CursorCoordinates, CursorData } from './tooltip-model';
|
|
2
3
|
/**
|
|
3
4
|
* Determine position of tooltip depending on chart dimensions and the number of focused series
|
|
4
5
|
*/
|
|
5
|
-
export declare function assembleTransform(mousePos: CursorData['coords'], chartWidth: number, pinnedPos: CursorCoordinates | null, tooltipHeight: number, tooltipWidth: number): string;
|
|
6
|
+
export declare function assembleTransform(mousePos: CursorData['coords'], chartWidth: number, pinnedPos: CursorCoordinates | null, tooltipHeight: number, tooltipWidth: number, containerElement?: Element | null): string;
|
|
7
|
+
/**
|
|
8
|
+
* Helper for tooltip positioning styles
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTooltipStyles(theme: Theme, pinnedPos: CursorCoordinates | null): {
|
|
11
|
+
minWidth: number;
|
|
12
|
+
maxWidth: number;
|
|
13
|
+
maxHeight: number;
|
|
14
|
+
padding: number;
|
|
15
|
+
position: string;
|
|
16
|
+
top: number;
|
|
17
|
+
left: number;
|
|
18
|
+
backgroundColor: `#${string}`;
|
|
19
|
+
borderRadius: string;
|
|
20
|
+
color: string;
|
|
21
|
+
fontSize: string;
|
|
22
|
+
visibility: string;
|
|
23
|
+
opacity: number;
|
|
24
|
+
transition: string;
|
|
25
|
+
zIndex: string | number;
|
|
26
|
+
overflow: string;
|
|
27
|
+
'&:hover': {
|
|
28
|
+
overflowY: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
6
31
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,iBAAiB,EACjB,UAAU,EAMX,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC9B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,iBAAiB,GAAG,IAAI,EACnC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,gBAAgB,CAAC,EAAE,OAAO,GAAG,IAAI,UAyClC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;EAuBjF"}
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { TOOLTIP_MAX_WIDTH, TOOLTIP_ADJUST_Y_POS_MULTIPLIER } from './tooltip-model';
|
|
13
|
+
import { TOOLTIP_MAX_WIDTH, TOOLTIP_MAX_HEIGHT, TOOLTIP_MIN_WIDTH, TOOLTIP_ADJUST_Y_POS_MULTIPLIER, TOOLTIP_BG_COLOR_FALLBACK } from './tooltip-model';
|
|
14
14
|
/**
|
|
15
15
|
* Determine position of tooltip depending on chart dimensions and the number of focused series
|
|
16
|
-
*/ export function assembleTransform(mousePos, chartWidth, pinnedPos, tooltipHeight, tooltipWidth) {
|
|
16
|
+
*/ export function assembleTransform(mousePos, chartWidth, pinnedPos, tooltipHeight, tooltipWidth, containerElement) {
|
|
17
17
|
if (mousePos === null) {
|
|
18
18
|
return 'translate3d(0, 0)';
|
|
19
19
|
}
|
|
@@ -22,20 +22,56 @@ import { TOOLTIP_MAX_WIDTH, TOOLTIP_ADJUST_Y_POS_MULTIPLIER } from './tooltip-mo
|
|
|
22
22
|
if (pinnedPos !== null) {
|
|
23
23
|
mousePos = pinnedPos;
|
|
24
24
|
}
|
|
25
|
-
//
|
|
25
|
+
// By default, tooltip is located in a Portal attached to the body.
|
|
26
26
|
// Using page coordinates instead of viewport ensures the tooltip is
|
|
27
27
|
// absolutely positioned correctly as the user scrolls
|
|
28
|
-
|
|
28
|
+
let x = mousePos.page.x;
|
|
29
29
|
let y = mousePos.page.y + cursorPaddingY;
|
|
30
|
+
// If containerElement is defined, tooltip is attached to the containerElement instead.
|
|
31
|
+
if (containerElement) {
|
|
32
|
+
// get the container's position relative to viewport
|
|
33
|
+
const containerRect = containerElement.getBoundingClientRect();
|
|
34
|
+
// calculate the mouse position relative to container
|
|
35
|
+
x = x - containerRect.left + containerElement.scrollLeft;
|
|
36
|
+
y = y - containerRect.top + containerElement.scrollTop;
|
|
37
|
+
}
|
|
30
38
|
// adjust so tooltip does not get cut off at bottom of chart
|
|
31
39
|
if (mousePos.client.y + tooltipHeight + cursorPaddingY > window.innerHeight) {
|
|
32
40
|
// multiplier ensures tooltip isn't overly adjusted and gets cut off at the top of the viewport
|
|
33
|
-
y =
|
|
41
|
+
y = y - tooltipHeight * TOOLTIP_ADJUST_Y_POS_MULTIPLIER;
|
|
34
42
|
}
|
|
35
43
|
// use tooltip width to determine when to repos from right to left
|
|
36
44
|
const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;
|
|
37
45
|
// reposition so tooltip is never too close to right side of chart or left side of browser window
|
|
38
46
|
return mousePos.plotCanvas.x > xPosAdjustThreshold && x > TOOLTIP_MAX_WIDTH ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)` : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;
|
|
39
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Helper for tooltip positioning styles
|
|
50
|
+
*/ export function getTooltipStyles(theme, pinnedPos) {
|
|
51
|
+
var ref;
|
|
52
|
+
var ref1;
|
|
53
|
+
return {
|
|
54
|
+
minWidth: TOOLTIP_MIN_WIDTH,
|
|
55
|
+
maxWidth: TOOLTIP_MAX_WIDTH,
|
|
56
|
+
maxHeight: TOOLTIP_MAX_HEIGHT,
|
|
57
|
+
padding: 0,
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
top: 0,
|
|
60
|
+
left: 0,
|
|
61
|
+
backgroundColor: (ref1 = (ref = theme.palette.designSystem) === null || ref === void 0 ? void 0 : ref.grey[800]) !== null && ref1 !== void 0 ? ref1 : TOOLTIP_BG_COLOR_FALLBACK,
|
|
62
|
+
borderRadius: '6px',
|
|
63
|
+
color: '#fff',
|
|
64
|
+
fontSize: '11px',
|
|
65
|
+
visibility: 'visible',
|
|
66
|
+
opacity: 1,
|
|
67
|
+
transition: 'all 0.1s ease-out',
|
|
68
|
+
// Ensure pinned tooltip shows behind edit panel drawer and sticky header
|
|
69
|
+
zIndex: pinnedPos !== null ? 'auto' : theme.zIndex.tooltip,
|
|
70
|
+
overflow: 'hidden',
|
|
71
|
+
'&:hover': {
|
|
72
|
+
overflowY: 'auto'
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
40
76
|
|
|
41
77
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeSeriesTooltip/utils.ts"],"sourcesContent":["// Copyright 2023 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 { CursorCoordinates
|
|
1
|
+
{"version":3,"sources":["../../src/TimeSeriesTooltip/utils.ts"],"sourcesContent":["// Copyright 2023 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 { Theme } from '@mui/material';\nimport {\n CursorCoordinates,\n CursorData,\n TOOLTIP_MAX_WIDTH,\n TOOLTIP_MAX_HEIGHT,\n TOOLTIP_MIN_WIDTH,\n TOOLTIP_ADJUST_Y_POS_MULTIPLIER,\n TOOLTIP_BG_COLOR_FALLBACK,\n} from './tooltip-model';\n\n/**\n * Determine position of tooltip depending on chart dimensions and the number of focused series\n */\nexport function assembleTransform(\n mousePos: CursorData['coords'],\n chartWidth: number,\n pinnedPos: CursorCoordinates | null,\n tooltipHeight: number,\n tooltipWidth: number,\n containerElement?: Element | null\n) {\n if (mousePos === null) {\n return 'translate3d(0, 0)';\n }\n\n const cursorPaddingX = 32;\n const cursorPaddingY = 16;\n\n if (pinnedPos !== null) {\n mousePos = pinnedPos;\n }\n\n // By default, tooltip is located in a Portal attached to the body.\n // Using page coordinates instead of viewport ensures the tooltip is\n // absolutely positioned correctly as the user scrolls\n let x = mousePos.page.x;\n let y = mousePos.page.y + cursorPaddingY;\n\n // If containerElement is defined, tooltip is attached to the containerElement instead.\n if (containerElement) {\n // get the container's position relative to viewport\n const containerRect = containerElement.getBoundingClientRect();\n // calculate the mouse position relative to container\n x = x - containerRect.left + containerElement.scrollLeft;\n y = y - containerRect.top + containerElement.scrollTop;\n }\n\n // adjust so tooltip does not get cut off at bottom of chart\n if (mousePos.client.y + tooltipHeight + cursorPaddingY > window.innerHeight) {\n // multiplier ensures tooltip isn't overly adjusted and gets cut off at the top of the viewport\n y = y - tooltipHeight * TOOLTIP_ADJUST_Y_POS_MULTIPLIER;\n }\n\n // use tooltip width to determine when to repos from right to left\n const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;\n\n // reposition so tooltip is never too close to right side of chart or left side of browser window\n return mousePos.plotCanvas.x > xPosAdjustThreshold && x > TOOLTIP_MAX_WIDTH\n ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)`\n : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;\n}\n\n/**\n * Helper for tooltip positioning styles\n */\nexport function getTooltipStyles(theme: Theme, pinnedPos: CursorCoordinates | null) {\n return {\n minWidth: TOOLTIP_MIN_WIDTH,\n maxWidth: TOOLTIP_MAX_WIDTH,\n maxHeight: TOOLTIP_MAX_HEIGHT,\n padding: 0,\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n borderRadius: '6px',\n color: '#fff',\n fontSize: '11px',\n visibility: 'visible',\n opacity: 1,\n transition: 'all 0.1s ease-out',\n // Ensure pinned tooltip shows behind edit panel drawer and sticky header\n zIndex: pinnedPos !== null ? 'auto' : theme.zIndex.tooltip,\n overflow: 'hidden',\n '&:hover': {\n overflowY: 'auto',\n },\n };\n}\n"],"names":["TOOLTIP_MAX_WIDTH","TOOLTIP_MAX_HEIGHT","TOOLTIP_MIN_WIDTH","TOOLTIP_ADJUST_Y_POS_MULTIPLIER","TOOLTIP_BG_COLOR_FALLBACK","assembleTransform","mousePos","chartWidth","pinnedPos","tooltipHeight","tooltipWidth","containerElement","cursorPaddingX","cursorPaddingY","x","page","y","containerRect","getBoundingClientRect","left","scrollLeft","top","scrollTop","client","window","innerHeight","xPosAdjustThreshold","plotCanvas","getTooltipStyles","theme","minWidth","maxWidth","maxHeight","padding","position","backgroundColor","palette","designSystem","grey","borderRadius","color","fontSize","visibility","opacity","transition","zIndex","tooltip","overflow","overflowY"],"mappings":"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"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License | Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing | software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS |
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND | either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "FontSizeSelector", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>FontSizeSelector
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _optionsEditorLayout = require("../OptionsEditorLayout");
|
|
23
|
+
const _settingsAutocomplete = require("../SettingsAutocomplete");
|
|
24
|
+
const FONT_SIZE_OPTIONS = [
|
|
25
|
+
{
|
|
26
|
+
id: 'default',
|
|
27
|
+
label: 'Default',
|
|
28
|
+
value: undefined
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: '12',
|
|
32
|
+
label: '12',
|
|
33
|
+
value: 12
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: '14',
|
|
37
|
+
label: '14',
|
|
38
|
+
value: 14
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: '16',
|
|
42
|
+
label: '16',
|
|
43
|
+
value: 16
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: '20',
|
|
47
|
+
label: '20',
|
|
48
|
+
value: 20
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: '24',
|
|
52
|
+
label: '24',
|
|
53
|
+
value: 24
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: '28',
|
|
57
|
+
label: '28',
|
|
58
|
+
value: 28
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: '32',
|
|
62
|
+
label: '32',
|
|
63
|
+
value: 32
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: '36',
|
|
67
|
+
label: '36',
|
|
68
|
+
value: 36
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: '40',
|
|
72
|
+
label: '40',
|
|
73
|
+
value: 40
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: '48',
|
|
77
|
+
label: '48',
|
|
78
|
+
value: 48
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: '56',
|
|
82
|
+
label: '56',
|
|
83
|
+
value: 56
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: '64',
|
|
87
|
+
label: '64',
|
|
88
|
+
value: 64
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: '72',
|
|
92
|
+
label: '72',
|
|
93
|
+
value: 72
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: '96',
|
|
97
|
+
label: '96',
|
|
98
|
+
value: 96
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: '128',
|
|
102
|
+
label: '128',
|
|
103
|
+
value: 128
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: '160',
|
|
107
|
+
label: '160',
|
|
108
|
+
value: 160
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: '192',
|
|
112
|
+
label: '192',
|
|
113
|
+
value: 192
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
function FontSizeSelector({ value , onChange }) {
|
|
117
|
+
const handleFontSizeChange = (_, { value })=>{
|
|
118
|
+
onChange(value);
|
|
119
|
+
};
|
|
120
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
|
|
121
|
+
label: "Font Size",
|
|
122
|
+
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_settingsAutocomplete.SettingsAutocomplete, {
|
|
123
|
+
value: FONT_SIZE_OPTIONS.find((o)=>o.value === value),
|
|
124
|
+
options: FONT_SIZE_OPTIONS,
|
|
125
|
+
getOptionLabel: (o)=>o.label,
|
|
126
|
+
onChange: handleFontSizeChange,
|
|
127
|
+
disableClearable: true
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./FontSizeSelector"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "LineChart", {
|
|
|
19
19
|
get: ()=>LineChart
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _react =
|
|
22
|
+
const _react = require("react");
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
24
|
const _core = require("echarts/core");
|
|
25
25
|
const _charts = require("echarts/charts");
|
|
@@ -29,46 +29,7 @@ const _echart = require("../EChart");
|
|
|
29
29
|
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
30
30
|
const _timeSeriesTooltip = require("../TimeSeriesTooltip");
|
|
31
31
|
const _timeZoneProvider = require("../context/TimeZoneProvider");
|
|
32
|
-
const _utils = require("
|
|
33
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
34
|
-
if (typeof WeakMap !== "function") return null;
|
|
35
|
-
var cacheBabelInterop = new WeakMap();
|
|
36
|
-
var cacheNodeInterop = new WeakMap();
|
|
37
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
38
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
39
|
-
})(nodeInterop);
|
|
40
|
-
}
|
|
41
|
-
function _interopRequireWildcard(obj, nodeInterop) {
|
|
42
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
43
|
-
return obj;
|
|
44
|
-
}
|
|
45
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
46
|
-
return {
|
|
47
|
-
default: obj
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
51
|
-
if (cache && cache.has(obj)) {
|
|
52
|
-
return cache.get(obj);
|
|
53
|
-
}
|
|
54
|
-
var newObj = {};
|
|
55
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
56
|
-
for(var key in obj){
|
|
57
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
58
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
59
|
-
if (desc && (desc.get || desc.set)) {
|
|
60
|
-
Object.defineProperty(newObj, key, desc);
|
|
61
|
-
} else {
|
|
62
|
-
newObj[key] = obj[key];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
newObj.default = obj;
|
|
67
|
-
if (cache) {
|
|
68
|
-
cache.set(obj, newObj);
|
|
69
|
-
}
|
|
70
|
-
return newObj;
|
|
71
|
-
}
|
|
32
|
+
const _utils = require("../utils");
|
|
72
33
|
(0, _core.use)([
|
|
73
34
|
_charts.LineChart,
|
|
74
35
|
_components.GridComponent,
|
|
@@ -97,7 +58,7 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
|
|
|
97
58
|
return {
|
|
98
59
|
highlightSeries ({ id }) {
|
|
99
60
|
if (!chartRef.current) {
|
|
100
|
-
//
|
|
61
|
+
// when chart undef, do not highlight series when hovering over legend
|
|
101
62
|
return;
|
|
102
63
|
}
|
|
103
64
|
chartRef.current.dispatchAction({
|
|
@@ -107,7 +68,7 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
|
|
|
107
68
|
},
|
|
108
69
|
clearHighlightedSeries: ()=>{
|
|
109
70
|
if (!chartRef.current) {
|
|
110
|
-
//
|
|
71
|
+
// when chart undef, do not clear highlight series
|
|
111
72
|
return;
|
|
112
73
|
}
|
|
113
74
|
(0, _utils.clearHighlightedSeries)(chartRef.current, data.timeSeries.length);
|
|
@@ -292,7 +253,7 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
|
|
|
292
253
|
}
|
|
293
254
|
},
|
|
294
255
|
children: [
|
|
295
|
-
showTooltip === true && ((ref1 = option.tooltip) === null || ref1 === void 0 ? void 0 : ref1.showContent) === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeSeriesTooltip.
|
|
256
|
+
showTooltip === true && ((ref1 = option.tooltip) === null || ref1 === void 0 ? void 0 : ref1.showContent) === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeSeriesTooltip.LineChartTooltip, {
|
|
296
257
|
chartRef: chartRef,
|
|
297
258
|
chartData: data,
|
|
298
259
|
wrapLabels: tooltipConfig.wrapLabels,
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
_exportStar(require("./LineChart"), exports);
|
|
18
|
-
_exportStar(require("./utils"), exports);
|
|
19
18
|
function _exportStar(from, to) {
|
|
20
19
|
Object.keys(from).forEach(function(k) {
|
|
21
20
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
@@ -49,7 +49,7 @@ const SERIES_NAME_FONT_WEIGHT = 400;
|
|
|
49
49
|
const VALUE_FONT_WEIGHT = 700;
|
|
50
50
|
function StatChart(props) {
|
|
51
51
|
var ref, ref1;
|
|
52
|
-
const { width , height , data , unit , color , sparkline , showSeriesName } = props;
|
|
52
|
+
const { width , height , data , unit , color , sparkline , showSeriesName , valueFontSize } = props;
|
|
53
53
|
const chartsTheme = (0, _chartsThemeProvider.useChartsTheme)();
|
|
54
54
|
let formattedValue = '';
|
|
55
55
|
if (data.calculatedValue === null) {
|
|
@@ -72,8 +72,10 @@ function StatChart(props) {
|
|
|
72
72
|
// calculate value font size and height
|
|
73
73
|
const availableWidth = width - containerPadding * 2;
|
|
74
74
|
const availableHeight = height - seriesNameHeight;
|
|
75
|
-
const
|
|
75
|
+
const optimalValueFontSize = (0, _calculateFontSize.useOptimalFontSize)({
|
|
76
76
|
text: formattedValue,
|
|
77
|
+
// override the font size if user selects it in the settings
|
|
78
|
+
fontSizeOverride: valueFontSize,
|
|
77
79
|
fontWeight: VALUE_FONT_WEIGHT,
|
|
78
80
|
// without sparkline, use only 50% of the available width so it looks better for multiseries
|
|
79
81
|
width: sparkline ? availableWidth : availableWidth * 0.5,
|
|
@@ -82,9 +84,9 @@ function StatChart(props) {
|
|
|
82
84
|
height: sparkline ? availableHeight * 0.25 : availableHeight * 0.9,
|
|
83
85
|
lineHeight: LINE_HEIGHT
|
|
84
86
|
});
|
|
85
|
-
const valueFontHeight =
|
|
87
|
+
const valueFontHeight = optimalValueFontSize * LINE_HEIGHT;
|
|
86
88
|
// make sure the series name font size is slightly smaller than value font size
|
|
87
|
-
seriesNameFontSize = Math.min(
|
|
89
|
+
seriesNameFontSize = Math.min(optimalValueFontSize * 0.7, seriesNameFontSize);
|
|
88
90
|
const option = (0, _react.useMemo)(()=>{
|
|
89
91
|
if (data.seriesData === undefined) return chartsTheme.noDataOption;
|
|
90
92
|
const series = data.seriesData;
|
|
@@ -163,7 +165,7 @@ function StatChart(props) {
|
|
|
163
165
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(Value, {
|
|
164
166
|
variant: "h3",
|
|
165
167
|
color: color,
|
|
166
|
-
fontSize:
|
|
168
|
+
fontSize: optimalValueFontSize,
|
|
167
169
|
padding: containerPadding,
|
|
168
170
|
children: formattedValue
|
|
169
171
|
}),
|
|
@@ -29,9 +29,13 @@ function getGlobalCanvasContext() {
|
|
|
29
29
|
}
|
|
30
30
|
return canvasContext;
|
|
31
31
|
}
|
|
32
|
-
function useOptimalFontSize({ text , fontWeight , width , height , lineHeight , maxSize }) {
|
|
32
|
+
function useOptimalFontSize({ text , fontWeight , width , height , lineHeight , maxSize , fontSizeOverride }) {
|
|
33
33
|
const ctx = getGlobalCanvasContext();
|
|
34
34
|
const chartsTheme = (0, _chartsThemeProvider.useChartsTheme)();
|
|
35
|
+
// if user has selected a font size in the settings, use it instead of calculating the optimal size
|
|
36
|
+
if (fontSizeOverride !== undefined) {
|
|
37
|
+
return Number(fontSizeOverride);
|
|
38
|
+
}
|
|
35
39
|
const textStyle = chartsTheme.echartsTheme.textStyle;
|
|
36
40
|
var ref;
|
|
37
41
|
const fontSize = (ref = Number(textStyle === null || textStyle === void 0 ? void 0 : textStyle.fontSize)) !== null && ref !== void 0 ? ref : 12;
|