locked
pie chart help needs RRS feed

  • Question

  • User806215137 posted

    i need help regarding pie chart In Asp.net(c#)
    my pie chart is working and data also show on the pie chart from the database
    problem is that i want to explain the color represent which thing  for example
    i have to attribute  complete project and incomplete project
    blue color represent incomplete project
    red color represent complete project
    i want to show along with the pie chart expalnation
     i tried much bt i can,t show these two things with my chart
    i also see many example on the net bt i can,t understand how the display  these  things

    i m new in c#
    this is my code 

    iused  this logic to display a pie chart
    i got yvalues from the database
    ========================================
    {
    double[] yValues = { one ,two };
    string[] xValues = { "complete", "incomplete" };


    for (int pointIndex = 0; pointIndex < 2; pointIndex++)
    {

    Chart1.Series[0].Points.DataBindXY(xValues,yValues);

    Chart1.Series[0].Font = new Font("Trebuchet MS", 8, FontStyle.Bold);
    Chart1.Series[0]["CollectedToolTip"] = "Other";
    Chart1.Series[0]["PieLabelStyle"] = "Outside";
    }

    Chart1.Series["Series1"]["PointWidth"] = "4";// Show data points labels

    }

    thanx in advance ..
    Saturday, March 13, 2010 10:53 AM

Answers

  • User187056398 posted

    It's easier to do it with the property editor which creates this markup:

        <asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource1">
            <Legends>
                <asp:Legend Name="Legend1">
                </asp:Legend>
            </Legends>
            <Series>
                <asp:Series ChartType="Pie" Legend="Legend1" Name="Series1">
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="ChartArea1">
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 13, 2010 2:08 PM

All replies

  • User187056398 posted

    It's easier to do it with the property editor which creates this markup:

        <asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource1">
            <Legends>
                <asp:Legend Name="Legend1">
                </asp:Legend>
            </Legends>
            <Series>
                <asp:Series ChartType="Pie" Legend="Legend1" Name="Series1">
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="ChartArea1">
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 13, 2010 2:08 PM
  • User3866881 posted

    Hey, what's up? is your problem solved?

    Maybe you can mark as an answer, or tell us by offering your both aspx and cs codes.

    Thx

    ^_^ 

    Monday, March 15, 2010 9:21 PM
  • User806215137 posted

    my problem is solved  by myself ....:)

    Sunday, March 28, 2010 8:53 AM
  • User216623931 posted

    Hey i am also facing the similar problem.

    I have used Legend to distinguish between 2 colors, but i need to show % as labels in the chart. But when i  assign different value (for ex: Used and UnUsed) to Legend, it is displaying label's text (Percentage).

    Here is the code in .cs

    int UsedSpace = Convert.ToInt32((doubleUsed / doubleTotal) * 100);

    int UnusedSpace = Convert.ToInt32(((doubleTotal - doubleUsed) / doubleTotal)*100);

      

    string[] usedString = { UsedSpace +"%" };

    string[] unUsedString = { UnusedSpace + "%" };

    double[] usedValue = { doubleUsed};

    double[] unUsedValue = { doubleTotal-doubleUsed };

    if (doubleUsed != 0 && (doubleTotal != 0.0))

    {

    string[] xValues = { UsedSpace + "%", UnusedSpace + "%" };

    double[] yValues = { doubleUsed, doubleTotal };

    Chart1.Series["Series1"].Points.DataBindXY(xValues, yValues);

    }

    else if (doubleUsed != 0)

    {

    Chart1.Series["Series1"].Points.DataBindXY(usedString, usedValue);

    }

    else if (doubleTotal != 0)

    {

    Chart1.Series["Series1"].Points.DataBindXY(unUsedString, unUsedValue);

    }

    Can anyone suggest me where i am going wrong...

    Thanks in Advance

    Friday, April 30, 2010 5:59 AM
  • User806215137 posted

    Label="#PERCENT{P1}

    use this label then % will be show on the chart

    <asp:Series Name="Series1"   CollectedLabel=Other, MinimumRelativePieSize=20" MarkerStyle="Circle" BorderColor="64, 64, 64, 64" Color="180, 65, 140, 240" Label="#PERCENT{P1}">
                                </asp:Series>

    I M NT UNDERSTAND WHAT U WANT TO ASK

    IF U SHOW LIKE THIS 30% ON THE PIE CHART LIKE THEN USE LABEL

    U CNA USE ON THE IT ON ASPX PAGE WHERE U PUT THE CHART ..

    if u any other problem .. then tel me  i  give u my code where u get more help to solve ur problem

    Monday, May 3, 2010 12:15 PM