module LazyHighCharts

Public Class Methods

generate_init_code(dependent_js) click to toggle source

generate initializing code

# File lib/daru/view/adapters/highcharts/iruby_notebook.rb, line 5
def self.generate_init_code(dependent_js)
  js_dir = File.expand_path(
    '../../../../../vendor/assets/javascripts/highcharts', __dir__
  )
  path = File.expand_path(
    '../../templates/highcharts/init.inline.js.erb', __dir__
  )
  template = File.read(path)
  ERB.new(template).result(binding)
end
generate_init_code_css(dependent_css) click to toggle source
# File lib/daru/view/adapters/highcharts/iruby_notebook.rb, line 16
def self.generate_init_code_css(dependent_css)
  css_dir = File.expand_path(
    '../../../../../vendor/assets/stylesheets/highcharts', __dir__
  )
  path = File.expand_path(
    '../../templates/highcharts/init.inline.css.erb', __dir__
  )
  template = File.read(path)
  ERB.new(template).result(binding)
end
init_css( dependent_css=HIGHCHARTS_DEPENDENCIES_CSS ) click to toggle source

Loads the dependent css required in styled mode

@param [Array] dependent css files required @return [String] CSS code of the dependent file(s)

# File lib/daru/view/adapters/highcharts/display.rb, line 31
def self.init_css(
  dependent_css=HIGHCHARTS_DEPENDENCIES_CSS
)
  css =  ''
  css << "\n<style type='text/css'>"
  css << LazyHighCharts.generate_init_code_css(dependent_css)
  css << "\n</style>"
  css
end
init_iruby( dependent_js=HIGHCHARTS_DEPENDENCIES_IRUBY ) click to toggle source

Enable to show plots on IRuby notebook

# File lib/daru/view/adapters/highcharts/iruby_notebook.rb, line 28
def self.init_iruby(
  dependent_js=HIGHCHARTS_DEPENDENCIES_IRUBY
)
  # TODO: include highstock.js for highstock and modules/*.js files for
  # exporting and getting data from various source like csv files etc.
  #
  # Highstock.js includes the highcharts.js, so only one of them required.
  # see: https://www.highcharts.com/errors/16
  #
  # Using Highmaps as a plugin for HighCharts so using map.js instead of
  # highmaps.js
  #
  # , 'modules/exporting.js' : for the exporting button
  # data.js for getting data as csv or html table.
  # 'highcharts-more.js' : for arearange and some other chart type
  # 'modules/offline-exporting.js': for enabling offline exporting. Used in
  #  #chart.extract_export_code method (to enable chart.exportChartLocal)
  #  to export the chart using code.
  # Note: Don't reorder the dependent_js elements. It must be loaded in
  # the same sequence. Otherwise some of the JS overlap and doesn't work.
  js = generate_init_code(dependent_js)
  IRuby.display(IRuby.javascript(js))
end
init_javascript( dependent_js=HIGHCHARTS_DEPENDENCIES_WEB ) click to toggle source

Loads the dependent javascript required

@param [Array] dependent js files required @return [String] js code of the dependent files

# File lib/daru/view/adapters/highcharts/display.rb, line 10
def self.init_javascript(
  dependent_js=HIGHCHARTS_DEPENDENCIES_WEB
)
  # Highstock is based on Highcharts, meaning it has all the core
  # functionality of Highcharts, plus some additional features. So
  # highstock.js contains highcharts.js .If highstock.js is removed then
  # add highchart.js to make chart script work.
  #
  # Note: Don't reorder the dependent_js elements. It must be loaded in
  # the same sequence. Otherwise some of the JS overlap and doesn't work.
  js = ''
  js << "\n<script type='text/javascript'>"
  js << LazyHighCharts.generate_init_code(dependent_js)
  js << "\n</script>"
  js
end
init_script() click to toggle source

Loads the dependent code required in styled mode

@return [String] code of the dependent css and js file(s)

# File lib/daru/view/adapters/highcharts/display.rb, line 44
def self.init_script
  init_code = ''
  init_code << init_css
  init_code << init_javascript
  init_code
end