核心图:RealTimePlot - 放置静态yAxis

时间:2012-05-23 08:24:01

标签: objective-c ios5 static core-plot

我的问题是我不能在我的RealTimePlot示例中放置静态yAxis(没有移动)。 在移动过程中,xAxis是静态的,但是yAxis消失了。

我的代码是:

-(void)renderInLayer:(CPTGraphHostingView *)layerHostingView withTheme:(CPTTheme *)theme
{

    graph = [[[CPTXYGraph alloc] initWithFrame:bounds] autorelease];
    layerHostingView.hostedGraph = graph;

    graph.plotAreaFrame.paddingTop    = 15.0;
    graph.plotAreaFrame.paddingRight  = 15.0;
    graph.plotAreaFrame.paddingBottom = 55.0;
    graph.plotAreaFrame.paddingLeft   = 55.0;

    // Axes
    // X axis
    CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
    CPTXYAxis *x          = axisSet.xAxis;
    x.labelingPolicy              = CPTAxisLabelingPolicyAutomatic;
    x.orthogonalCoordinateDecimal = CPTDecimalFromUnsignedInteger(0);
    x.minorTicksPerInterval       = 9;
    x.title                       = @"X Axis";
    x.titleOffset                 = 35.0;

    // Y axis
    CPTXYAxis *y = axisSet.yAxis;
    y.labelingPolicy              = CPTAxisLabelingPolicyAutomatic;
    y.orthogonalCoordinateDecimal = CPTDecimalFromUnsignedInteger(0);
    y.minorTicksPerInterval       = 3;
    y.labelOffset                 = 5.0;
    y.title                       = @"Y Axis";
    y.titleOffset                 = 30.0;

    y.constraints = CPTMakeConstraints(CPTConstraintNone, CPTConstraintFixed);

    // Rotate the labels by 45 degrees, just to show it can be done.
    x.labelRotation = M_PI * 0.25;

    // Create the plot
    CPTScatterPlot *dataSourceLinePlot = [[[CPTScatterPlot alloc] init] autorelease];
    dataSourceLinePlot.identifier     = kPlotIdentifier;
    dataSourceLinePlot.cachePrecision = CPTPlotCachePrecisionDouble;

    CPTMutableLineStyle *lineStyle = [[dataSourceLinePlot.dataLineStyle mutableCopy] autorelease];
    lineStyle.lineWidth              = 3.0;
    lineStyle.lineColor              = [CPTColor greenColor];
    dataSourceLinePlot.dataLineStyle = lineStyle;

    dataSourceLinePlot.dataSource = self;
    [graph addPlot:dataSourceLinePlot];

}

我的CorePlot版本是1.0。

任何想法??

1 个答案:

答案 0 :(得分:3)

{1.0}版本之前constraints语法已更改。尝试

y.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];