質問

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