【问题标题】:Core Plot: RealTimePlot - put static yAxis核心情节:RealTimePlot - 放置静态 yAxis
【发布时间】:2012-05-23 08:24:01
【问题描述】:

我的问题是我不能在我的 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。

有什么想法吗??

【问题讨论】:

    标签: objective-c ios5 static core-plot


    【解决方案1】:

    constraints 语法在 1.0 版本之前已更改。试试

    y.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];
    

    【讨论】:

    • Core Plot 1.0 中不可能使用这一行,已弃用!!
    • 不,不是。在添加 CPTConstraints 类的同时删除了 CPTMakeConstraints 函数。此更改是在 0.9 版本之前进行的,因此您不能使用 1.0 版本包。请参阅 Core Plot 更改日志 (core-plot.googlecode.com/hg/documentation/changelog.txt) 和此处的更改详细信息:code.google.com/p/core-plot/source/…
    • 好的,这段代码没有错误:y.constraints = CPTMakeConstraints(CPTConstraintNone, CPTConstraintFixed);或 y.constraints = CPTMakeConstraints(CPTCConstraintNone, CPTConstraintNone);但结果没有找到.... yAxi 移动时消失。
    • 确保您的应用引用了正确的 Core Plot 库和标题。 CPTMakeConstraints() 函数在 1.0 中不存在,应该会导致编译器错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多