File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
packages/x-charts/src/RadarChart/RadarAxisHighlight Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -30,16 +30,19 @@ export function RadarAxisSliceHighlight(props: RadarAxisSliceHighlightProps) {
30
30
{ series . map ( ( { id, color } , seriesIndex ) => {
31
31
const { highlighted, next = highlighted , previous = highlighted } = points [ seriesIndex ] ;
32
32
33
+ const ratioPrev = previous . r / ( previous . r + highlighted . r ) ;
34
+ const ratioNext = next . r / ( next . r + highlighted . r ) ;
35
+
33
36
return (
34
37
< path
35
38
className = { classes ?. slice }
36
39
key = { id }
37
40
fill = { color }
38
41
d = { `M
39
42
${ center . cx } ${ center . cy }
40
- L ${ ( previous . x + highlighted . x ) / 2 } ${ ( previous . y + highlighted . y ) / 2 }
43
+ L ${ previous . x * ( 1 - ratioPrev ) + highlighted . x * ratioPrev } ${ previous . y * ( 1 - ratioPrev ) + highlighted . y * ratioPrev }
41
44
L ${ highlighted . x } ${ highlighted . y }
42
- L ${ ( next . x + highlighted . x ) / 2 } ${ ( next . y + highlighted . y ) / 2 }
45
+ L ${ next . x * ( 1 - ratioNext ) + highlighted . x * ratioNext } ${ next . y * ( 1 - ratioNext ) + highlighted . y * ratioNext }
43
46
Z
44
47
` }
45
48
pointerEvents = "none"
Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ interface UseRadarAxisHighlightReturnValue {
59
59
interface Point {
60
60
x : number ;
61
61
y : number ;
62
+ r : number ;
63
+ angle : number ;
62
64
value : number ;
63
65
}
64
66
@@ -110,12 +112,15 @@ export function useRadarAxisHighlight(
110
112
points : radarSeries . map ( ( series ) => {
111
113
const value = series . data [ highlightedIndex ] ;
112
114
113
- const [ x , y ] = instance . polar2svg ( radiusScale ( value ) ! , angle ) ;
115
+ const r = radiusScale ( value ) ! ;
116
+ const [ x , y ] = instance . polar2svg ( r , angle ) ;
114
117
115
118
const retrunedValue : Points = {
116
119
highlighted : {
117
120
x,
118
121
y,
122
+ r,
123
+ angle,
119
124
value,
120
125
} ,
121
126
} ;
@@ -139,6 +144,8 @@ export function useRadarAxisHighlight(
139
144
retrunedValue . previous = {
140
145
x : px ,
141
146
y : py ,
147
+ r : prevR ,
148
+ angle : prevAngle ,
142
149
value : prevValue ,
143
150
} ;
144
151
}
@@ -151,6 +158,8 @@ export function useRadarAxisHighlight(
151
158
retrunedValue . next = {
152
159
x : nx ,
153
160
y : ny ,
161
+ r : nextR ,
162
+ angle : nextAngle ,
154
163
value : nextValue ,
155
164
} ;
156
165
}
You can’t perform that action at this time.
0 commit comments