In [1]:
require 'daru/view'
Install the spreadsheet gem version ~>1.1.1 for using spreadsheet functions.

Install the mechanize gem version ~>2.7.5 for using mechanize functions.
Out[1]:
true
In [2]:
Daru::View.plotting_library = :googlecharts
Out[2]:
:googlecharts
In [3]:
idx = Daru::Index.new ['Topping', 'Slices']
data_rows = [
          ['Mushrooms', 1],
          ['Onions', 1],
          ['Olives', 2],
          ['Zucchini', 2],
          ['Pepperoni', 1]
]
df_sarah = Daru::DataFrame.rows(data_rows)
df_sarah.vectors = idx
df_sarah
Out[3]:
Daru::DataFrame(5x2)
Topping Slices
0 Mushrooms 1
1 Onions 1
2 Olives 2
3 Zucchini 2
4 Pepperoni 1
In [4]:
options = {
  type: :pie,
  title:'How Much Pizza Sarah Ate Last Night',
  width:400,
  height:300}
pizza_sarah = Daru::View::Plot.new(df_sarah, options)
pizza_sarah.show_in_iruby
Out[4]:
In [5]:
idx = Daru::Index.new ['Topping', 'Slices']
data_rows = [
          ['Mushrooms', 2],
          ['Onions', 2],
          ['Olives', 2],
          ['Zucchini', 0],
          ['Pepperoni', 3]
]
df_anthony = Daru::DataFrame.rows(data_rows)
df_anthony.vectors = idx
df_anthony
Out[5]:
Daru::DataFrame(5x2)
Topping Slices
0 Mushrooms 2
1 Onions 2
2 Olives 2
3 Zucchini 0
4 Pepperoni 3
In [6]:
options = {
  type: :pie,
  title:'How Much Pizza Anthony Ate Last Night',
  width:400,
  height:300}
pizza_anthony = Daru::View::Plot.new(df_anthony, options)
pizza_anthony.show_in_iruby
Out[6]:
In [7]:
combined_pizza = Daru::View::Plot.new([pizza_sarah, pizza_anthony])
combined_pizza.show_in_iruby
Out[7]:
In [8]:
pizza_sarah_table = Daru::View::Table.new(df_sarah)
combined = Daru::View::Plot.new([pizza_sarah_table, pizza_sarah])
combined.show_in_iruby
Out[8]:
In [9]:
pizza_anthony_table = Daru::View::Table.new(df_anthony)
combined = Daru::View::Plot.new([pizza_anthony_table, pizza_anthony])
combined.show_in_iruby
Out[9]:
In [10]:
pizza_sarah_table = Daru::View::Table.new(df_sarah)
pizza_anthony_table = Daru::View::Table.new(df_anthony)
combined_table = Daru::View::Plot.new([pizza_sarah_table, pizza_sarah, pizza_anthony_table, pizza_anthony])
combined_table.show_in_iruby
Out[10]:
In [11]:
options = {
  type: :bar,
  title:'How Much Pizza Sarah Ate Last Night',
  width:400,
  height:300}
pizza_sarah_bar = Daru::View::Plot.new(df_sarah, options)
combined = Daru::View::Plot.new([pizza_sarah, pizza_sarah_bar])
combined.show_in_iruby
Out[11]: