核心绘图-添加OutOfRange以绘制随标签"OL"动态变化的图形. [英] Core plot-Add OutOfRange to draw graph that changes dynamically with label "OL"

查看:198
本文介绍了核心绘图-添加OutOfRange以绘制随标签"OL"动态变化的图形.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在开发已建立的应用程序,该应用程序使用Core plot,特别是使用ScatterPlot绘制图形.使用从连接的蓝牙设备获得的值绘制该图,因此可以动态绘制该图. XY图,其中X轴具有时间值,Y轴具有来自BLE设备的值.

Currently I am working on already established application which uses Core plot and in specific its using ScatterPlot to draw a graph. This graph is drawn with values obtained from connected bluetooth device so the graph is dynamically drawn. XY graph with X axis having time value and Y axis having value from BLE device.

现在的要求是在图形中添加一个超出范围的值并带有标签"OL",并且该值不是蓝牙设备的固定常数(其更多是在BLE层中构造的模型对象中设置的状态)以及针对该状态获得的垃圾值,然后我们可以找出其超出范围的值).

Now the requirement is to add an out of range value with a label "OL" in the graph and its not a fixed constant value for the bluetooth device(Its more of a state set in model object that is constructed in BLE layer with junk value obtained for that state and on which we can figure out its a out of range value).

因此,例如,如果我最初获得"OL"值,则需要将其添加到0以上的图形上,并带有标签"OL".标记为-OL的'-OL'低于0.从BLE获得的值将连续添加到数组中,并使用该数组重绘图形.

So for e.g., if I get 'OL' value initially then I need to add it on graph above 0 with label "OL". '-OL' below 0 with label "-OL". The values obtained from BLE is continuously added to array and the graph is redrawn using this array.

因此,预期行为如下: 如果我在数组中获得200作为值,并且如果数组具有OL值,则必须将OL值绘制在200之上,并且如果BLE的下一个值是300,它将被添加到数组中,并且由于OL大于200,则OL具有绘制在300以上.

So behaviour is expected as below: If I get 200 as value in the array and if the array has OL value then OL value has to be plotted above 200 and if the next value from BLE is 300 which will be added to array and since OL is above 200, now OL has to be plotted above 300.

我尝试了2-3种不同的方法来找到解决方案,但没有成功.

I tried 2-3 different approaches to figure out a solution for this but with no success.

预期要求的图片:

如果有可能使用Core plot来实现,则需要别人的帮助.

Require someone to help out if its possible to implement this using Core plot.

推荐答案

红线需要第二个散点图.在主图中,从数据源返回nil以获取超出有效范围的值.这将在行中留下间隙,并用其他图解填充.

You'll need a second scatter plot for the red lines. In the main plot, return nil from the datasource for the values that are outside the valid range. This will leave gaps in the line, to be filled in with the other plot.

对于第二个图,从每个数据索引中返回nil,但超出有效范围的索引除外.返回这些点的范围极限值.您还需要返回超出范围值两侧的两个点的正确范围内值,以将线连接到主绘图线.

For the second plot, return nil from every data index, except ones that are out of the valid range. Return the range limit value for those points. You'll also need to return the correct in-range value for the two points on either side of the out-of-range values to connect the line to the main plot line.

这篇关于核心绘图-添加OutOfRange以绘制随标签"OL"动态变化的图形.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