In [2]:
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[2]:
true
In [3]:
Daru::View.plotting_library = :googlecharts
Out[3]:
:googlecharts
In [4]:
line1 = Daru::View::Plot.new([])
Out[4]:
#<Daru::View::Plot:0x007fa6b4ca69f0 @data=[], @options={}, @adapter=Daru::View::Adapter::GooglechartsAdapter, @chart=#<GoogleVisualr::Interactive::LineChart:0x007fa6b4ca6748 @data_table=#<GoogleVisualr::DataTable:0x007fa6b4ca68b0 @cols=[], @rows=[], @options={}>, @listeners=[], @version="1.0", @language=nil, @material=false, @options={}>>
In [5]:
line1.class
Out[5]:
Daru::View::Plot
In [6]:
line1.show_in_iruby
Out[6]:
In [7]:
time_popularity = [
        [0, 0],   [1, 10],  [2, 23],  [3, 17],  [4, 18],  [5, 9],
        [6, 11],  [7, 27],  [8, 33],  [9, 40],  [10, 32], [11, 35],
        [12, 30], [13, 40], [14, 42], [15, 47], [16, 44], [17, 48],
        [18, 52], [19, 54], [20, 42], [21, 55], [22, 56], [23, 57],
        [24, 60], [25, 50], [26, 52], [27, 51], [28, 49], [29, 53],
        [30, 55], [31, 60], [32, 61], [33, 59], [34, 62], [35, 65],
        [36, 62], [37, 58], [38, 55], [39, 61], [40, 64], [41, 65],
        [42, 63], [43, 66], [44, 67], [45, 69], [46, 69], [47, 70],
        [48, 72], [49, 68], [50, 66], [51, 65], [52, 67], [53, 70],
        [54, 71], [55, 72], [56, 73], [57, 75], [58, 70], [59, 68],
        [60, 64], [61, 60], [62, 65], [63, 67], [64, 68], [65, 69],
        [66, 70], [67, 72], [68, 75], [69, 80]
      ]
df_tp = Daru::DataFrame.rows(time_popularity)
Out[7]:
Daru::DataFrame(70x2)
0 1
0 0 0
1 1 10
2 2 23
3 3 17
4 4 18
5 5 9
6 6 11
7 7 27
8 8 33
9 9 40
10 10 32
11 11 35
12 12 30
13 13 40
14 14 42
15 15 47
16 16 44
17 17 48
18 18 52
19 19 54
20 20 42
21 21 55
22 22 56
23 23 57
24 24 60
25 25 50
26 26 52
27 27 51
28 28 49
29 29 53
... ... ...
69 69 80
In [8]:
line_dv = Daru::View::Plot.new(df_tp)
Out[8]:
#<Daru::View::Plot:0x007fa6b4c0ec40 @data=#<Daru::DataFrame(70x2)>
       0   1
   0   0   0
   1   1  10
   2   2  23
   3   3  17
   4   4  18
   5   5   9
   6   6  11
   7   7  27
   8   8  33
   9   9  40
  10  10  32
  11  11  35
  12  12  30
  13  13  40
  14  14  42
 ... ... ..., @options={}, @adapter=Daru::View::Adapter::GooglechartsAdapter, @chart=#<GoogleVisualr::Interactive::LineChart:0x007fa6b4bcf900 @data_table=#<GoogleVisualr::DataTable:0x007fa6b4c0ebf0 @cols=[{:type=>"number", :label=>"0"}, {:type=>"number", :label=>"1"}], @rows=[[#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdfc60 @v=0, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdfbe8 @v=0, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdfad0 @v=1, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdfa58 @v=10, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdf940 @v=2, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdf8c8 @v=23, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdf710 @v=3, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdf698 @v=17, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdf5a8 @v=4, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdf530 @v=18, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdf418 @v=5, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdf3a0 @v=9, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdf2b0 @v=6, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdf170 @v=11, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdf080 @v=7, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdf008 @v=27, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdeef0 @v=8, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdee78 @v=33, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bded60 @v=9, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdecc0 @v=40, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdeb08 @v=10, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdea90 @v=32, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bde9a0 @v=11, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bde928 @v=35, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bde810 @v=12, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bde798 @v=30, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bde590 @v=13, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bde4f0 @v=40, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bde3d8 @v=14, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bde338 @v=42, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bde248 @v=15, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bde1d0 @v=47, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bde0e0 @v=16, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bddfa0 @v=44, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bddeb0 @v=17, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdde38 @v=48, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bddd48 @v=18, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bddcd0 @v=52, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bddbe0 @v=19, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bddb40 @v=54, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdd938 @v=20, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdd898 @v=42, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdd7a8 @v=21, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdd730 @v=55, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdd618 @v=22, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdd578 @v=56, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdd3e8 @v=23, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdd370 @v=57, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdd280 @v=24, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdd1e0 @v=60, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdd0c8 @v=25, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdd000 @v=50, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdce98 @v=26, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdcdf8 @v=52, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdcce0 @v=27, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdcc68 @v=51, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdcb28 @v=28, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdcab0 @v=49, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdc9c0 @v=29, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdc808 @v=53, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdc6a0 @v=30, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdc600 @v=55, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdc4c0 @v=31, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdc448 @v=60, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdc268 @v=32, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdc1f0 @v=61, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bdc100 @v=33, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bdc088 @v=59, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bde3b0 @v=34, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd7f88 @v=62, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd7e20 @v=35, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd7d80 @v=65, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd7c40 @v=36, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd7ba0 @v=62, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd7a60 @v=37, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd79c0 @v=58, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd77b8 @v=38, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd7718 @v=55, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd7588 @v=39, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd7510 @v=61, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd73f8 @v=40, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd7380 @v=64, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd71a0 @v=41, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd70d8 @v=65, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6fc0 @v=42, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6f48 @v=63, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6e58 @v=43, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6db8 @v=66, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6c00 @v=44, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6b88 @v=67, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6a98 @v=45, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6a20 @v=69, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd68e0 @v=46, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6868 @v=69, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6778 @v=47, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6610 @v=70, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd64f8 @v=48, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6480 @v=72, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6390 @v=49, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd62f0 @v=68, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd61d8 @v=50, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd6160 @v=66, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5f80 @v=51, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5f08 @v=65, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5dc8 @v=52, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5d28 @v=67, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5c38 @v=53, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5bc0 @v=70, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5a08 @v=54, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5990 @v=71, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd58a0 @v=55, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5828 @v=72, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5738 @v=56, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd56c0 @v=73, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd55d0 @v=57, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd54e0 @v=75, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5378 @v=58, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5300 @v=70, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5210 @v=59, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5198 @v=68, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd50a8 @v=60, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5030 @v=64, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd4e78 @v=61, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd4e00 @v=60, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd4d10 @v=62, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd4c98 @v=65, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd4ba8 @v=63, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd4b30 @v=67, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd4a18 @v=64, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd49a0 @v=68, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd47e8 @v=65, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd4720 @v=69, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd4568 @v=66, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd44f0 @v=70, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd4270 @v=67, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bd41a8 @v=72, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bd5fd0 @v=68, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bcff68 @v=75, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4bcfd38 @v=69, @type="number">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4bcfc70 @v=80, @type="number">]], @options={}>, @listeners=[], @version="1.0", @language=nil, @material=false, @options={}>>
