Вопрос

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