核心图:刻度间隔 [英] Core Plot: Tick Intervals

查看:63
本文介绍了核心图:刻度间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在iOS应用程序中使用Core Plot,并且想格式化轴的步距。我得到的只是0.5的步长,我不知道还有什么要改变的。我的刻度位置应为5、10、15和20。

I'm using Core Plot in an iOS-Application and want to format the steps of axis. All I get is steps of 0.5 and I don't know what else to change. My tick Locations should by 5, 10, 15 and 20.

以下是绘制我的坐标轴的代码:

Here is the code that draws my axis:

-(void) addAxis{

    // Create grid line styles
    CPTMutableLineStyle *majorGridLineStyle = [CPTMutableLineStyle lineStyle];
    majorGridLineStyle.lineWidth = 1.0f;
    majorGridLineStyle.lineColor = [[CPTColor whiteColor] colorWithAlphaComponent:0.75];

    NSSet *majorTickLocations = [NSSet setWithObjects:[NSDecimalNumber zero],
                                 [NSDecimalNumber numberWithUnsignedInteger:5],
                                 [NSDecimalNumber numberWithUnsignedInteger:10],
                                 [NSDecimalNumber numberWithUnsignedInteger:15],
                                 [NSDecimalNumber numberWithUnsignedInteger:20],
                                 nil];

    // Create axes
    CPTXYAxisSet *axisSet = (CPTXYAxisSet *)self.graph.axisSet;
    CPTXYAxis *x = axisSet.xAxis;
    {
        x.labelingPolicy = CPTAxisLabelingPolicyLocationsProvided;
        x.tickDirection = CPTSignNone;
        x.majorTickLocations = majorTickLocations;
        x.labelOffset = 6.0;
        x.labelRotation = M_PI/2;
        x.visibleRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(19.0f)];
        x.gridLinesRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(30.0f)];
        x.title = @"Jahre";
        x.titleOffset = 35.0f;
        x.titleLocation = CPTDecimalFromFloat(x.visibleRange.lengthDouble / 2.0);
        x.plotSpace = self.barPlotSpace;
    }

    CPTXYAxis *y = axisSet.yAxis;
    {
        y.labelingPolicy = CPTAxisLabelingPolicyLocationsProvided;
        y.majorTickLocations = majorTickLocations;
        y.minorTicksPerInterval = 0;
        y.preferredNumberOfMajorTicks = 8;
        y.majorGridLineStyle = majorGridLineStyle;
        y.axisLineStyle = nil;
        y.majorTickLineStyle = nil;
        y.minorTickLineStyle = nil;
        y.labelOffset = 10.0;
        y.visibleRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(30.0f)];
        y.gridLinesRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(18.5f)];
        y.title = @"Sparbetrag";
        y.titleOffset = 40.0f;
        y.titleLocation = CPTDecimalFromFloat(y.visibleRange.lengthDouble / 2.0);
        y.plotSpace = barPlotSpace;
    }

    // Set axes
    self.graph.axisSet.axes = [NSArray arrayWithObjects:x, y, nil];
}


推荐答案

找到了解决方案:主题改变了情节的绘画行为。如果我不应用主题-一切都很好。

Found the solution: Applying a theme changes the painting-behavior of the plot. If I don't apply a theme - everything is fine.

这不是很直观。我希望主题只会改变颜色,或者某些方面可以被覆盖。

For this is not very intuitive. I would expect that a theme only changes colors or that some aspects can be overridden.

这篇关于核心图:刻度间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