我正在使用核心繪圖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];
沒有運氣。我用代碼片段更新了我的問題,顯示了我如何添加刻度。 – Cliff 2010-10-22 15:25:47