Skip to content

Instantly share code, notes, and snippets.

@zuhao
zuhao / README.md
Last active December 23, 2015 16:29
Plotrb Example: Bar

This example is taken from Vega's gallery

The following is the Ruby code that generates bar.json.

require 'plotrb'

data = pdata.name('table').values(
    [
      {x: 1,  y: 28}, {x: 2,  y: 55},
@zuhao
zuhao / README.md
Last active December 23, 2015 16:39
Plotrb Example: Arc

This example is taken from Vega's gallery

The following is the Ruby code that generates arc.json.

require 'plotrb'

data = pdata.name('table').values([12,23,47,6,52,19]).transform(pie_transform)

scale = sqrt_scale.name('r').from(data).to([20,100])
@zuhao
zuhao / README.md
Last active December 23, 2015 16:39
Plotrb Example: Area

This example is taken from Vega's gallery

The following is the Ruby code that generates area.json.

require 'plotrb'

data = pdata.name('table').values(
    [
        {x: 1,  y: 28}, {x: 2,  y: 55},
@zuhao
zuhao / README.md
Last active December 23, 2015 16:48
Plotrb Example: Lifelines

This example is taken from Vega's gallery

The following is the Ruby code that generates lifelines.json.

require 'plotrb'

people = pdata.name('people').url('people.json')

events = pdata.name('events').url('events.json') do
@zuhao
zuhao / README.md
Last active December 23, 2015 16:49
Plotrb Exmaple: Barley

This example is taken from Vega's gallery

The following is the Ruby code that generates barley.json.

require 'plotrb'

raw_data = pdata.name('barley').url('barley_data.json')
variety = pdata.name('variety').source('barley').transform [
  facet_transform.keys('variety'),
@zuhao
zuhao / README.md
Last active December 23, 2015 16:49
Plotrb Example: Choropleth

This example is taken from Vega's gallery

The following is the Ruby code that generates choropleth.json.

require 'plotrb.rb'

ump_data = pdata.name('unemp') do
  url('/zuhao/raw/6666293/unemployment.tsv')
@zuhao
zuhao / unemployment.tsv
Created September 23, 2013 03:44
Some data collections.
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 2 in line 1.
id rate
1001 .097
1003 .091
1005 .134
1007 .121
1009 .099
1011 .164
1013 .167
1015 .108
1017 .186