-
Notifications
You must be signed in to change notification settings - Fork 20
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
Multiple charts in a row #97
Multiple charts in a row #97
Conversation
Added docs
14efb07
to
0d75e8e
Compare
2e662f8
to
a291110
Compare
4a9d9bc
to
132cbf6
Compare
d6c9c61
to
3f2c9a2
Compare
Updated examples. I have added |
Now, multiple charts can be shown with googlecharts, google datatables, highcharts and nyaplot. Updated examples. |
Pull Request Test Coverage Report for Build 600
💛 - Coveralls |
77ca735
to
3e18eef
Compare
@Shekharrajak can you please review the changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include more than 2 charts in IRuby examples.
lib/daru/view/plot_list.rb
Outdated
plot.is_a?(Daru::View::Plot) || | ||
plot.is_a?(Daru::View::Table) | ||
} | ||
raise ArgumentError, 'Invalid Argument Passed!' unless |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also write what are the valid parameter types.
lib/daru/view/plot_list.rb
Outdated
@@ -4,7 +4,7 @@ | |||
require 'daru/view/adapters/googlecharts/display' | |||
|
|||
# Otherwise Daru::IRuby module was used and IRuby.html method was not working. | |||
|
|||
# Have disabled rubocop Style/Mixin for this in .rubocop.yml file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once it is merged , then open the issue for it. So that we can keep track to solve it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted.
@@ -17,7 +17,7 @@ AllCops: | |||
- 'daru-view.gemspec' | |||
- '**/*.rake' | |||
DisplayCopNames: true | |||
TargetRubyVersion: 2.1 | |||
TargetRubyVersion: 2.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated target ruby version to 2.2 in .rubocoop.yml file as rubocop was producing this error:
Error: Unsupported Ruby version 2.1 found in TargetRubyVersion parameter (in .rubocop.yml). 2.1-compatible analysis was dropped after version 0.58.
lib/daru/view/plot_list.rb
Outdated
charts_script = '' | ||
@data.each do |plot| | ||
chart_script = extract_chart_script(plot) | ||
charts_div_tag << chart_script.partition(%r{<div(.*?)<\/div>}ixm)[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's name must be chart_id_div_tag
or something that tell about the value it contains.
# TODO: Implement this for datatables too | ||
return plot.div unless defined?(IRuby.html) && | ||
plot.is_a?(Daru::View::Plot) && | ||
plot.chart.is_a?(LazyHighCharts::HighChart) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to check HighCharts
explicitly ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In HighCharts
, js for web frameworks (includes onload) and IRuby notebook is generated separately. So, plot.div
would generate the wrong script for HighCharts in case of IRuby notebook. That's why I have checked it separately.
@@ -89,6 +88,7 @@ def show_in_iruby(placeholder=random_canvas_id) | |||
# `high_chart_iruby` which doesn't use `onload` in chart script. | |||
def to_html_iruby(placeholder=random_canvas_id) | |||
# TODO : placeholder pass, in plot#div | |||
load_dependencies('iruby') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to_html_iruby
is for generating the html and javascript only. At that time will don't want to load the dependent files, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
load_dependecies
is used to load the dependencies for HighCharts modules (provided in the modules option) and HighMaps dependent files. Right now, in web frameworks too, these dependencies are loaded in to_html
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay in this case we have to load it during the generation of body html code.
expect(content).to match(/window.addEventListener\('load_nyaplot', render/) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line here
@@ -0,0 +1,8 @@ | |||
<table class='columns'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class='columns'
is for ?
spec/plot_list_spec.rb
Outdated
subject (:js) { combined.div } | ||
it 'generates a table in js' do | ||
expect(js).to match(/<table class='columns'>/) | ||
expect(js).to match(/<td><div id=/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check 4 times <div id=
. It would be better if we can test the custom id, that was passed as well.
spec/plot_list_spec.rb
Outdated
expect(js).to match(/<td><div id=/) | ||
end | ||
context 'when js of the plots is generated' do | ||
it 'generates js of googlecharts' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the data and other tags , if required as well.
Also commit after running IRUby examples. |
This feature provides the facility to visualize multiple google charts in a single cell in IRuby notebook and in a single row in web frameworks. Examples link.