Skip to content

Latest commit

 

History

History
52 lines (33 loc) · 1.27 KB

README.md

File metadata and controls

52 lines (33 loc) · 1.27 KB

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.