Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iOS中创建具有x和y轴的Coreplot线图_Ios_Core Plot_Linegraph - Fatal编程技术网

在iOS中创建具有x和y轴的Coreplot线图

在iOS中创建具有x和y轴的Coreplot线图,ios,core-plot,linegraph,Ios,Core Plot,Linegraph,我看过很多关于核心情节的示例教程,但其中大多数都有问题。如果有人能提供一个工作教程,使用iOS中的Core Plot framework创建数据为X=(九月、十月、十一月、十二月)和Y=(20,40,80,30)且X&Y轴的折线图?任何代码都会对我很有帮助。如果你想在核心图中绘制线性图,有一些事情需要记住。首先确保您的视图控制器能够绘制图形。需要将其设置为打印代理、打印数据源和打印空间代理 @interface ViewController : UIViewController <CPTS

我看过很多关于核心情节的示例教程,但其中大多数都有问题。如果有人能提供一个工作教程,使用iOS中的Core Plot framework创建数据为X=(九月、十月、十一月、十二月)和Y=(20,40,80,30)且X&Y轴的折线图?任何代码都会对我很有帮助。

如果你想在核心图中绘制线性图,有一些事情需要记住。首先确保您的视图控制器能够绘制图形。需要将其设置为打印代理、打印数据源和打印空间代理

@interface ViewController : UIViewController <CPTScatterPlotDelegate, CPTPlotSpaceDelegate, CPTPlotDataSource>
_数据是我用来存储所有内容的数组。接下来,您要绘制数据图。使用numberForPlot方法。这里又是一个例子

- (NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
NSLog(@"numberForPlot");
if ([plot.identifier isEqual:@"linear"])
{
    NSValue *value = [self.data objectAtIndex:index];
    CGPoint point = [value CGPointValue];

    // FieldEnum determines if we return an X or Y value.
    if (fieldEnum == CPTScatterPlotFieldX) 
    {
        return [NSNumber numberWithFloat:point.x];

    }
    else    // Y-Axis
    {
        return [NSNumber numberWithFloat:point.y];

    }
    NSLog(@"x is %.2f", point.x);
    NSLog(@"y is %.2f", point.y);
}
return [NSNumber numberWithFloat:0];
}

希望这能让你开始。核心情节是一个很好的方式来图表的事情,他们的网站充满了伟大的信息。希望这有帮助。

如果你想在核心图中绘制线性图,有一些事情需要记住。首先确保您的视图控制器能够绘制图形。需要将其设置为打印代理、打印数据源和打印空间代理

@interface ViewController : UIViewController <CPTScatterPlotDelegate, CPTPlotSpaceDelegate, CPTPlotDataSource>
_数据是我用来存储所有内容的数组。接下来,您要绘制数据图。使用numberForPlot方法。这里又是一个例子

- (NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
NSLog(@"numberForPlot");
if ([plot.identifier isEqual:@"linear"])
{
    NSValue *value = [self.data objectAtIndex:index];
    CGPoint point = [value CGPointValue];

    // FieldEnum determines if we return an X or Y value.
    if (fieldEnum == CPTScatterPlotFieldX) 
    {
        return [NSNumber numberWithFloat:point.x];

    }
    else    // Y-Axis
    {
        return [NSNumber numberWithFloat:point.y];

    }
    NSLog(@"x is %.2f", point.x);
    NSLog(@"y is %.2f", point.y);
}
return [NSNumber numberWithFloat:0];
}

希望这能让你开始。核心情节是一个很好的方式来图表的事情,他们的网站充满了伟大的信息。希望这有帮助。

是的,是的。这很有帮助。。谢谢你是的,是的。这很有帮助。。非常感谢。