开发者

What's the best way to draw a pie chart in Android with selectable slices?

开发者 https://www.devze.com 2023-02-05 23:06 出处:网络
I\'ve looked into achartengine and a couple other options, but none of them seem to 开发者_运维技巧support any way to implement drill down into the data.I had a similar problem, but with histograms. I

I've looked into achartengine and a couple other options, but none of them seem to 开发者_运维技巧support any way to implement drill down into the data.


I had a similar problem, but with histograms. I ended up creating a custom view that:

  • takes a maximum value as the top of the graph, to make a proportion with values to graph (you have 360 constant degrees)
  • an array of values
  • a parameter for column width

then draws the histogram (it won't be too hard drawing a pie chart) and overriding onTouchEvent() to determine which column was clicked.

As we're talking of a pie chart you'll have to do some more maths to find which slice was clicked.

0

精彩评论

暂无评论...
验证码 换一张
取 消