@perses-dev/components 0.37.2 → 0.38.0

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 (86) hide show
  1. package/README.md +1 -0
  2. package/dist/BarChart/BarChart.d.ts +16 -0
  3. package/dist/BarChart/BarChart.d.ts.map +1 -0
  4. package/dist/BarChart/BarChart.js +123 -0
  5. package/dist/BarChart/BarChart.js.map +1 -0
  6. package/dist/BarChart/index.d.ts +2 -0
  7. package/dist/BarChart/index.d.ts.map +1 -0
  8. package/dist/BarChart/index.js +15 -0
  9. package/dist/BarChart/index.js.map +1 -0
  10. package/dist/Dialog/DiscardChangesConfirmationDialog.d.ts +10 -0
  11. package/dist/Dialog/DiscardChangesConfirmationDialog.d.ts.map +1 -0
  12. package/dist/Dialog/DiscardChangesConfirmationDialog.js +47 -0
  13. package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -0
  14. package/dist/Dialog/index.d.ts +1 -0
  15. package/dist/Dialog/index.d.ts.map +1 -1
  16. package/dist/Dialog/index.js +1 -0
  17. package/dist/Dialog/index.js.map +1 -1
  18. package/dist/Legend/ListLegendItem.d.ts +1 -1
  19. package/dist/LineChart/LineChart.d.ts.map +1 -1
  20. package/dist/LineChart/LineChart.js +2 -1
  21. package/dist/LineChart/LineChart.js.map +1 -1
  22. package/dist/ModeSelector/ModeSelector.d.ts +9 -0
  23. package/dist/ModeSelector/ModeSelector.d.ts.map +1 -0
  24. package/dist/ModeSelector/ModeSelector.js +43 -0
  25. package/dist/ModeSelector/ModeSelector.js.map +1 -0
  26. package/dist/ModeSelector/index.d.ts +2 -0
  27. package/dist/ModeSelector/index.d.ts.map +1 -0
  28. package/dist/ModeSelector/index.js +15 -0
  29. package/dist/ModeSelector/index.js.map +1 -0
  30. package/dist/SortSelector/SortSelector.d.ts +8 -0
  31. package/dist/SortSelector/SortSelector.d.ts.map +1 -0
  32. package/dist/SortSelector/SortSelector.js +42 -0
  33. package/dist/SortSelector/SortSelector.js.map +1 -0
  34. package/dist/SortSelector/index.d.ts +2 -0
  35. package/dist/SortSelector/index.d.ts.map +1 -0
  36. package/dist/SortSelector/index.js +15 -0
  37. package/dist/SortSelector/index.js.map +1 -0
  38. package/dist/TimeChart/TimeChart.d.ts +1 -0
  39. package/dist/TimeChart/TimeChart.d.ts.map +1 -1
  40. package/dist/TimeChart/TimeChart.js +49 -12
  41. package/dist/TimeChart/TimeChart.js.map +1 -1
  42. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts +5 -0
  43. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -1
  44. package/dist/TimeSeriesTooltip/LineChartTooltip.js +12 -5
  45. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
  46. package/dist/TimeSeriesTooltip/nearby-series.d.ts +1 -1
  47. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  48. package/dist/TimeSeriesTooltip/nearby-series.js +87 -96
  49. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  50. package/dist/UnitSelector/UnitSelector.d.ts +2 -1
  51. package/dist/UnitSelector/UnitSelector.d.ts.map +1 -1
  52. package/dist/UnitSelector/UnitSelector.js +3 -2
  53. package/dist/UnitSelector/UnitSelector.js.map +1 -1
  54. package/dist/cjs/BarChart/BarChart.js +129 -0
  55. package/dist/cjs/BarChart/index.js +28 -0
  56. package/dist/cjs/Dialog/DiscardChangesConfirmationDialog.js +53 -0
  57. package/dist/cjs/Dialog/index.js +1 -0
  58. package/dist/cjs/LineChart/LineChart.js +2 -1
  59. package/dist/cjs/ModeSelector/ModeSelector.js +49 -0
  60. package/dist/cjs/ModeSelector/index.js +28 -0
  61. package/dist/cjs/SortSelector/SortSelector.js +48 -0
  62. package/dist/cjs/SortSelector/index.js +28 -0
  63. package/dist/cjs/TimeChart/TimeChart.js +52 -10
  64. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +11 -4
  65. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +87 -96
  66. package/dist/cjs/UnitSelector/UnitSelector.js +3 -2
  67. package/dist/cjs/index.js +3 -0
  68. package/dist/cjs/model/graph.js +35 -3
  69. package/dist/cjs/utils/chart-actions.js +61 -1
  70. package/dist/cjs/utils/theme-gen.js +34 -6
  71. package/dist/index.d.ts +3 -0
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +3 -0
  74. package/dist/index.js.map +1 -1
  75. package/dist/model/graph.d.ts +11 -2
  76. package/dist/model/graph.d.ts.map +1 -1
  77. package/dist/model/graph.js +25 -0
  78. package/dist/model/graph.js.map +1 -1
  79. package/dist/utils/chart-actions.d.ts +3 -0
  80. package/dist/utils/chart-actions.d.ts.map +1 -1
  81. package/dist/utils/chart-actions.js +66 -0
  82. package/dist/utils/chart-actions.js.map +1 -1
  83. package/dist/utils/theme-gen.d.ts.map +1 -1
  84. package/dist/utils/theme-gen.js +34 -6
  85. package/dist/utils/theme-gen.js.map +1 -1
  86. package/package.json +3 -3
@@ -0,0 +1,53 @@
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, "DiscardChangesConfirmationDialog", {
18
+ enumerable: true,
19
+ get: ()=>DiscardChangesConfirmationDialog
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const _dialog = require("./Dialog");
24
+ const DiscardChangesConfirmationDialog = (props)=>{
25
+ const { description , isOpen , onCancel , onDiscardChanges } = props;
26
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_dialog.Dialog, {
27
+ open: isOpen,
28
+ "aria-labelledby": "discard-dialog",
29
+ children: [
30
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dialog.Dialog.Header, {
31
+ children: "Discard Changes"
32
+ }),
33
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dialog.Dialog.Content, {
34
+ children: description
35
+ }),
36
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_dialog.Dialog.Actions, {
37
+ children: [
38
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
39
+ variant: "contained",
40
+ onClick: onDiscardChanges,
41
+ children: "Discard Changes"
42
+ }),
43
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
44
+ variant: "outlined",
45
+ color: "secondary",
46
+ onClick: onCancel,
47
+ children: "Cancel"
48
+ })
49
+ ]
50
+ })
51
+ ]
52
+ });
53
+ };
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  _exportStar(require("./Dialog"), exports);
18
+ _exportStar(require("./DiscardChangesConfirmationDialog"), exports);
18
19
  function _exportStar(from, to) {
19
20
  Object.keys(from).forEach(function(k) {
20
21
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
@@ -261,7 +261,8 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
261
261
  unit: unit,
262
262
  onUnpinClick: ()=>{
263
263
  setTooltipPinnedCoords(null);
264
- }
264
+ },
265
+ containerId: chartsTheme.tooltipPortalContainerId
265
266
  }),
266
267
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_echart.EChart, {
267
268
  sx: {
@@ -0,0 +1,49 @@
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, "ModeSelector", {
18
+ enumerable: true,
19
+ get: ()=>ModeSelector
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _optionsEditorLayout = require("../OptionsEditorLayout");
23
+ const _settingsAutocomplete = require("../SettingsAutocomplete");
24
+ const MODE_OPTIONS = [
25
+ {
26
+ id: 'value',
27
+ label: 'Value'
28
+ },
29
+ {
30
+ id: 'percentage',
31
+ label: 'Percentage'
32
+ }
33
+ ];
34
+ function ModeSelector({ disablePercentageMode , onChange , value ='value' }) {
35
+ const handleModeChange = (_, { id })=>{
36
+ onChange(id);
37
+ };
38
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
39
+ label: "Mode",
40
+ control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_settingsAutocomplete.SettingsAutocomplete, {
41
+ value: MODE_OPTIONS.find((o)=>o.id === value),
42
+ options: MODE_OPTIONS,
43
+ getOptionLabel: (o)=>o.label,
44
+ getOptionDisabled: (o)=>o.id === 'percentage' && disablePercentageMode,
45
+ onChange: handleModeChange,
46
+ disableClearable: true
47
+ })
48
+ });
49
+ }
@@ -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
+ }
@@ -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,
@@ -45,7 +53,7 @@ const _timeZoneProvider = require("../context/TimeZoneProvider");
45
53
  _components.TooltipComponent,
