@perses-dev/components 0.0.0-snapshot-time-chart-rewrite-4667058 → 0.0.0-snapshot-panel-extra-content-2-2767e21
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/README.md +1 -0
- package/dist/BarChart/BarChart.d.ts +16 -0
- package/dist/BarChart/BarChart.d.ts.map +1 -0
- package/dist/BarChart/BarChart.js +123 -0
- package/dist/BarChart/BarChart.js.map +1 -0
- package/dist/BarChart/index.d.ts +2 -0
- package/dist/BarChart/index.d.ts.map +1 -0
- package/dist/BarChart/index.js +15 -0
- package/dist/BarChart/index.js.map +1 -0
- package/dist/Dialog/DiscardChangesConfirmationDialog.d.ts +10 -0
- package/dist/Dialog/DiscardChangesConfirmationDialog.d.ts.map +1 -0
- package/dist/Dialog/DiscardChangesConfirmationDialog.js +47 -0
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -0
- package/dist/Dialog/index.d.ts +1 -0
- package/dist/Dialog/index.d.ts.map +1 -1
- package/dist/Dialog/index.js +1 -0
- package/dist/Dialog/index.js.map +1 -1
- 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/Legend/ListLegendItem.d.ts +1 -1
- package/dist/LineChart/LineChart.d.ts +2 -2
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +4 -3
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/ModeSelector/ModeSelector.d.ts +9 -0
- package/dist/ModeSelector/ModeSelector.d.ts.map +1 -0
- package/dist/ModeSelector/ModeSelector.js +43 -0
- package/dist/ModeSelector/ModeSelector.js.map +1 -0
- package/dist/ModeSelector/index.d.ts +2 -0
- package/dist/ModeSelector/index.d.ts.map +1 -0
- package/dist/ModeSelector/index.js +15 -0
- package/dist/ModeSelector/index.js.map +1 -0
- package/dist/SortSelector/SortSelector.d.ts +8 -0
- package/dist/SortSelector/SortSelector.d.ts.map +1 -0
- package/dist/SortSelector/SortSelector.js +42 -0
- package/dist/SortSelector/SortSelector.js.map +1 -0
- package/dist/SortSelector/index.d.ts +2 -0
- package/dist/SortSelector/index.d.ts.map +1 -0
- package/dist/SortSelector/index.js +15 -0
- package/dist/SortSelector/index.js.map +1 -0
- 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 +3 -2
- package/dist/TimeChart/TimeChart.d.ts.map +1 -1
- package/dist/TimeChart/TimeChart.js +57 -17
- package/dist/TimeChart/TimeChart.js.map +1 -1
- package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts +5 -0
- package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/LineChartTooltip.js +12 -5
- package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +8 -3
- package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +12 -5
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +3 -5
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.js +90 -102
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +1 -0
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +1 -0
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts +2 -2
- package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js +22 -8
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/UnitSelector/UnitSelector.d.ts +2 -1
- package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
- package/dist/UnitSelector/UnitSelector.js +3 -2
- package/dist/UnitSelector/UnitSelector.js.map +1 -1
- package/dist/cjs/BarChart/BarChart.js +129 -0
- package/dist/cjs/BarChart/index.js +28 -0
- package/dist/cjs/Dialog/DiscardChangesConfirmationDialog.js +53 -0
- package/dist/cjs/Dialog/index.js +1 -0
- package/dist/cjs/FontSizeSelector/FontSizeSelector.js +130 -0
- package/dist/cjs/FontSizeSelector/index.js +28 -0
- package/dist/cjs/LineChart/LineChart.js +4 -3
- package/dist/cjs/ModeSelector/ModeSelector.js +49 -0
- package/dist/cjs/ModeSelector/index.js +28 -0
- package/dist/cjs/SortSelector/SortSelector.js +48 -0
- package/dist/cjs/SortSelector/index.js +28 -0
- package/dist/cjs/StatChart/StatChart.js +7 -5
- package/dist/cjs/StatChart/calculateFontSize.js +5 -1
- package/dist/cjs/TimeChart/TimeChart.js +59 -14
- package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +11 -4
- package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +11 -4
- package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +3 -5
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +90 -102
- package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +2 -0
- package/dist/cjs/TimeSeriesTooltip/utils.js +21 -7
- package/dist/cjs/UnitSelector/UnitSelector.js +3 -2
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/model/graph.js +35 -3
- package/dist/cjs/utils/chart-actions.js +61 -1
- package/dist/cjs/utils/theme-gen.js +39 -7
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/model/graph.d.ts +14 -5
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/graph.js +25 -0
- 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/chart-actions.d.ts +3 -0
- package/dist/utils/chart-actions.d.ts.map +1 -1
- package/dist/utils/chart-actions.js +66 -0
- package/dist/utils/chart-actions.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 +39 -7
- package/dist/utils/theme-gen.js.map +1 -1
- package/package.json +3 -3
|
@@ -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("./ModeSelector"), 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
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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, "SortSelector", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>SortSelector
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _optionsEditorLayout = require("../OptionsEditorLayout");
|
|
23
|
+
const _settingsAutocomplete = require("../SettingsAutocomplete");
|
|
24
|
+
const SORT_OPTIONS = [
|
|
25
|
+
{
|
|
26
|
+
id: 'asc',
|
|
27
|
+
label: 'Ascending'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'desc',
|
|
31
|
+
label: 'Descending'
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
function SortSelector({ onChange , value ='desc' }) {
|
|
35
|
+
const handleSortChange = (_, { id })=>{
|
|
36
|
+
onChange(id);
|
|
37
|
+
};
|
|
38
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
|
|
39
|
+
label: "Sort",
|
|
40
|
+
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_settingsAutocomplete.SettingsAutocomplete, {
|
|
41
|
+
value: SORT_OPTIONS.find((o)=>o.id === value),
|
|
42
|
+
options: SORT_OPTIONS,
|
|
43
|
+
getOptionLabel: (o)=>o.label,
|
|
44
|
+
onChange: handleSortChange,
|
|
45
|
+
disableClearable: true
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -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("./SortSelector"), 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
|
+
}
|
|
@@ -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;
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "TimeChart", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _react = require("react");
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
|
+
const _merge = /*#__PURE__*/ _interopRequireDefault(require("lodash/merge"));
|
|
24
25
|
const _dateFnsTz = require("date-fns-tz");
|
|
25
26
|
const _core = require("@perses-dev/core");
|
|
26
27
|
const _core1 = require("echarts/core");
|
|
@@ -28,12 +29,19 @@ const _charts = require("echarts/charts");
|
|
|
28
29
|
const _components = require("echarts/components");
|
|
29
30
|
const _renderers = require("echarts/renderers");
|
|
30
31
|
const _echart = require("../EChart");
|
|
32
|
+
const _graph = require("../model/graph");
|
|
31
33
|
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
32
34
|
const _utils = require("../utils");
|
|
33
35
|
const _timeSeriesTooltip = require("../TimeSeriesTooltip");
|
|
34
36
|
const _timeZoneProvider = require("../context/TimeZoneProvider");
|
|
37
|
+
function _interopRequireDefault(obj) {
|
|
38
|
+
return obj && obj.__esModule ? obj : {
|
|
39
|
+
default: obj
|
|
40
|
+
};
|
|
41
|
+
}
|
|
35
42
|
(0, _core1.use)([
|
|
36
43
|
_charts.LineChart,
|
|
44
|
+
_charts.BarChart,
|
|
37
45
|
_components.GridComponent,
|
|
38
46
|
_components.DatasetComponent,
|
|
39
47
|
_components.DataZoomComponent,
|
|
@@ -43,10 +51,9 @@ const _timeZoneProvider = require("../context/TimeZoneProvider");
|
|
|
43
51
|
_components.TitleComponent,
|
|
44
52
|
_components.ToolboxComponent,
|
|
45
53
|
_components.TooltipComponent,
|
|
46
|
-
_components.LegendComponent,
|
|
47
54
|
_renderers.CanvasRenderer
|
|
48
55
|
]);
|
|
49
|
-
const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ height , data , seriesMapping , timeScale: timeScaleProp , yAxis , unit , grid , tooltipConfig ={
|
|
56
|
+
const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ height , data , seriesMapping , timeScale: timeScaleProp , yAxis , unit , grid , isStackedBar =false , tooltipConfig ={
|
|
50
57
|
wrapLabels: true
|
|
51
58
|
} , noDataVariant ='message' , syncGroup , onDataZoom , onDoubleClick , __experimentalEChartsOptionsOverride , }, ref) {
|
|
52
59
|
var ref1;
|
|
@@ -85,7 +92,7 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
|
|
|
85
92
|
return {
|
|
86
93
|
highlightSeries ({ name }) {
|
|
87
94
|
if (!chartRef.current) {
|
|
88
|
-
//
|
|
95
|
+
// when chart undef, do not highlight series when hovering over legend
|
|
89
96
|
return;
|
|
90
97
|
}
|
|
91
98
|
chartRef.current.dispatchAction({
|
|
@@ -95,7 +102,7 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
|
|
|
95
102
|
},
|
|
96
103
|
clearHighlightedSeries: ()=>{
|
|
97
104
|
if (!chartRef.current) {
|
|
98
|
-
//
|
|
105
|
+
// when chart undef, do not clear highlight series
|
|
99
106
|
return;
|
|
100
107
|
}
|
|
101
108
|
(0, _utils.clearHighlightedSeries)(chartRef.current, totalSeries);
|
|
@@ -123,19 +130,19 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
|
|
|
123
130
|
};
|
|
124
131
|
onDataZoom(zoomEvent);
|
|
125
132
|
}
|
|
133
|
+
},
|
|
134
|
+
finished: ()=>{
|
|
135
|
+
if (chartRef.current !== undefined) {
|
|
136
|
+
(0, _utils.enableDataZoom)(chartRef.current);
|
|
137
|
+
}
|
|
126
138
|
}
|
|
127
139
|
};
|
|
128
140
|
}, [
|
|
129
141
|
onDataZoom,
|
|
130
142
|
setTooltipPinnedCoords
|
|
131
143
|
]);
|
|
132
|
-
if (chartRef.current !== undefined) {
|
|
133
|
-
(0, _utils.enableDataZoom)(chartRef.current);
|
|
134
|
-
}
|
|
135
144
|
const { noDataOption } = chartsTheme;
|
|
136
145
|
const option = (0, _react.useMemo)(()=>{
|
|
137
|
-
// TODO: fix loading state and noData variants
|
|
138
|
-
// if (data === undefined) return {};
|
|
139
146
|
// The "chart" `noDataVariant` is only used when the `timeSeries` is an
|
|
140
147
|
// empty array because a `null` value will throw an error.
|
|
141
148
|
if (data === null || data.length === 0 && noDataVariant === 'message') return noDataOption;
|
|
@@ -173,14 +180,19 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
|
|
|
173
180
|
axisLabel: {
|
|
174
181
|
hideOverlap: true,
|
|
175
182
|
formatter: (0, _utils.getFormattedAxisLabel)((_rangeMs = timeScale.rangeMs) !== null && _rangeMs !== void 0 ? _rangeMs : 0)
|
|
183
|
+
},
|
|
184
|
+
axisPointer: {
|
|
185
|
+
snap: false
|
|
176
186
|
}
|
|
177
187
|
},
|
|
178
188
|
yAxis: (0, _utils.getYAxes)(yAxis, unit),
|
|
179
189
|
animation: false,
|
|
180
190
|
tooltip: {
|
|
181
191
|
show: true,
|
|
182
|
-
trigger: 'axis',
|
|
183
|
-
|
|
192
|
+
trigger: isStackedBar ? 'item' : 'axis',
|
|
193
|
+
// ECharts tooltip content hidden since we use custom tooltip instead
|
|
194
|
+
showContent: isStackedBar,
|
|
195
|
+
appendToBody: true
|
|
184
196
|
},
|
|
185
197
|
// https://echarts.apache.org/en/option.html#axisPointer
|
|
186
198
|
axisPointer: {
|
|
@@ -188,7 +200,7 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
|
|
|
188
200
|
z: 0,
|
|
189
201
|
triggerEmphasis: false,
|
|
190
202
|
triggerTooltip: false,
|
|
191
|
-
snap:
|
|
203
|
+
snap: false
|
|
192
204
|
},
|
|
193
205
|
toolbox: {
|
|
194
206
|
feature: {
|
|
@@ -204,6 +216,8 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
|
|
|
204
216
|
return __experimentalEChartsOptionsOverride(option);
|
|
205
217
|
}
|
|
206
218
|
return option;
|
|
219
|
+
// tooltipPinnedCoords is needed in dep array so crosshair stays beside pinned tooltip onClick
|
|
220
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
207
221
|
}, [
|
|
208
222
|
data,
|
|
209
223
|
seriesMapping,
|
|
@@ -214,13 +228,38 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
|
|
|
214
228
|
noDataOption,
|
|
215
229
|
__experimentalEChartsOptionsOverride,
|
|
216
230
|
noDataVariant,
|
|
217
|
-
timeZone
|
|
231
|
+
timeZone,
|
|
232
|
+
tooltipPinnedCoords,
|
|
233
|
+
isStackedBar
|
|
218
234
|
]);
|
|
219
235
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
220
236
|
sx: {
|
|
221
237
|
height
|
|
222
238
|
},
|
|
223
239
|
onClick: (e)=>{
|
|
240
|
+
var ref;
|
|
241
|
+
// Determine where on chart canvas to plot pinned crosshair as markLine.
|
|
242
|
+
const pointInGrid = (0, _utils.getPointInGrid)(e.nativeEvent.offsetX, e.nativeEvent.offsetY, chartRef.current);
|
|
243
|
+
if (pointInGrid === null) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
// Clear previously set pinned crosshair
|
|
247
|
+
const isCrosshairPinned = ((ref = seriesMapping[seriesMapping.length - 1]) === null || ref === void 0 ? void 0 : ref.name) === _graph.PINNED_CROSSHAIR_SERIES_NAME;
|
|
248
|
+
if (tooltipPinnedCoords !== null && isCrosshairPinned) {
|
|
249
|
+
seriesMapping.pop();
|
|
250
|
+
} else if (seriesMapping.length !== data.length + 1) {
|
|
251
|
+
// Only add pinned crosshair line series when there is not one already in seriesMapping.
|
|
252
|
+
const pinnedCrosshair = (0, _merge.default)(_graph.DEFAULT_PINNED_CROSSHAIR, {
|
|
253
|
+
markLine: {
|
|
254
|
+
data: [
|
|
255
|
+
{
|
|
256
|
+
xAxis: pointInGrid[0]
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
seriesMapping.push(pinnedCrosshair);
|
|
262
|
+
}
|
|
224
263
|
// Pin and unpin when clicking on chart canvas but not tooltip text.
|
|
225
264
|
if (e.target instanceof HTMLCanvasElement) {
|
|
226
265
|
setTooltipPinnedCoords((current)=>{
|
|
@@ -297,12 +336,18 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
|
|
|
297
336
|
},
|
|
298
337
|
children: [
|
|
299
338
|
showTooltip === true && ((ref1 = option.tooltip) === null || ref1 === void 0 ? void 0 : ref1.showContent) === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeSeriesTooltip.TimeChartTooltip, {
|
|
339
|
+
containerId: chartsTheme.tooltipPortalContainerId,
|
|
300
340
|
chartRef: chartRef,
|
|
301
341
|
data: data,
|
|
302
342
|
seriesMapping: seriesMapping,
|
|
303
343
|
wrapLabels: tooltipConfig.wrapLabels,
|
|
304
344
|
pinnedPos: tooltipPinnedCoords,
|
|
305
|
-
unit: unit
|
|
345
|
+
unit: unit,
|
|
346
|
+
onUnpinClick: ()=>{
|
|
347
|
+
setTooltipPinnedCoords(null);
|
|
348
|
+
// Clear previously set pinned crosshair
|
|
349
|
+
seriesMapping.pop();
|
|
350
|
+
}
|
|
306
351
|
}),
|
|
307
352
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_echart.EChart, {
|
|
308
353
|
sx: {
|
|
@@ -32,10 +32,11 @@ function _interopRequireDefault(obj) {
|
|
|
32
32
|
default: obj
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
const LineChartTooltip = /*#__PURE__*/ (0, _react.memo)(function LineChartTooltip({ chartRef , chartData , wrapLabels , unit , onUnpinClick , pinnedPos }) {
|
|
35
|
+
const LineChartTooltip = /*#__PURE__*/ (0, _react.memo)(function LineChartTooltip({ chartRef , chartData , wrapLabels , unit , onUnpinClick , pinnedPos , containerId }) {
|
|
36
36
|
const [showAllSeries, setShowAllSeries] = (0, _react.useState)(false);
|
|
37
37
|
const mousePos = (0, _tooltipModel.useMousePosition)();
|
|
38
38
|
const { height , width , ref: tooltipRef } = (0, _useResizeObserver.default)();
|
|
39
|
+
const transform = (0, _react.useRef)('');
|
|
39
40
|
const isTooltipPinned = pinnedPos !== null;
|
|
40
41
|
if (mousePos === null || mousePos.target === null) return null;
|
|
41
42
|
// Ensure user is hovering over a chart before checking for nearby series.
|
|
@@ -43,7 +44,6 @@ const LineChartTooltip = /*#__PURE__*/ (0, _react.memo)(function LineChartToolti
|
|
|
43
44
|
const chart = chartRef.current;
|
|
44
45
|
var ref;
|
|
45
46
|
const chartWidth = (ref = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && ref !== void 0 ? ref : _tooltipModel.FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
|
|
46
|
-
const cursorTransform = (0, _utils.assembleTransform)(mousePos, chartWidth, pinnedPos, height !== null && height !== void 0 ? height : 0, width !== null && width !== void 0 ? width : 0);
|
|
47
47
|
// Get series nearby the cursor and pass into tooltip content children.
|
|
48
48
|
const nearbySeries = (0, _nearbySeries.legacyGetNearbySeriesData)({
|
|
49
49
|
mousePos,
|
|
@@ -57,8 +57,15 @@ const LineChartTooltip = /*#__PURE__*/ (0, _react.memo)(function LineChartToolti
|
|
|
57
57
|
return null;
|
|
58
58
|
}
|
|
59
59
|
const totalSeries = chartData.timeSeries.length;
|
|
60
|
+
const containerElement = containerId ? document.querySelector(containerId) : undefined;
|
|
61
|
+
// if tooltip is attached to a container, set max height to the height of the container so tooltip does not get cut off
|
|
62
|
+
const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;
|
|
63
|
+
if (!isTooltipPinned) {
|
|
64
|
+
transform.current = (0, _utils.assembleTransform)(mousePos, chartWidth, pinnedPos, height !== null && height !== void 0 ? height : 0, width !== null && width !== void 0 ? width : 0, containerElement);
|
|
65
|
+
}
|
|
60
66
|
var ref1;
|
|
61
67
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Portal, {
|
|
68
|
+
container: containerElement,
|
|
62
69
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
63
70
|
ref: tooltipRef,
|
|
64
71
|
sx: (theme)=>{
|
|
@@ -66,7 +73,7 @@ const LineChartTooltip = /*#__PURE__*/ (0, _react.memo)(function LineChartToolti
|
|
|
66
73
|
return {
|
|
67
74
|
minWidth: _tooltipModel.TOOLTIP_MIN_WIDTH,
|
|
68
75
|
maxWidth: _tooltipModel.TOOLTIP_MAX_WIDTH,
|
|
69
|
-
maxHeight: _tooltipModel.TOOLTIP_MAX_HEIGHT,
|
|
76
|
+
maxHeight: maxHeight !== null && maxHeight !== void 0 ? maxHeight : _tooltipModel.TOOLTIP_MAX_HEIGHT,
|
|
70
77
|
padding: 0,
|
|
71
78
|
position: 'absolute',
|
|
72
79
|
top: 0,
|
|
@@ -87,7 +94,7 @@ const LineChartTooltip = /*#__PURE__*/ (0, _react.memo)(function LineChartToolti
|
|
|
87
94
|
};
|
|
88
95
|
},
|
|
89
96
|
style: {
|
|
90
|
-
transform:
|
|
97
|
+
transform: transform.current
|
|
91
98
|
},
|
|
92
99
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
93
100
|
spacing: 0.5,
|
|
@@ -32,8 +32,9 @@ function _interopRequireDefault(obj) {
|
|
|
32
32
|
default: obj
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
const TimeChartTooltip = /*#__PURE__*/ (0, _react.memo)(function TimeChartTooltip({ chartRef , data , seriesMapping , wrapLabels , unit , onUnpinClick , pinnedPos }) {
|
|
35
|
+
const TimeChartTooltip = /*#__PURE__*/ (0, _react.memo)(function TimeChartTooltip({ containerId , chartRef , data , seriesMapping , wrapLabels , unit , onUnpinClick , pinnedPos }) {
|
|
36
36
|
const [showAllSeries, setShowAllSeries] = (0, _react.useState)(false);
|
|
37
|
+
const transform = (0, _react.useRef)('');
|
|
37
38
|
const mousePos = (0, _tooltipModel.useMousePosition)();
|
|
38
39
|
const { height , width , ref: tooltipRef } = (0, _useResizeObserver.default)();
|
|
39
40
|
const isTooltipPinned = pinnedPos !== null;
|
|
@@ -43,7 +44,12 @@ const TimeChartTooltip = /*#__PURE__*/ (0, _react.memo)(function TimeChartToolti
|
|
|
43
44
|
const chart = chartRef.current;
|
|
44
45
|
var ref;
|
|
45
46
|
const chartWidth = (ref = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && ref !== void 0 ? ref : _tooltipModel.FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
|
|
46
|
-
const
|
|
47
|
+
const containerElement = containerId ? document.querySelector(containerId) : undefined;
|
|
48
|
+
// if tooltip is attached to a container, set max height to the height of the container so tooltip does not get cut off
|
|
49
|
+
const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;
|
|
50
|
+
if (!isTooltipPinned) {
|
|
51
|
+
transform.current = (0, _utils.assembleTransform)(mousePos, chartWidth, pinnedPos, height !== null && height !== void 0 ? height : 0, width !== null && width !== void 0 ? width : 0, containerElement);
|
|
52
|
+
}
|
|
47
53
|
// Get series nearby the cursor and pass into tooltip content children.
|
|
48
54
|
const nearbySeries = (0, _nearbySeries.getNearbySeriesData)({
|
|
49
55
|
mousePos,
|
|
@@ -59,11 +65,12 @@ const TimeChartTooltip = /*#__PURE__*/ (0, _react.memo)(function TimeChartToolti
|
|
|
59
65
|
}
|
|
60
66
|
const totalSeries = data.length;
|
|
61
67
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Portal, {
|
|
68
|
+
container: containerElement,
|
|
62
69
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
63
70
|
ref: tooltipRef,
|
|
64
|
-
sx: (theme)=>(0, _utils.getTooltipStyles)(theme, pinnedPos),
|
|
71
|
+
sx: (theme)=>(0, _utils.getTooltipStyles)(theme, pinnedPos, maxHeight),
|
|
65
72
|
style: {
|
|
66
|
-
transform:
|
|
73
|
+
transform: transform.current
|
|
67
74
|
},
|
|
68
75
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
69
76
|
spacing: 0.5,
|
|
@@ -61,6 +61,7 @@ const TooltipHeader = /*#__PURE__*/ (0, _react.memo)(function TooltipHeader({ ne
|
|
|
61
61
|
};
|
|
62
62
|
// TODO: accurately calc whether more series are outside scrollable region using yBuffer, avg series name length, TOOLTIP_MAX_HEIGHT
|
|
63
63
|
const showAllSeriesToggle = totalSeries > 5;
|
|
64
|
+
const pinTooltipHelpText = isTooltipPinned ? 'Click to unpin' : 'Click chart to pin';
|
|
64
65
|
var ref2;
|
|
65
66
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
66
67
|
sx: (theme)=>{
|
|
@@ -130,16 +131,13 @@ const TooltipHeader = /*#__PURE__*/ (0, _react.memo)(function TooltipHeader({ ne
|
|
|
130
131
|
direction: "row",
|
|
131
132
|
alignItems: "center",
|
|
132
133
|
children: [
|
|
133
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
134
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
134
135
|
sx: {
|
|
135
136
|
marginRight: 0.5,
|
|
136
137
|
fontSize: 11,
|
|
137
138
|
verticalAlign: 'middle'
|
|
138
139
|
},
|
|
139
|
-
children:
|
|
140
|
-
"Click to ",
|
|
141
|
-
isTooltipPinned ? 'Unpin' : 'Pin'
|
|
142
|
-
]
|
|
140
|
+
children: pinTooltipHelpText
|
|
143
141
|
}),
|
|
144
142
|
isTooltipPinned ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pin.default, {
|
|
145
143
|
onClick: ()=>{
|