Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where does the offset on the Annotation comp. come from ? #30

Open
harvey56 opened this issue Nov 20, 2019 · 0 comments
Open

Where does the offset on the Annotation comp. come from ? #30

harvey56 opened this issue Nov 20, 2019 · 0 comments

Comments

@harvey56
Copy link

harvey56 commented Nov 20, 2019

I'm trying to use react-annotation on a pie chart.

<Annotation
     x={centroidX}
     y={centroidY}
     dx={startAngle < Math.PI ? 170 : -170}
     dy={startAngle < Math.PI ? 70 : -70}
     radius={35}
     color={"#9610ff"}
     title={arc.data.value}
>
    <ConnectorElbow>
       <ConnectorEndDot />
    </ConnectorElbow>
    <Note align="middle" lineType="vertical" padding={startAngle < Math.PI ? -5 : 5} />
</Annotation>

centroidX and centroidY are calculated before and enable to get the coordinates of the point in the middle of the "pie" (mid-radius and mid-angle). So, with a pie of size PI and radius=1 on the pie chart, centroid would be located at radius=0.5, and an angle of Pi/2.

So, this works, except that an offset is introduced, for some reason, in the annotation component. The value that the component is offset with is the value in the transform translate in the ConnectorEndDot component. Same value on x and on y.
If I add these x and y offset values to the translate values of the Annotation component in the html code, then things will display as expected, with the connector dot located at centroid.

There does not seem to be any parameter to fix this in the API doc.

Any idea where that offset comes from ? How can I fix that ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant