Awesome
LTTB (Largest Triangle Three Buckets)
[](https://travis-ci.org/Guillaume Béal/LTTB)
Largest Triangle Three Buckets
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."(http://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
Example
To run the LTTB downsampler, clone the repo, and run pod install
from the LTTB directory first.
Installation
LTTB is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "LTTB"
Usage
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)]
Bibliography
- Downsampling Time Series for Visual Representation by Sveinn Steinarsson.
License
LTTB is available under the MIT license. See the LICENSE file for more info.
Author
Guillaume Béal
Original version by Sveinn Steinarsson(https://github.com/sveinn-steinarsson/highcharts-downsample)