Hi, I am attempting to write an application with core-plot that will scale the y-axis values between the smallest value and the largest value. This part works well, however when these values are drawn on the y-axis line, the values do not take up the entire length of the y axis.
Statement to set up y-range:
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat([self getYBottomValueWithOffset:0]) length:CPDecimalFromFloat([self getYTopValueWithOffset:0])];
Method to set up y-axis views
-(void)configureYAxisForGraph:(CPXYGraph*)graphForAxis{
CPXYAxisSet *axisSet = (CPXYAxisSet *)graphForAxis.axisSet;
CPXYAxis *y = axisSet.yAxis;
y.minorTicksPerInterval = 0;
y.labelOffset = 0.0f;
y.labelingPolicy = CPAxisLabelingPolicyNone;
//set the starting position of the x-axis
y.orthogonalCoordinateDecimal = CPDecimalFromString(@"0");
y.title = kYAxisTitle;
y.titleOffset = 60.0;
int yRange = [self getYTopValueWithOffset:0] - [self getYBottomValueWithOffset:0];
NSMutableArray *customTickLocations = [[NSMutableArray alloc] initWithCapacity:yRange];
float sample = ([self getYTopValueWithOffset:0] - [self getYBottomValueWithOffset:0])/kSampleRate;
for (int x = 0; x < (kSampleRate + 1); x++) {
[customTickLocations addObject:[NSNumber numberWithFloat:((x*sample) + [self getYBottomValueWithOffset:0])]];
}
NSMutableArray *customLabels = [[NSMutableArray alloc] initWithCapacity: customTickLocations.count];
for (int i = 0; i < [customTickLocations count]; i++) {
NSNumber *tickLocation = [customTickLocations objectAtIndex:i];
//only show every second label
if (i % 2 == 0) {
CPAxisLabel *newLabel = [[CPAxisLabel alloc] initWithText:[NSString stringWithFormat:@"%@", tickLocation] textStyle:y.labelTextStyle];
newLabel.tickLocation = [tickLocation decimalValue];
newLabel.offset = y.labelOffset + y.majorTickLength;
[customLabels addObject:newLabel];
[newLabel release];
}
}
y.alternatingBandFills = [NSArray arrayWithObjects:[[CPColor whiteColor] colorWithAlphaComponent:0.2], [NSNull null], nil];
y.axisLabels = [NSSet setWithArray:customLabels];
y.majorTickLocations = [NSSet setWithArray:customTickLocations];
y.masksToBorder = YES;
}
Thanks,
William