Skip to content

HighCharts features

Prakriti Gupta edited this page Jun 13, 2018 · 9 revisions

HighStock

API

To use HighStock, daru-view user just need to pass an additional option chart_class with its value as 'stock'.

For example: HighStock

Examples

For more examples do visit the following links.

How daru-view generates the JS code

Following are the steps to know how js code has been generated.

  • Firstly, daru-view user will generate the Daru::View::Plot(data, options) object and will call div(for web frameworks and show_in_iruby for IRuby notebook).

  • As plotting_library must already be set to :highcharts, transfer goes to highcharts.rb and then to the display.rb (when the methods div and show_in_iruby are called).

  • Now, in web frameworks ultimately to_html is called. In to_html

    • load_dependences is called to load the additional dependencies:

      • Modules will be loaded only if any dependencies are provided in modules option. These are the additional modules required to draw the chart apart from the ones loaded while setting the plotting_library. Once a module is loaded then there is no need afterwards to load it again.
      • If the HighMap is being drawn by the user, then the required map data will be extracted from options[:map][:chart].
    • chart_class is extracted and compared.

    • If class_chart equals StockChart, then high_stock method from lazy_high_charts is called.

  • In Iruby notebook, ultimately show_in_iruby is called in display.rb. In show_in_iruby

    • Dependencies are similarly loaded if any.
    • Extracted chart_class is passed to high_chart_iruby method.
    • All of the code to generate js in IRuby notebook is present in layout_helper_iruby.rb.

HighMap

API

To use HighMap, a daru-view user just need to pass an additional option chart_class with its value as 'map'.

For example: HighMap

Examples

HighMaps additional official examples for each country can be found here. For more examples do visit the following links.

How daru-view generates the JS code

Following are the steps to know how js code has been generated.

  • Firstly, daru-view user will generate the Daru::View::Plot(data, options) object and will call div(for web frameworks and show_in_iruby for IRuby notebook).

  • As plotting_library must already be set to :highcharts, transfer goes to highcharts.rb and then to the display.rb (when the methods div and show_in_iruby are called).

  • Now, in web frameworks ultimately to_html is called. In to_html

    • load_dependences is called to load the additional dependencies:

      • Modules will be loaded only if any dependencies are provided in modules option. These are the additional modules required to draw the chart apart from the ones loaded while setting the plotting_library. Once a module is loaded then there is no need afterwards to load it again.
      • If the HighMap is being drawn by the user, then the required map data will be extracted from options[:map][:chart].
    • chart_class is extracted and compared.

    • If class_chart equals Map, then high_map method is called to generate the js.

  • In Iruby notebook, ultimately show_in_iruby is called in display.rb. In show_in_iruby

    • Dependencies are similarly loaded if any.
    • Extracted chart_class is passed to high_chart_iruby method.
    • All of the code to generate js in IRuby notebook is present in layout_helper_iruby.rb.

TODOs (Challenges faced)

  • If the user provides modules again then it will be loaded again (no matter if it's already been loaded). Similarly, map data is loaded again. So, there is a need to optimize this loading of dependent js files by implementing some appropriate design pattern (like proxy design) to load the modules and map data in HighCharts.
  • As HighCharts supports multiple series in a single chart, we can add a feature to visualize multiple Daru::DataFrame and Daru::Vector in a single chart (Need to think how user will provide the data - maybe in the series format or some other).
  • Due the large number of map data, js files have been increased tremendously which makes the gem bulky. Other way round is to completely switch too online mode to load the js files.

Clone this wiki locally