Coder Social home page Coder Social logo

sciruby / daru-view Goto Github PK

View Code? Open in Web Editor NEW
95.0 10.0 20.0 18.75 MB

daru-view is for easy and interactive plotting in web application & IRuby notebook. daru-view is a plugin gem to the existing daru gem.

Home Page: https://sciruby.github.io/daru-view/

License: MIT License

Ruby 0.36% HTML 0.90% Jupyter Notebook 98.74% CSS 0.01% JavaScript 0.01%
daru daru-view data-visualization plot-library charts graphs ruby data-analysis rails sinatra

daru-view's Introduction

SciRuby meta gem Build Status

Tools for Scientific Computing in Ruby

Description

This gem acts as a meta gem which collects and provides multiple scientific gems, including numeric and visualization libraries.

Getting started

Installation:

gem install sciruby
gem install sciruby-full

If you want to have a full-blown installation, install sciruby-full.

Start a notebook server:

iruby notebook

Enter commands:

require 'sciruby'
# Scientific gems are auto loaded, you can use them directly!
plot = Nyaplot::Plot.new
sc = plot.add(:scatter, [0,1,2,3,4], [-1,2,-3,4,-5])

Take a look at gems.yml or the list of gems for interesting gems which are included in sciruby-full.

License

Copyright (c) 2010 onward, The Ruby Science Foundation.

All rights reserved.

SciRuby is licensed under the BSD 3-clause license. See LICENSE for details.

Donations

Support a SciRuby Fellow via Pledgie.

daru-view's People

Contributors

abhishek-sopho avatar iamrajiv avatar kojix2 avatar lokeshh avatar pjotrp avatar prakriti-nith avatar rohitner avatar sayant1204 avatar shekharrajak avatar snpd25 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

daru-view's Issues

[Rails] Daru, Highcharts, etc gems are not automatically loaded while including `daru-view` in Rails Gemfile

Before Daru wasn't included:

