gpt4 book ai didi

ios - 核心剧情: Grid lines don't appear when labeling policy is not automatic

转载 作者:行者123 更新时间:2023-11-28 18:00:19 25 4
gpt4 key购买 nike

我正在尝试在 iPhone 应用程序中使用 Core Plot 绘制简单的统计数据。我最初将标签策略用作两个轴的 CPTAxisLabelingPolicyAutomatic,并且网格线看起来很好,如下所示:

enter image description here

您可以看到该图同时具有垂直和水平网格线。然后,我将标签策略更改为

    axisSet.xAxis.labelingPolicy = CPTAxisLabelingPolicyNone;
axisSet.yAxis.labelingPolicy = CPTAxisLabelingPolicyAutomatic;

NSUInteger labelLocation = 0;
NSMutableArray *customLabels = [NSMutableArray arrayWithCapacity:xAxisLabels.count];
CPTMutableTextStyle *textStyle = [[CPTMutableTextStyle alloc] init];
textStyle.color = [CPTColor lightGrayColor];

for (NSNumber *tickLocation in customTickLocations) {
CPTAxisLabel *newLabel = [[CPTAxisLabel alloc]
initWithText:[NSString stringWithFormat:@"%@",(NSDate *)[xAxisLabels objectAtIndex:labelLocation++]] textStyle:textStyle];
newLabel.tickLocation = [tickLocation decimalValue];
newLabel.rotation = 25.0;
newLabel.offset = 10.0;
[customLabels addObject:newLabel];
}
axisSet.xAxis.axisLabels = [NSSet setWithArray:customLabels];

但是,因为当我为 X 轴添加自定义标签时,X 轴网格线(即垂直网格线)没有出现。只能看到水平网格线,如下面的 App 截图所示:

enter image description here

最佳答案

CPTAxisLabelingPolicyNone 标签策略不会创建任何标签或刻度线。您需要创建位置集并设置 majorTickLocations 和/或 minorTickLocations

这是 Plot Gallery 示例应用程序中的一些示例代码:

NSSet *majorTickLocations = [NSSet setWithObjects:[NSDecimalNumber zero],
[NSDecimalNumber numberWithUnsignedInteger:30],
[NSDecimalNumber numberWithUnsignedInteger:50],
[NSDecimalNumber numberWithUnsignedInteger:85],
[NSDecimalNumber numberWithUnsignedInteger:100],
nil];
xAxis.majorTickLocations = majorTickLocations;

刻度位置通常与标签位置相同,但并非必须如此。

关于ios - 核心剧情: Grid lines don't appear when labeling policy is not automatic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16682717/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com