Rubyvis

Description

Ruby port of Protovis library According to the protovis site

Protovis composes custom views of data with simple marks such as bars and dots. Unlike low-level graphics libraries that quickly become tedious for visualization, Protovis defines marks through dynamic properties that encode data, allowing inheritance, scales and layouts to simplify construction.

As Protovis, Rubyvis is free and open-source, provided under the BSD License. Its delivers SVG natively, which could be exported to PNG, JPEG and others graphics formats

Current Version: 0.7.0

Protovis API Version: 3.3

Source code

https://github.com/clbustos/rubyvis

Installation

gem install rubyvis

Synopsis

Ruby

require 'rubygems'
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 # Output final SVG

SVG

<svg fill="none" font-family="sans-serif" 
font-size="10px" height="150.0" stroke="none" 
stroke-width="1.5" width="150.0">
<g transform="translate(0.0,0.0)">
<rect fill="rgb(31,119,180)" height="80" 
width="20" y="70"/>
<rect fill="rgb(31,119,180)" height="96.0" 
width="20" x="25" y="54.0"/>
<rect fill="rgb(31,119,180)" height="136.0" 
width="20" x="50" y="14.0"/>
<rect fill="rgb(31,119,180)" height="120.0" 
width="20" x="75" y="30.0"/>
<rect fill="rgb(31,119,180)" height="56.0" 
width="20"  x="100" y="94.0"/>
<rect fill="rgb(31,119,180)" height="24.0" 
width="20" x="125" y="126.0"/>
</g>
</svg>

Image

Resources

Examples

Several based on Protovis gallery