GSoC 2108 Project [ Advance features in daru-view ] discussion

Update on daru-view:

  1. Formatters in GoogleCharts (PR #110):
    The Google Visualization API provides formatters that can be used to reformat data in a visualization.
    For more details, visit this page.

  2. Added a method to load dependent scripts for multiple adapters (PR #107):
    Have a look at these examples.

  3. Rake Task to add new adapter templates (PR #112):
    Added a rake task to generate the sample template for the adapter.

  4. Rename Daru::DataTables::DataTable to Daru::View::DataTable (PR #114 in daru-view, PR in daru-data_tables):
    As daru-data_tables is a plugin gem for daru-view, it needs to be initialized in a different way. Now, it can be instantiated as Daru::View::DataTable.new(data, options).

  5. Reduce a bunch of lines due to JS files in source HTML in rails (PR #115 in daru-view, PR #23 in daru-data_tables):
    This aims to remove a bunch of lines that occur in the head tag in rails. In rails, the one line of code we actually need to write in daru-view is for a class called Engine, this is going to inherit from Rails::Engine, and this is more or less saying that when rails loads this gem, it’s going to look for this Engine class, and if it’s defined, it’s going to treat this gem’s directory structure a little bit differently. It’s going to work sort of like your rails application, almost as if you had a rails app inside of a rails app.
    To carry this out, dependent JS and CSS files are shifted to vendor/assets/javascripts and vendor/assets/stylesheets respectively, so that, JS can be included in the app/assets/javascripts/application.js file as:

//= require highcharts/highcharts                                                           
//= require highcharts/highcharts-more
//= require highcharts/map
//= require jquery-latest.min
//= require jquery.dataTables

and CSS files can be included as:

 *= require jquery.dataTables

Include the below line in the head of the layout file:

<%= javascript_include_tag "application" %>
<%= stylesheet_link_tag "application" %>

Note: The previous method to use <%=raw Daru::View.dependent_script(:highcharts) %> will also work.

Difficulties:
Right now this has only been done for rails. Other web frameworks do not provide much flexibility and there are fewer resources available to search. I am trying to reduce lines in Sinatra and nanoc too but still facing many difficulties. Loading JS and CSS files in the app (by keeping these files in the app) can be done, but loading these files from daru-view in the sinatra/nanoc/other frameworks is not an easy task. I have also opened this issue in the sinatra repo.

  1. Improved Code Quality (PR #116, PR #76, PR #73, PR #74):
    Improved code quality of the project by fixing various rubocop comments in these PRs and also during working in other PRs.

  2. Added examples in web frameworks:
    Rails examples:

  • Importing data from google spreadsheet in google charts - #2
  • HighCharts, HighStock, HighMaps examples - #3
  • Custom CSS in highcharts example - #4
  • ChartWrapper examples - #6
  • Multiple Charts using PlotList examples - #8
  • DataTables examples - #10
  • ChartEditor examples - #9
  • Formatters examples - #11
  • Handling events examples - #12

Sinatra Examples:

  • Importing data from google spreadsheet in google charts - #5 commit
  • HighCharts, HighStock, HighMaps examples - #14
  • Custom CSS in highcharts examples - #13
  • ChartWrapper examples - #5 commit
  • Multiple Charts using PlotList examples - #5 commit
  • DataTables examples - #5 commit
  • Handling events examples - #5 commit
  • Formatters examples - #16
  • ChartEditor examples - #17