In [9]:
line_dv.chart
Out[9]:
In [10]:
line_dv.chart.data_table
Out[10]:
In [11]:
line_dv.chart.data_table.options = {pageSize: 10}
Out[11]:
{:pageSize=>10}
In [12]:
line_dv.chart.data_table
Out[12]:
In [13]:
p line_dv.chart.options
line_dv.chart.options = {
        hAxis: {
          title: 'Time'
        },
        vAxis: {
          title: 'Popularity'
        }
      }
{}
Out[13]:
{"hAxis"=>{:title=>"Time"}, "vAxis"=>{:title=>"Popularity"}}
In [14]:
line_dv.show_in_iruby
Out[14]:
In [15]:
# dataframe `df_tp` column name is default (df_tp.vectors is 0, 1) . Let's update it.
line_dv.chart.data_table.cols[0] = {type: 'number',label:  'X'}
line_dv.chart.data_table.cols[1] = {type: 'number', label:  'Dogs'}
line_dv.show_in_iruby
Out[15]:
In [16]:
city = Daru::Vector.new(['New York City, NY','Los Angeles, CA','Chicago, IL', 'Houston, TX', 'Philadelphia, PA'], name: 'city')
population = Daru::Vector.new([ 8175000, 3792000,2695000,2099000, 1526000], name: '2010 Population')
df_population_us_city = Daru::DataFrame.new(city: city, population: population)
Out[16]:
Daru::DataFrame(5x2)
city population
0 New York City, NY 8175000
1 Los Angeles, CA 3792000
2 Chicago, IL 2695000
3 Houston, TX 2099000
4 Philadelphia, PA 1526000
In [17]:
line_basic = Daru::View::Plot.new(df_population_us_city)
Out[17]:
#<Daru::View::Plot:0x007fa6b4a58f40 @data=#<Daru::DataFrame(5x2)>
                  city population
          0 New York C    8175000
          1 Los Angele    3792000
          2 Chicago, I    2695000
          3 Houston, T    2099000
          4 Philadelph    1526000, @options={}, @adapter=Daru::View::Adapter::GooglechartsAdapter, @chart=#<GoogleVisualr::Interactive::LineChart:0x007fa6b51dc618 @data_table=#<GoogleVisualr::DataTable:0x007fa6b4a58ef0 @cols=[{:type=>"string", :label=>:city}, {:type=>"number", :label=>:population}], @rows=[[#<GoogleVisualr::DataTable::Cell:0x007fa6b51dcd98 @v="New York City, NY", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa6b51dccf8 @v=8175000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b51dcc30 @v="Los Angeles, CA", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa6b51dcbb8 @v=3792000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b51dcaf0 @v="Chicago, IL", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa6b51dca78 @v=2695000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b51dc960 @v="Houston, TX", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa6b51dc8c0 @v=2099000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b51dc7a8 @v="Philadelphia, PA", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa6b51dc708 @v=1526000, @type="number">]], @options={}>, @listeners=[], @version="1.0", @language=nil, @material=false, @options={}>>
