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]:
line1 = Daru::View::Plot.new([])
Out[3]:
#<Daru::View::Plot:0x000000024820e0 @data=[], @options={}, @user_options={}, @adapter=Daru::View::Adapter::GooglechartsAdapter, @chart=#<GoogleVisualr::Interactive::LineChart:0x00000002481488 @data_table=#<GoogleVisualr::DataTable:0x00000002481b90 @cols=[], @rows=[], @listeners=[], @options={}>, @listeners=[], @version="1.0", @language=nil, @material=false, @options={}, @user_options={}, @data=[]>>
In [4]:
line1.class
Out[4]:
Daru::View::Plot
In [5]:
line1.show_in_iruby
Out[5]:
In [6]:
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[6]:
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 [7]:
line_dv = Daru::View::Plot.new(df_tp)
Out[7]:
#<Daru::View::Plot:0x000000021e3208 @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={}, @user_options={}, @adapter=Daru::View::Adapter::GooglechartsAdapter, @chart=#<GoogleVisualr::Interactive::LineChart:0x00000001b9dba0 @data_table=#<GoogleVisualr::DataTable:0x000000021e3190 @cols=[{:type=>"number", :label=>"0"}, {:type=>"number", :label=>"1"}], @rows=[[#<GoogleVisualr::DataTable::Cell:0x00000001bfc088 @v=0, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bf3f00 @v=0, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bf3cd0 @v=1, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bf3bb8 @v=10, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bf3988 @v=2, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bf3848 @v=23, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bf3410 @v=3, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bf32f8 @v=17, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bf2ec0 @v=4, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bf2ce0 @v=18, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bf28a8 @v=5, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bf26a0 @v=9, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bf2420 @v=6, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bf20d8 @v=11, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bf1c50 @v=7, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bf1a98 @v=27, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bf17c8 @v=8, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bf1520 @v=33, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bf1160 @v=9, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bf1098 @v=40, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bf0d00 @v=10, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bf09e0 @v=32, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001be3b28 @v=11, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001be35b0 @v=35, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001be2a48 @v=12, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001be27c8 @v=30, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001be1e18 @v=13, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001be1710 @v=40, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001be0838 @v=14, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001be05b8 @v=42, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001be0310 @v=15, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001be01d0 @v=47, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bdb4f0 @v=16, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bdb1f8 @v=44, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bdae10 @v=17, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bdad20 @v=48, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bdaa00 @v=18, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bda848 @v=52, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bda640 @v=19, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bda410 @v=54, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bda118 @v=20, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bd9ec0 @v=42, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bd9c18 @v=21, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bd9a38 @v=55, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bd96f0 @v=22, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bd9560 @v=56, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bd9218 @v=23, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bd8f48 @v=57, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bd88b8 @v=24, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bd86d8 @v=60, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bd82a0 @v=25, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bd8110 @v=50, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bcfdf8 @v=26, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bcfad8 @v=52, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bcf128 @v=27, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bcedb8 @v=51, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bce4f8 @v=28, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bce2f0 @v=49, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bcd4b8 @v=29, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bcd080 @v=53, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bcccc0 @v=30, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bcc928 @v=55, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bcc338 @v=31, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bcc018 @v=60, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bc3c88 @v=32, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bc3b48 @v=61, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bc3800 @v=33, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bc3710 @v=59, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bc3490 @v=34, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bc3210 @v=62, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bc2bf8 @v=35, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bc2b08 @v=65, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bc2720 @v=36, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bc2568 @v=62, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bc21d0 @v=37, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bc1c58 @v=58, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bc13e8 @v=38, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bc1190 @v=55, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bc07b8 @v=39, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bc06c8 @v=61, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bc0470 @v=40, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bc0268 @v=64, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bc0038 @v=41, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bbbe20 @v=65, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bbbab0 @v=42, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bbb8f8 @v=63, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bbb5b0 @v=43, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bbb3f8 @v=66, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bbaef8 @v=44, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bbaa48 @v=67, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bba890 @v=45, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bba7c8 @v=69, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bba5c0 @v=46, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bba4a8 @v=69, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bba228 @v=47, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bba138 @v=70, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bb9f58 @v=48, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bb9d78 @v=72, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bb9468 @v=49, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bb8f90 @v=68, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001babe08 @v=50, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001babb10 @v=66, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bab818 @v=51, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bab750 @v=65, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bab570 @v=52, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001bab340 @v=67, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001bab1b0 @v=53, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001baaff8 @v=70, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001baad78 @v=54, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001baacd8 @v=71, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001baa9e0 @v=55, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001baa8f0 @v=72, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001baa508 @v=56, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001baa300 @v=73, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001ba9fb8 @v=57, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001ba9db0 @v=75, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001ba98d8 @v=58, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001ba97e8 @v=70, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001ba9608 @v=59, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001ba94c8 @v=68, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001ba9220 @v=60, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001ba9180 @v=64, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001ba8fa0 @v=61, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001ba8f00 @v=60, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001ba8d20 @v=62, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001ba8c30 @v=65, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001ba8aa0 @v=63, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001ba8a00 @v=67, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001ba87a8 @v=64, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001ba8690 @v=68, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001ba8488 @v=65, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001ba82f8 @v=69, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001b9fd38 @v=66, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001b9fba8 @v=70, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001b9f360 @v=67, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001b9ebb8 @v=72, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001b9e4b0 @v=68, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001b9e3e8 @v=75, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001b9e190 @v=69, @type="number">, #<GoogleVisualr::DataTable::Cell:0x00000001b9e0f0 @v=80, @type="number">]], @listeners=[], @options={}>, @listeners=[], @version="1.0", @language=nil, @material=false, @options={}, @user_options={}, @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
 ... ... ...>>
In [8]:
line_dv.chart
Out[8]:
In [9]:
line_dv.chart.data_table
Out[9]:
In [10]:
line_dv.chart.data_table.options = {pageSize: 10}
Out[10]:
{:pageSize=>10}
In [11]:
line_dv.chart.data_table
Out[11]:
In [12]:
p line_dv.chart.options
line_dv.chart.options = {
        hAxis: {
          title: 'Time'
        },
        vAxis: {
          title: 'Popularity'
        }
      }
{}
Out[12]:
{"hAxis"=>{:title=>"Time"}, "vAxis"=>{:title=>"Popularity"}}
In [13]:
line_dv.show_in_iruby
Out[13]:
In [14]:
# 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[14]:
In [15]:
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[15]:
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 [16]:
line_basic = Daru::View::Plot.new(df_population_us_city)
Out[16]:
#<Daru::View::Plot:0x000000021df270 @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={}, @user_options={}, @adapter=Daru::View::Adapter::GooglechartsAdapter, @chart=#<GoogleVisualr::Interactive::LineChart:0x00000001ce69f8 @data_table=#<GoogleVisualr::DataTable:0x000000021df1f8 @cols=[{:type=>"string", :label=>:city}, {:type=>"number", :label=>:population}], @rows=[[#<GoogleVisualr::DataTable::Cell:0x00000001cf0d40 @v="New York City, NY", @type="string">, #<GoogleVisualr::DataTable::Cell:0x00000001cf0c78 @v=8175000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001cf0660 @v="Los Angeles, CA", @type="string">, #<GoogleVisualr::DataTable::Cell:0x00000001cf02f0 @v=3792000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001ce9b80 @v="Chicago, IL", @type="string">, #<GoogleVisualr::DataTable::Cell:0x00000001ce7ec0 @v=2695000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001ce7d08 @v="Houston, TX", @type="string">, #<GoogleVisualr::DataTable::Cell:0x00000001ce7bc8 @v=2099000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x00000001ce7880 @v="Philadelphia, PA", @type="string">, #<GoogleVisualr::DataTable::Cell:0x00000001ce76c8 @v=1526000, @type="number">]], @listeners=[], @options={}>, @listeners=[], @version="1.0", @language=nil, @material=false, @options={}, @user_options={}, @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>>
In [17]:
line_basic.chart
Out[17]:
In [18]:
bar_basic = Daru::View::Plot.new(df_population_us_city, type: :bar)
Out[18]:
#<Daru::View::Plot:0x000000015e9fd8 @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={}, @user_options={}, @adapter=Daru::View::Adapter::GooglechartsAdapter, @chart=#<GoogleVisualr::Interactive::BarChart:0x000000015d4c78 @data_table=#<GoogleVisualr::DataTable:0x000000015e9e98 @cols=[{:type=>"string", :label=>:city}, {:type=>"number", :label=>:population}], @rows=[[#<GoogleVisualr::DataTable::Cell:0x000000015d8e18 @v="New York City, NY", @type="string">, #<GoogleVisualr::DataTable::Cell:0x000000015d8cd8 @v=8175000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x000000015d8878 @v="Los Angeles, CA", @type="string">, #<GoogleVisualr::DataTable::Cell:0x000000015d8558 @v=3792000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x000000015d82d8 @v="Chicago, IL", @type="string">, #<GoogleVisualr::DataTable::Cell:0x000000015d8198 @v=2695000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x000000015d7798 @v="Houston, TX", @type="string">, #<GoogleVisualr::DataTable::Cell:0x000000015d76f8 @v=2099000, @type="number">], [#<GoogleVisualr::DataTable::Cell:0x000000015d62a8 @v="Philadelphia, PA", @type="string">, #<GoogleVisualr::DataTable::Cell:0x000000015d60a0 @v=1526000, @type="number">]], @listeners=[], @options={}>, @listeners=[], @version="1.0", @language=nil, @material=false, @options={}, @user_options={}, @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>>
In [19]:
bar_basic.show_in_iruby
Out[19]:
In [20]:
options = {
        title: 'Population of Largest U.S. Cities',
        chartArea: {width: '50%'},
        hAxis: {
          title: 'Total Population',
          minValue: 0
        },
        vAxis: {
          title: 'City'
        }
      };
Out[20]:
{:title=>"Population of Largest U.S. Cities", :chartArea=>{:width=>"50%"}, :hAxis=>{:title=>"Total Population", :minValue=>0}, :vAxis=>{:title=>"City"}}
In [21]:
bar_basic.chart.options= options
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
Out[22]:
In [23]:
bar_basic.chart.options[:pageSize] = 3
Out[23]:
3
In [24]:
bar_basic.show_in_iruby # or bar_basic.chart
Out[24]:
In [25]:
bar_basic.chart.options
Out[25]:
{"title"=>"Population of Largest U.S. Cities", "chartArea"=>{:width=>"50%"}, "hAxis"=>{:title=>"Total Population", :minValue=>0}, "vAxis"=>{:title=>"City"}, :pageSize=>3}
In [26]:
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[26]:
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 [27]:
t_lang = Daru::View::Table.new(df_lang, {pageSize: 5})
t_lang.show_in_iruby
Out[27]:
In [28]:
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[28]:
In [29]:
# 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[29]:
true
In [30]:
pie_lang.show_in_iruby
Out[30]: