Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added HighMaps #92

Merged
merged 18 commits into from
Jun 16, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions lib/daru/view/adapters/highcharts/display.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module LazyHighCharts
def self.init_script(
dependent_js=['highstock.js', 'highcharts-more.js', 'modules/exporting.js',
dependent_js=['highstock.js', 'map.js', 'modules/exporting.js',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is constant we must place all the constant variable into one file, to make it loosely coupled. Accessing these constants into multiple files will be better.

'highcharts-3d.js', 'modules/data.js']
)
# Highstock is based on Highcharts, meaning it has all the core
Expand Down Expand Up @@ -33,22 +33,25 @@ class HighChart
#
def to_html(placeholder=random_canvas_id)
chart_hash_must_be_present
script = load_modules('web_frameworks')
# Helps to denote either of the three classes.
chart_class = extract_chart_class
# When user wants to plot a HighMap
if chart_class == 'Map'
high_map(placeholder, self)
script << high_map(placeholder, self)
# When user wants to plot a HighStock
elsif chart_class == 'StockChart'
high_stock(placeholder, self)
script << high_stock(placeholder, self)
# When user wants to plot a HighChart
elsif chart_class == 'Chart'
high_chart(placeholder, self)
script << high_chart(placeholder, self)
end
script
end

def show_in_iruby(placeholder=random_canvas_id)
# TODO : placeholder pass, in plot#div
load_modules('iruby')
IRuby.html to_html_iruby(placeholder)
end

Expand All @@ -61,6 +64,17 @@ def to_html_iruby(placeholder=random_canvas_id)
high_chart_iruby(extract_chart_class, placeholder, self)
end

# @return load the dependent modules of the chart
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least Input parameter and return object must be documented according to yard.

def load_modules(type)
modules = options.delete(:modules).collect { |module_js| 'modules/' + module_js } unless
options[:modules].nil?
if type == 'iruby'
LazyHighCharts.init_iruby(modules) unless modules.nil?
elsif type == 'web_frameworks'
modules.nil? ? '' : LazyHighCharts.init_script(modules)
end
end

# @return [String] the class of the chart
def extract_chart_class
# Provided by user and can take two values ('stock' or 'map').
Expand Down
5 changes: 4 additions & 1 deletion lib/daru/view/adapters/highcharts/iruby_notebook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.generate_init_code(dependent_js)

# Enable to show plots on IRuby notebook
def self.init_iruby(
dependent_js=['highstock.js', 'highcharts-more.js', 'modules/exporting.js',
dependent_js=['highstock.js', 'map.js', 'modules/exporting.js',
'highcharts-3d.js', 'modules/data.js']
)
# TODO: include highstock.js for highstock and modules/*.js files for
Expand All @@ -18,6 +18,9 @@ def self.init_iruby(
# 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
Expand Down
8 changes: 8 additions & 0 deletions lib/daru/view/adapters/highcharts/layout_helper_iruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ def high_chart_iruby(chart_class, placeholder, object, &block)
).concat(content_tag('div', '', object.html_options))
end

def high_map(placeholder, object, &block)
object.html_options[:id] = placeholder
object.options[:chart][:renderTo] = placeholder
build_html_output(
'Map', placeholder, object, &block
).concat(content_tag('div', '', object.html_options))
end

private

def build_html_output_iruby(type, placeholder, object, &block)
Expand Down
142 changes: 74 additions & 68 deletions lib/daru/view/adapters/js/highcharts_js/highcharts-3d.js

Large diffs are not rendered by default.

794 changes: 401 additions & 393 deletions lib/daru/view/adapters/js/highcharts_js/highcharts.js

Large diffs are not rendered by default.

436 changes: 436 additions & 0 deletions lib/daru/view/adapters/js/highcharts_js/highmaps.js

Large diffs are not rendered by default.

1,049 changes: 536 additions & 513 deletions lib/daru/view/adapters/js/highcharts_js/highstock.js

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions lib/daru/view/adapters/js/highcharts_js/map.js

Large diffs are not rendered by default.

101 changes: 61 additions & 40 deletions lib/daru/view/adapters/js/highcharts_js/modules/accessibility.js

Large diffs are not rendered by default.

30 changes: 22 additions & 8 deletions lib/daru/view/adapters/js/highcharts_js/modules/annotations.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading