Awesome
flot-downsample: Downsample plugin for Flot
- Author: Sveinn Steinarsson
- Special thanks: Borgar Þorsteinsson and DataMarket
This plugin for Flot charts downsamples data before rendering the chart. The purpose is to try retain the visual characteristics of the original line using considerably fewer data points. The algorithm (called Largest-Triangle-Three-Buckets or LTTB) used in this plugin is described in a Master's thesis (see hdl.handle.net/1946/15343) in Computer Science by Sveinn Steinarsson at the University of Iceland. The topic of the thesis is how to downsample time series for visual representation and was initially suggested by DataMarket. JavaScript optimization was done with the help of Borgar Þorsteinsson.
Status
The Flot library is not commonly used nowadays, but the LTTB (Largest-Triangle-Three-Buckets) algorithm remains popular and is well-established for downsampling chart data.
For using LTTB in other libraries or frameworks, you can refer to the LTTB adapted for other programming languages or frameworks section.
Demo
Demo can viewed at base.is/flot/.
Additional demo concerning chart resizing is also available at base.is/flot/resize/
Usage
series: {
downsample: {
threshold: 1000 // 0 disables downsampling for this series.
}
}
Known limitations
- Does not support gaps (null values) in the data array.
- X-values must be in a strictly increasing order.
Articles related to the algorithm (LTTB)
- The Billion Data Point Challenge by Benjamin Raskin and Nikunj Aggarwal at Uber Technologies Inc.
- An SQL implementation of the 'Largest Triangle Three Bucket' algorithm by Peter Coppens
- Visualize Big Data on Mobile by dduraz
- The Challenge of Metrics Visualization by Mark Troyer
- Downsampling data – Not a trivial task by DataMarket (The company was acquired by Qlik. Linking to archived version since the original blog is no longer accessible)
- Sampling large datasets in d3fc by William Ferguson
- Downsampling algorithms by Adrian S. Tam
- Plot your data faster without losing its shape with Elixir and ExLTTB by Riccardo Binetti
- Implementation of Downsampling Algorithm in MSChart Extension by Code Artist
- MinMaxLTTB: Leveraging MinMax-Preselection to Scale LTTB by Jeroen & Jonas Van Der Donckt
The algorithm (LTTB) adapted for other programming languages or frameworks
- C# by Daniel Judge
- C# by Adrian Seeley
- MSChartExtension in C# by Code Artist
- Elixir by Riccardo Binetti
- Go by Damian Gryski
- node.js by Matej Drolc
- Java by drcrane
- Java8 by Guillermo Gutierrez Almazor
- Scala by Graham Tackley
- R by Jack Viljoen
- Javascript (without the flot plugin) by Josh Carr
- Highcarts Plugin by Sveinn Steinarsson
- Chart.js Plugin by Sean
- PHP by dbojdo
- Python by Olivier Devoisin
- Python + Numpy by Jack Viljoen
- Python using C by dgoeries
- Python using Rust by Jeroen Van Der Donckt
- Perl by troxel
- C++ by parkertomatoes
- Ruby by Julian Lübke
- Swift by Guillaume Beal
- Rust by Jerome Froelich
- Clojure by Kimmo Koskinen
- Dart by bnap00
- PL/PGSQL by Rio Fujita
- PostgreSQL Extension by Brian Rowe
Note: I have not tested all these versions and some might have different or additional features.
(Please let me know if you make your own port of the LTTB algorithm so I can list it here.)
License
flot-downsample is released under the terms of the MIT License.