46
54
  _renderers.CanvasRenderer
47
55
  ]);
48
- 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 ={
49
57
  wrapLabels: true
50
58
  } , noDataVariant ='message' , syncGroup , onDataZoom , onDoubleClick , __experimentalEChartsOptionsOverride , }, ref) {
51
59
  var ref1;
@@ -122,19 +130,19 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
122
130
  };
123
131
  onDataZoom(zoomEvent);
124
132
  }
133
+ },
134
+ finished: ()=>{
135
+ if (chartRef.current !== undefined) {
136
+ (0, _utils.enableDataZoom)(chartRef.current);
137
+ }
125
138
  }
126
139
  };
127
140
  }, [
128
141
  onDataZoom,
129
142
  setTooltipPinnedCoords
130
143
  ]);
131
- if (chartRef.current !== undefined) {
132
- (0, _utils.enableDataZoom)(chartRef.current);
133
- }
134
144
  const { noDataOption } = chartsTheme;
135
145
  const option = (0, _react.useMemo)(()=>{
136
- // TODO: fix loading state and noData variants
137
- // if (data === undefined) return {};
138
146
  // The "chart" `noDataVariant` is only used when the `timeSeries` is an
139
147
  // empty array because a `null` value will throw an error.
140
148
  if (data === null || data.length === 0 && noDataVariant === 'message') return noDataOption;
@@ -172,14 +180,19 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
172
180
  axisLabel: {
173
181
  hideOverlap: true,
174
182
  formatter: (0, _utils.getFormattedAxisLabel)((_rangeMs = timeScale.rangeMs) !== null && _rangeMs !== void 0 ? _rangeMs : 0)
183
+ },
184
+ axisPointer: {
185
+ snap: false
175
186
  }
176
187
  },
177
188
  yAxis: (0, _utils.getYAxes)(yAxis, unit),
178
189
  animation: false,
179
190
  tooltip: {
180
191
  show: true,
181
- trigger: 'axis',
182
- showContent: false
192
+ trigger: isStackedBar ? 'item' : 'axis',
193
+ // ECharts tooltip content hidden since we use custom tooltip instead
194
+ showContent: isStackedBar,
195
+ appendToBody: true
183
196
  },
184
197
  // https://echarts.apache.org/en/option.html#axisPointer
185
198
  axisPointer: {
@@ -187,7 +200,7 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
187
200
  z: 0,
188
201
  triggerEmphasis: false,
189
202
  triggerTooltip: false,
190
- snap: true
203
+ snap: false
191
204
  },
192
205
  toolbox: {
193
206
  feature: {
@@ -203,6 +216,8 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
203
216
  return __experimentalEChartsOptionsOverride(option);
204
217
  }
205
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
206
221
  }, [
207
222
  data,
208
223
  seriesMapping,
@@ -213,13 +228,38 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
213
228
  noDataOption,
214
229
  __experimentalEChartsOptionsOverride,
215
230
  noDataVariant,
216
- timeZone
231
+ timeZone,
232
+ tooltipPinnedCoords,
233
+ isStackedBar
217
234
  ]);
218
235
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
219
236
  sx: {
220
237
  height
221
238
  },
222
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
+ }
223
263
  // Pin and unpin when clicking on chart canvas but not tooltip text.
224
264
  if (e.target instanceof HTMLCanvasElement) {
225
265
  setTooltipPinnedCoords((current)=>{
@@ -305,6 +345,8 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
305
345
  unit: unit,
306
346
  onUnpinClick: ()=>{
307
347
  setTooltipPinnedCoords(null);
348
+ // Clear previously set pinned crosshair
349
+ seriesMapping.pop();
308
350
  }
309
351
  }),
310
352
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_echart.EChart, {
@@ -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: cursorTransform
97
+ transform: transform.current
91
98
  },
92
99
  children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
93
100
  spacing: 0.5,