-
Notifications
You must be signed in to change notification settings - Fork 20
HighCharts features
To use HighStock, daru-view user just need to pass an additional option chart_class
with its value as 'stock' in the third parameter of the Plot object (refer this PR).
For example:
For more examples do visit the following links.
- HighStock - Chart types
- HighStock - General
- HighStock - Various Features
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 andshow_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 methodsdiv
andshow_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 amodule
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].
- Modules will be loaded only if any dependencies are provided in
-
chart_class
is extracted and compared. -
If
class_chart
equalsStockChart
, then high_stock method from lazy_high_charts is called.
-
-
In Iruby notebook, ultimately
show_in_iruby
is called in display.rb. Inshow_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.
To use HighMap, a daru-view user just need to pass an additional option chart_class
with its value as 'map' in the third parameter of the Plot object.
For example:
HighMaps additional official examples for each country can be found here. For more examples do visit the following links.
- HighMaps - Countries
- HighMaps - General
- HighMaps - Series type
- HighMaps - Dynamic
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 andshow_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 methodsdiv
andshow_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 amodule
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].
- Modules will be loaded only if any dependencies are provided in
-
chart_class
is extracted and compared. -
If
class_chart
equalsMap
, thenhigh_map
method is called to generate the js.
-
-
In Iruby notebook, ultimately
show_in_iruby
is called in display.rb. Inshow_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 - Refer this comment)
- 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. Refer this comment.
- 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 to a large number of map data, js files have been increased tremendously which makes the gem bulky. Another way round is to completely switch to the online mode to load the js files.
To use custom styling CSS in HighCharts, a daru-view user needs to pass an additional option css
in which he/she can specify the CSS to apply on that Chart as a String Array.
For example:
To understand the usage of this feature, check out some more examples here.