Skip to content

Commit 2507f42

Browse files
committed
[charts] Enable tooltip disable portal
1 parent ceabbf5 commit 2507f42

16 files changed

Lines changed: 50 additions & 46 deletions

File tree

docs/data/charts/bars/bars.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ Here's how the Bar Chart is composed:
207207
<ChartsAxisHighlight />
208208
</g>
209209
<ChartsAxis />
210-
<ChartsTooltip />
211210
<ChartsClipPath id={clipPathId} />
212211
</ChartsSurface>
212+
<ChartsTooltip />
213213
</ChartsWrapper>
214214
</ChartDataProvider>
215215
```

docs/data/charts/lines/lines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ Here's how the Line Chart is composed:
294294
<MarkPlot />
295295
</g>
296296
<LineHighlightPlot />
297-
<ChartsTooltip />
298297
<ChartsClipPath id={clipPathId} />
299298
</ChartsSurface>
299+
<ChartsTooltip />
300300
</ChartsWrapper>
301301
</ChartDataProvider>
302302
```

docs/data/charts/pie/pie.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ Here's how the Pie Chart is composed:
138138
<ChartsSurface>
139139
<PiePlot />
140140
<ChartsOverlay />
141-
<ChartsTooltip trigger="item" />
142141
</ChartsSurface>
142+
<ChartsTooltip trigger="item" />
143143
</ChartsWrapper>
144144
</ChartDataProvider>
145145
```

docs/data/charts/radar/radar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ Here's how the Radar Chart is composed:
137137
<RadarSeriesMarks />
138138
{/* Other components */}
139139
<ChartsOverlay />
140-
<ChartsTooltip />
141140
</ChartsSurface>
141+
<ChartsTooltip />
142142
</ChartsWrapper>
143143
</RadarDataProvider>
144144
```