lokeshh:~/workspace/daru_rails (master) $ rails s -b $IP -p $PORT
RubyDep: WARNING: Your Ruby is outdated/buggy.
RubyDep: WARNING: Your Ruby is: 2.3.0 (buggy). Recommendation: upgrade to 2.3.1.
RubyDep: WARNING: (To disable warnings, see:http://github.com/e2/ruby_dep/wiki/Disabling-warnings )
/usr/local/rvm/gems/ruby-2.3.0/bundler/gems/daru-view-5cd8bb74476f/lib/daru/view/adapters/nyaplot.rb:3:in `require': cannot load such file -- daru (LoadError)
        from /usr/local/rvm/gems/ruby-2.3.0/bundler/gems/daru-view-5cd8bb74476f/lib/daru/view/adapters/nyaplot.rb:3:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.3.0/bundler/gems/daru-view-5cd8bb74476f/lib/daru/view/plot.rb:15:in `require'
        from /usr/local/rvm/gems/ruby-2.3.0/bundler/gems/daru-view-5cd8bb74476f/lib/daru/view/plot.rb:15:in `adapter='
<...>

After including Daru I got errors like lazy_high_charts not found. I'm wondering why aren't the included automatically.

Add #to_html method

As per discussion on SciRuby/daru#405, I think it'd be apt for the the to_html to be added to daru-view rather than in daru or daru-io. Please mirror the changes caused by SciRuby/daru#366 here. 😄

However, if further discussions on the issue tracker end up in a different conclusion, feel free to close this issue. I'm temporarily closing SciRuby/daru-io#39.

Improve code quality

Just go through the files and check if there is any rubocop disabled comment. Try to remove it and fix it.

HighChart generating chart body part in html

In main LazyHighCharts gem the html code generated using high_charts method contains var onload = window.onload; , So this script can't show charts in iruby. I have removed onload var and used the main script to generate body part of the chart (modification in lib/adapters/highcarts/layout_helper_iruby.rb) . But there must be a html code that works in both webpage as well as iruby notebook. I tried few modifications but it was not working on both.

Examples to be added for new features, in demo apps

We have demo_daru-view repo where we maintain our examples to demonstrate the features of daru-view and how we can use daru-view in different Ruby web frameworks (Rails/ Sinatra / Nanoc / Hanami).

Since we have added new features in this GSoC 2018 period we should update our demo apps accordingly.
Some real world examples (simple to advance) will be appreciated.

Remove executables from gem specification

Due to this line in .gemspec:

 spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }

...and to fact that bin contains executables of rake, thor, pry, rails (why?..), when `daru-view is installed, your versions of this executables replace the system ones. That should be fixed ASAP, it is a huge problem.

Nyaplot library generating model of the chart wrongly

Nyaplot library is working fine in IRuby notebook and generated the correct div part in IRuby . But in Web application Rails it is just showing the box not the charts in it. I hope JS files are loaded properly and I have checked it , it is fine.

Problem is generate_body which is generating the model of the chart slightly wrong. (It is adding the property also in the div hash, which must not be added).

Download chart button for highcharts library

Download button will be automatically added in right corner of the chart , when modules/exporting.js is added in LazyHighCharts.init_script and LazyHighCharts.init_iruby method.

Using the button we can download the charts as image/pdf.

Right now I get some problem in iruby notebook , when I try to add all dependent JS.

Issue with Arrow and Bar Formatters

Out of these six formatters, Arrow and Bar are causing some issues and rest are working fine. Bar formatter is working correctly in rails but in IRuby notebook it generates weird bars. See examples. Arrow formatter is neither generating arrows in nbviewer (working fine in localhost) nor in rails.

Google charts JS won't work offline

I have added google charts dependent JS loader.js and google_visualr.js in js folder. But these files have some internal internet dependencies.

See these line : https://github.com/Shekharrajak/daru-view/blob/master/lib/daru/view/adapters/js/googlecharts_js/google_visualr.js#L6

you can search https in the file. These may have some way to use it offline by loading the all the files.

(Note : google charts is created to be used as online and downloading the JS file is not recommended in google charts tool website as well)

[Rails] Where to add the dependent JS files?

From the README:

`In view, add the required JS files (for the plotting library), in head tag (generally) using the line , e.g. : Daru::View.dependent_script(:highcharts)

Could you mention specifically where this line needs to be added?

Daru::View::Plot.new gives NameError: uninitialized constant Daru::DataFrame

To reproduce the bug, execute:

require 'daru/view'
Daru::View::Plot.new

Here's the whole trace:

NameError: uninitialized constant Daru::DataFrame
/home/ubuntu/workspace/daru-view/lib/daru/view/adapters/highcharts.rb:43:in `init'
/home/ubuntu/workspace/daru-view/lib/daru/view/plot.rb:87:in `plot_data'
/home/ubuntu/workspace/daru-view/lib/daru/view/plot.rb:32:in `initialize'
(pry):180:in `new'
(pry):180:in `<main>'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:355:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:355:in `evaluate_ruby'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:323:in `handle_line'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:243:in `block (2 levels) in eval'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:242:in `catch'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:242:in `block in eval'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:241:in `catch'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:241:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/backend.rb:66:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/backend.rb:12:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/kernel.rb:87:in `execute_request'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/kernel.rb:47:in `dispatch'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/kernel.rb:37:in `run'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/command.rb:70:in `run_kernel'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/command.rb:34:in `run'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/bin/iruby:5:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/bin/iruby:23:in `load'
/usr/local/rvm/gems/ruby-2.3.0/bin/iruby:23:in `<main>'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

Strange error Daru::Vector#plot undefined

Refer : #28 (comment)

For library nyaplot . Which worked fine in spec/dummy_iruby/Nyaplot_basic iruby notebook example.
It displayed this :

screen shot 2017-06-23 at 10 25 12 am

daru is fetched from sciruby/daru github repo and the above example works fine in console and dummy_rails app.

Reduce the size of the gem

We can see the gem size here : https://rubygems.org/gems/daru-view

image

Looks like our dummy_iruby notebook examples and js files increasing the gem size.But

  • we should have all the features demo in iruby notebook.
  • we should have dependent js files present in source code, so that it can work offline.

Is there anything else that causes, this much size ?

problem while installing rbczmq

last few lines of error :

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -pedantic -Werror -Wall -D_GNU_SOURCE -DLINUX -D_REENTRANT -D_THREAD_SAFE -g -I/usr/local/lib/ruby/gems/2.5.0/gems/rbczmq-1.7.9/ext/rbczmq/dst/include -g -fPIC -MT zdir.lo -MD -MP -MF .deps/zdir.Tpo -c zdir.c -o zdir.o
zdir.c: In function ‘zdir_new’:
zdir.c:156:9: error: ‘readdir_r’ is deprecated [-Werror=deprecated-declarations]
         int rc = readdir_r (handle, entry, &result);
         ^~~
In file included from ../include/czmq_prelude.h:257:0,
                 from ../include/czmq.h:31,
                 from zdir.c:35:
/usr/include/dirent.h:183:12: note: declared here
 extern int readdir_r (DIR *__restrict __dirp,
            ^~~~~~~~~
zdir.c:159:13: error: ‘readdir_r’ is deprecated [-Werror=deprecated-declarations]
             rc = readdir_r (handle, entry, &result);
             ^~
In file included from ../include/czmq_prelude.h:257:0,
                 from ../include/czmq.h:31,
                 from zdir.c:35:
/usr/include/dirent.h:183:12: note: declared here
 extern int readdir_r (DIR *__restrict __dirp,
            ^~~~~~~~~
cc1: all warnings being treated as errors
Makefile:774: recipe for target 'zdir.lo' failed
make[2]: *** [zdir.lo] Error 1
make[2]: Leaving directory '/usr/local/lib/ruby/gems/2.5.0/gems/rbczmq-1.7.9/ext/czmq/src'
Makefile:586: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/usr/local/lib/ruby/gems/2.5.0/gems/rbczmq-1.7.9/ext/czmq/src'
Makefile:414: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
CZMQ compile error!
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/local/bin/$(RUBY_BASE_NAME)
	--with-system-libs
	--without-system-libs
	--with-system-libs
	--without-system-libs

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.5.0/gems/rbczmq-1.7.9 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0-static/rbczmq-1.7.9/gem_make.out

Error When Using Highcharts / Googlecharts

Hi,
when I try to use another plotting library other than the default I get an error.

Example:

require 'daru/view'

Daru::View.plotting_library = :googlecharts

df = Daru::DataFrame.new(
  {'Names' => %w(A B C), 'Data' => [2,3,5]}
)
  
Daru::View::Plot.new(df, {type: :bar, x: 'Names', y: 'Data'})

The error is:

NoMethodError
(undefined method `access_row_tuples_by_indexs' for #<Daru::DataFrame:0x00005598eae589f8>)

I'm using:

  • Daru 0.2.1
  • Daru-View 0.2.4
  • Ruby 2.5

Installation Help

get problems with installation on windows 10
gem install daru-view Invalid argument @ rb_sysopen - D:/SIM/script/ruby/setup/ruby22/lib/ruby/gems/2.2.0/gems/daru-view-0.1.0/spec/dummy_iruby/.ipynb_checkpoints/DataTables | basic examples-checkpoint.ipynb

Post GSoC: cleanup, refactoring, docs

First of all: I need to apologize for my insufficient participation in your work during summer.
Being one of initial proposal authors and SciRuby's dedicated code qulaity mentor, I've should provide you with much more help and suggestions. And I'd definitely do that, if not for the fact that I've fighted with severe clinical depression this summer.

But now I feel like being back to life (as you probably 've noticed by much more of dumb suggestions and discussions!) and are excited by the project. Yet I have a lot of suggestions on small things, and on how to make project more accessible to newcomers (e.g. docs and tutorials).

As 3 days before GSoC end is a bit :trollface: late for those changes, I'd like to work together on the project cleanup and enchancement after GSoC would be finished and the dust will settle. (Of course, this means that we are gratefully accepting your summer work!)

If you are willing to work on a project after GSoC (which I am really hoping you are, but of course can't force or even ask you, if your plans differ), let's make this issue a "communication hub" for those further encancements?

Error with Daru::View.plotting_library = :highcharts

require 'daru/view' returns true but Daru::View.plotting_library = :highcharts gives the following error

LoadError: cannot load such file -- daru/view/adapters/Highcharts/iruby_notebook
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:120:in `require'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:120:in `require'
/home/ubuntu/workspace/daru-view/lib/daru/view.rb:50:in `load_lib_in_iruby'
/home/ubuntu/workspace/daru-view/lib/daru/view.rb:28:in `plotting_library='
(pry):2:in `<main>'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:355:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:355:in `evaluate_ruby'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:323:in `handle_line'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:243:in `block (2 levels) in eval'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:242:in `catch'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:242:in `block in eval'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:241:in `catch'
/usr/local/rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:241:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/backend.rb:66:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/backend.rb:12:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/kernel.rb:87:in `execute_request'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/kernel.rb:47:in `dispatch'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/kernel.rb:37:in `run'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/command.rb:70:in `run_kernel'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/lib/iruby/command.rb:34:in `run'
/usr/local/rvm/gems/ruby-2.3.0/gems/iruby-0.3/bin/iruby:5:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/bin/iruby:23:in `load'
/usr/local/rvm/gems/ruby-2.3.0/bin/iruby:23:in `<main>'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

[Nyaplot] Loading http over https

This doesn't belong here but writing it down so that we don't forget it.

Plotting using nyaplot over https doesn't work. One need to explicitly click on "Load unsafe" scripts in Google Chrome to make it work.

Highcharts IRuby notebook : load dependent JS

Dependent JS files :

  • Initial
<script type="text/javascript" src="http://code.highcharts.com/highcharts.js"></script>
  • for 3d plotting
<script src="https://code.highcharts.com/highcharts-3d.js"> </script>
  • data.js dependencies when load data from html table/csv
<script src="https://code.highcharts.com/modules/data.js"></script>
  • exporting download button at the right corner of the chart
<script src="https://code.highcharts.com/modules/exporting.js"></script>
  • area range chart, bubble chart, bubble-3d chart type dependency
<script src="https://code.highcharts.com/highcharts-more.js"></script>
  • for drilldown
<script src="https://code.highcharts.com/modules/drilldown.js"> </script>

There are many other JS files present but I think above these are enough.

Update JS files for the libraries

Developers can update the js files using these command in the repo:

rake library_name:update

e.g. rake highcharts:update

To update all the JS files : rake update_all

But how user will update it (who have installed the gem from the source or using gem install) ?

Probably we can have CLI and using command daur-view update_js library_name user can update the particular js . I like the way Thor gem works. But there is some other good Command Line Interface Gems as well.

Improve the coverage report

When we run the rspec; using simpleCov we get the coverage report . Try to improve it as much as possible.

We just need more test cases written in spec folder for all the adapters and files.

Issue with exporting HighCharts in IRuby notebook

Exporting in web frameworks is completely offline. In IRuby notebook, offline-export supports only the exporting to png, jpeg and SVG format. Export to PDF is not working (not even through the exporting button in highchart). So, online exporting is done in IRuby notebook.
Now, there is a problem in online exporting that if we run-all all the cells of IRuby notebook then only the last chart will be exported. Individually, running the cells works fine.
So, either we need to find a way to export HighChart to PDF format when offline exporting is done or we should resolve the bug in online exporting.

Unable to install daru-view on my local computer

Gemfile has the following contents:

gem 'daru', path: '/Users/shekharrajak/Documents/gsoc17/daru'
gem 'nyaplot', path: '/Users/shekharrajak/Documents/gsoc17/nyaplot'

which doesn't enable me to install daru-view and try it out.

Google charts features

google Datatable have lots of features . But in google_visualr all the methods are not defined.
May be google charts is updated or added new methods/features. (Also google_visualr is not maintained for long). There may be different google chart gem that is better than this. All we can have some good methods in daru-view that can handle most of the methods.

Add more examples

These are many things we can do using Highcharts, GoogleCharts, Nyaplot, DataTables. I tried to add most of the basic examples in iruby notebook/rails/sinatra/nanoc web application in spec folder.

But there are many advance examples we can show for the highcharts, that must be added in iruby notebook spec/dummy_iruby

few are present here (for highcharts) : https://www.highcharts.com/community/charts/

Add proper dependencies

image

  1. All these dependencies should ideally reside in daru-view gemspec so user just have to use gem 'daru-view'

  2. There are other gems like 'datatables' that daru-view complain about while working. Those should be included in daru-view gemspec.

Highcharts in IRuby notebook works properly when it is saved

When we plot using HighCharts in daru-view in iruby notebook, it loads the dependent JS files properly but not able to display it in output cell (shows nothing).

But when we save the notebook file, and run the downloaded html file or other format it shows in chart properly in output cell.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.