我需要在我的应用程序中制作折线图来跟踪数据。我看了核心情节,似乎很复杂。有没有更简单的方法来制作一个可以水平移动的折线图,并且它需要能够添加新的段。并且不会导致巨大的内存过载,因为会经常添加很多内容,但我可以让它在飞蛾或其他东西后删除。所以我的问题基本上是:有没有比核心情节更简单的方法,如果有人可以引导我朝着能够添加更多自定义数据的方向发展。提前致谢。
编辑
我试过这个
- (void)drawRect:(CGRect)rect
{
// Drawing code
[super drawRect:rect];
// find min and max values of data
float max = -HUGE_VALF, min = HUGE_VALF;
for (int i = 0; i < 0; i ++)
{
min = MIN(min, 0);
max = MAX(max, 10);
}
// build path
for (int i = 0; i < 0; i ++)
{
// line spacing is the distance you want between line vertices
float x = i * 1;
// scale y to view height
float y = ((1 - min) / (max - min)) * self.bounds.size.height;
if (i == 0)
{
CGContextMoveToPoint(ctx, x, y);
}
else
{
CGContextAddLineToPoint(ctx, x, y);
}
}
// stroke path (configure color, width, etc before this)
CGContextStrokePath(nil);
}
@end