iOS & macOS Charting Documentation - SciChart iOS & macOS Charts SDK v4.x
DataSeries Types in SciChart
SciChart features a proprietary DataSeries API, which internally uses the fastest possible data-structures to allow fast manipulation of data bound to charts.
Our DataSeries are highly optimized data-structures for indexing, searching and iterating over data, enabling SciChart to achieve its record performance!
The following DataSeries types exist in SciChart iOS.
NOTE: Allowable types in SciChart include NSDate, Int64, Int32, Int16, Byte, Double, Float.
Manipulating DataSeries Data
Data in ISCIDataSeries
may be manipulated using the Append, Insert, Update, Remove functions.
In addition, xRange and yRange may be accessed as well as any of the underlying data may be directly accessed.
Also, DataSeries feature two modes: standard and FIFO (First in first out). In FIFO mode data may be streamed and old data-points discarded as new arrive.
Finally, you can control Data Distribution using ISCIDataDistributionCalculator
.
The following sections show how you can manipulate data in the DataSeries types in SciChart.
Append, Insert, Update, Remove
All DataSeries types include Append, Insert, Update, Remove methods. Many of these also have overloads which accept a range of data, e.g. the ISCIXyDataSeries
protocol has the following:
-[ISCIXyDataSeries appendX:y:]
-[ISCIXyDataSeries appendArrayX:y:]
-[ISCIXyDataSeries appendValuesX:y:]
-[ISCIXyDataSeries insertX:y:at:]
-[ISCIXyDataSeries insertArrayX:y:at:]
-[ISCIXyDataSeries insertValuesX:y:at:]
-[ISCIXyDataSeries updateX:at:]
-[ISCIXyDataSeries updateY:at:]
-[ISCIXyDataSeries updateX:y:at:]
-[ISCIXyDataSeries updateArrayX:at:]
-[ISCIXyDataSeries updateArrayY:at:]
-[ISCIXyDataSeries updateArrayX:y:at:]
-[ISCIXyDataSeries updateValuesX:at:]
-[ISCIXyDataSeries updateValuesY:at:]
-[ISCIXyDataSeries updateValuesX:y:at:]
Other DataSeries have similar methods appropriate to underlying data which they hold.
NOTE: It is highly recommended to use set of methods, which works with our
ISCIValues
data-structures, to achieve better performance and omit boxing/unboxing into Cocoa native types.
X and Y Ranges
All DataSeries types expose the XRange and YRange of the underlying DataSeries as well as corresponding Max and Min values. See the following methods:
ISCIDataSeries.xMin
ISCIDataSeries.xMax
ISCIDataSeries.xRange
ISCIDataSeries.yMin
ISCIDataSeries.yMax
ISCIDataSeries.yRange
NOTE: These perform a calculation every time the property is accessed, so should be used sparingly.
NOTE: SciChart Xamarin.iOS has generic wrappers to our native DataSeries classes. These generic classes can be constructed and used without the need of the SCIDataType. It will be inferred automatically.
Accessing X, Y, [other] Values
All DataSeries types expose the lists of underlying data. There is a set of protocols, which provides an access for the underlying data, which names has a pattern as follows: ISCI[Something]DataSeriesValues
, e.g.:
ISCIXDataSeriesValues
- provides an access to thexValues
.ISCIXyDataSeriesValues
- provides an access to theyValues
(in addition toxValues
).
Those are read-only ISCIList
s. Data can be accessed by casting to the underlying list type, e.g. ISCIListDouble
.
Fifo (First-In-First-Out) DataSeries
DataSeries allow First-In-First-Out behaviour, where a maximum capacity is set, once reached, old data-points are discarded. To declare a Fifo dataseries, simply set the ISCIDataSeries.fifoCapacity
property.
Considering the code above, the behaviour will be the following. Once the 1001-st point have been added, the very first point will be discarded. Appending another 5 points, the next oldest 5 points will be discarded. The window continues to scroll no matter how many points are appended and memory never increases beyond 1000 points.
Fifo DataSeries are a very memory and CPU efficient way of scrolling and discarding old data and creating scrolling, streaming charts.
DataSeries Data Distribution
The ISCIDataDistributionCalculator
is a protocol which determines the distribution of your data (sorted in X or not, evenly spaced in X or not) and the flags are used to determine the correct algorithm(s) for resampling, hit-testing and indexing of data.
By default, this all works automatically, however, if you want to save a few CPU cycles and you know in advance the distribution of your data, you can override the flags as follows:
DataSeries AcceptsUnsortedData
By default, DataSeries are designed to throw an exception if data is appended unsorted in X. This is because unsorted data is detrimental to performance, and many people were unintentionally appending data unsorted in the X-direction.
SciChart can however accept unsorted data, you just need to specify the flag ISCIDataSeries.acceptsUnsortedData
= true. This will signal to SciChart that your appending of unsorted data was intentional and the chart will then draw it.