docs/data/charts/scatter/scatter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ Here's how the Scatter Chart is composed:
154154
</g>
155155
<ChartsOverlay />
156156
<ChartsAxisHighlight />
157-
<ChartsTooltip trigger="item" />
158157
</ChartsSurface>
158+
<ChartsTooltip trigger="item" />
159159
</ChartsWrapper>
160160
</ChartDataProvider>
161161
```

docs/data/charts/tooltip/tooltip.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ To apply the same style as we're trying to apply above, we need to use the `sx`
178178

179179
{{"demo": "TooltipStyle.js"}}
180180

181+
You can also disable the portal by setting `slotProps.tooltip.disablePortal` to `true`.
182+
181183
## Composition
182184

183185
If you're using composition, by default, the axis listens for mouse events to get its current x/y values.

packages/x-charts-pro/src/BarChartPro/BarChartPro.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ const BarChartPro = React.forwardRef(function BarChartPro(
9494
</g>
9595
<ChartsAxis {...chartsAxisProps} />
9696
<ChartZoomSlider />
97-
{!props.loading && <Tooltip {...props.slotProps?.tooltip} />}
9897
<ChartsClipPath {...clipPathProps} />
9998
{children}
10099
</ChartsSurface>
100+
{!props.loading && <Tooltip {...props.slotProps?.tooltip} />}
101101
</ChartsWrapper>
102102
</ChartDataProviderPro>
103103
);

packages/x-charts-pro/src/FunnelChart/FunnelChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ const FunnelChart = React.forwardRef(function FunnelChart(
9696
<FunnelPlot {...funnelPlotProps} />
9797
<ChartsOverlay {...overlayProps} />
9898
<ChartsAxisHighlight {...axisHighlightProps} />
99-
{!themedProps.loading && <Tooltip {...themedProps.slotProps?.tooltip} trigger="item" />}
10099
<ChartsAxis {...chartsAxisProps} />
101100
{children}
102101
</ChartsSurface>
102+
{!themedProps.loading && <Tooltip {...themedProps.slotProps?.tooltip} trigger="item" />}
103103
</ChartsWrapper>
104104
</ChartDataProviderPro>
105105
);

packages/x-charts-pro/src/Heatmap/Heatmap.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { MakeOptional } from '@mui/x-internals/types';
77
import { interpolateRgbBasis } from '@mui/x-charts-vendor/d3-interpolate';
88
import { ChartsAxis, ChartsAxisProps } from '@mui/x-charts/ChartsAxis';
99
import { ChartsTooltipProps } from '@mui/x-charts/ChartsTooltip';
10+
import { ChartsSurface } from '@mui/x-charts/ChartsSurface';
1011
import {
1112
ChartsAxisSlots,
1213
ChartsAxisSlotProps,
@@ -22,13 +23,14 @@ import {
2223
ChartsOverlaySlots,
2324
} from '@mui/x-charts/ChartsOverlay';
2425
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '@mui/x-charts/constants';
25-
import { ChartContainerPro, ChartContainerProProps } from '../ChartContainerPro';
26+
import { ChartContainerProProps } from '../ChartContainerPro';
2627
import { HeatmapSeriesType } from '../models/seriesType/heatmap';
2728
import { HeatmapPlot } from './HeatmapPlot';
2829
import { seriesConfig as heatmapSeriesConfig } from './seriesConfig';
2930
import { HeatmapTooltip, HeatmapTooltipProps } from './HeatmapTooltip/HeatmapTooltip';
3031
import { HeatmapItemSlotProps, HeatmapItemSlots } from './HeatmapItem';
3132
import { HEATMAP_PLUGINS, HeatmapPluginsSignatures } from './Heatmap.plugins';
33+
import { ChartDataProviderPro } from '../ChartDataProviderPro';
3234

3335
export interface HeatmapSlots extends ChartsAxisSlots, ChartsOverlaySlots, HeatmapItemSlots {
3436
/**
@@ -181,8 +183,7 @@ const Heatmap = React.forwardRef(function Heatmap(
181183
const Tooltip = props.slots?.tooltip ?? HeatmapTooltip;
182184

183185
return (
184-
<ChartContainerPro<'heatmap', HeatmapPluginsSignatures>
185-
ref={ref}
186+
<ChartDataProviderPro<'heatmap', HeatmapPluginsSignatures>
186187
seriesConfig={seriesConfig}
187188
series={series.map((s) => ({
188189
type: 'heatmap',
@@ -196,23 +197,24 @@ const Heatmap = React.forwardRef(function Heatmap(
196197
zAxis={zAxisWithDefault}
197198
colors={colors}
198199
dataset={dataset}
199-
sx={sx}
200200
disableAxisListener
201201
highlightedItem={highlightedItem}
202202
onHighlightChange={onHighlightChange}
203203
onAxisClick={onAxisClick}
204204
plugins={HEATMAP_PLUGINS}
205205
>
206-
<g clipPath={`url(#${clipPathId})`}>
207-
<HeatmapPlot slots={slots} slotProps={slotProps} />
208-
<ChartsOverlay loading={loading} slots={slots} slotProps={slotProps} />
209-
</g>
210-
<ChartsAxis slots={slots} slotProps={slotProps} />
211-
{!loading && <Tooltip {...slotProps?.tooltip} />}
206+
<ChartsSurface ref={ref} sx={sx}>
207+
<g clipPath={`url(#${clipPathId})`}>
208+
<HeatmapPlot slots={slots} slotProps={slotProps} />
209+
<ChartsOverlay loading={loading} slots={slots} slotProps={slotProps} />
210+
</g>
211+
<ChartsAxis slots={slots} slotProps={slotProps} />
212212

213-
<ChartsClipPath id={clipPathId} />
214-
{children}
215-
</ChartContainerPro>
213+
<ChartsClipPath id={clipPathId} />
214+
{children}
215+
</ChartsSurface>
216+
{!loading && <Tooltip {...slotProps?.tooltip} />}
217+
</ChartDataProviderPro>
216218
);
217219
});
218220

packages/x-charts-pro/src/LineChartPro/LineChartPro.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ const LineChartPro = React.forwardRef(function LineChartPro(
107107
<MarkPlot {...markPlotProps} />
108108
</g>
109109
<LineHighlightPlot {...lineHighlightPlotProps} />
110-
{!props.loading && <Tooltip {...props.slotProps?.tooltip} />}
111110
<ChartsClipPath {...clipPathProps} />
112111
{children}
113112
</ChartsSurface>
113+
{!props.loading && <Tooltip {...props.slotProps?.tooltip} />}
114114
</ChartsWrapper>
115115
</ChartDataProviderPro>
116116
);

0 commit comments

Comments
 (0)