In [18]:
line_basic.chart
Out[18]:
In [19]:
bar_basic = Daru::View::Plot.new(df_population_us_city, type: :bar)
Out[19]:
#<Daru::View::Plot:0x007fa6b521e270 @data=#<Daru::DataFrame(5x2)>
                  city population
          0 New York C    8175000
          1 Los Angele    3792000
          2 Chicago, I    2695000
          3 Houston, T    2099000
          4 Philadelph    1526000, @options={}, @adapter=Daru::View::Adapter::GooglechartsAdapter, @chart=#<GoogleVisualr::Interactive::BarChart:0x007fa6b4a48550 @data_table=#<GoogleVisualr::DataTable:0x007fa6b521e248 @cols=[{:type=>"string", :label=>:city}, {:type=>"number", :label=>:population}], @rows=[[#<GoogleVisualr::DataTable::Cell:0x007fa6b4a49748 @v="New York City, NY", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4a495e0 @v=8175000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4a493d8 @v="Los Angeles, CA", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4a492c0 @v=3792000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4a48fa0 @v="Chicago, IL", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4a48e88 @v=2695000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4a48c58 @v="Houston, TX", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4a48af0 @v=2099000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x007fa6b4a488c0 @v="Philadelphia, PA", @type="string">, #<GoogleVisualr::DataTable::Cell:0x007fa6b4a48730 @v=1526000, @type="number">]], @options={}>, @listeners=[], @version="1.0", @language=nil, @material=false, @options={}>>
In [20]:
bar_basic.show_in_iruby
Out[20]:
In [21]:
options = {
        title: 'Population of Largest U.S. Cities',
        chartArea: {width: '50%'},
        hAxis: {
          title: 'Total Population',
          minValue: 0
        },
        vAxis: {
          title: 'City'
        }
      };
Out[21]:
{:title=>"Population of Largest U.S. Cities", :chartArea=>{:width=>"50%"}, :hAxis=>{:title=>"Total Population", :minValue=>0}, :vAxis=>{:title=>"City"}}
In [22]:
bar_basic.chart.options= options
Out[22]:
{"title"=>"Population of Largest U.S. Cities", "chartArea"=>{:width=>"50%"}, "hAxis"=>{:title=>"Total Population", :minValue=>0}, "vAxis"=>{:title=>"City"}}
In [23]:
bar_basic.chart
Out[23]:
In [24]:
bar_basic.chart.options[:pageSize] = 3
Out[24]:
3
In [25]:
bar_basic.show_in_iruby # or bar_basic.chart
Out[25]:
In [26]:
bar_basic.chart.options
Out[26]:
{"title"=>"Population of Largest U.S. Cities", "chartArea"=>{:width=>"50%"}, "hAxis"=>{:title=>"Total Population", :minValue=>0}, "vAxis"=>{:title=>"City"}, :pageSize=>3}
In [27]:
lang = Daru::Vector.new(['Assamese', 'Bengali','Bodo','Dogri', 'Gujarati', 'Hindi','Kannada', 'Kashmiri', 'Konkani','Maithili', 'Malayalam', 'Manipuri','Marathi', 'Nepali', 'Oriya','Punjabi', 'Sanskrit', 'Santhali', 'Sindhi', 'Tamil', 'Telugu','Urdu'] , name: 'Language')
speakers = Daru::Vector.new([13, 83, 1.4, 2.3, 46, 300, 38, 5.5, 5, 20, 33, 1.5, 72, 2.9,33,29, 0.01, 6.5,2.5, 61, 74, 52] , name: 'Speakers (in millions)')
df_lang = Daru::DataFrame.new(lang: lang, speakers: speakers)
Out[27]:
Daru::DataFrame(22x2)
lang speakers
0 Assamese 13
1 Bengali 83
2 Bodo 1.4
3 Dogri 2.3
4 Gujarati 46
5 Hindi 300
6 Kannada 38
7 Kashmiri 5.5
8 Konkani 5
9 Maithili 20
10 Malayalam 33
11 Manipuri 1.5
12 Marathi 72
13 Nepali 2.9
14 Oriya 33
15 Punjabi 29
16 Sanskrit 0.01
17 Santhali 6.5
18 Sindhi 2.5
19 Tamil 61
20 Telugu 74
21 Urdu 52
In [28]:
t_lang = Daru::View::Table.new(df_lang, {pageSize: 5})
t_lang.show_in_iruby
Out[28]:
In [29]:
pie_lang = Daru::View::Plot.new(t_lang.table, {type: :pie,  title: 'Indian Language Use', width: 800, height: 700})
pie_lang.show_in_iruby
Out[29]:
In [30]:
# add/update new options
# there are a lot of options and configuration we can do in google pie charts
# refere : https://developers.google.com/chart/interactive/docs/gallery/piechart
pie_lang.chart.options[:is3D] = true
Out[30]:
true
In [31]:
pie_lang.show_in_iruby
Out[31]:
In [ ]: