This repository contains a number of examples of using JRuby and the JFreeCharts library to generate beautiful charts without any external processes or network traffic. JRuby allows you to call JVM-based libraries from the comfort of Ruby!
These examples should work with any recent version of JRuby, but we recommend installing the latest JRuby 10 release using your favorite Ruby installer or downloading from jruby.org.
- Install a JDK, if you don't already have one. JRuby 10 requires JDK 21+, JRuby 9.4 will work with JDK 8 (also known as 1.8).
- Install JRuby. Most Ruby installers know about JRuby, but there's also packages for major operating systems. You can also just download a JRuby tarball, unpack it, and put the
bindir in yourPATH. It's that easy! - Run
jruby -S lock_jarsfrom the root of this repository to fetch and install the JFreeChart library. - Run any of the scripts in the
examplesdirectory from the root of this repository!
For example, these commands run from the repository root directory will do the setup and run all the examples, outputting the generated graphs to that same directory:
jruby -S lock_jars
jruby examples/category_chart.rb
jruby examples/barchart.rb
jruby examples/piechart.rb
jruby examples/bubble_chart.rb
jruby examples/line_chart.rb