Skip to content

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

@harvey56

Description

@harvey56

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions