0
votes

I am using CorePlot in iOS to show graphs, and i am able to show y-axis custom label but not able to see X-Axis custom labels.

Here is code i am using for showing the X-Axis custom labels..

 // 2 - Get axis set
CPTXYAxisSet *axisSet = (CPTXYAxisSet *) self.hostView.hostedGraph.axisSet;

// 3 - Configure x-axis
CPTAxis *x = axisSet.xAxis;
x.titleTextStyle = axisTitleStyle;
x.titleOffset = 0.0f;
x.axisLineStyle = axisLineStyle;
x.labelingPolicy = CPTAxisLabelingPolicyNone;
x.labelTextStyle = axisTextStyle;
x.majorTickLineStyle = axisLineStyle;
x.majorTickLength = 4.0f;
x.minorTickLength = 0.0f;
x.tickDirection = CPTSignNegative;

//    Draw labels
NSArray *xCustomTickLocations = [NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:1], [NSDecimalNumber numberWithInt:2],[NSDecimalNumber numberWithInt:3],[NSDecimalNumber numberWithInt:4],[NSDecimalNumber numberWithInt:5],[NSDecimalNumber numberWithInt:6],[NSDecimalNumber numberWithInt:7] ,nil];
NSArray *xAxisLabels = [NSArray arrayWithObjects:@"A", @"B", @"C", @"D", @"E",@"F",@"G", nil];
NSUInteger labelLocation = 0;
NSMutableArray *xCustomLabels = [NSMutableArray arrayWithCapacity:[xAxisLabels count]];
for (NSNumber *tickLocation in xCustomTickLocations) {
    CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText: [xAxisLabels objectAtIndex:labelLocation++] textStyle:x.labelTextStyle];
    newLabel.tickLocation = [tickLocation decimalValue];
    [xCustomLabels addObject:newLabel];
}

x.axisLabels = [NSSet setWithArray:xCustomLabels];
x.majorTickLocations = [NSSet setWithArray:xCustomTickLocations];

Please help me in what i am doing wrong. Tick marks are visible but not Labels.

1

1 Answers

0
votes

I found the issue, actually the labels are getting plotted but going outside of the frame.

So i just increased the graph bottom padding.