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 7026579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:08:11+00:00 2026-05-28T00:08:11+00:00

I have downloaded CorePlot_0.9 from google and imported in my iPhone project. I want

  • 0

I have downloaded CorePlot_0.9 from google and imported in my iPhone project. I want to draw line(ScatterPlot) in iphone app. I just reviewed and copy the code from 'CPTTestApp-iPhone' CPTTestAppScatterPlotController class and run the project it working very good. But, i want to change the chart values. I tried my level best but, i can’t find where i need to give the values and how the scatterplot values show in the graph. Here is the code,

    This is in ViewDidLoad
    {
// Create a green plot area
    CPTScatterPlot *dataSourceLinePlot = [[[CPTScatterPlot alloc] init] autorelease];
    CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];
    lineStyle.lineWidth = 5.f;
    lineStyle.miterLimit = 1.0f;
    lineStyle.lineWidth = 3.0f;
    lineStyle.lineColor = [CPTColor blackColor];
    lineStyle.dashPattern = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0f], [NSNumber numberWithFloat:0.0f], nil];
    dataSourceLinePlot.dataLineStyle = lineStyle;
    dataSourceLinePlot.identifier = @"Green Plot";
    dataSourceLinePlot.dataSource = self;

     // Add some initial data
            NSMutableArray *contentArray = [NSMutableArray arrayWithCapacity:100];
            NSUInteger i;
            for ( i = 0; i < 20; i++ )
            {
                id x = [NSNumber numberWithFloat:0+i*0.5];//1+i*0.05
                //NSLog(@"Rand_Max : %d", RAND_MAX);//Rand_Max : 2147483647
                id y = [NSNumber numberWithFloat:3.2*rand()/(float)RAND_MAX+0.2];//1.2*rand()/(float)RAND_MAX + 1.2
                [contentArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:x, @"x", y, @"y", nil]];
            }
            dataForPlot = contentArray;
    }

    #pragma mark -
    #pragma mark Plot Data Source Methods

    -(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot 
    {
        return [dataForPlot count];
    }

    -(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index 
    {
        NSLog(@"NumberForPlot calling");
        NSNumber *num = [[dataForPlot objectAtIndex:index] valueForKey:(fieldEnum == CPTScatterPlotFieldX ? @"x" : @"y")];
        // Green plot gets shifted above the blue
        if ([(NSString *)plot.identifier isEqualToString:@"Green Plot"])
        {
            if ( fieldEnum == CPTScatterPlotFieldY ) 
                num = [NSNumber numberWithDouble:[num doubleValue] + 0.0];
        }
        return num;
    }

Please help where i need to give the values to change the values appear in graph? And also give me suggestion how can i change the values dynamically for the graph? Thanks in advance. Please help me.

  • 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-05-28T00:08:12+00:00Added an answer on May 28, 2026 at 12:08 am

    I have created a method like -(void) drawScatterPlot; and wrote the code to draw the scatter plots in that method like this below,

    {
    // Create a green plot area
        CPTScatterPlot *dataSourceLinePlot = [[[CPTScatterPlot alloc] init] autorelease];
        CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];
        lineStyle.lineWidth = 5.f;
        lineStyle.miterLimit = 1.0f;
        lineStyle.lineWidth = 3.0f;
        lineStyle.lineColor = [CPTColor blackColor];
        lineStyle.dashPattern = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0f], [NSNumber numberWithFloat:0.0f], nil];
        dataSourceLinePlot.dataLineStyle = lineStyle;
        dataSourceLinePlot.identifier = @"Green Plot";
        dataSourceLinePlot.dataSource = self;
    
         NSMutableArray *contentArray = [[NSMutableArray alloc] init]; 
       NSUInteger i;
       for ( i = 0; i < 4; i++ )
         {
        int xVal = [[customTickLocations objectAtIndex:i] intValue];
        id x = [NSNumber numberWithInt:xVal];
    
        int yVal = [[scatterValuesArray objectAtIndex:i] intValue];
        id y = [NSNumber numberWithInt:yVal];
    
        NSLog(@"X and Y in content Array Loop : %@ , %@", x , y);
        [contentArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:x, @"x", y, @"y", nil]];
          }
                dataForPlot = contentArray;
     }
    

    And i reload this method while when am getting new real time values.

    Thanks.

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

Sidebar

Related Questions

I have downloaded facebook-java-api-3.0.2-bin from http://code.google.com/p/facebook-java-api/ for connecting to face book.I want to use
I have downloaded a project from a website. But I don‘t want to import
I have downloaded a web project from CodePlex and am getting the following error
I have downloaded xcode and have developed a crud app (on the iphone) that
I have downloaded an Android project. To avoid name conflicts I want to move
I have downloaded an .osm file from open street map and I want to
I have downloaded an application from internet(from Chrome browser) named a.app, and there will
have downloaded Orca to edit an MSI file. I want to remove some banner
I have downloaded the silver light from this http://www.microsoft.com/silverlight// I need to use this
I have downloaded Skype4COM from Skype so my question is, can i integrate it

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.