Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > custom pie charts

Reply
Thread Tools

custom pie charts

 
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      04-02-2007
hey all,

i learned how to make simple pie charts using code like the following from
an article referenced at the end of post:

For i = 0 To yaxis.Length - 1
currentangle = yaxis(i) / totalAng * 360
g.FillPie(New SolidBrush(GetColor(i)), 100, 40, 150, 150,
startangle, currentangle)
g.DrawPie(Pens.Black, 100, 40, 150, 150, startangle, currentangle)
startangle += currentangle
Next i


how would i put the values inside each pie section?


thanks,
rodchar

http://www.dotnetbips.com/articles/0...5679031ff.aspx


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      04-02-2007
Do you mean "how would I put the values as text inside each pie section?" If
so...

You need to define the business rules first.

You would have to determine how to orient the text. Since you're drawing
inside a wedge of a circle, you need to establish the rules for the
placement of the text. For example, you could draw the text all facing in
the same direction (as usual, horizontally), or you could draw it at an
angle projecting from the center of the circle. There are other ways I can
imagine as well.

Next, you have to define the business rules regarding how to handle text
that is too large to fit inside a single wedge. Should it begin inside the
wedge and continue outside the wedge, begin outside the wedge and finish
inside the wedge, or be centered at some point inside the wedge and extend
beyond in both directions if necessary?

Next, you have to define the business rules regarding overlapping labels.
How do you handle it if, using your other rules, the labels will overlap?
How will you displace or resize the labels?

After that it's a fairly simple matter of applying the business rules in
your code, using some geometric math to determine the starting point for
each label, the Graphics.MeasureString method to determine the sizes of the
labels, and some Matrix math (if necessary) to rotate them.

Bob Powell has an excellent site that explains the various drawing
mechanisms you need. See

http://www.bobpowell.net/faqmain.htm

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"rodchar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hey all,
>
> i learned how to make simple pie charts using code like the following from
> an article referenced at the end of post:
>
> For i = 0 To yaxis.Length - 1
> currentangle = yaxis(i) / totalAng * 360
> g.FillPie(New SolidBrush(GetColor(i)), 100, 40, 150, 150,
> startangle, currentangle)
> g.DrawPie(Pens.Black, 100, 40, 150, 150, startangle,
> currentangle)
> startangle += currentangle
> Next i
>
>
> how would i put the values inside each pie section?
>
>
> thanks,
> rodchar
>
> http://www.dotnetbips.com/articles/0...5679031ff.aspx
>
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      04-03-2007
I appreciate it Kevin, thank you.
Rod.

"Kevin Spencer" wrote:

> Do you mean "how would I put the values as text inside each pie section?" If
> so...
>
> You need to define the business rules first.
>
> You would have to determine how to orient the text. Since you're drawing
> inside a wedge of a circle, you need to establish the rules for the
> placement of the text. For example, you could draw the text all facing in
> the same direction (as usual, horizontally), or you could draw it at an
> angle projecting from the center of the circle. There are other ways I can
> imagine as well.
>
> Next, you have to define the business rules regarding how to handle text
> that is too large to fit inside a single wedge. Should it begin inside the
> wedge and continue outside the wedge, begin outside the wedge and finish
> inside the wedge, or be centered at some point inside the wedge and extend
> beyond in both directions if necessary?
>
> Next, you have to define the business rules regarding overlapping labels.
> How do you handle it if, using your other rules, the labels will overlap?
> How will you displace or resize the labels?
>
> After that it's a fairly simple matter of applying the business rules in
> your code, using some geometric math to determine the starting point for
> each label, the Graphics.MeasureString method to determine the sizes of the
> labels, and some Matrix math (if necessary) to rotate them.
>
> Bob Powell has an excellent site that explains the various drawing
> mechanisms you need. See
>
> http://www.bobpowell.net/faqmain.htm
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
>
> Printing Components, Email Components,
> FTP Client Classes, Enhanced Data Controls, much more.
> DSI PrintManager, Miradyne Component Libraries:
> http://www.miradyne.net
>
> "rodchar" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > hey all,
> >
> > i learned how to make simple pie charts using code like the following from
> > an article referenced at the end of post:
> >
> > For i = 0 To yaxis.Length - 1
> > currentangle = yaxis(i) / totalAng * 360
> > g.FillPie(New SolidBrush(GetColor(i)), 100, 40, 150, 150,
> > startangle, currentangle)
> > g.DrawPie(Pens.Black, 100, 40, 150, 150, startangle,
> > currentangle)
> > startangle += currentangle
> > Next i
> >
> >
> > how would i put the values inside each pie section?
> >
> >
> > thanks,
> > rodchar
> >
> > http://www.dotnetbips.com/articles/0...5679031ff.aspx
> >
> >

>
>
>

 
Reply With Quote
 
Rad [Visual C# MVP]
Guest
Posts: n/a
 
      04-03-2007
On Mon, 2 Apr 2007 05:56:02 -0700, rodchar wrote:

> hey all,
>
> i learned how to make simple pie charts using code like the following from
> an article referenced at the end of post:
>
> For i = 0 To yaxis.Length - 1
> currentangle = yaxis(i) / totalAng * 360
> g.FillPie(New SolidBrush(GetColor(i)), 100, 40, 150, 150,
> startangle, currentangle)
> g.DrawPie(Pens.Black, 100, 40, 150, 150, startangle, currentangle)
> startangle += currentangle
> Next i
>
> how would i put the values inside each pie section?
>
> thanks,
> rodchar
>
> http://www.dotnetbips.com/articles/0...5679031ff.aspx


You can also use a free library like ZedGraph to draw your graphs ...
someone has already gone to the trouble of solving such problems
--
Bits.Bytes
http://bytes.thinkersroom.com
 
Reply With Quote
 
dotNET learner
Guest
Posts: n/a
 
      04-04-2007
Yes, ZedGraph does excellent job for plotting pie chart and several other
types of charts.

Have a look at :

http://zedgraph.org/wiki/index.php?title=Sample_Graphs
and
http://www.codeproject.com/csharp/zedgraph.asp


"Rad [Visual C# MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Mon, 2 Apr 2007 05:56:02 -0700, rodchar wrote:
>
>> hey all,
>>
>> i learned how to make simple pie charts using code like the following
>> from
>> an article referenced at the end of post:
>>
>> For i = 0 To yaxis.Length - 1
>> currentangle = yaxis(i) / totalAng * 360
>> g.FillPie(New SolidBrush(GetColor(i)), 100, 40, 150, 150,
>> startangle, currentangle)
>> g.DrawPie(Pens.Black, 100, 40, 150, 150, startangle,
>> currentangle)
>> startangle += currentangle
>> Next i
>>
>> how would i put the values inside each pie section?
>>
>> thanks,
>> rodchar
>>
>> http://www.dotnetbips.com/articles/0...5679031ff.aspx

>
> You can also use a free library like ZedGraph to draw your graphs ...
> someone has already gone to the trouble of solving such problems
> --
> Bits.Bytes
> http://bytes.thinkersroom.com



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
labels legibility in matplotlib pie charts and bar plots meow Python 0 06-01-2010 01:18 PM
Best software for professional pie charts? A Shropshire Lad Computer Support 3 12-17-2005 02:57 AM
Bar or Pie charts on a webpage with ASP.NET page populated Patrick.O.Ige ASP .Net 8 10-14-2004 11:49 AM
problem in displaying bar and pie charts krishna ASP .Net Mobile 0 06-11-2004 06:33 AM
Re: GD::Graph Pie Chart Display Problem IPaul Perl 0 04-02-2004 12:06 PM



Advertisments