如何使用核心图中的数字绘制散点图

发布于 2024-10-30 18:54:27 字数 47 浏览 4 评论 0原文

我需要在 iPhone 中使用给定的数字数组绘制散点图。我怎样才能实现这个目标?

I need to draw a scatter plot with the given array of numbers in iPhone. How can I achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

脱离于你 2024-11-06 18:54:27

您只需要编写一个方法,该方法将返回 (NSNumber *) 对象并以 NSInteger (它将是您想要值的索引)作为参数。在此方法中,您将从 NSMutableArray 的特定索引中检索值。

现在步骤 2) 编写如下所示的方法。通过这种方法,图形将知道要绘制多少个坐标。

-(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot {
    return (here you should call your method that will return the length of your array);
}

步骤 3) 这是您的图表将用来绘制坐标的方法。

-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index {

    if (fieldEnum == CPScatterPlotFieldX)
    {
        return (value that you want to plot on X- axis. for example index);
    }
    else
    {
        return ( call your method you implemented in step 1) that will fetch a value from your array and pass (index) as parameter); // It will plot the value on the y-axis.
    }
}

You just need to write a method which will returns an object of (NSNumber *) and takes NSInteger (it will be the index for which you want the value) as parameter. Inside this method you will retrieve the value from a specific index of your NSMutableArray.

Now step number 2) write the method as shown below. By this method the graph will know how many co - ordinates are to be plotted.

-(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot {
    return (here you should call your method that will return the length of your array);
}

Step 3) This is the method to which your graph will look at for plotting a coordinate.

-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index {

    if (fieldEnum == CPScatterPlotFieldX)
    {
        return (value that you want to plot on X- axis. for example index);
    }
    else
    {
        return ( call your method you implemented in step 1) that will fetch a value from your array and pass (index) as parameter); // It will plot the value on the y-axis.
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文