iOS Scatter核心图,如何用一条线连接两个点?

标签 ios ipad ios6 core-plot scatter-plot

例如,如果绘图有五个数据点,即 x 轴上的 1-5。但我只想通过跳过 2 和 4 来仅在 1,3 和 5 处绘制点。我已经在 1,3,5 处绘制了点。但我无法用一条线连接这三个点。谁能帮我解决这个问题 提前致谢

这是我正在使用的代码

-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
    NSInteger valueCount = [[[CPDStockPriceStore sharedInstance] datesInMonth] count];

    switch (fieldEnum) {
        case CPTScatterPlotFieldX:
            if ((index < valueCount) && ((index%3)==0)) {
                return [NSNumber numberWithUnsignedInteger:(index)];
            }
        break;

        case CPTScatterPlotFieldY:
            if ([plot.identifier isEqual:CPDTickerSymbolAAPL] == YES)//graph1{
                return [[[CPDStockPriceStore sharedInstance] monthlyPrices:CPDTickerSymbolAAPL] objectAtIndex:index];
            } else
            if (([plot.identifier isEqual:CPDTickerSymbolGOOG] == YES) && ((index%3)==0))//graph2 {
                return [[[CPDStockPriceStore sharedInstance] monthlyPrices:CPDTickerSymbolGOOG] objectAtIndex:index];
            } else if ([plot.identifier isEqual:CPDTickerSymbolMSFT] == YES)//graph3 {
                return [[[CPDStockPriceStore sharedInstance] monthlyPrices:CPDTickerSymbolMSFT] objectAtIndex:index];
            }
        break;
    }
    return [NSDecimalNumber notANumber];
}

这里有三个不同的图,graph2 仅当索引 % 3 等于 0 时才会绘制点。现在我想加入该 graph2 绘制的所有点。这段代码取自raywenderlich核心图示例。

最佳答案

要仅绘制三个点,请让 -numberOfRecordsForPlot: 返回三 (3)。 x 值不必等于索引。

Index    x     y
-----------------------
  0      1     y0
  1      3     y1
  2      5     y2

关于iOS Scatter核心图,如何用一条线连接两个点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18736557/

相关文章:

ios - 由于预期为 Int 而不是 String,无法从外部 Firebase 服务器中删除 .childRemoved

ios - 如何在 swift 中显示 CGPDFDocument?

javascript - 当 iPad 中的方向从横向模式变为纵向模式时页面缩小

ipad - iPad 上字体的亚像素渲染

ios - 更改iOS锁屏的行为

iphone - 如何跟踪IOS5中的崩溃?

ios - 在for循环后按值对字典数组进行排序?

iphone - 将我的应用提交到商店而无意出售

iphone - viewWillDisappear 和 viewDidDisappear 之间存在巨大延迟

ios - 使用 UIImageView 显示动画时遇到问题