Project

lttb

0.0
No commit activity in last 3 years
No release in over 3 years
The code has been translated from the work of Sveinn Steinarsson in his plugin for Flot charts. More information is available on [his page](https://github.com/sveinn-steinarsson/flot-downsample/), and you can find the thesis describing the algorithm [here](http://skemman.is/handle/1946/15343).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0
 Project Readme

lttb - Largest-Triangle-Three-Buckets (Ruby)

This is an implementation of the Largest-Triangle-Three-Buckets (LTTB) downsampling algorithm in Ruby.

The code has been translated from the work of Sveinn Steinarsson in his plugin for Flot charts. More information is available on his page, and you can find the thesis describing the algorithm here.

Installation

Add this line to your application's Gemfile:

gem 'lttb'

And then execute:

$ bundle

Or install it yourself as:

$ gem install lttb

Usage

Data passed should be in the format [[x1,y1],[x2,y2]].

  data = [[1, 1], [2, 4], [3, 9], [4, 16], [5, 25]]
  threshold = 3
  Lttb.process(data, threshold)
  # => [1, 1], [3, 9], [5, 25]]

Pass :dates => true to process DateTime objects correctly.

  Lttb.process(data, threshold, dates: true)

Known limitations

Does not support gaps (null values) in the data array. X-values must be in a strictly increasing order.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Jubke/lttb.

License

The gem is available as open source under the terms of the MIT License.