例如,如果该图有五个数据点,例如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];
}
这里有三个不同的图,并且只有索引%3等于0时graph2才会绘制点。现在,我想加入此graph2绘制的所有点。这段代码摘自raywenderlich核心图示例。
要仅绘制三个点,请-numberOfRecordsForPlot:
返回三(3)。x值不必等于索引。
索引xy ----------------------- 0 1 y0 1 3年1 2 5年
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句