【问题标题】:iOS Scatter core Plot,how to join two points by a line?iOS Scatter core Plot,如何将两点连成一条线?
【发布时间】:2013-09-15 04:54:09
【问题描述】:

例如,如果绘图有五个数据点,则表示 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];
}

这里有三个不同的图表,只有当 index % 3 等于 0 时,graph2 才会绘制点。现在我想加入这个 graph2 绘制的所有点。这段代码取自 raywenderlich core plot example。

【问题讨论】:

    标签: ios ipad ios6 core-plot scatter-plot


    【解决方案1】:

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

    索引 x y ---------------------- 0 1 年 1 3 年 1 2 5 岁2

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-18
      • 2013-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多