简体   繁体   English

使用核心图中的加速度计数据绘制图形

[英]Draw graph using accelerometer data in core-plot

I'm new to this core-plot framework and trying to draw a line graph based on X and Y acceleration. 我是这个核心情节框架的新手,并尝试绘制基于X和Y加速度的折线图。 I can already get my X and Y values and have successfully added core-plot in my project. 我已经可以获得我的X和Y值,并已在我的项目中成功添加了核心图。 I'm quite lost on how to start this, so basically, I will have X and Y values and how do I plot this using core-plot? 我很失落如何开始这个,所以基本上,我将有X和Y值,我如何使用核心情节绘制这个? any help is suggested. 建议任何帮助。 Thanks! 谢谢!

Maybe my answer is a little bit off topic, as it's not using core-plot, but did you look at the "AccelerometerGraph" sample app provided with Xcode? 也许我的答案有点偏离主题,因为它没有使用核心情节,但你看看Xcode提供的“AccelerometerGraph”示例应用程序? It provides a nice plot which is dynamically updated while new accelerometer events are registered. 它提供了一个很好的情节,在注册新的加速计事件时动态更新。 The great of this sample is the way CoreAnimation has been used to "speed-up" Quartz2D. 这个样本的优点是CoreAnimation用于“加速”Quartz2D的方式。 And you get all of this using system framework only and no third party code (apart your adaptation of Apple's one). 而且你只使用系统框架并且没有第三方代码(除了你改编Apple的代码之外)。

Look at the Core Plot examples to see how to set up a basic graph. 查看Core Plot示例以了解如何设置基本图表。 You'll want to use a scatter plot. 您将需要使用散点图。 Call -reloadData on the plot whenever you have new data to display. 无论何时要显示新数据, -reloadData在绘图上调用-reloadData If only some of the data points change on each frame, you can use the following methods to do a partial update: 如果每个帧上只有一些数据点发生变化,您可以使用以下方法进行部分更新:

-(void)reloadDataInIndexRange:(NSRange)indexRange;
-(void)insertDataAtIndex:(NSUInteger)index
         numberOfRecords:(NSUInteger)numberOfRecords;
-(void)deleteDataInIndexRange:(NSRange)indexRange;

The Real Time Plot in the Plot Gallery example app shows one way to use these methods. Plot Gallery示例应用程序中的实时绘图显示了使用这些方法的一种方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM