【发布时间】:2010-10-22 23:25:26
【问题描述】:
我正在使用 Core Plot alpha 版本 0.2 并生成带有自定义标签的图。标签出现在正确的位置,但我没有刻度线。我已经尝试了这些设置的所有组合:
x.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"5"] decimalValue]; x.minorTicksPerInterval = 0; x.majorTickLineStyle = lineStyle; x.minorTickLineStyle = lineStyle; x.axisLineStyle = 线型; 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];
【问题讨论】:
标签: core-plot