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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:26:34+00:00 2026-06-14T00:26:34+00:00

I was looking for some ready code so I could insert my data, labels

  • 0

I was looking for some ready code so I could insert my data, labels etc. into a function and receive a ready google-chart like this.

enter image description here

But I didn’t find any. Any ideas?

  • 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-14T00:26:37+00:00Added an answer on June 14, 2026 at 12:26 am

    In the mean time, I wrote a function that receive all the necessary parameters, creates a google chart and converts it UIImage. Here it is:

    -(UIImage )produceGoogleChartImage:(NSString)title

                               xAxis:(NSArray*)axisXLabels
                              yAxis:(NSArray*)axisYLabels
                            andData:(NSArray*)dataValues
                              color:(NSString*)lineColor
                         chartWidth:(NSNumber*)width
                         chartHight:(NSNumber*)hight
                        lagendLabel:(NSString*)legend
                           minScale:(NSNumber*)minScale
                           maxScale:(NSNumber*)maxScale{
    
    NSMutableString *myurl = [NSMutableString stringWithString:@"http://chart.googleapis.com/chart?chxl=0:|"];
    
    
    //axisXLabels
    int countAxisXLabels = [axisXLabels count];
    
    for(NSUInteger i = 0; i < countAxisXLabels; ++i)
    {
        NSNumber *value = [axisXLabels objectAtIndex:i];
        [myurl appendFormat:@"%@", value];
        if(i < countAxisXLabels - 1)
            [myurl appendString:@"|"];
    }
    
    [myurl appendString:@"|1:|"];
    
    
    //axisYLabels
     int countAxisYLabels = [axisYLabels count];
    for(NSUInteger i = 0; i < countAxisYLabels; ++i)
    {
        NSNumber *value = [axisYLabels objectAtIndex:i];
        [myurl appendFormat:@"%@", value];
        if(i < countAxisYLabels - 1)
            [myurl appendString:@"|"];
    }
    
    [myurl appendString:@"&chxr=0,0,105|1,3.333,100&chxt=x,y&chs="];
    
    //size
    [myurl appendFormat:@"%@x%@&cht=lc&chd=t:", width,hight];
    
    //dataValues
    int countDataValues = [dataValues count];
    
    for(NSUInteger i = 0; i < countDataValues; ++i)
    {
        NSNumber *value = [dataValues objectAtIndex:i];
        [myurl appendFormat:@"%@", value];
        if(i < countDataValues - 1)
        [myurl appendString:@","];
    }
    
    //legend
    [myurl appendFormat:@"&chdl=%@&chg=25,50&chls=2&",legend];
    
    //color
    [myurl appendFormat:@"chm=o,%@,0,-2,8&chco=%@",lineColor,lineColor];
    
    //title
    [myurl appendFormat:@"&chtt=+%@",title];
    
    //scale
    [myurl appendFormat:@"&chds=%@,%@",minScale,maxScale];
    
    
    
    NSString *theurl=[myurl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:theurl]
    

    cachePolicy:NSURLRequestUseProtocolCachePolicy
    timeoutInterval:60.0];

    NSURLResponse* response;
    NSError* error;
    NSData *imageData=[NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response
    

    error:&error];
    NSLog(@”%@”,error);
    NSLog(@”%@”,response);
    NSLog(@”%@”,imageData);

    UIImage *myimage = [[UIImage alloc] initWithData:imageData];
    
    
    return myimage;
    
    // Chart Wizard: https://developers.google.com/chart/image/docs/chart_wizard
     }
    

    And here is the test function:

    -(void)test{

    NSString* title = @"Height History";
    NSArray *axisXLabels = [NSArray arrayWithObjects:
                           @"Jan",
                           @"Feb",
                           @"Mar",
                           @"Jun",
                           @"Jul",
                           @"Aug",
                           nil];
    
    
    NSArray *axisYLabels = [NSArray arrayWithObjects:
                            [NSNumber numberWithInt:0],
                            [NSNumber numberWithInt:50],
                            [NSNumber numberWithInt:150],
                            [NSNumber numberWithInt:200],
                            nil];
    
    NSArray *dataValues = [NSArray arrayWithObjects:
                           [NSNumber numberWithInt:130],
                           [NSNumber numberWithInt:140],
                           [NSNumber numberWithInt:140],
                           [NSNumber numberWithInt:150],
                           [NSNumber numberWithInt:170],
                           [NSNumber numberWithInt:180],
                           nil];
    
    NSString *lineColor = @"FF9900";
    
    NSNumber *width = [NSNumber numberWithInt:300];
    
    NSNumber *hight = [NSNumber numberWithInt:200];
    
    NSNumber *minScale = [NSNumber numberWithInt:0];
    
    NSNumber *maxScale = [NSNumber numberWithInt:200];
    
    NSString *legendLabel = @"cm";
    
    UIImage *myimage =[self produceGoogleChartImage:title xAxis:axisXLabels yAxis:axisYLabels andData:dataValues color:lineColor
    

    chartWidth:width chartHight:hight lagendLabel:legendLabel
    minScale:minScale maxScale:maxScale];

    _chartImage.image=myimage;
    

    }

    You should get image, like the one in the question.

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

Sidebar

Related Questions

I'd like some help with the following jQuery code if possible... $(document).ready(function() { $('table.sortable').each(function()
Looking for some best-practice guidance. Let's say I have a line of code like
I've been looking into some DHT systems, specially Pastry and Chord. I've read some
Looking at some assembly code for x86_64 on my Mac, I see the following
Looking at some of the code System.Linq I've come across some examples of Buffer<TSource>
I'm cleaning up some pretty complicated code that I didn't write and I'm looking
I'm looking into speeding up my python code, which is all matrix math, using
I am wondering if someone could help me with some probably rather simple code,
We use scrollto. Code:js $(document).ready(function() { $(a.anchorLink).anchorAnimate() }); jQuery.fn.anchorAnimate = function(settings) { settings =
I am looking for some tips how to read strings from a remote server

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.