Implementation of Jenks' Natural Breaks Algorithm in Ruby. I converted it from Tom MacWright's original Javascript into Ruby, and then optimized it for Ruby's strengths.
Add this line to your application's Gemfile:
gem 'jenks'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jenks
Jenks adds a single method, #jenks to the Array class.
data = (1..20).to_a + (41..60).to_a + (81..100).to_a # Three distinct sets in one array
data.jenks(3) # [1,20,60,100]
- Fork it ( https://github.com/judy/jenks/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Install development gems (
bundle install) - Benchmark with
ruby benchmarks/array_benchmark.rb - Fix bugs or add a feature.
- Verify everything passes (
rspec) - Benchmark again, leave the code as fast or faster than when you forked.
- Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new pull request.