ECG plotting in IOS using Core Plot library. - ios

I'm trying to plot a ECG on an IOS application using Core Plot library like this video .I have tried to plot ECG like in the video in my IOS APP.I got the following result.
In general ECG graph should be plotted from the left end of the graph(Lead 1 in Screen shot) after a specific time interval.When i'm plotting ECG in my APP after the specified time interval,Each graph gets plotted on top of the previous graph.
How can we solve this?

You can implement this similar to the "Real Time Plot" demo in the Plot Gallery example app, although your application is a little simpler since you don't need to update the plot space after each frame of new data. You can leave a gap in the plot line by inserting a data point with a NSNull or NAN value between the points on either side of the break.
The plot must redraw after every change to the plot data, so you need to balance the size (pixel dimensions) of the plot and the number of data points with the desired update rate. Note that ranges are specified with a start location and the length of the range. To add a new data point and move the blank space over one spot, reload a range starting at the arrayIndex and length of two (2). Increment the arrayIndex for each new point and wrap around to index zero (0) when you get to the end.

Related

Core plot-Add OutOfRange to draw graph that changes dynamically with label "OL"

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.
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).
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.
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.
I tried 2-3 different approaches to figure out a solution for this but with no success.
Image of the expected requirement:
Require someone to help out if its possible to implement this using Core plot.
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.
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.

Highstock marker points do not display on line series with grouped data

Using highstock v1.2.2 I am trying to set a few red marker points on a line series with approximately 8000 points.
However, the marker points are only displayed when the data is not being grouped.
When i increase the size of my navigator and the data is grouped, the marker points are no longer displayed.
I searched the highstock api and didn't find anything helpful. All i found was this issue: Fixed issue with disappearing point markers after switching from non, that was fixed about a year ago.
I also tried to increase the turboThreshold attribute with no luck. So how can i display marker points on a large data set when the points are grouped?
You say that you set "a few" marker points. In that case, the markers will disappear when those individual points are grouped with other points, since the global option is that markers are disabled.
As an alternative, you should consider using flags for the points you want to emphasize. Or to make them look like regular point markers, you can even use a scatter series on top of the line series.

How to Set Plot Position in Core Plot

I need to draw multiple plots. How can I set the position of each plot in codes instead of setting one by one in storyboard?
The image I want to achieve is here. In this image, each small curve is a plot. So there are in total 20 x 15 small plots. I need to position and feed different data for each of them. But I don't want to set their positions one by one coz it's tedious.
Do you need to allow user interaction or frequently update the plots? If not, your best bet is to use one graph with a single plot. Render it into small images, once for each plot, changing the data each time. Draw the images into a view laid out in your grid.
If you can't use the image approach, you'll probably run out of memory long before setting up 300 individual graphs. Instead, use one graph with a single plot space if possible. Offset and scale the data values for each plot so they appear in the appropriate section. Use as few plots as you can (one for each line style). Separate the line segments with empty (NAN or nil) data values.

How do you use CPScatterPlotInterpolationLinear?

I just happened to stumble across "CPScatterPlotInterpolationLinear" via google search for 'interpolation'.
Does this mean that I could plug gaps of scatter/linear data via interpolation?
I had asked a similar question earlier and was told that CP doesn't add points to a graph.
I attempted to create a 6-month fixed-interval scatter plot by creating an array of 180 elements for 180 days/6 months. The missing data/day were filled with [NSNull null] objects... but CP merely plots the non-nulls without the interpolation.
The 'CPScatterPlotInterpolationLinear' enum got me to re-think.
Question: How do I employ 'CPScatterPlotInterpolationLinear' to interpolate missing data on a graph? ... no need to actually add data points, just 'connect the dots'.
When you set the line style on a scatter plot, Core Plot will connect the data points with a line drawn using the given style. The interpolation property controls how the points are connected:
CPTScatterPlotInterpolationLinear: This is the default. Data points are connected with straight lines drawn directly between successive points.
CPTScatterPlotInterpolationStepped: Steps are drawn beginning at each data point.
CPTScatterPlotInterpolationHistogram: Steps are drawn centered at each data point.
CPTScatterPlotInterpolationCurved: Data points are connected with a smooth curved line drawn between successive points.
None of these styles will add data points (i.e., points that can be indicated with plot symbols or data labels). They simply connect the data points provided by the datasource.

How to display live core plot graph in iPad? [duplicate]

I want to use core-plot for drawing line graph dynamically. data won't come at a time, we will be receiving point by point dynamically.
Is it possible to draw the chart dynamically using core-plot i.e drawing point by point as on when we receive the (x,y) point?
Please help me, Thanks.
Yes, you can do this reasonably easily. For each received data point, append it to an array of values to display. As these data points come in, call -reloadData on the Core Plot graph (or just the particular plot) to redraw the graph, passing in the array you just added a value to in response to the -numbersForPlot:field:recordIndexRange: delegate method.
If you need to adjust the plot range to track your data points (for a moving ticker), recalculate the new CPPlotRange for the X axis and set the plot space's xRange property to that.
Use the CPTestApp-iPhone, AAPLot, or StockPlot examples as templates for how to set up the line chart overall, and modify from that starting point.
I do something similar to this on the Mac in a scientific application:
(source: sunsetlakesoftware.com)
Sounds like you could make use of a demo project I put together and wrote about here (not core plot related though).
It draws a EKG graph but should easily be modified to use another input than the repeated "heart beat"...See line 320 in EAGLView.m where the indata is entered into the array.

Resources