Skip to content
/ lttb Public

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

License

Notifications You must be signed in to change notification settings

Jubke/lttb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published