File tree Expand file tree Collapse file tree 4 files changed +8
-5
lines changed
Expand file tree Collapse file tree 4 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,8 @@ function App() {
1919 data = { fruit }
2020 label = "label"
2121 value = "value"
22- legend = "top-right "
22+ legend = "top-left "
2323 outerRadius = { 240 }
24- legendLabel = "fruit"
2524 pieLabel = { true }
2625 />
2726 < BarChart
Original file line number Diff line number Diff line change @@ -268,6 +268,8 @@ export default function PieChart({
268268 d = { arcGenerator ( d ) }
269269 id = { `arc- + ${ i } ` }
270270 setTooltip = { setTooltip }
271+ margin = { margin }
272+ cWidth = { cWidth }
271273 />
272274 { pieLabel && (
273275 < PieLabel
Original file line number Diff line number Diff line change 11import React from 'react' ;
22
33import { ArcProps } from '../../types' ;
4- import useWindowDimensions from '../hooks/useWindowDimensions' ;
54
65export const Arc = React . memo (
76 ( {
@@ -12,8 +11,9 @@ export const Arc = React.memo(
1211 strokeWidth = '1px' ,
1312 d,
1413 setTooltip,
14+ margin,
15+ cWidth,
1516 } : ArcProps ) : JSX . Element => {
16- const { width } = useWindowDimensions ( ) ;
1717
1818 let tooltipState = {
1919 cursorX : 0 ,
@@ -29,7 +29,7 @@ export const Arc = React.memo(
2929 cursorX : e . pageX ,
3030 cursorY : e . pageY ,
3131 distanceFromTop : e . clientY ,
32- distanceFromRight : width - e . pageX ,
32+ distanceFromRight : ( margin . left + cWidth + margin . right ) - cWidth ,
3333 distanceFromLeft : e . pageX ,
3434 data,
3535 } ;
Original file line number Diff line number Diff line change @@ -345,6 +345,8 @@ export interface ArcProps {
345345 id ?: string | number ;
346346 cellCenter ?: { cx : number ; cy : number ; tooltipData : Data } ;
347347 setTooltip ?: React . Dispatch < any > ;
348+ margin : Margin ;
349+ cWidth : number ;
348350}
349351
350352// eslint-disable-next-line import/export
You can’t perform that action at this time.
0 commit comments