In [1]:
require 'daru/view'
Out[1]:
true
In [2]:
Daru::View.plotting_library = :googlecharts
Out[2]:
:googlecharts
In [3]:
idx = Daru::Index.new ['City', '2010 Population',]
data_rows = [
['New York City, NY', 8175000],
        ['Los Angeles, CA', 3792000],
        ['Chicago, IL', 2695000],
        ['Houston, TX', 2099000],
        ['Philadelphia, PA', 1526000]
]
df_city_pop = Daru::DataFrame.rows(data_rows)
df_city_pop.vectors = idx
df_city_pop
Out[3]:
Daru::DataFrame(5x2)
City 2010 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 [5]:
bar_basic_options = {
  title: 'Population of Largest U.S. Cities',
  type: :bar,
}
bar_basic_chart = Daru::View::Plot.new(df_city_pop, bar_basic_options, chart_class: 'Charteditor')
bar_basic_chart.show_in_iruby
Out[5]:
In [ ]: