2010-10-18 108 views
2

我正在使用核心绘图alpha版本0.2并生成具有自定义标签的绘图。标签出现在正确的位置,但我没有刻度线。我已尝试这些设置的每个组合:核心绘图,自定义标签和刻度标记

x.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@“5”] decimalValue]; x.minorTicksPerInterval = 0; x.majorTickLineStyle = lineStyle; x.minorTickLineStyle = lineStyle; x.axisLineStyle = lineStyle; x.minorTickLength = 5.0f; x.majorTickLength = 7.0f; x.tickDirection = CPSignNegative;

我使用还添加填充,以曲线图的底部:

graph.plotAreaFrame.paddingBottom = 10.0;

它具有将X轴向上移动的效果,但不会显示刻度标记。这看起来应该很简单,在自定义标签的位置生成一个刻度标记。但我看不出有任何办法可以做到这一点。

想法?

** * *下面是我使用生成的标签和刻度线,你需要提供的代码,没有运气*

for (int i = 0; i < [xAxisLabels count]; i++) { 
    NSDictionary * labelDict = [xAxisLabels objectAtIndex:i]; 
    NSString *label=[labelDict valueForKey:@"element"]; 

    NSNumber *offset=[labelDict valueForKey:@"x"]; 

    float location=[offset floatValue]*multiplier; 
    CPAxisLabel *newLabel = [[CPAxisLabel alloc] initWithText: label textStyle:labelStyle]; 
    newLabel.tickLocation = CPDecimalFromFloat(location); 
    newLabel.offset = x.labelOffset + x.majorTickLength; 
    [customTicks addObject:[NSDecimalNumber decimalNumberWithDecimal:CPDecimalFromFloat(location)]]; 
    [customLabels addObject:newLabel]; 
    [newLabel release]; 
} 
x.axisLabels = [NSSet setWithArray:customLabels]; 
[x setMinorTickLocations:[NSSet setWithArray:customTicks]]; 
[x setMajorTickLocations:[NSSet setWithArray:customTicks]]; 
[customTicks release]; 

回答

1

随着CPAxisLabelingPolicyNone勾号位置(minorTickLocationsmajorTickLocations)。

+0

没有运气。我用代码片段更新了我的问题,显示了我如何添加刻度。 – Cliff 2010-10-22 15:25:47