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

  • Home
  • SEARCH
  • 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 6380695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:18:04+00:00 2026-05-25T02:18:04+00:00

I am working on a iphone barchart application. I am not getting the ticker

  • 0

I am working on a iphone barchart application. I am not getting the ticker label value in accordance as shown in below image:

enter image description here

barChart = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
CPTTheme *theme = [CPTTheme themeNamed:kCPTStocksTheme];
[barChart applyTheme:theme];
CPTGraphHostingView *hostingView =(CPTGraphHostingView *)self.view;
//[self.scrollview addSubview:hostingView];
hostingView.hostedGraph = barChart;

// Border
barChart.plotAreaFrame.borderLineStyle = nil;
barChart.plotAreaFrame.cornerRadius = 10.0f;

// Paddings
barChart.paddingLeft = 0.0f;
barChart.paddingRight = 0.0f;
barChart.paddingTop = 0.0f;
barChart.paddingBottom = 0.0f;

barChart.plotAreaFrame.paddingLeft = 70.0;
barChart.plotAreaFrame.paddingTop = 20.0;
barChart.plotAreaFrame.paddingRight = 20.0;
barChart.plotAreaFrame.paddingBottom = 80.0;

// Graph title
barChart.title = @"Statistics";
CPTMutableTextStyle *textStyle = [CPTTextStyle textStyle];
textStyle.color = [CPTColor greenColor];
textStyle.fontSize = 20.0f;
textStyle.textAlignment = CPTTextAlignmentCenter;
barChart.titleTextStyle = textStyle;
barChart.titleDisplacement = CGPointMake(0.0f, -20.0f);
barChart.titlePlotAreaFrameAnchor = CPTRectAnchorTop;

// Add plot space for horizontal bar charts
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)barChart.defaultPlotSpace;
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(15.0f)];
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(20.0f)];
plotSpace.globalXRange=[CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(20.0f)];
    plotSpace.globalYRange=[CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(20.0f)];
plotSpace.allowsUserInteraction=TRUE;



CPTXYAxisSet *axisSet = (CPTXYAxisSet *)barChart.axisSet;
CPTXYAxis *x = axisSet.xAxis;
x.axisLineStyle = nil;
x.majorTickLineStyle = nil;
[x setMinorTickLineStyle:CPTLinearBlendingMode];
x.majorIntervalLength = CPTDecimalFromString(@"10");
x.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0");
x.title = @"Quiz Date";
x.majorTickLength=10.0f;
x.titleLocation = CPTDecimalFromFloat(7.5f);
x.titleOffset = 60.0f;
x.labelOffset=5.0f;

// Define some custom labels for the data elements
x.labelRotation = M_PI/2;
x.labelingPolicy = CPTAxisLabelingPolicyNone;
//NSDecimalNumber add=0;


CPTPlotRange *globalxrange=[CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0f) length:CPTDecimalFromDouble(1000.0f)];
plotSpace.globalXRange=globalxrange; 

NSMutableArray *customTickLocations = [[NSMutableArray alloc]init];
NSDecimalNumber *num = nil;
for (int i=0;i<[arr count];i++) {
    num = (NSDecimalNumber *)[NSDecimalNumber numberWithUnsignedInteger:i*5];
    [customTickLocations addObject:num];
}

NSArray *xAxisLabels =[[NSMutableArray alloc]initWithArray:labelValue]; //[NSArray arrayWithObjects:@"Label A", @"Label B", @"Label C", @"Label D", @"Label E", nil];
NSUInteger labelLocation = 0;
NSMutableArray *customLabels = [NSMutableArray arrayWithCapacity:[xAxisLabels count]];
for (NSNumber *tickLocation in customTickLocations) {
    CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText: [xAxisLabels objectAtIndex:labelLocation++] textStyle:x.labelTextStyle];
    newLabel.tickLocation = [tickLocation decimalValue];
    newLabel.offset =x.labelOffset+ x.majorTickLength ;
    newLabel.rotation =M_PI/2;
    NSLog(@"-=-=-=--=-=-=- %d",x.labelOffset+ x.majorTickLength );
    [customLabels addObject:newLabel];
    [newLabel release];
}
x.axisLabels =  [NSSet setWithArray:customLabels];





CPTXYAxis *y = axisSet.yAxis;
y.labelingPolicy=CPTAxisLabelingPolicyAutomatic;
y.axisLineStyle = nil;
y.majorTickLineStyle = nil;
y.minorTickLineStyle = nil;
y.majorIntervalLength = CPTDecimalFromString(@"1");
y.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0");
y.title = @"No. of Questions";
y.titleOffset = 50.0f;
y.titleLocation = CPTDecimalFromFloat(150.0f);

// First bar plot
CPTBarPlot *barPlot = [CPTBarPlot tubularBarPlotWithColor:[CPTColor blueColor] horizontalBars:NO];
barPlot.baseValue = CPTDecimalFromString(@"0");
barPlot.dataSource = self;
barPlot.barWidth=CPTDecimalFromFloat(1.0f);
barPlot.plotRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0)                                       length:CPTDecimalFromDouble(x.labelOffset + x.majorTickLength)];
barPlot.barOffset =CPTDecimalFromFloat(1.0f);
barPlot.barCornerRadius = 2.0f;
barPlot.identifier = @"Bar Plot 1";

[barChart addPlot:barPlot toPlotSpace:plotSpace];
    `// barPlot.barOffset = CPTDecimalFromFloat(0.25f);
barPlot.barCornerRadius = 2.0f;
barPlot.identifier = @"Bar Plot 2";
[barChart addPlot:barPlot toPlotSpace:plotSpace];`

// third bar plot
barPlot = [CPTBarPlot tubularBarPlotWithColor:[CPTColor redColor] horizontalBars:NO];
barPlot.dataSource = self;
barPlot.barWidth=CPTDecimalFromFloat(1.0f);
barPlot.baseValue = CPTDecimalFromString(@"0"); 
barPlot.plotRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0)length:CPTDecimalFromDouble(x.labelOffset + x.majorTickLength)];
barPlot.barOffset =CPTDecimalFromFloat(3.0f);
barPlot.barCornerRadius = 2.0f;
barPlot.identifier = @"Bar Plot 3";
[barChart addPlot:barPlot toPlotSpace:plotSpace];


// arrayWithObjects:[NSDecimalNumber numberWithInt:5], [NSDecimalNumber numberWithInt:10], [NSDecimalNumber numberWithInt:15], nil];}

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

-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index `{`
NSDecimalNumber *num = nil;
if ( [plot isKindOfClass:[CPTBarPlot class]] ) {
    switch ( fieldEnum ) {
        case CPTBarPlotFieldBarLocation:
            num = (NSDecimalNumber *)[NSDecimalNumber numberWithUnsignedInteger:index];
            break;

        case CPTBarPlotFieldBarTip:
            if ( [plot.identifier isEqual:@"Bar Plot 1"] ) 
                num=[NSDecimalNumber decimalNumberWithString:[totalValues objectAtIndex:index]];

            if ( [plot.identifier isEqual:@"Bar Plot 2"] ) 
                num=[NSDecimalNumber decimalNumberWithString:[correctValues objectAtIndex:index]];

            if ( [plot.identifier isEqual:@"Bar Plot 3"] ) 
                num=[NSDecimalNumber decimalNumberWithString:[wrongArray objectAtIndex:index]];

            break;


        case CPTScatterPlotFieldX:  
            if ( [plot.identifier isEqual:@"Bar Plot 1"] ) 
                num=[NSDecimalNumber decimalNumberWithString:[totalValues objectAtIndex:index]];
            return num;

            if ( [plot.identifier isEqual:@"Bar Plot 2"] ) 
                num=[NSDecimalNumber decimalNumberWithString:[correctValues objectAtIndex:index]];
                return num;

            if ( [plot.identifier isEqual:@"Bar Plot 3"] ) 
                num=[NSDecimalNumber decimalNumberWithString:[wrongArray objectAtIndex:index]];
            return num;

            break;


    }
}

return num;`}`

-(CPTFill *) barFillForBarPlot:(CPTBarPlot *)barPlot recordIndex:(NSNumber *)index; 
{
return nil;
}
  • 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-25T02:18:04+00:00Added an answer on May 25, 2026 at 2:18 am

    Set the barOffset to zero for the plot that you want lined up with the labels. Set the others relative to that one. For example:

    barPlot1.barOffset = CPTDecimalFromDouble(-1.0);
    barPlot2.barOffset = CPTDecimalFromDouble( 0.0);
    barPlot3.barOffset = CPTDecimalFromDouble( 1.0);
    

    You will also need to adjust the xRange of the plot space to keep the first couple of bars visible.

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

Sidebar

Related Questions

I'm working on an iphone application (not web app) and I'd like to build
I am working on Iphone application and new to dev. I am sorry if
I am working on iphone networking application.. I am using asihttp , a wrapper
I'm working on iphone application which needs to run offline at an exhibition. It
I am working on an iPhone Application that stores images in the Applications 'Document'
I'm working on an iPhone application. I have an object of class Row that
I'm working on an iPhone application which will use long-polling to send event notifications
I have an existing working iPhone project inside XCode 4.2. I localized an image
I am working on iphone application in which i have to return the keyboard
I am working on iphone application in which i have to insert multiples values

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.