Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7979447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:46:58+00:00 2026-06-04T09:46:58+00:00

I am creating a pie chart in iphone app it gets 4 values from

  • 0

I am creating a pie chart in iphone app it gets 4 values from array then creates pie chart it shows pie chart filled with separate colors i also want that it must show percent for each part like if 1 is 15% then 15% 35% and 35% like this i am using following code for creating pie chart.

below is the Pie Class implementation

  - (void)drawRect:(CGRect)rect
{

   int c=[itemArray count];

   CGFloat angleArray[c];
   CGFloat offset;
   int sum=0;

   CGContextRef context = UIGraphicsGetCurrentContext();


  CGContextSetAllowsAntialiasing(context, false);
  CGContextSetShouldAntialias(context, false);
   for(int i=0;i<[itemArray count];i++)

    {


    sum+=[[itemArray objectAtIndex:i] intValue];


}


   for(int i=0;i<[itemArray count];i++)

   {

    angleArray[i]=(float)(([[itemArray objectAtIndex:i] intValue])/(float)sum)*(2*3.14); // in radians
    CGContextMoveToPoint(context, radius, radius);
    if(i==0)
        CGContextAddArc(context, radius, radius, radius, 0,angleArray[i], 0);
    else
        CGContextAddArc(context, radius, radius, radius,offset,offset+angleArray[i], 0);
    offset+=angleArray[i];


    CGContextSetFillColorWithColor(context, ((UIColor *)[myColorArray objectAtIndex:i]).CGColor);
    CGContextClosePath(context); 
    CGContextFillPath(context);



    }



   }


   -(void)createGraph{

PieClass *myPieClass=[[PieClass alloc]initWithFrame:CGRectMake(10,440,230,200)];

myPieClass.backgroundColor=[UIColor clearColor];

myPieClass.itemArray=[[NSArray alloc]initWithObjects:valueOne,valueTwo,valueThree,valueFour, nil];

myPieClass.myColorArray=[[NSArray alloc]initWithObjects:[UIColor blueColor],[UIColor redColor],[UIColor greenColor],[UIColor brownColor], nil];

myPieClass.radius=100;

[self.view addSubview:myPieClass];

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:47:00+00:00Added an answer on June 4, 2026 at 9:47 am

    here is the link to the source code for pie chart with % ratio display. This will help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm assigned with new task for creating chart application in iphone like.,(BarChart,PieChart,etc..,).But,i have no
I am creating a pie chart using PyChart library in Python. Here is my
I'm creating a simple pie chart with three data points. The first and second
I'm using fusioncharts free and creating some 3d pie charts like so... <div style=margin:0
(creating a separate question after comments on this: Javascript redeclared global variable overrides old
When creating iPhone apps in simulator, I sometimes see messages like Springboard failed to
How to set the color of a UILabel object same as the pie chart
creating 20 viewcontrollers and calling them one after the other from the mainviewcontroller as
I want to create a pie chart in JavaScript. On searching I found the
Creating an Iphone application, I used to perform INSERT QUERY on different databases. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.