require 'daru/view' Daru::View.plotting_library = :googlecharts data = [ ['Year', 'Sales', 'Expenses'], ['2013', 1000, 400], ['2014', 1170, 460], ['2015', 660, 1120], ['2016', 1030, 540] ] area_chart_table = Daru::View::Table.new(data, {}, chart_class: 'Chartwrapper') area_chart_table.show_in_iruby area_chart_options = { type: :area } area_chart_chart = Daru::View::Plot.new(area_chart_table.table, area_chart_options, chart_class: 'ChartWrapper') area_chart_chart.show_in_iruby line_basic_options = { title: 'Company Performance', curveType: 'function', legend: { position: 'bottom' } } line_basic_chart = Daru::View::Plot.new(data, line_basic_options, chart_class: 'Chartwrapper') line_basic_chart.show_in_iruby area_chart_options = { type: :area, view: {columns: [0, 1]} } area_chart_chart = Daru::View::Plot.new(area_chart_table.table, area_chart_options, chart_class: 'ChartWrapper') area_chart_chart.show_in_iruby area_chart_options = { type: :area, view: {columns: [1, 2]} } area_chart_chart = Daru::View::Plot.new(area_chart_table.table, area_chart_options, chart_class: 'ChartWrapper') area_chart_chart.show_in_iruby data_str = 'https://docs.google.com/spreadsheets/d/1aXns2ch8y_rl9ZLxSYZIU5ewUB1ZNAg5O6iPLZLApZI/gviz/tq?header=1&tq=' table = Daru::View::Table.new(data_str, {width: 500}, chart_class: 'Chartwrapper') table.show_in_iruby data_str = 'https://docs.google.com/spreadsheets/d/1aXns2ch8y_rl9ZLxSYZIU5ewUB1ZNAg5O6iPLZLApZI/gviz/tq?header=1&tq=' table = Daru::View::Plot.new(data_str, {width: 500}, chart_class: 'Chartwrapper') table.show_in_iruby data_str = 'https://docs.google.com/spreadsheets/d/1aXns2ch8y_rl9ZLxSYZIU5ewUB1ZNAg5O6iPLZLApZI/gviz/tq?header=1&tq=' table = Daru::View::Plot.new(data_str, {width: 500, view: {columns: [0, 1]}}, chart_class: 'Chartwrapper') table.show_in_iruby 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 bar_basic_table = Daru::View::Table.new(df_city_pop, {}, chart_class: 'Chartwrapper') bar_basic_table.show_in_iruby 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: 'Chartwrapper') bar_basic_chart.show_in_iruby bar_basic_options = { title: 'Population of Largest U.S. Cities', type: :column } bar_basic_chart = Daru::View::Plot.new(bar_basic_table.table, bar_basic_options, chart_class: 'Chartwrapper') bar_basic_chart.show_in_iruby bar_basic_table = Daru::View::Table.new(df_city_pop, {view: {columns: [0]}}, chart_class: 'Chartwrapper') bar_basic_table.show_in_iruby query_string = 'SELECT A, H, O, Q, R, U LIMIT 5 OFFSET 8' data_spreadsheet = 'https://docs.google.com/spreadsheets/d/1XWJLkAwch5GXAt_7zOFDcg8Wm8Xv29_8PWuuW15qmAE/gviz/tq?gid=0&headers=1&tq=' data_spreadsheet << query_string table_spreadsheet = Daru::View::Table.new(data_spreadsheet, {width: 800}, chart_class: 'Chartwrapper') table_spreadsheet.show_in_iruby