I have a core plot graph in which I have prices data. The x-axis represents the time, while the y represents the price. I've determined that it's this code specifically that determines the space in between the tick marks:

CGFloat dateCount = [timestamps count];
NSMutableSet *xLabels = [NSMutableSet setWithCapacity:dateCount];
NSMutableSet *xLocations = [NSMutableSet setWithCapacity:dateCount];
float i = 0;
for (NSString *date in timestampStrings) {
    CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:date textStyle:x.labelTextStyle];
    CGFloat location = i+=spaceBetweenXAxisTicks; // Here's where the space between is set
    label.tickLocation = CPTDecimalFromCGFloat(location);
    label.offset = x.majorTickLength;
    if (label) {
        [xLabels addObject:label];
        [xLocations addObject:[NSNumber numberWithFloat:location]];
    }
}

Is there some way to dynamically set the space in between so the last tick hits the right of the graph? Thanks!

有帮助吗?

解决方案

The spaceBetweenXAxisTicks should be the length of the plot space xRange divided by the number of tick marks minus one (1).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top