@@ -21,9 +21,9 @@ import {
21
21
selectorChartAxisZoomData ,
22
22
UseChartProZoomSignature ,
23
23
} from '../../internals/plugins/useChartProZoom' ;
24
- import { ChartAxisZoomSliderHandle } from './ChartAxisZoomSliderHandle ' ;
24
+ import { ChartAxisZoomSliderThumb } from './ChartAxisZoomSliderThumb ' ;
25
25
26
- const BackgroundRect = styled ( 'rect' ) ( ( { theme } ) => ( {
26
+ const ZoomSliderTrack = styled ( 'rect' ) ( ( { theme } ) => ( {
27
27
'&' : {
28
28
fill :
29
29
theme . palette . mode === 'dark'
@@ -32,7 +32,7 @@ const BackgroundRect = styled('rect')(({ theme }) => ({
32
32
} ,
33
33
} ) ) ;
34
34
35
- const ZoomRangePreviewRect = styled ( 'rect' ) ( ( { theme } ) => ( {
35
+ const ZoomSliderActiveTrackRect = styled ( 'rect' ) ( ( { theme } ) => ( {
36
36
'&' : {
37
37
fill :
38
38
theme . palette . mode === 'dark'
@@ -53,15 +53,15 @@ interface ChartZoomSliderProps {
53
53
axisDirection : 'x' | 'y' ;
54
54
}
55
55
56
- const ZOOM_SLIDER_BACKGROUND_SIZE = 8 ;
57
- const ZOOM_SLIDER_FOREGROUND_SIZE = 10 ;
58
- const ZOOM_SLIDER_HANDLE_HEIGHT = 20 ;
59
- const ZOOM_SLIDER_HANDLE_WIDTH = 10 ;
56
+ const ZOOM_SLIDER_TRACK_SIZE = 8 ;
57
+ const ZOOM_SLIDER_ACTIVE_TRACK_SIZE = 10 ;
58
+ const ZOOM_SLIDER_THUMB_HEIGHT = 20 ;
59
+ const ZOOM_SLIDER_THUMB_WIDTH = 10 ;
60
60
const ZOOM_SLIDER_SIZE = Math . max (
61
- ZOOM_SLIDER_BACKGROUND_SIZE ,
62
- ZOOM_SLIDER_FOREGROUND_SIZE ,
63
- ZOOM_SLIDER_HANDLE_HEIGHT ,
64
- ZOOM_SLIDER_HANDLE_WIDTH ,
61
+ ZOOM_SLIDER_TRACK_SIZE ,
62
+ ZOOM_SLIDER_ACTIVE_TRACK_SIZE ,
63
+ ZOOM_SLIDER_THUMB_HEIGHT ,
64
+ ZOOM_SLIDER_THUMB_WIDTH ,
65
65
) ;
66
66
67
67
/**
@@ -118,19 +118,19 @@ export function ChartAxisZoomSlider({ axisDirection, axisId }: ChartZoomSliderPr
118
118
axisPosition = axis . position ?? 'left' ;
119
119
}
120
120
121
- const backgroundRectOffset = ( ZOOM_SLIDER_SIZE - ZOOM_SLIDER_BACKGROUND_SIZE ) / 2 ;
121
+ const backgroundRectOffset = ( ZOOM_SLIDER_SIZE - ZOOM_SLIDER_TRACK_SIZE ) / 2 ;
122
122
123
123
return (
124
124
< g transform = { `translate(${ x } ${ y } )` } >
125
- < BackgroundRect
125
+ < ZoomSliderTrack
126
126
x = { axisDirection === 'x' ? 0 : backgroundRectOffset }
127
127
y = { axisDirection === 'x' ? backgroundRectOffset : 0 }
128
- height = { axisDirection === 'x' ? ZOOM_SLIDER_BACKGROUND_SIZE : drawingArea . height }
129
- width = { axisDirection === 'x' ? drawingArea . width : ZOOM_SLIDER_BACKGROUND_SIZE }
130
- rx = { ZOOM_SLIDER_BACKGROUND_SIZE / 2 }
131
- ry = { ZOOM_SLIDER_BACKGROUND_SIZE / 2 }
128
+ height = { axisDirection === 'x' ? ZOOM_SLIDER_TRACK_SIZE : drawingArea . height }
129
+ width = { axisDirection === 'x' ? drawingArea . width : ZOOM_SLIDER_TRACK_SIZE }
130
+ rx = { ZOOM_SLIDER_TRACK_SIZE / 2 }
131
+ ry = { ZOOM_SLIDER_TRACK_SIZE / 2 }
132
132
/>
133
- < ChartAxisZoomSliderSpan
133
+ < ChartAxisZoomSliderActiveTrack
134
134
zoomData = { zoomData }
135
135
axisId = { axisId }
136
136
axisPosition = { axisPosition }
@@ -144,7 +144,7 @@ export function ChartAxisZoomSlider({ axisDirection, axisId }: ChartZoomSliderPr
144
144
const formatter = Intl . NumberFormat ( undefined , { maximumFractionDigits : 0 } ) ;
145
145
const zoomValueFormatter = ( value : number ) => formatter . format ( value ) ;
146
146
147
- function ChartAxisZoomSliderSpan ( {
147
+ function ChartAxisZoomSliderActiveTrack ( {
148
148
axisId,
149
149
axisDirection,
150
150
axisPosition,
@@ -163,14 +163,14 @@ function ChartAxisZoomSliderSpan({
163
163
const store = useStore < [ UseChartProZoomSignature ] > ( ) ;
164
164
const drawingArea = useDrawingArea ( ) ;
165
165
const activePreviewRectRef = React . useRef < SVGRectElement > ( null ) ;
166
- const [ startHandleEl , setStartHandleEl ] = React . useState < SVGRectElement | null > ( null ) ;
167
- const [ endHandleEl , setEndHandleEl ] = React . useState < SVGRectElement | null > ( null ) ;
166
+ const [ startThumbEl , setStartThumbEl ] = React . useState < SVGRectElement | null > ( null ) ;
167
+ const [ endThumbEl , setEndThumbEl ] = React . useState < SVGRectElement | null > ( null ) ;
168
168
const [ showTooltip , setShowTooltip ] = React . useState < null | 'start' | 'end' | 'both' > ( null ) ;
169
169
170
- const previewHandleWidth =
171
- axisDirection === 'x' ? ZOOM_SLIDER_HANDLE_WIDTH : ZOOM_SLIDER_HANDLE_HEIGHT ;
172
- const previewHandleHeight =
173
- axisDirection === 'x' ? ZOOM_SLIDER_HANDLE_HEIGHT : ZOOM_SLIDER_HANDLE_WIDTH ;
170
+ const previewThumbWidth =
171
+ axisDirection === 'x' ? ZOOM_SLIDER_THUMB_WIDTH : ZOOM_SLIDER_THUMB_HEIGHT ;
172
+ const previewThumbHeight =
173
+ axisDirection === 'x' ? ZOOM_SLIDER_THUMB_HEIGHT : ZOOM_SLIDER_THUMB_WIDTH ;
174
174
175
175
React . useEffect ( ( ) => {
176
176
const activePreviewRect = activePreviewRectRef . current ;
@@ -265,7 +265,7 @@ function ChartAxisZoomSliderSpan({
265
265
} ;
266
266
} , [ axisDirection , axisId , instance , reverse , store , svgRef ] ) ;
267
267
268
- const onStartHandleMove = ( event : PointerEvent ) => {
268
+ const onStartThumbMove = ( event : PointerEvent ) => {
269
269
const element = svgRef . current ;
270
270
271
271
if ( ! element ) {
@@ -304,7 +304,7 @@ function ChartAxisZoomSliderSpan({
304
304
} ) ;
305
305
} ;
306
306
307
- const onEndHandleMove = ( event : PointerEvent ) => {
307
+ const onEndThumbMove = ( event : PointerEvent ) => {
308
308
const element = svgRef . current ;
309
309
310
310
if ( ! element ) {
@@ -347,58 +347,58 @@ function ChartAxisZoomSliderSpan({
347
347
let previewY : number ;
348
348
let previewWidth : number ;
349
349
let previewHeight : number ;
350
- let startHandleX : number ;
351
- let startHandleY : number ;
352
- let endHandleX : number ;
353
- let endHandleY : number ;
350
+ let startThumbX : number ;
351
+ let startThumbY : number ;
352
+ let endThumbX : number ;
353
+ let endThumbY : number ;
354
354
355
355
if ( axisDirection === 'x' ) {
356
356
previewX = ( zoomData . start / 100 ) * drawingArea . width ;
357
357
previewY = 0 ;
358
358
previewWidth = ( drawingArea . width * ( zoomData . end - zoomData . start ) ) / 100 ;
359
- previewHeight = ZOOM_SLIDER_FOREGROUND_SIZE ;
359
+ previewHeight = ZOOM_SLIDER_ACTIVE_TRACK_SIZE ;
360
360
361
- startHandleX = ( zoomData . start / 100 ) * drawingArea . width ;
362
- startHandleY = 0 ;
363
- endHandleX = ( zoomData . end / 100 ) * drawingArea . width ;
364
- endHandleY = 0 ;
361
+ startThumbX = ( zoomData . start / 100 ) * drawingArea . width ;
362
+ startThumbY = 0 ;
363
+ endThumbX = ( zoomData . end / 100 ) * drawingArea . width ;
364
+ endThumbY = 0 ;
365
365
366
366
if ( reverse ) {
367
367
previewX = drawingArea . width - previewX - previewWidth ;
368
368
369
- startHandleX = drawingArea . width - startHandleX ;
370
- endHandleX = drawingArea . width - endHandleX ;
369
+ startThumbX = drawingArea . width - startThumbX ;
370
+ endThumbX = drawingArea . width - endThumbX ;
371
371
}
372
372
373
- startHandleX -= previewHandleWidth / 2 ;
374
- endHandleX -= previewHandleWidth / 2 ;
373
+ startThumbX -= previewThumbWidth / 2 ;
374
+ endThumbX -= previewThumbWidth / 2 ;
375
375
} else {
376
376
previewX = 0 ;
377
377
previewY = drawingArea . height - ( zoomData . end / 100 ) * drawingArea . height ;
378
- previewWidth = ZOOM_SLIDER_FOREGROUND_SIZE ;
378
+ previewWidth = ZOOM_SLIDER_ACTIVE_TRACK_SIZE ;
379
379
previewHeight = ( drawingArea . height * ( zoomData . end - zoomData . start ) ) / 100 ;
380
380
381
- startHandleX = 0 ;
382
- startHandleY = drawingArea . height - ( zoomData . start / 100 ) * drawingArea . height ;
383
- endHandleX = 0 ;
384
- endHandleY = drawingArea . height - ( zoomData . end / 100 ) * drawingArea . height ;
381
+ startThumbX = 0 ;
382
+ startThumbY = drawingArea . height - ( zoomData . start / 100 ) * drawingArea . height ;
383
+ endThumbX = 0 ;
384
+ endThumbY = drawingArea . height - ( zoomData . end / 100 ) * drawingArea . height ;
385
385
386
386
if ( reverse ) {
387
387
previewY = drawingArea . height - previewY - previewHeight ;
388
388
389
- startHandleY = drawingArea . height - startHandleY ;
390
- endHandleY = drawingArea . height - endHandleY ;
389
+ startThumbY = drawingArea . height - startThumbY ;
390
+ endThumbY = drawingArea . height - endThumbY ;
391
391
}
392
392
393
- startHandleY -= previewHandleHeight / 2 ;
394
- endHandleY -= previewHandleHeight / 2 ;
393
+ startThumbY -= previewThumbHeight / 2 ;
394
+ endThumbY -= previewThumbHeight / 2 ;
395
395
}
396
396
397
- const previewOffset = ( ZOOM_SLIDER_HANDLE_HEIGHT - ZOOM_SLIDER_FOREGROUND_SIZE ) / 2 ;
397
+ const previewOffset = ( ZOOM_SLIDER_THUMB_HEIGHT - ZOOM_SLIDER_ACTIVE_TRACK_SIZE ) / 2 ;
398
398
399
399
return (
400
400
< React . Fragment >
401
- < ZoomRangePreviewRect
401
+ < ZoomSliderActiveTrackRect
402
402
ref = { activePreviewRectRef }
403
403
x = { previewX + ( axisDirection === 'x' ? 0 : previewOffset ) }
404
404
y = { previewY + ( axisDirection === 'x' ? previewOffset : 0 ) }
@@ -407,39 +407,39 @@ function ChartAxisZoomSliderSpan({
407
407
onPointerEnter = { ( ) => setShowTooltip ( 'both' ) }
408
408
onPointerLeave = { ( ) => setShowTooltip ( null ) }
409
409
/>
410
- < ChartAxisZoomSliderHandle
411
- ref = { setStartHandleEl }
412
- x = { startHandleX }
413
- y = { startHandleY }
414
- width = { previewHandleWidth }
415
- height = { previewHandleHeight }
410
+ < ChartAxisZoomSliderThumb
411
+ ref = { setStartThumbEl }
412
+ x = { startThumbX }
413
+ y = { startThumbY }
414
+ width = { previewThumbWidth }
415
+ height = { previewThumbHeight }
416
416
orientation = { axisDirection === 'x' ? 'horizontal' : 'vertical' }
417
- onMove = { onStartHandleMove }
417
+ onMove = { onStartThumbMove }
418
418
onPointerEnter = { ( ) => setShowTooltip ( 'start' ) }
419
419
onPointerLeave = { ( ) => setShowTooltip ( null ) }
420
420
placement = "start"
421
421
/>
422
- < ChartAxisZoomSliderHandle
423
- ref = { setEndHandleEl }
424
- x = { endHandleX }
425
- y = { endHandleY }
426
- width = { previewHandleWidth }
427
- height = { previewHandleHeight }
422
+ < ChartAxisZoomSliderThumb
423
+ ref = { setEndThumbEl }
424
+ x = { endThumbX }
425
+ y = { endThumbY }
426
+ width = { previewThumbWidth }
427
+ height = { previewThumbHeight }
428
428
orientation = { axisDirection === 'x' ? 'horizontal' : 'vertical' }
429
- onMove = { onEndHandleMove }
429
+ onMove = { onEndThumbMove }
430
430
onPointerEnter = { ( ) => setShowTooltip ( 'end' ) }
431
431
onPointerLeave = { ( ) => setShowTooltip ( null ) }
432
432
placement = "end"
433
433
/>
434
434
< ChartsTooltipZoomSliderValue
435
- anchorEl = { startHandleEl }
435
+ anchorEl = { startThumbEl }
436
436
open = { showTooltip === 'start' || showTooltip === 'both' }
437
437
placement = { axisPosition }
438
438
>
439
439
{ valueFormatter ( zoomData . start ) }
440
440
</ ChartsTooltipZoomSliderValue >
441
441
< ChartsTooltipZoomSliderValue
442
- anchorEl = { endHandleEl }
442
+ anchorEl = { endThumbEl }
443
443
open = { showTooltip === 'end' || showTooltip === 'both' }
444
444
placement = { axisPosition }
445
445
>
0 commit comments