Module: Nyaplot

Defined in:
lib/daru/view/adapters/nyaplot/display.rb,
lib/daru/view/adapters/nyaplot/iruby_notebook.rb

Class Method Summary collapse

Class Method Details

.generate_init_code_offline(dependent_js) ⇒ Object

generate initializing code



3
4
5
6
7
8
9
10
11
12
# File 'lib/daru/view/adapters/nyaplot/iruby_notebook.rb', line 3

def self.generate_init_code_offline(dependent_js)
  js_dir = File.expand_path(
    '../../../../../vendor/assets/javascripts/nyaplot', __dir__
  )
  path = File.expand_path(
    '../../templates/nyaplot/init.inline.js.erb', __dir__
  )
  template = File.read(path)
  ERB.new(template).result(binding)
end

.generate_init_code_onlineObject

generate initializing code



15
16
17
# File 'lib/daru/view/adapters/nyaplot/iruby_notebook.rb', line 15

def self.generate_init_code_online
  # TODO : better than present Nyaplot.generate_init_code
end

.init_irubyObject

Enable to show plots on IRuby notebook



20
21
22
23
24
25
# File 'lib/daru/view/adapters/nyaplot/iruby_notebook.rb', line 20

def self.init_iruby(*)
  #
  # dependent_js=['d3.min.js', 'd3-downloadable.js', 'nyaplot.js']
  js = generate_init_code
  IRuby.display(IRuby.javascript(js))
end

.init_scriptObject

dependent JS to include in head tag of the web application



3
4
5
6
7
8
# File 'lib/daru/view/adapters/nyaplot/display.rb', line 3

def self.init_script
  init = Nyaplot.generate_init_code
  path = File.expand_path('../../templates/nyaplot/init_script.erb', __dir__)
  template = File.read(path)
  ERB.new(template).result(binding)
end