require 'daru/view' # used for creating table and charts Daru::View.plotting_library = :googlecharts data = [ ['Galaxy', 'Distance', 'Brightness', 'Distance-Galaxy'], ['Canis Major Dwarf', 8000, 230.3, 0], ['Sagittarius Dwarf', 24000, 4000.5, 0], ['Ursa Major II Dwarf', 30000, 1412.3, 0], ['Lg. Magellanic Cloud', 50000, 120.9, 0], ['Bootes I', 60000, 1223.1, 0] ] user_options = { formatters: { # ArrowFormat is working on localhost but not working on nbviewer. formatter1: { type: 'Arrow', options: { base: 30000 }, columns: 1 }, formatter2: { type: 'Color', range: [[1000, 30000, 'red', '#000000'], [40000, nil, 'green', 'pink']], columns: [1,2] }, formatter3: { type: 'Pattern', format_string: "{1} - {0}", src_cols: [0, 1], des_col: 3 }, formatter4: { type: 'Number', options: {prefix: '*', negativeParens: true}, columns: 2 }, } } table = Daru::View::Table.new(data, {allowHtml: true}, user_options) table.show_in_iruby data = [ ['Employee', 'Start Date (Long)', 'Start Date (Medium)', 'Start Date (Short)'], ['Mike', Date.parse('2007-11-28'), Date.parse('2007-11-28'), Date.parse('2007-11-28')], ['Bob', Date.parse('2006-7-16'), Date.parse('2006-7-16'), Date.parse('2006-7-16')], ['Alice', Date.parse('2007-9-2'), Date.parse('2007-9-2'), Date.parse('2007-9-2')] ] user_options = { formatters: { f1: { type: 'Date', options: { formatType: 'long' }, columns: 1 }, f2: { type: 'Date', options: { formatType: 'medium' }, columns: 2 }, f3: { type: 'Date', options: { formatType: 'short' }, columns: 3 } } } table = Daru::View::Table.new(data, {allowHtml: true}, user_options) table.show_in_iruby data = [ ['Year', 'Sales', 'Expenses'], ['2013', 1000, 400], ['2014', 1170, 460], ['2015', 660, 1120], ['2016', 1030, 540] ] user_options = { # Generating wierd bars in IRuby notebook, it is working fine in rails formatters: { f1: { type: 'Bar', options: { base: 1000, width: 120 }, columns: 2 } } } table = Daru::View::Table.new(data, {allowHtml: true}, user_options) table.show_in_iruby