@@ -18,21 +18,37 @@ import {
1818import { styled } from '@mui/material/styles' ;
1919import { useXAxes , useYAxes } from '@mui/x-charts/hooks' ;
2020import { rafThrottle } from '@mui/x-internals/rafThrottle' ;
21+ import { shouldForwardProp } from '@mui/system' ;
2122import { ChartsTooltipZoomSliderValue } from './ChartsTooltipZoomSliderValue' ;
2223import {
2324 selectorChartAxisZoomData ,
2425 UseChartProZoomSignature ,
2526} from '../../internals/plugins/useChartProZoom' ;
2627import { ChartAxisZoomSliderThumb } from './ChartAxisZoomSliderThumb' ;
2728
28- const ZoomSliderTrack = styled ( 'rect' ) ( ( { theme } ) => ( {
29- '&' : {
30- fill :
31- theme . palette . mode === 'dark'
32- ? ( theme . vars || theme ) . palette . grey [ 800 ]
33- : ( theme . vars || theme ) . palette . grey [ 300 ] ,
34- cursor : 'crosshair' ,
35- } ,
29+ const ZoomSliderTrack = styled ( 'rect' , {
30+ shouldForwardProp : ( prop ) =>
31+ shouldForwardProp ( prop ) && prop !== 'axisDirection' && prop !== 'isSelecting' ,
32+ } ) < { axisDirection : 'x' | 'y' ; isSelecting : boolean } > ( ( { theme } ) => ( {
33+ fill :
34+ theme . palette . mode === 'dark'
35+ ? ( theme . vars || theme ) . palette . grey [ 800 ]
36+ : ( theme . vars || theme ) . palette . grey [ 300 ] ,
37+ cursor : 'pointer' ,
38+ variants : [
39+ {
40+ props : { axisDirection : 'x' , isSelecting : true } ,
41+ style : {
42+ cursor : 'ew-resize' ,
43+ } ,
44+ } ,
45+ {
46+ props : { axisDirection : 'y' , isSelecting : true } ,
47+ style : {
48+ cursor : 'ns-resize' ,
49+ } ,
50+ } ,
51+ ] ,
3652} ) ) ;
3753
3854const ZoomSliderActiveTrackRect = styled ( 'rect' ) ( ( { theme } ) => ( {
@@ -162,6 +178,7 @@ function ChartAxisZoomSliderTrack({
162178 const ref = React . useRef < SVGRectElement > ( null ) ;
163179 const { instance, svgRef } = useChartContext < [ UseChartProZoomSignature ] > ( ) ;
164180 const store = useStore < [ UseChartProZoomSignature ] > ( ) ;
181+ const [ isSelecting , setIsSelecting ] = React . useState ( false ) ;
165182
166183 const onPointerDown = function onPointerDown ( event : React . PointerEvent < SVGRectElement > ) {
167184 const rect = ref . current ;
@@ -241,6 +258,7 @@ function ChartAxisZoomSliderTrack({
241258 rect . releasePointerCapture ( pointerUpEvent . pointerId ) ;
242259 rect . removeEventListener ( 'pointermove' , onPointerMove ) ;
243260 document . removeEventListener ( 'pointerup' , onPointerUp ) ;
261+ setIsSelecting ( false ) ;
244262
245263 if ( pointerMoved ) {
246264 return ;
@@ -271,14 +289,23 @@ function ChartAxisZoomSliderTrack({
271289 document . addEventListener ( 'pointerup' , onPointerUp ) ;
272290 rect . addEventListener ( 'pointermove' , onPointerMove ) ;
273291
292+ setIsSelecting ( true ) ;
274293 instance . setAxisZoomData ( axisId , ( prev ) => ( {
275294 ...prev ,
276295 start : zoomFromPointerDown ,
277296 end : zoomFromPointerDown ,
278297 } ) ) ;
279298 } ;
280299
281- return < ZoomSliderTrack ref = { ref } onPointerDown = { onPointerDown } { ...other } /> ;
300+ return (
301+ < ZoomSliderTrack
302+ ref = { ref }
303+ onPointerDown = { onPointerDown }
304+ axisDirection = { axisDirection }
305+ isSelecting = { isSelecting }
306+ { ...other }
307+ />
308+ ) ;
282309}
283310
284311const formatter = Intl . NumberFormat ( undefined , { maximumFractionDigits : 0 } ) ;
0 commit comments