module Daru::View::Adapter::NyaplotAdapter

Public Instance Methods

export(_plot, _export_type='png', _file_name='chart') click to toggle source
# File lib/daru/view/adapters/nyaplot.rb, line 19
def export(_plot, _export_type='png', _file_name='chart')
  raise 'Not implemented yet'
end
export_html_file(plot, path) click to toggle source
# File lib/daru/view/adapters/nyaplot.rb, line 15
def export_html_file(plot, path)
  plot.export_html path
end
generate_body(plot) click to toggle source
# File lib/daru/view/adapters/nyaplot.rb, line 31
def generate_body(plot)
  plot.to_iruby[1]
end
init(data, options, _user_options={}) click to toggle source
# File lib/daru/view/adapters/nyaplot.rb, line 10
def init(data, options, _user_options={})
  data_new = guess_data(data)
  data_new.plot(options)
end
init_iruby() click to toggle source
# File lib/daru/view/adapters/nyaplot.rb, line 35
def init_iruby
  Nyaplot.init_iruby
end
init_script() click to toggle source
# File lib/daru/view/adapters/nyaplot.rb, line 27
def init_script
  Nyaplot.init_script
end
show_in_iruby(plot) click to toggle source
# File lib/daru/view/adapters/nyaplot.rb, line 23
def show_in_iruby(plot)
  plot.show
end

Private Instance Methods

guess_data(data_set) click to toggle source
# File lib/daru/view/adapters/nyaplot.rb, line 45
def guess_data(data_set)
  case
  when [Daru::DataFrame, Daru::Vector].include?(data_set.class)
    data_set
  when data_set.is_a?(Array)
    if data_set.empty?
      Daru::Vector.new([])
    else
      multi_dimension_check(data_set)? Daru::DataFrame.new(data_set) : Daru::Vector.new(data_set)
    end
  else
    raise ArgumentError, "For Nyaplot Library, data must be in
    Daru::Vector or Daru::DataFrame.\n You can change the plotting
    library using the code : \n
    ` Daru::View.plotting_library = :highcharts` or other library."
  end
end
multi_dimension_check(arr) click to toggle source
# File lib/daru/view/adapters/nyaplot.rb, line 41
def multi_dimension_check(arr)
  arr.all? { |a| a.class==Array }
end