【发布时间】:2010-02-24 11:04:17
【问题描述】:
我想在core-plot中添加类似于下图的数据指示线。
Plot Image http://img203.imageshack.us/img203/9412/plota.png
知道如何使用 core-plot 来实现这一点。我刚刚开始了解 core-plot,所以任何提示都会非常有用。
谢谢
编辑:
为了更好地理解,我创建了一个截屏视频来说明我的意思:
http://www.screencast.com/users/GauravVerma/folders/Jing/media/78fbef04-8785-46d6-9347-4f35d257109c
添加于 2 月 26 日:
我通过使用两个数据图解决了部分问题。这是当前的实现:
http://www.screencast.com/users/GauravVerma/folders/Jing/media/02a1e685-8bf8-41a9-aaa6-5ea6445f6a6c
我使用了两个数据图,一个是主要的,另一个只绘制一个数据点,当滑块值发生变化时会重新加载。
这是我的数据源方法(可能对某人有所帮助):
-(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot {
if ([(NSString *)plot.identifier isEqualToString:@"Blue Plot"]){
return [dataForPlot count];
}else {
return 1;
}
}
-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
if ([(NSString *)plot.identifier isEqualToString:@"Green Plot"]) {
index = floor((double)[slider value]);
if (index > [dataForPlot count] -1) {
index = [dataForPlot count] -1;
}
NSLog(@"Green plot index : %f",index);
}
NSNumber *num = [[dataForPlot objectAtIndex:index] valueForKey:(fieldEnum == CPScatterPlotFieldX ? @"x" : @"y")];
num = [NSNumber numberWithDouble:[num doubleValue] + 1.0];
return num;
}
现在唯一的问题是找到一种简单的方法来画线。有什么想法吗??
【问题讨论】:
-
您显示的图像中的哪个元素是“数据指示器”?
-
红线,表示当前值。当用户移动滑块时,红线也会移动,在顶部显示当前值。有关实现,请查看 Roambi 应用程序的 Cardex 视图 (roambi.com)
标签: iphone objective-c cocoa-touch core-plot