【问题标题】:Core Plot, custom labels and tick marks核心图、自定义标签和刻度线
【发布时间】: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


    【解决方案1】:

    对于 CPAxisLabelingPolicyNone,您还需要提供刻度位置(minorTickLocationsmajorTickLocations)。

    【讨论】:

    • 不走运。我用代码 sn-p 更新了我的问题,显示了我是如何尝试添加刻度的。
    猜你喜欢
    • 2016-01-07
    • 2015-02-27
    • 1970-01-01
    • 2014-04-10
    • 1970-01-01
    • 1970-01-01
    • 2012-05-08
    • 2019-04-11
    • 1970-01-01
    相关资源
    最近更新 更多