Otto
Otto

Reputation: 1685

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

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.

Upvotes: 1

Views: 758

Answers (1)

bigstones
bigstones

Reputation: 15267

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.

Upvotes: 2

Related Questions