Ruby version of Protovis, a visualization toolkit.
Ruby port of Protovis, a Javascript visualization toolkit.
This library implements almost completely core API of protovis, including all static marks, SVG builder class and data classes. Spec coverage is near 90%
Implemented:
Using protovis examples[http://vis.stanford.edu/protovis/ex/] as reference
I try to maintain, when posible, complete compatibility with Javascript API, including camel case naming of functions.
User could use +pv+ freely, cause is defined as a global method which call Rubyvis.
Nokogiri is used as XML library. If not available, or $rubyvis_no_nokogiri is set to true, REXML is used. Nokogiri is 30%-35% faster that REXML on our test.
The primary API, based on Gregory Brown's Ruby Best Practices, uses blocks and name of marks as methods
require 'rubyvis'
vis = Rubyvis::Panel.new do
width 150
height 150
bar do
data [1, 1.2, 1.7, 1.5, 0.7, 0.3]
width 20
height {|d| d * 80}
bottom(0)
left {index * 25}
end
end
vis.render
puts vis.to_svg
The library allows you to use chain methods API, like original protovis
require 'rubyvis'
vis = Rubyvis::Panel.new.width(150).height(150);
vis.add(pv.Bar).
data([1, 1.2, 1.7, 1.5, 0.7, 0.3]).
width(20).
height(lambda {|d| d * 80}).
bottom(0).
left(lambda {self.index * 25});
vis.render
puts vis.to_svg
See examples directory for original protovis examples adaptations and others graphics. You can see all of them online on the documentation page.
Why use a server-side technology if I can use a client-side, which is faster and more economic for developer?
If you want to present graphs: (a) complex and/or dynamically generated, (b) only on the web and (c) on modern browsers, Protovis is an excellent option. For simpler charts, Protovis is overkill. I recomend jqPlot.
Rubyvis is designed mainly for off-line operation, like batch creation of graphs for use on printed documents (rtf-pdf), with possibility of use easily the script for on-line use.
Tested on Ruby 2.1 to 2.6 and Jruby (mode 1.9) UPDATE 2024-02-08: Tested on 3.2.2
$ gem install rubyvis
BSD 2-Clause (see LICENSE.txt)