繁体   English   中英

核心图:使x轴间距均匀分布

[英]Core plot: Make x-axis ticks evenly spaced

我有一个核心情节图,其中我有价格数据。 x轴表示时间,而y表示价格。 我已经确定这个代码专门用来确定刻度线之间的空格:

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]];
    }
}

有没有办法在两者之间动态设置空间,以便最后一个刻度点击到图表的右边? 谢谢!

spaceBetweenXAxisTicks应该是绘图空间xRange的长度除以刻度线的数量减去一(1)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM