Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby language bindings to c2po
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
.gitignore
LICENSE
README.markdown
c2po.gemspec

README.markdown

C2PO Ruby language bindings

C2PO is a grammar of graphics implementation inspired by Hadley Wickham's ggplot2 library. This Rubygem uses the free online C2PO compiler and is limited to 1 MB of data. Plot specifications are compiled directly to an SVG string, which is returned:

require 'c2po'

#Make some random data:
data = 20.times.collect do
  {:a => 10*rand, :b => 5*rand}
end

#Specify a simple scatterplot graphic:
scatterplot_spec = {
  :data => data,
  :geom => :point,
  :mapping => {:x => :a, :y => :b}}

#Render an SVG string:
C2PO.render scatterplot_spec
  #=> '<svg height="660" width="660" ...'

Install

For the plain client library, run

gem install c2po

or add

c2po, "0.0.1"

to your Gemfile.

If you want to learn the grammar and work interactively with the examples in /examples, just clone this repo:

git clone https://github.com/keminglabs/c2po-ruby

install the deps:

cd examples
bundle install

then run:

bundle exec guard

to launch a live-reloading web server on localhost:3000 for displaying graphics. Walk through and execute the example code in examples/1-usage.rb to get started.

Something went wrong with that request. Please try again.