Skip to content

Making daru view gem independent

Shekhar Prasad Rajak edited this page Dec 11, 2018 · 6 revisions

We should have daru-view gem independent from 3rd party plotting gems (lazy_high_charts and googlevisualr), since now we have solved the problems like daru dataframe/vector compatible plotting gem, that can work smoothly in any Ruby web application framework, IRuby notebook as well as terminal.

Why?

Because :

  • we don't have much control over these gems and also we want to keep adding new features directly from HighCharts and Google Charts official sites.
  • we have extended (overload and override) most of the methods from lazy_high_charts and googlevisualr, to make it compatible for IRuby notebook and all ruby frameworks or to add new chart features already presents in HighCharts and Google Charts.
  • daru-view should be able to handle future chart types as well without (or very less) modifying code.

What to do for it?

Writing code for generating Google Charts and HighCharts Javascript code for varioous charts in daru-view gem itself such that :

  • It is totally compatible with daru dataframe and vector with all public api.
  • Alternate data source : List, array of array, json format, URL
  • Export chart in pdf, jpg, svg, png and other formats if we can (and javascript library can't).
  • Builder classes that are responsible for generating HTML file, JS code, CSS code for the any javascript chart lirary.
  • Dependent Javascript file loader will be responsible loading dependent js in IRuby notebook and any Ruby web application framework effectively, fast and smartly(Online/Offline or lazy loading).

HighCharts specific:

  • Extendable code to generate Highcharts , Highstock, Highmap, Grantt javascript chart code.
  • Checkout road map and understand new features to make it modular.

GoogleCharts specific:

  • TODO

How we can achieve it:

  • daru-view is already able to use HighChart, HighStock, HighMap (extended the lazy_highcharts functionalities in daru-view), so when we remove the lazy_highcharts gem, our gem design should be such that at runtime(may be Template and (or Strategy) design pattern can help to generate respective JS code and class) it switch the chart class (HighChart, HighStock, HighMap, Grantt).

  • Html Builder class will be used in daru/view/highchart and daru/view/googlechart class. ( may be Bridge design pattern ) So to choose correct html template. It will choose jsCodeGeneratore class and htmlTemplate class in initialize(jsCodeGeneratore , htmlTemplate ) e.g. In class HighchartsHtmlFileBuilder => initialize(HighchartsJsCodeGeneratore , HighchartsHtmlTemplate ) Similar things for googlecharts

  • Util module will be used for general purpose for example to make data source daru dataframe daru vector compatible for googlechart , highchart list or list of lists. (may be facade design pattern) . Also IRuby notebook related code will be in Util module.

Our util module should be able to create json object for data source that will be used in highcharts googlecharts. For example :

If our daru vector have name 'Installation' and array '[43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]' that means in HighChart javascript our seriese will be


{
          name: 'Installation',
          data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
}

  • TODO

Skills required :

Since it is always better to solve designing problems using design pattern and SOLID design principles. We must have good knowledge about when to use which design pattern and why; keeping the future modification in mind.

Good links to learn design pattern :

Clone this wiki locally