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

defined show and show_in_iruby methods #236

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Shekharrajak
Copy link

@Shekharrajak Shekharrajak commented Jun 3, 2017

Fixes #235

e.g. in iruby notebook :

chart = LazyHighCharts::HighChart.new('graph') do |f|
      f.title({ :text=>"Combination chart"})
      f.options[:xAxis][:categories] = ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']
      f.labels(:items=>[:html=>"Total fruit consumption", :style=>{:left=>"40px", :top=>"8px", :color=>"black"} ])      
      f.series(:type=> 'column',:name=> 'Jane',:data=> [3, 2, 1, 3, 4])
      f.series(:type=> 'column',:name=> 'John',:data=> [2, 3, 5, 7, 6])
      f.series(:type=> 'column', :name=> 'Joe',:data=> [4, 3, 3, 9, 0])
      f.series(:type=> 'spline',:name=> 'Average', :data=> [3, 2.67, 3, 6.33, 3.33])
      f.series(:type=> 'pie',:name=> 'Total consumption', 
        :data=> [
          {:name=> 'Jane', :y=> 13, :color=> 'red'}, 
          {:name=> 'John', :y=> 23,:color=> 'green'},
          {:name=> 'Joe', :y=> 19,:color=> 'blue'}
        ],
        :center=> [100, 80], :size=> 100, :showInLegend=> false)
    end

include LazyHighCharts::LayoutHelper
IRuby.display high_chart("some_id", chart), mime: 'text/html'
# or
IRuby.html high_chart("some_id", chart).to_s

I am not able to understand why high_chart_iruby("some_id1", chart) not working.

@Shekharrajak
Copy link
Author

Ping @michelson

end

# generate initializing code
def self.generate_init_code(assets=:inline)
Copy link
Author

Choose a reason for hiding this comment

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

assets= :cdn is not working . I don't know why.

@@ -10,6 +10,10 @@ def high_chart(placeholder, object, &block)
high_graph(placeholder, object, &block).concat(content_tag("div", "", object.html_options))
end

def high_chart_iruby(placeholder, object, &block)
Copy link
Author

Choose a reason for hiding this comment

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

Display nothing. @michelson can you check why it doesn't work ?

@Shekharrajak
Copy link
Author

@michelson , if this PR is merged, then it will be very helpful for me to use it in Daru gem and plugin gem daru-view. So please try to review it as soon as possible.

@michelson
Copy link
Owner

Hi @Shekharrajak , this looks good!. Could you provide an example in spec/dummy for iruby in order to do some integration tests?

best!

@Shekharrajak Shekharrajak changed the title IRuby.display works now for high_chart defined show and show_in_iruby methods Jun 4, 2017
@Shekharrajak Shekharrajak force-pushed the iruby_setup branch 3 times, most recently from 0824718 to c7a6259 Compare June 4, 2017 05:31
@Shekharrajak Shekharrajak force-pushed the iruby_setup branch 3 times, most recently from 7900453 to 1989e71 Compare June 4, 2017 08:53
@Shekharrajak
Copy link
Author

@michelson , I hope, now it is good to go.

@Shekharrajak
Copy link
Author

Using show and show_in_iruby method use don't need to run these lines :

include LazyHighCharts::LayoutHelper
IRuby.display high_chart("some_id", chart), mime: 'text/html'

@Shekharrajak
Copy link
Author

Most of the time developers and users try their code in iruby notebook. So it will be very helpful if lazy_high_charts is usable in iruby notebook. I have tried one example and pushed in this branch. You can check it in this link : http://nbviewer.jupyter.org/github/Shekharrajak/lazy_high_charts/blob/iruby_setup/examples/notebook/lazy_high_charts.ipynb

It will be helpful for me to continue my work on daru-view, if this PR is merged as soon as possible. Thanks.

@michelson
Copy link
Owner

michelson commented Jun 5, 2017 via email

@michelson
Copy link
Owner

michelson commented Jun 6, 2017

Hi @Shekharrajak ,
The example should be moved to spec/dummy_iruby
in order to merge this the example should contain all the dependences in a Gemfile , and the iRuby dep should be removed from gemspec. The Gemfile from the example project should be something like:

source "http://rubygems.org"
gem "iruby"
gem "cztop"
gemspec  :path => '../../'

btw I'm having troubles to run the notebook, all the output is turned to text, so is no chart. but I can see the example you pointed on jupyter.org correctly

regards

@Shekharrajak
Copy link
Author

Thanks for review . @michelson are you getting nothing in output cell of the notebook, when you run show_in_iruby ?

@Shekharrajak
Copy link
Author

I have added more examples in spec/dummy_iruby : http://nbviewer.jupyter.org/github/Shekharrajak/lazy_high_charts/blob/iruby_setup/spec/dummy_iruby/lazy_high_charts_basics.ipynb

Please check the last example, why it is failing. I think that is other issue.

@michelson
Copy link
Owner

yup , I'm not seeing any html output for the graph

i'm doing bundle exec iruby notebook inside spec/dummy_iruby

image

I've updated the gemfile as follows:

source "http://rubygems.org"
gem "iruby"
gem "cztop"
#gem 'rbczmq' <- this is not compiling on ruby 2.4.0 (osx)
gem 'actionview', '~> 4.2'
gemspec  :path => '../../'

is this working for you on local environment ? I get some errors just after notebook starts , FATAL -- : Kernel died: uninitialized constant IRuby::Kernel::Session

@Shekharrajak
Copy link
Author

gem 'rbczmq' # or 'ffi-rzmq'

is needed for iruby notebook. You can try it with 2.3 ruby

see : https://stackoverflow.com/questions/35999925/kernel-dies-when-creating-iruby-notebook

yup , I'm not seeing any html output for the graph'

When you do print preview in iruby notebook you will be able to see the chart. I also got the same problem I didn't understand why.

@Shekharrajak
Copy link
Author

@michelson , I think for 3d charts need to use <script src="/https://code.highcharts.com/highcharts-3d.js"><script>. But previously I thought 3d charts is usable with highcharts.js only. Is there any dependency in 3d plotting?

@Shekharrajak
Copy link
Author

Problem is onload method used here . I will update the PR soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants