Click here to Skip to main content
15,889,456 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
I create small code to find total space C and free space
and display them in labels

now I try to create image or chart to display these values
how can I do that?
Posted
Updated 29-Aug-14 3:10am
v2
Comments
Leo Chapiro 29-Aug-14 9:11am    
What have you already achived? have you tried just to draw a circle like this: http://msdn.microsoft.com/en-us/library/aa287520%28v=vs.71%29.aspx ?

For example consider Microsoft Charts: http://msdn.microsoft.com/en-us/library/dd456632.aspx[^] (for .NET v.4.0-4.5).

For v.3.5, download http://www.microsoft.com/en-us/download/details.aspx?id=14422[^].

—SA
 
Share this answer
 
Try this:

C#
public void DrawPieChartOnForm()
{
    //100% C volume, 60% free space on it
    int[] myPiePercent = { 40, 60 };
    Color[] myPieColors = { Color.Red, Color.Black };

    using (Graphics myPieGraphic = this.CreateGraphics())
    {
        //Give Location Which Will Display Chart At That Location.
        Point myPieLocation = new Point(10, 10);

        //Set Here Size Of The Chart…
        Size myPieSize = new Size(150, 150);

        //Call Function Which Will Draw Pie of Values.
        DrawPieChart(myPiePercent, myPieColors, myPieGraphic, myPieLocation, myPieSize);
    }
}


// Draws a pie chart.
public void DrawPieChart(int[] myPiePerecents, Color[] myPieColors, Graphics myPieGraphic, Point myPieLocation, Size myPieSize)
{
    int PiePercentTotal = 0;
    for (int PiePercents = 0; PiePercents < myPiePerecents.Length; PiePercents++)
    {
        using (SolidBrush brush = new SolidBrush(myPieColors[PiePercents]))
        {

            //Here it Will Convert Each Value Into 360, So Total Into 360 & Then It Will Draw A Full Pie Chart.
            myPieGraphic.FillPie(brush, new Rectangle(new Point(10, 10), myPieSize), Convert.ToSingle(PiePercentTotal * 360 / 100), Convert.ToSingle(myPiePerecents[PiePercents] * 360 / 100));
        }

        PiePercentTotal += myPiePerecents[PiePercents];
    }
    return;
}
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900