Updating specific part of graph using core plot? - ios

I'm using [thePlot5 insertDataAtIndex:i numberOfRecords:150]; for inserting data into the real time graph.The graph contains almost 10000 data points(i need 10000 points in that graph).
But i'm updating 150 data points every time.
But -(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot method returns 10000 every time. so that iteration in -(double)doubleForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)idx will be 20000 thousand times for together x and y.This reduces performance.
I just want to update only the new points(i.e. 150 points not entire 10000 points).Please help me guys.

The -insertDataAtIndex:numberOfRecords: method tells the plot to load only the new data points. In the example given in the question, the plot should ask the datasource for 150 new points, starting at data index i. Note that after the insert call, -numberOfRecordsForPlot: should return the old value plus the number of new records (10000 + 150 = 10150). If you want to keep the total number of points constant, you'll need to remove some old points with -deleteDataInIndexRange:.

Related

Formula for calculating a cell value based on variable percentage bands with specific threshold levels

I have a Google Sheet with two tabs - one containing percentage "bands" values and the other with data in a table which includes rows for new entries and columns off to the right edge which store running totals depending on the entry type. The running totals depend on the row entry being of the same type and month period. This all works as expected.
I need to calculate a value in column I based on a row entry amount/cell (column H) which references the running total for that entry type AA:AF and month and then uses the relevant predefined percentage "bands" values (tab R1).
I had successfully got this working when a single entry would only ever cross one "band" level (the bands were previously tens of thousands apart) by using SWITCH and VLOOKUP functions.
The current formulas in column I use this method which no longer works since the percentage bands are now much closer together than they were before and a single entry could take the running total value for that entry over multiple bands (and not just the previous band, as before).
On the example sheet, cell H6 contains 9,900 as a test value since this increases the running total for that row AB6 to 16,313 from the prior running total for that type, 6,413 and spans 4 percentage bands:
Band A: 0-7,500 - 5%
Band B: 7,500-10,000 - 7.5%
Band C: 10,000-15,000 - 15%
Band D: 15,000 - 25,0000 - 17.5%
My original formula first checks the entry Type using a SWITCH, then matches the highest "band" value using a VLOOKUP and then an IF to check if the previous running total was less than the highest matched "band" value, calculating and adding the difference if needed.
I've tried to figure out how to calculate the same result when multiple bands are crossed (as in example) but I can't find a way to structure the formula so that it can apply universally down the column using the matched band rate(s), previous running total and new running total values.
Is there a mathematical way to do this or will this require multiple nested IF statements etc or would another approach work better?
I solved this by modifying the formulas on this page. Changing the layout of the bands was a good first move.
Now, column I calculates the value from the current running total (matched from type in column A) and subtracts the value calculated in the same way but using the previous running total to give the amount applicable to the newly entered value on the same row in column H. I've some more testing to do but fairly sure it works correctly. Any other ideas, feel free to suggest!
Provisionally working sheet here: https://docs.google.com/spreadsheets/d/1e2pdyOi7dz_ZA8zfNtsHxieEUb5fiZGpD_FwRvkHyYw/edit?usp=sharing

mean and standard deviation in timeseries

I have a financial time series and I want to make a new dataset out of it . I want to take every 20 data point(rows) and replace them with one data points like this :
[mean of those 20 data points , standard deviation of those 20 data points].
I actually think I need gaussian model for the variation or the standard deviation.
and I use python 3.
my dataset is like the first column is the index(number of days) and the second column is the close prices
I do not know the code for taking every 20 data point and replace them with data I wrote above
If the data points are stored in a dataframe, say df, you could group them using groupby like this -
df.groupby(df.index / 20)
You could compute the mean and standard deviation of the groups as follows, and concatenate both of them if you need to.
df.groupby(df.index / 20).mean()
df.groupby(df.index / 20).std()

Core Plot Reload Data

Beginner in Core Plot,I'm trying to plot real time graph using core plot where the data comes every 0.3 second and I am plotting for about 1 hour duration. Now every time when the reload data method is called does core plot start plotting the graph all over or only the newly appended point in the datasource is considered?What I am targeting is only the newly appended point to be reloaded to be plotted on the plot and the rest points in datasource already plotted without reloading.
You have several options for updating the plot data:
-reloadData: Queries the datasource for all of the data points.
-insertDataAtIndex:numberOfRecords:: Insert records into the plot data cache at the given index. The datasource is only queried for the new data. Use a starting index equal to the old data count to append records to the end of the existing data set.
-reloadDataInIndexRange:: Refresh only the data points in the given range.
-deleteDataInIndexRange:: Removes existing data int the given range.

Updating Highstock chart points

I need to update the most recent candle in my chart. Typically, I would use this to update a point:
//javascript
chart.series[0].data[n].update({...});
However, my series.data array is empty when I show the entire data set possibly because of:
Official HighStock Documentation: data
Read only. An array with the series' data point objects. In case the series data length exceeds the cropThreshold, or if the data is grouped, series.data doesn't contain all the points. It only contains the points that have been created on demand. In these cases, all original X and Y values can be read from series.xData and series.yData. Additionally, series.options.data contains all configuration objects for the points, whether they be numbers, arrays or objects.
Returns Array
How can I update my most recent candle point when the interface to the Point.update method is only accessible via the series.data collection? When my series.data array is empty do I just overwrite the point properties via series.options.data?
I've also considered invoking the series.update(options) method, but I may need to perform a candle update many times as a result of real time activity. Therefore, an update on the entire series object would not be a good decision because of overhead.
The data array is empty because Highstock does data grouping - when enabled it uses groupedData array instead. Unfortunately, you cannot update a grouped point (Highcharts throws the error).
What you can do, is disabling data grouping, then you will get a data array and point.update is possible or use Series.removePoint and Series.addPoint()
chart.series[0].removePoint([chart.series[0].groupedData.length - 1]);
chart.series[0].addPoint([
Date.UTC(2016, 11, 8),
115,
2,
30,
20
]);
example: http://jsfiddle.net/0z95x58t/

HighCharts : Update a point when grouping data

TL;DR: Have a lot of points, dataGrouping is on, how do I update an individual point?
I'm trying to make a HighCharts/HighStock chart that shows "per minute" averages over time. I do this by loading in a bunch of data that represents the "counts" and there is one record for every minute. Then, depending on how much chart data I have, I use the HighCharts dataGrouping with average approximation method to group all of the data.
Here's the kicker, I would like the most recent minute to update every second with its current count. Then, when we're on to the next minute, add a point and keep going. Typically I would do something like this to do that:
chart.series[0].data[99].update(newVal)
The problem is, data is empty by design when dataGrouping is on. I can see some point objects in series.points but updating them doesn't seem to do what I intend. I can also access and update the original data at series.options.data but updating it there doesn't seem to update the chart.
Here is a basic fiddle demonstrating the problem. I have ~30 minutes of random consecutive data there and I have forced it to group in 5 minute windows. Anyone who can make an individual point update when I press that button gets my gratitude and a shiny green check mark next to your answer.
http://jsfiddle.net/kZRCa/2/
$('#button').click(function() {
var chart = $('#container').highcharts();
var series = chart.get("S1");
var _data = series.options.data;
// try and make a point (ANY POINT) update
_data[10][1] = 200;
series.setData(_data);
});
Edit: forgot to mention that I also gave the series an id so it was easier to get() it.

Resources