Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

displaying tooltips on pie chart slice 1

Status
Not open for further replies.

sajidi99

Programmer
Jun 7, 2005
53
SE

Hi,

Does anybody know how to display tootips on each pie chart's slice?

Thanx
Sajid
 
What pie chart are you using? Did you use GDI+ to create your own?

If so - you can find out where in the pie's arc the mouse is sitting and calculate which section it actually touches. Then you can adjust the tooltip text for its current position. It's a lot of work though.

There may be 3rd party tools that already allow you to do this.
 

yes I made a simple pie chart using C# GDI+ .

I know the basic alogorithm and i can get the mouse cordinates as well in the mouse_move event. But how to find out whether mouse lies on a particular slice or not ?!

 
First, determine if the mouse position is within the radius of the pie.

If it is, find which angle from the center where the mouse is. Then find which piece of pie goes past that angle.

For example, Say you start your drawing from 0 Degrees and your mouse is at 110 degrees.

110
\__ 0


The first piece of pie could be 75 degrees, the second 90 degrees. So drawing from the left you would see:

75 110
/__ 0 \___ 0
/
165

the first piece of pie doesn't touch the 110 mark but the next 90 does - so your 90 degree piece is the one the mouse is touching.

Does that help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top