[](https://travis-ci.org/Guillaume Béal/LTTB)
Largest Triangle Three Buckets downsampling algorithm in Swift. Downsample timeseries to display millions of points.
The visualization isn’t meant to give you access to the individual values of tens of thousands of data points on a line, it’s meant to show you how that data looks and is trending over time."(https://blackops.io/blog/2014/05/time-series-graphs-and-downsampling/)
This algorithm shrinks a timeserie and keeps the visual apsect of the serie.
Pre-process your time serie with LTTB in order to display a thousands of points on a Graph.
Works well with Charts API https://github.com/danielgindi/Charts
To run the LTTB downsampler, clone the repo, and run pod install
from the LTTB directory first.
LTTB is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "LTTB"
In case you installed LTTB via CocoaPods you need to import it (add this somewhere at the top of your source code file):
import LTTB
- Dataset: The array (of tuples) to downsample
- threshold: The number of element to keep
let lttb = LTTB()
let result = lttb.downSample(dataSet: [(x: Double,y: Double)], threshold: Int)
In any cases the function will return an array of tuples (x: Double,y: Double):
[(x: Double,y: Double)]
- Downsampling Time Series for Visual Representation by Sveinn Steinarsson.
LTTB is available under the MIT license. See the LICENSE file for more info.
Guillaume Béal
Original version by Sveinn Steinarsson(https://github.com/sveinn-steinarsson/highcharts-downsample)