@perses-dev/components 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/ECharts.d.ts +59 -0
  2. package/dist/ECharts.d.ts.map +1 -0
  3. package/dist/ECharts.js +1 -0
  4. package/dist/GaugeChart.d.ts +14 -0
  5. package/dist/GaugeChart.d.ts.map +1 -0
  6. package/dist/GaugeChart.js +1 -0
  7. package/dist/LineChart.d.ts +22 -0
  8. package/dist/LineChart.d.ts.map +1 -0
  9. package/dist/LineChart.js +1 -0
  10. package/dist/StatChart.d.ts +24 -0
  11. package/dist/StatChart.d.ts.map +1 -0
  12. package/dist/StatChart.js +1 -0
  13. package/dist/cjs/ECharts.js +103 -0
  14. package/dist/cjs/ErrorAlert.js +25 -0
  15. package/dist/cjs/ErrorBoundary.js +18 -0
  16. package/dist/cjs/GaugeChart.js +178 -0
  17. package/dist/cjs/LineChart.js +227 -0
  18. package/dist/cjs/StatChart.js +205 -0
  19. package/dist/cjs/index.js +37 -0
  20. package/dist/cjs/model/graph-model.js +16 -0
  21. package/dist/cjs/model/units.js +211 -0
  22. package/dist/cjs/tooltip/SeriesInfo.js +76 -0
  23. package/dist/cjs/tooltip/SeriesMarker.js +30 -0
  24. package/dist/cjs/tooltip/Tooltip.js +99 -0
  25. package/dist/cjs/tooltip/TooltipContent.js +50 -0
  26. package/dist/cjs/tooltip/focused-series.js +108 -0
  27. package/dist/cjs/tooltip/tooltip-model.js +82 -0
  28. package/dist/cjs/utils/combine-sx.js +30 -0
  29. package/dist/index.d.ts +6 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +1 -1
  32. package/dist/model/graph-model.d.ts +13 -0
  33. package/dist/model/graph-model.d.ts.map +1 -0
  34. package/dist/model/graph-model.js +1 -0
  35. package/dist/model/units.d.ts +25 -0
  36. package/dist/model/units.d.ts.map +1 -0
  37. package/dist/model/units.js +1 -0
  38. package/dist/tooltip/SeriesInfo.d.ts +11 -0
  39. package/dist/tooltip/SeriesInfo.d.ts.map +1 -0
  40. package/dist/tooltip/SeriesInfo.js +1 -0
  41. package/dist/tooltip/SeriesMarker.d.ts +7 -0
  42. package/dist/tooltip/SeriesMarker.d.ts.map +1 -0
  43. package/dist/tooltip/SeriesMarker.js +1 -0
  44. package/dist/tooltip/Tooltip.d.ts +13 -0
  45. package/dist/tooltip/Tooltip.d.ts.map +1 -0
  46. package/dist/tooltip/Tooltip.js +1 -0
  47. package/dist/tooltip/TooltipContent.d.ts +9 -0
  48. package/dist/tooltip/TooltipContent.d.ts.map +1 -0
  49. package/dist/tooltip/TooltipContent.js +1 -0
  50. package/dist/tooltip/focused-series.d.ts +24 -0
  51. package/dist/tooltip/focused-series.d.ts.map +1 -0
  52. package/dist/tooltip/focused-series.js +1 -0
  53. package/dist/tooltip/tooltip-model.d.ts +79 -0
  54. package/dist/tooltip/tooltip-model.d.ts.map +1 -0
  55. package/dist/tooltip/tooltip-model.js +1 -0
  56. package/package.json +7 -3
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SeriesInfo = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ // Copyright 2021 The Perses Authors
6
+ // Licensed under the Apache License, Version 2.0 (the "License");
7
+ // you may not use this file except in compliance with the License.
8
+ // You may obtain a copy of the License at
9
+ //
10
+ // http://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing, software
13
+ // distributed under the License is distributed on an "AS IS" BASIS,
14
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ // See the License for the specific language governing permissions and
16
+ // limitations under the License.
17
+ const material_1 = require("@mui/material");
18
+ const SeriesMarker_1 = require("./SeriesMarker");
19
+ const tooltip_model_1 = require("./tooltip-model");
20
+ function SeriesInfo(props) {
21
+ const { seriesName, y, markerColor, totalSeries, wrapLabels } = props;
22
+ // TODO (sjcobb): regex to remove __name__, improve series labels
23
+ const formattedSeriesLabels = seriesName.replace(/[{}"]/g, '');
24
+ if (totalSeries === 1) {
25
+ const jsonFormattedSeries = seriesName[0] === '{' ? true : false;
26
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 0.5, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: (theme) => ({
27
+ height: '16px',
28
+ display: 'flex',
29
+ flexDirection: 'row',
30
+ alignItems: 'center',
31
+ justifyContent: 'left',
32
+ color: theme.palette.common.white,
33
+ fontSize: '11px',
34
+ }), children: [(0, jsx_runtime_1.jsx)(SeriesMarker_1.SeriesMarker, { markerColor: markerColor }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", children: ["value:", (0, jsx_runtime_1.jsx)(material_1.Box, { component: "span", sx: (theme) => ({
35
+ color: theme.palette.common.white,
36
+ fontWeight: 700,
37
+ paddingLeft: '2px',
38
+ }), children: y })] })] }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: (theme) => ({
39
+ borderColor: theme.palette.grey['500'],
40
+ }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: (theme) => ({
41
+ color: theme.palette.common.white,
42
+ }), children: formattedSeriesLabels.split(',').map((name) => {
43
+ if (name) {
44
+ const [key, value] = jsonFormattedSeries ? name.split(':') : name.split('=');
45
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: '4px' }, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { sx: { fontSize: '11px' }, children: [key, ":"] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { sx: (theme) => ({
46
+ color: theme.palette.common.white,
47
+ fontWeight: 700,
48
+ fontSize: '11px',
49
+ }), children: value })] }, name));
50
+ }
51
+ }) })] }));
52
+ }
53
+ const inlineSeriesLabels = formattedSeriesLabels.replace(/[,]/g, ', ').replace(/[:=]/g, ': ');
54
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
55
+ display: 'table-row',
56
+ paddingTop: 0.5,
57
+ }, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
58
+ display: 'table-cell',
59
+ maxWidth: '520px',
60
+ }, children: [(0, jsx_runtime_1.jsx)(SeriesMarker_1.SeriesMarker, { markerColor: markerColor }), (0, jsx_runtime_1.jsx)(material_1.Box, { component: "span", sx: (theme) => ({
61
+ color: theme.palette.common.white,
62
+ display: 'inline-block',
63
+ maxWidth: tooltip_model_1.TOOLTIP_LABELS_MAX_WIDTH,
64
+ overflow: 'hidden',
65
+ textOverflow: 'ellipsis',
66
+ whiteSpace: wrapLabels ? 'normal' : 'nowrap',
67
+ width: 'calc(100% - 20px)',
68
+ }), children: inlineSeriesLabels })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
69
+ display: 'table-cell',
70
+ fontWeight: '700',
71
+ paddingLeft: 1.5,
72
+ textAlign: 'right',
73
+ verticalAlign: 'top',
74
+ }, children: y })] }));
75
+ }
76
+ exports.SeriesInfo = SeriesInfo;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SeriesMarker = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ // Copyright 2021 The Perses Authors
6
+ // Licensed under the Apache License, Version 2.0 (the "License");
7
+ // you may not use this file except in compliance with the License.
8
+ // You may obtain a copy of the License at
9
+ //
10
+ // http://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing, software
13
+ // distributed under the License is distributed on an "AS IS" BASIS,
14
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ // See the License for the specific language governing permissions and
16
+ // limitations under the License.
17
+ const material_1 = require("@mui/material");
18
+ function SeriesMarker(props) {
19
+ const { markerColor } = props;
20
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
21
+ display: 'inline-block',
22
+ width: '12px',
23
+ borderRadius: '2px',
24
+ height: '12px',
25
+ marginTop: 0.25,
26
+ marginRight: 1,
27
+ verticalAlign: 'top',
28
+ }, style: { backgroundColor: markerColor } }));
29
+ }
30
+ exports.SeriesMarker = SeriesMarker;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tooltip = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ // Copyright 2021 The Perses Authors
6
+ // Licensed under the Apache License, Version 2.0 (the "License");
7
+ // you may not use this file except in compliance with the License.
8
+ // You may obtain a copy of the License at
9
+ //
10
+ // http://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing, software
13
+ // distributed under the License is distributed on an "AS IS" BASIS,
14
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ // See the License for the specific language governing permissions and
16
+ // limitations under the License.
17
+ const react_1 = require("react");
18
+ const material_1 = require("@mui/material");
19
+ const focused_series_1 = require("./focused-series");
20
+ const tooltip_model_1 = require("./tooltip-model");
21
+ const TooltipContent_1 = require("./TooltipContent");
22
+ function Tooltip(props) {
23
+ var _a, _b;
24
+ const { chartRef, chartData } = props;
25
+ const [pinnedPos, setPinnedPos] = (0, react_1.useState)(null);
26
+ const mousePos = (0, tooltip_model_1.useMousePosition)();
27
+ if (mousePos === null)
28
+ return null;
29
+ const chart = chartRef.current;
30
+ const focusedSeries = (0, focused_series_1.getFocusedSeriesData)(mousePos, chartData, pinnedPos, chart);
31
+ const chartWidth = (_a = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && _a !== void 0 ? _a : 750;
32
+ const chartHeight = (_b = chart === null || chart === void 0 ? void 0 : chart.getHeight()) !== null && _b !== void 0 ? _b : 230;
33
+ const cursorTransform = assembleTransform(mousePos, focusedSeries.length, chartWidth, chartHeight, pinnedPos);
34
+ function handleMouseEnter() {
35
+ if (mousePos !== null) {
36
+ setPinnedPos(mousePos);
37
+ }
38
+ }
39
+ function handleMouseLeave() {
40
+ if (pinnedPos !== null) {
41
+ setPinnedPos(null);
42
+ }
43
+ }
44
+ if (focusedSeries.length === 0) {
45
+ return null;
46
+ }
47
+ return ((0, jsx_runtime_1.jsx)(material_1.Portal, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: (theme) => ({
48
+ maxWidth: tooltip_model_1.TOOLTIP_MAX_WIDTH,
49
+ maxHeight: tooltip_model_1.TOOLTIP_MAX_HEIGHT,
50
+ position: 'absolute',
51
+ top: 0,
52
+ left: 0,
53
+ overflowY: 'scroll',
54
+ backgroundColor: '#000',
55
+ borderRadius: '6px',
56
+ color: '#fff',
57
+ fontSize: '11px',
58
+ visibility: 'visible',
59
+ opacity: 1,
60
+ transition: 'all 0.1s ease-out',
61
+ zIndex: theme.zIndex.tooltip,
62
+ }), style: {
63
+ transform: cursorTransform,
64
+ }, onMouseEnter: () => handleMouseEnter(), onMouseLeave: () => handleMouseLeave(), children: (0, jsx_runtime_1.jsx)(TooltipContent_1.TooltipContent, { focusedSeries: focusedSeries, wrapLabels: props.wrapLabels }) }) }));
65
+ }
66
+ exports.Tooltip = Tooltip;
67
+ function assembleTransform(mousePos, seriesNum, chartWidth, chartHeight, pinnedPos) {
68
+ if (mousePos === null) {
69
+ return 'translate3d(0, 0)';
70
+ }
71
+ if (pinnedPos !== null) {
72
+ mousePos = pinnedPos;
73
+ }
74
+ const cursorPaddingX = 32;
75
+ const cursorPaddingY = 16;
76
+ const x = mousePos.viewport.x;
77
+ let y = mousePos.viewport.y + cursorPaddingY;
78
+ const isCloseToBottom = mousePos.viewport.y > window.innerHeight * 0.8;
79
+ const yPosAdjustThreshold = chartHeight * 0.75;
80
+ // adjust so tooltip does not get cut off at bottom of chart, reduce multiplier to move up
81
+ if (isCloseToBottom === true) {
82
+ if (seriesNum > 6) {
83
+ y = mousePos.viewport.y * 0.65;
84
+ }
85
+ else {
86
+ y = mousePos.viewport.y * 0.75;
87
+ }
88
+ }
89
+ else if (mousePos.plotCanvas.y > yPosAdjustThreshold) {
90
+ y = mousePos.viewport.y * 0.85;
91
+ }
92
+ // use tooltip width to determine when to repos from right to left (width is narrower when only 1 focused series since labels wrap)
93
+ const tooltipWidth = seriesNum > 1 ? tooltip_model_1.TOOLTIP_MAX_WIDTH : tooltip_model_1.TOOLTIP_MAX_WIDTH / 2;
94
+ const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;
95
+ // reposition so tooltip is never too close to right side of chart or left side of browser window
96
+ return mousePos.plotCanvas.x > xPosAdjustThreshold && x > tooltip_model_1.TOOLTIP_MAX_WIDTH
97
+ ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)`
98
+ : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;
99
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TooltipContent = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ // Copyright 2021 The Perses Authors
6
+ // Licensed under the Apache License, Version 2.0 (the "License");
7
+ // you may not use this file except in compliance with the License.
8
+ // You may obtain a copy of the License at
9
+ //
10
+ // http://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing, software
13
+ // distributed under the License is distributed on an "AS IS" BASIS,
14
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ // See the License for the specific language governing permissions and
16
+ // limitations under the License.
17
+ const react_1 = require("react");
18
+ const material_1 = require("@mui/material");
19
+ const SeriesInfo_1 = require("./SeriesInfo");
20
+ function TooltipContent(props) {
21
+ const { focusedSeries, wrapLabels } = props;
22
+ const seriesTime = focusedSeries && focusedSeries[0] && focusedSeries[0].date ? focusedSeries[0].date : null;
23
+ const formatTimeSeriesHeader = (timeString) => {
24
+ const [month, year, time] = timeString.split(',');
25
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", sx: (theme) => ({
26
+ color: theme.palette.common.white,
27
+ }), children: [month, ", ", year, " \u2013"] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", children: (0, jsx_runtime_1.jsx)("strong", { children: time }) })] }));
28
+ };
29
+ const sortedFocusedSeries = (0, react_1.useMemo)(() => {
30
+ if (focusedSeries === null)
31
+ return null;
32
+ return focusedSeries.sort((a, b) => (a.y > b.y ? -1 : 1));
33
+ }, [focusedSeries]);
34
+ if (sortedFocusedSeries !== null && seriesTime !== null) {
35
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { py: 1, px: 1.5, spacing: 0.5, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", children: formatTimeSeriesHeader(seriesTime) }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: (theme) => ({
36
+ borderColor: theme.palette.grey['500'],
37
+ }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
38
+ display: 'table',
39
+ }, children: sortedFocusedSeries.map(({ datumIdx, seriesIdx, seriesName, y, markerColor }) => {
40
+ if (datumIdx === null || seriesIdx === null)
41
+ return null;
42
+ const key = seriesIdx.toString() + datumIdx.toString();
43
+ return ((0, jsx_runtime_1.jsx)(SeriesInfo_1.SeriesInfo, { seriesName: seriesName, y: y, markerColor: markerColor, totalSeries: sortedFocusedSeries.length, wrapLabels: wrapLabels }, key));
44
+ }) })] }));
45
+ }
46
+ else {
47
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
48
+ }
49
+ }
50
+ exports.TooltipContent = TooltipContent;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ // Copyright 2021 The Perses Authors
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getFocusedSeriesData = exports.getNearbySeries = void 0;
16
+ const tooltip_model_1 = require("./tooltip-model");
17
+ /**
18
+ * Returns formatted series data for the points that are close to the user's cursor
19
+ * Adjust yBuffer to increase or decrease number of series shown
20
+ */
21
+ function getNearbySeries(data, pointInGrid, yBuffer) {
22
+ var _a, _b, _c, _d, _e;
23
+ const currentFocusedData = [];
24
+ const focusedX = (_a = pointInGrid[0]) !== null && _a !== void 0 ? _a : null;
25
+ const focusedY = (_b = pointInGrid[1]) !== null && _b !== void 0 ? _b : null;
26
+ if (focusedX === null || focusedY === null) {
27
+ return currentFocusedData;
28
+ }
29
+ if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {
30
+ for (let seriesIdx = 0; seriesIdx < data.timeSeries.length; seriesIdx++) {
31
+ const currentSeries = data.timeSeries[seriesIdx];
32
+ if (currentFocusedData.length > tooltip_model_1.TOOLTIP_MAX_ITEMS)
33
+ break;
34
+ if (currentSeries !== undefined) {
35
+ const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';
36
+ const markerColor = (_c = currentSeries.color) !== null && _c !== void 0 ? _c : '#000';
37
+ if (Array.isArray(currentSeries.data)) {
38
+ for (let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++) {
39
+ const xValue = (_d = data.xAxis[datumIdx]) !== null && _d !== void 0 ? _d : 0;
40
+ const yValue = (_e = currentSeries.data[datumIdx]) !== null && _e !== void 0 ? _e : 0;
41
+ if (focusedX === datumIdx) {
42
+ if (yValue !== '-' && focusedY <= yValue + yBuffer && focusedY >= yValue - yBuffer) {
43
+ const formattedDate = tooltip_model_1.TOOLTIP_DATE_FORMAT.format(xValue * 1000);
44
+ currentFocusedData.push({
45
+ seriesIdx: seriesIdx,
46
+ datumIdx: datumIdx,
47
+ seriesName: currentSeriesName,
48
+ date: formattedDate,
49
+ x: xValue,
50
+ y: yValue,
51
+ markerColor: markerColor.toString(),
52
+ });
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ return currentFocusedData;
61
+ }
62
+ exports.getNearbySeries = getNearbySeries;
63
+ /**
64
+ * Uses mouse position to determine whether user is hovering over a chart canvas
65
+ * If yes, convert from pixel values to logical cartesian coordinates and return all focused series
66
+ */
67
+ function getFocusedSeriesData(mousePos, chartData, pinnedPos, chart) {
68
+ var _a, _b;
69
+ if (chart === undefined || mousePos === null)
70
+ return [];
71
+ // prevents multiple tooltips showing from adjacent charts
72
+ let cursorTargetMatchesChart = false;
73
+ if (mousePos.target !== null) {
74
+ const currentParent = mousePos.target.parentElement;
75
+ if (currentParent !== null) {
76
+ const currentGrandparent = currentParent.parentElement;
77
+ if (currentGrandparent !== null) {
78
+ const chartDom = chart.getDom();
79
+ if (chartDom === currentGrandparent) {
80
+ cursorTargetMatchesChart = true;
81
+ }
82
+ }
83
+ }
84
+ }
85
+ // allows moving cursor inside tooltip
86
+ if (pinnedPos !== null) {
87
+ mousePos = pinnedPos;
88
+ cursorTargetMatchesChart = true;
89
+ }
90
+ if (cursorTargetMatchesChart === false)
91
+ return [];
92
+ if (chart['_model'] === undefined)
93
+ return [];
94
+ const chartModel = chart['_model'];
95
+ const yAxisInterval = chartModel.getComponent('yAxis').axis.scale._interval;
96
+ const seriesNum = chartData.timeSeries.length;
97
+ // tooltip trigger area gets smaller with more series
98
+ const yBuffer = seriesNum > tooltip_model_1.TOOLTIP_MAX_ITEMS ? yAxisInterval * 0.5 : yAxisInterval * 2;
99
+ const pointInPixel = [(_a = mousePos.plotCanvas.x) !== null && _a !== void 0 ? _a : 0, (_b = mousePos.plotCanvas.y) !== null && _b !== void 0 ? _b : 0];
100
+ if (chart.containPixel('grid', pointInPixel)) {
101
+ const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
102
+ if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
103
+ return getNearbySeries(chartData, pointInGrid, yBuffer);
104
+ }
105
+ }
106
+ return [];
107
+ }
108
+ exports.getFocusedSeriesData = getFocusedSeriesData;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ // Copyright 2021 The Perses Authors
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.useMousePosition = exports.emptyTooltipData = exports.defaultCursorData = exports.TOOLTIP_DATE_FORMAT = exports.TOOLTIP_MAX_ITEMS = exports.TOOLTIP_LABELS_MAX_WIDTH = exports.TOOLTIP_MAX_HEIGHT = exports.TOOLTIP_MAX_WIDTH = void 0;
16
+ const react_1 = require("react");
17
+ exports.TOOLTIP_MAX_WIDTH = 650;
18
+ exports.TOOLTIP_MAX_HEIGHT = 230;
19
+ exports.TOOLTIP_LABELS_MAX_WIDTH = exports.TOOLTIP_MAX_WIDTH - 150;
20
+ exports.TOOLTIP_MAX_ITEMS = 50;
21
+ exports.TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {
22
+ year: 'numeric',
23
+ month: 'short',
24
+ day: 'numeric',
25
+ hour: 'numeric',
26
+ minute: 'numeric',
27
+ second: 'numeric',
28
+ hour12: true,
29
+ });
30
+ exports.defaultCursorData = {
31
+ coords: {
32
+ viewport: {
33
+ x: 0,
34
+ y: 0,
35
+ },
36
+ plotCanvas: {
37
+ x: 0,
38
+ y: 0,
39
+ },
40
+ zrender: {
41
+ x: 0,
42
+ y: 0,
43
+ },
44
+ target: null,
45
+ },
46
+ chartWidth: 0,
47
+ };
48
+ exports.emptyTooltipData = {
49
+ cursor: exports.defaultCursorData,
50
+ focusedSeries: null,
51
+ };
52
+ const useMousePosition = () => {
53
+ const [coords, setCoords] = (0, react_1.useState)(null);
54
+ (0, react_1.useEffect)(() => {
55
+ const setFromEvent = (e) => {
56
+ return setCoords({
57
+ viewport: {
58
+ x: e.clientX,
59
+ y: e.clientY,
60
+ },
61
+ plotCanvas: {
62
+ x: e.offsetX,
63
+ y: e.offsetY,
64
+ },
65
+ zrender: {
66
+ // echarts canvas coordinates added automatically by zrender
67
+ // zrX and zrY are similar to offsetX and offsetY but they return undefined when not hovering over a chart canvas
68
+ x: e.zrX,
69
+ y: e.zrY,
70
+ },
71
+ // necessary to check whether cursor target matches correct chart canvas (since each chart has its own mousemove listener)
72
+ target: e.target,
73
+ });
74
+ };
75
+ window.addEventListener('mousemove', setFromEvent);
76
+ return () => {
77
+ window.removeEventListener('mousemove', setFromEvent);
78
+ };
79
+ }, []);
80
+ return coords;
81
+ };
82
+ exports.useMousePosition = useMousePosition;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ // Copyright 2021 The Perses Authors
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.combineSx = void 0;
16
+ /**
17
+ * Combines sx props from multiple sources. Useful when creating a component and
18
+ * you want consumers to be able to provide SxProps that should be combined with
19
+ * some built-in styles.
20
+ */
21
+ function combineSx(...sxProps) {
22
+ return sxProps.flatMap((sx) => {
23
+ if (sx === undefined)
24
+ return [];
25
+ if (Array.isArray(sx))
26
+ return sx;
27
+ return [sx];
28
+ });
29
+ }
30
+ exports.combineSx = combineSx;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,10 @@
1
+ export * from './ECharts';
1
2
  export * from './ErrorAlert';
2
3
  export * from './ErrorBoundary';
4
+ export * from './GaugeChart';
5
+ export * from './LineChart';
6
+ export * from './StatChart';
3
7
  export * from './utils/combine-sx';
8
+ export * from './model/graph-model';
9
+ export * from './model/units';
4
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export*from"./ErrorAlert";export*from"./ErrorBoundary";export*from"./utils/combine-sx";
1
+ export*from"./ECharts";export*from"./ErrorAlert";export*from"./ErrorBoundary";export*from"./GaugeChart";export*from"./LineChart";export*from"./StatChart";export*from"./utils/combine-sx";export*from"./model/graph-model";export*from"./model/units";
@@ -0,0 +1,13 @@
1
+ import { LineSeriesOption } from 'echarts/charts';
2
+ export declare const PROGRESSIVE_MODE_SERIES_LIMIT = 500;
3
+ export declare type UnixTimeMs = number;
4
+ export declare type GraphSeriesValueTuple = [timestamp: UnixTimeMs, value: number];
5
+ export declare type EChartsValues = number | null | '-';
6
+ export interface EChartsTimeSeries extends Omit<LineSeriesOption, 'data'> {
7
+ data: Iterable<GraphSeriesValueTuple> | EChartsValues[];
8
+ }
9
+ export declare type EChartsDataFormat = {
10
+ timeSeries: EChartsTimeSeries[];
11
+ xAxis: number[];
12
+ };
13
+ //# sourceMappingURL=graph-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-model.d.ts","sourceRoot":"","sources":["../../src/model/graph-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD,oBAAY,UAAU,GAAG,MAAM,CAAC;AAEhC,oBAAY,qBAAqB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAE3E,oBAAY,aAAa,GAAG,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC;AAEhD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAEvE,IAAI,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GAAG,aAAa,EAAE,CAAC;CACzD;AAED,oBAAY,iBAAiB,GAAG;IAC9B,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC"}
@@ -0,0 +1 @@
1
+ export const PROGRESSIVE_MODE_SERIES_LIMIT=500;
@@ -0,0 +1,25 @@
1
+ export declare type UnitOptions = TimeUnitOptions | PercentUnitOptions | DecimalUnitOptions;
2
+ export declare function formatValue(value: number, unitOptions?: UnitOptions): string;
3
+ declare const timeUnitKinds: readonly ["Milliseconds", "Seconds", "Minutes", "Hours", "Days", "Weeks", "Months", "Years"];
4
+ declare type TimeUnitOptions = {
5
+ kind: typeof timeUnitKinds[number];
6
+ };
7
+ declare const percentUnitKinds: readonly ["Percent", "PercentDecimal"];
8
+ declare type PercentUnitOptions = {
9
+ kind: typeof percentUnitKinds[number];
10
+ decimal_places: number;
11
+ };
12
+ declare const decimalUnitKinds: readonly ["Decimal"];
13
+ declare type DecimalUnitOptions = {
14
+ kind: typeof decimalUnitKinds[number];
15
+ decimal_places: number;
16
+ suffix?: 'string';
17
+ unitDisplay?: 'short' | 'long' | 'narrow';
18
+ };
19
+ export declare function abbreviateLargeNumber(num: number): string | number;
20
+ export declare function isSanctionedSimpleUnitIdentifier(unitIdentifier: string): boolean;
21
+ export declare const SANCTIONED_UNITS: string[];
22
+ export declare function removeUnitNamespace(unit: string): string;
23
+ export declare const SIMPLE_UNITS: string[];
24
+ export {};
25
+ //# sourceMappingURL=units.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/model/units.ts"],"names":[],"mappings":"AAeA,oBAAY,WAAW,GAAG,eAAe,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAEpF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAmB5E;AAED,QAAA,MAAM,aAAa,8FAA+F,CAAC;AAGnH,aAAK,eAAe,GAAG;IACrB,IAAI,EAAE,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;CACpC,CAAC;AA0EF,QAAA,MAAM,gBAAgB,wCAAyC,CAAC;AAGhE,aAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtC,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAcF,QAAA,MAAM,gBAAgB,sBAAuB,CAAC;AAG9C,aAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;CAC3C,CAAC;AAkCF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,mBAUhD;AAGD,wBAAgB,gCAAgC,CAAC,cAAc,EAAE,MAAM,WAEtE;AAGD,eAAO,MAAM,gBAAgB,UA4C5B,CAAC;AAGF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,UAE/C;AAED,eAAO,MAAM,YAAY,UAA4C,CAAC"}
@@ -0,0 +1 @@
1
+ import{milliseconds}from"date-fns";export function formatValue(e,i){if(void 0===i)return e.toString();if(isTimeUnit(i))return formatTime(e,i);if(isPercentUnit(i))return formatPercent(e,i);if(isDecimalUnit(i))return formatDecimal(e,i);throw new Error(`Unknown unit options ${i}`)}const timeUnitKinds=["Milliseconds","Seconds","Minutes","Hours","Days","Weeks","Months","Years"],timeUnitKindsSet=new Set(timeUnitKinds);function isTimeUnit(e){return timeUnitKindsSet.has(e.kind)}function formatTime(e,i){const t={};switch(i.kind){case"Milliseconds":t.seconds=e/1e3;break;case"Seconds":t.seconds=e;break;case"Minutes":t.minutes=e;break;case"Hours":t.hours=e;break;case"Days":t.days=e;break;case"Weeks":t.weeks=e;break;case"Months":t.months=e;break;case"Years":t.years=e;break;default:const n=i.kind;throw new Error(`Unknown time unit type ${n}`)}const n=milliseconds(t),r=n/1e3;if(r<1)return`${n.toFixed()} milliseconds`;const a=r/60;if(a<1)return`${r.toFixed()} seconds`;const s=a/60;if(s<1)return`${a.toFixed()} minutes`;const o=s/24;if(o<1)return`${s.toFixed()} hours`;const c=o/7;if(c<1)return`${o.toFixed()} days`;const m=c/52;return m<1?`${c.toFixed()} weeks`:`${m.toFixed()} years`}const percentUnitKinds=["Percent","PercentDecimal"],percentUnitKindsSet=new Set(percentUnitKinds);function isPercentUnit(e){return percentUnitKindsSet.has(e.kind)}function formatPercent(e,i){return"PercentDecimal"===i.kind&&(e*=100),e.toFixed(i.decimal_places)+"%"}const decimalUnitKinds=["Decimal"],decimalUnitKindsSet=new Set(decimalUnitKinds);function isDecimalUnit(e){return decimalUnitKindsSet.has(e.kind)}function formatDecimal(e,i){var t,n;const r=null!==(t=i.decimal_places)&&void 0!==t?t:2;if(void 0!==i.suffix&&isSanctionedSimpleUnitIdentifier(i.suffix)){const t={style:"unit",minimumFractionDigits:0,maximumFractionDigits:r,useGrouping:!0,unit:i.suffix,unitDisplay:null!==(n=i.unitDisplay)&&void 0!==n?n:"narrow"};return new Intl.NumberFormat("en-US",t).format(e)}const a={style:"decimal",minimumFractionDigits:0,maximumFractionDigits:r,useGrouping:!0};return new Intl.NumberFormat("en-US",a).format(e)}export function abbreviateLargeNumber(e){return e>=1e12?e/1e12+"T":e>=1e9?e/1e9+"B":e>=1e6?e/1e6+"M":e>=1e3?e/1e3+"k":e}export function isSanctionedSimpleUnitIdentifier(e){return SIMPLE_UNITS.indexOf(e)>-1}export const SANCTIONED_UNITS=["angle-degree","area-acre","area-hectare","concentr-percent","digital-bit","digital-byte","digital-gigabit","digital-gigabyte","digital-kilobit","digital-kilobyte","digital-megabit","digital-megabyte","digital-petabyte","digital-terabit","digital-terabyte","duration-day","duration-hour","duration-millisecond","duration-minute","duration-month","duration-second","duration-week","duration-year","length-centimeter","length-foot","length-inch","length-kilometer","length-meter","length-mile-scandinavian","length-mile","length-millimeter","length-yard","mass-gram","mass-kilogram","mass-ounce","mass-pound","mass-stone","temperature-celsius","temperature-fahrenheit","volume-fluid-ounce","volume-gallon","volume-liter","volume-milliliter"];export function removeUnitNamespace(e){return e.slice(e.indexOf("-")+1)}export const SIMPLE_UNITS=SANCTIONED_UNITS.map(removeUnitNamespace);
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ interface SeriesInfoProps {
3
+ seriesName: string;
4
+ y: number;
5
+ markerColor: string;
6
+ totalSeries: number;
7
+ wrapLabels?: boolean;
8
+ }
9
+ export declare function SeriesInfo(props: SeriesInfoProps): JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=SeriesInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SeriesInfo.d.ts","sourceRoot":"","sources":["../../src/tooltip/SeriesInfo.tsx"],"names":[],"mappings":";AAiBA,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eAiHhD"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Box,Divider,Stack,Typography}from"@mui/material";import{SeriesMarker}from"./SeriesMarker";import{TOOLTIP_LABELS_MAX_WIDTH}from"./tooltip-model";export function SeriesInfo(e){const{seriesName:o,y:r,markerColor:t,totalSeries:i,wrapLabels:s}=e,l=o.replace(/[{}"]/g,"");if(1===i){const e="{"===o[0];return _jsxs(Stack,{spacing:.5,children:[_jsxs(Box,{sx:e=>({height:"16px",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"left",color:e.palette.common.white,fontSize:"11px"}),children:[_jsx(SeriesMarker,{markerColor:t}),_jsxs(Box,{component:"span",children:["value:",_jsx(Box,{component:"span",sx:e=>({color:e.palette.common.white,fontWeight:700,paddingLeft:"2px"}),children:r})]})]}),_jsx(Divider,{sx:e=>({borderColor:e.palette.grey[500]})}),_jsx(Box,{sx:e=>({color:e.palette.common.white}),children:l.split(",").map((o=>{if(o){const[r,t]=e?o.split(":"):o.split("=");return _jsxs(Box,{sx:{display:"flex",gap:"4px"},children:[_jsxs(Typography,{sx:{fontSize:"11px"},children:[r,":"]}),_jsx(Typography,{sx:e=>({color:e.palette.common.white,fontWeight:700,fontSize:"11px"}),children:t})]},o)}}))})]})}const n=l.replace(/[,]/g,", ").replace(/[:=]/g,": ");return _jsxs(Box,{sx:{display:"table-row",paddingTop:.5},children:[_jsxs(Box,{sx:{display:"table-cell",maxWidth:"520px"},children:[_jsx(SeriesMarker,{markerColor:t}),_jsx(Box,{component:"span",sx:e=>({color:e.palette.common.white,display:"inline-block",maxWidth:TOOLTIP_LABELS_MAX_WIDTH,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:s?"normal":"nowrap",width:"calc(100% - 20px)"}),children:n})]}),_jsx(Box,{sx:{display:"table-cell",fontWeight:"700",paddingLeft:1.5,textAlign:"right",verticalAlign:"top"},children:r})]})}
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ interface SeriesMarkerProps {
3
+ markerColor: string;
4
+ }
5
+ export declare function SeriesMarker(props: SeriesMarkerProps): JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=SeriesMarker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SeriesMarker.d.ts","sourceRoot":"","sources":["../../src/tooltip/SeriesMarker.tsx"],"names":[],"mappings":";AAeA,UAAU,iBAAiB;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eAgBpD"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{Box}from"@mui/material";export function SeriesMarker(r){const{markerColor:i}=r;return _jsx(Box,{sx:{display:"inline-block",width:"12px",borderRadius:"2px",height:"12px",marginTop:.25,marginRight:1,verticalAlign:"top"},style:{backgroundColor:i}})}
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { ECharts as EChartsInstance } from 'echarts/core';
3
+ import { EChartsDataFormat } from '../model/graph-model';
4
+ import { TooltipData } from './tooltip-model';
5
+ interface TooltipProps {
6
+ chartRef: React.MutableRefObject<EChartsInstance | undefined>;
7
+ tooltipData: TooltipData;
8
+ chartData: EChartsDataFormat;
9
+ wrapLabels?: boolean;
10
+ }
11
+ export declare function Tooltip(props: TooltipProps): JSX.Element | null;
12
+ export {};
13
+ //# sourceMappingURL=Tooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAGL,WAAW,EAIZ,MAAM,iBAAiB,CAAC;AAGzB,UAAU,YAAY;IACpB,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAC9D,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,sBAyD1C"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useState}from"react";import{Box,Portal}from"@mui/material";import{getFocusedSeriesData}from"./focused-series";import{TOOLTIP_MAX_HEIGHT,TOOLTIP_MAX_WIDTH,useMousePosition}from"./tooltip-model";import{TooltipContent}from"./TooltipContent";export function Tooltip(t){var o,e;const{chartRef:r,chartData:l}=t,[n,i]=useState(null),s=useMousePosition();if(null===s)return null;const a=r.current,u=getFocusedSeriesData(s,l,n,a),p=null!==(o=null==a?void 0:a.getWidth())&&void 0!==o?o:750,T=null!==(e=null==a?void 0:a.getHeight())&&void 0!==e?e:230,m=assembleTransform(s,u.length,p,T,n);return 0===u.length?null:_jsx(Portal,{children:_jsx(Box,{sx:t=>({maxWidth:TOOLTIP_MAX_WIDTH,maxHeight:TOOLTIP_MAX_HEIGHT,position:"absolute",top:0,left:0,overflowY:"scroll",backgroundColor:"#000",borderRadius:"6px",color:"#fff",fontSize:"11px",visibility:"visible",opacity:1,transition:"all 0.1s ease-out",zIndex:t.zIndex.tooltip}),style:{transform:m},onMouseEnter:()=>{null!==s&&i(s)},onMouseLeave:()=>{null!==n&&i(null)},children:_jsx(TooltipContent,{focusedSeries:u,wrapLabels:t.wrapLabels})})})}function assembleTransform(t,o,e,r,l){if(null===t)return"translate3d(0, 0)";null!==l&&(t=l);const n=t.viewport.x;let i=t.viewport.y+16;const s=.75*r;!0==t.viewport.y>.8*window.innerHeight?i=o>6?.65*t.viewport.y:.75*t.viewport.y:t.plotCanvas.y>s&&(i=.85*t.viewport.y);const a=e-.9*(o>1?TOOLTIP_MAX_WIDTH:TOOLTIP_MAX_WIDTH/2);return t.plotCanvas.x>a&&n>TOOLTIP_MAX_WIDTH?`translate3d(${n-32}px, ${i}px, 0) translateX(-100%)`:`translate3d(${n+32}px, ${i}px, 0)`}
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { FocusedSeriesArray } from './focused-series';
3
+ interface TooltipContentProps {
4
+ focusedSeries: FocusedSeriesArray | null;
5
+ wrapLabels?: boolean;
6
+ }
7
+ export declare function TooltipContent(props: TooltipContentProps): JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=TooltipContent.d.ts.map