custom pie charts

Discussion in 'ASP .Net' started by =?Utf-8?B?cm9kY2hhcg==?=, Apr 2, 2007.

  1. 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/0e826454-619f-41de-8532-c855679031ff.aspx
     
    =?Utf-8?B?cm9kY2hhcg==?=, Apr 2, 2007
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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/0e826454-619f-41de-8532-c855679031ff.aspx
    >
    >
     
    Kevin Spencer, Apr 2, 2007
    #2
    1. Advertising

  3. 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" <> wrote in message
    > news:...
    > > 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/0e826454-619f-41de-8532-c855679031ff.aspx
    > >
    > >

    >
    >
    >
     
    =?Utf-8?B?cm9kY2hhcg==?=, Apr 3, 2007
    #3
  4. 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/0e826454-619f-41de-8532-c855679031ff.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
     
    Rad [Visual C# MVP], Apr 3, 2007
    #4
  5. 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]" <> wrote in message
    news:...
    > 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/0e826454-619f-41de-8532-c855679031ff.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
     
    dotNET learner, Apr 5, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. IPaul
    Replies:
    0
    Views:
    611
    IPaul
    Apr 2, 2004
  2. Cliff Harris

    Pie Chart control

    Cliff Harris, Jun 12, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    436
    Ken Cox [Microsoft MVP]
    Jun 12, 2004
  3. Patrick.O.Ige
    Replies:
    8
    Views:
    517
    Patrick.O.Ige
    Oct 14, 2004
  4. meow
    Replies:
    0
    Views:
    951
  5. krishna

    problem in displaying bar and pie charts

    krishna, Jun 11, 2004, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    114
    krishna
    Jun 11, 2004
Loading...

Share This Page