我想知道如何将单位附加到动态的“核心绘图”轴,如下所示。不幸的是,这并不像遍历标签和附加文本那样简单(我相信是由于层处理和渲染)。有人知道该怎么做吗?

    CPTXYAxis *x = axisSet.xAxis;
    x.orthogonalCoordinateDecimal = CPTDecimalFromDouble(self.plotSpace1.xRange.minLimitDouble);//Where the Y Axis meets the X axis
    x.majorIntervalLength = CPTDecimalFromDouble(200.0);//Interval for X Axis
    x.minorTicksPerInterval = 0;
//    x.tickDirection = CPTSignNone;
//    x.axisLineStyle = axisLineStyle;
//    x.majorTickLength = 12.0;
//    x.majorTickLineStyle = axisLineStyle;
//    x.minorTickLength = 8.0;
    x.title = cYards;
    x.titleTextStyle = axisTitleTextStyle;
    x.titleOffset = 25.0;
    x.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];


    // Label y with an automatic labeling policy.
    axisLineStyle.lineColor = [CPTColor greenColor];

    CPTXYAxis *y = axisSet.yAxis;
    y.labelingPolicy = CPTAxisLabelingPolicyAutomatic;
    y.preferredNumberOfMajorTicks = 11;
    y.majorIntervalLength = CPTDecimalFromDouble(100.0);
    y.minorTicksPerInterval = 0;
    y.tickDirection = CPTSignNegative;
    y.axisLineStyle = axisLineStyle;
    y.majorTickLineStyle = axisLineStyle;
    y.orthogonalCoordinateDecimal = CPTDecimalFromDouble(self.plotSpace1.xRange.minLimitDouble);
    y.title = cInches;
    y.titleTextStyle = axisTitleTextStyle;
    y.titleOffset = 30.0;


    // Label y2 with an equal division labeling policy.
    axisLineStyle.lineColor = [CPTColor orangeColor];

    CPTXYAxis *y2 = [[CPTXYAxis alloc] init];
    y2.coordinate = CPTCoordinateY;
    y2.plotSpace = self.plotSpace2;
    y2.orthogonalCoordinateDecimal = CPTDecimalFromDouble(self.plotSpace1.xRange.maxLimitDouble);//Where the Y Axis meets the X axis
    y2.preferredNumberOfMajorTicks = 8;

    y2.majorIntervalLength = CPTDecimalFromDouble(200.0);
    y2.minorTicksPerInterval = 0;
    y2.tickDirection = CPTSignPositive;
    y2.axisLineStyle = axisLineStyle;
    y2.majorTickLineStyle = axisLineStyle;
    y2.title= cFps;
    y2.titleTextStyle = axisTitleTextStyle;
    y2.titleOffset = 30.0;

最佳答案

创建一个NSNumberFormatter,设置positiveSuffix和/或negativeSuffix,并将其设置为轴labelFormatter

关于ios - 用单位标记核心绘图轴,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19104806/

10-09 07:55