How to get coordinates of slices along the edge of a pie chart?

前端 未结 3 2075
离开以前
离开以前 2020-12-19 05:10

I am creating a piechart with D3 using d3.layout.pie(). It looks like this one, without black dots (I\'ve put them manually in Photoshop to illustrate my issue

3条回答
  •  长情又很酷
    2020-12-19 06:05

    It may sound trivial but I was trying to find the x and y coordinates inside each slice, and when I saw the formula posted above,

    x = cx + r * cos(a)

    y = cy + r * sin(a)

    , it can be done by increasing r from (cx+1 or cy+1) to radius length, and repeating by increasing (a) from origin angle to destination angle, then adding (cx, cy). Hope it helps someone.

提交回复
热议问题