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.
true
Daru::View.plotting_library = :googlecharts
:googlecharts
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
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 |
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