olap-view 0.0.16 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f3b038c310c143d32f519d6cde23b7a55dbc3c6
4
- data.tar.gz: 81d3fd71328ccd924aef8542882bd078682f09a6
3
+ metadata.gz: d47ed5ee836d6be6b422ce2ad82afd779dee8e70
4
+ data.tar.gz: 6c21c6ef7b239bfd05c682024ab286ca63a6b65c
5
5
  SHA512:
6
- metadata.gz: 897faed30cbadf5f7aeef57604b7a509ac71e0322fc1101806ba1fa1f7465f92d537297e9bc4bfb3de58b800895c59f6daf17b433eebcfbb0feaf1822ee75aac
7
- data.tar.gz: 230ac258e29d09cbaf5d49fea07d53abb8cef4db154e28886d5e78a0ef7fd440bba0c1d6510e686bcb6d5da20649ce4889fc0eb1d0141e1198c9ee3dee66e925
6
+ metadata.gz: 3746b2528e9263d2178e83ee27d47a70231aaadc1a6f6b0a7980e689baa7ca05919a33b4105cd9a16a912dbbc2d49844783913b10687a3e20c56f9cbbef01e0c
7
+ data.tar.gz: 52c16e20f93fca55e34133df7a2e59dc2488a7d2178f78d8796abb0e27f565ddd91d10a5c7430f9975215c83c2534112db2e77d2e0cc621cf38d8501d44165e4
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Olap::View
2
2
 
3
- TODO: Write a gem description
3
+ Ruby On Rails gem to visualize by Google Charts MDX queries on OLAP databases using XMLA connection. Can be used with any XMLA-compliant server, like Olaper or Mondrian.
4
4
 
5
5
  ## Installation
6
6
 
@@ -19,8 +19,81 @@ Or install it yourself as:
19
19
  $ gem install olap-view
20
20
 
21
21
  ## Usage
22
+ ### Include required files in the application
23
+
24
+ Include Olap::View helper to `application_helper.rb`
25
+
26
+ ```ruby
27
+ include OlapViewHelper
28
+ ```
29
+
30
+ Import olap-view Sass file (for example, `application.scss`) to get all of olap-view style:
31
+
32
+ ```sass
33
+ @import "olap-view/olap-view";
34
+ ```
35
+
36
+ Add Google Charts initialize into `<head>` tag in your laoyut (for examlpe, `application.html.erb`):
37
+
38
+ ```html
39
+ <head>
40
+ ...
41
+ <%= olap_view_charts_init %>
42
+ </head>
43
+ ```
44
+
45
+ ### Configuration in Rails
46
+
47
+ ### Querying MDX
48
+ This gem use `olap-xmla` ( https://github.com/Wondersoft/olap-xmla ) and does not parse MDX, just passes it to XMLA server.
49
+ However, it can do substituting parameters in the query:
50
+
51
+ ```ruby
52
+ MDX_QUERY = 'SET [~ROWS_Date] AS {[DateTime].[Date].[Date].[%DATE%]}'
53
+
54
+ Olap::View.request MDX_QUERY, {'%DATE%' => '20150530'}
55
+ ```
56
+
57
+ ### Render Google Chart by MDX
58
+ At the moment only available `:table` and `:piechart` charts.
59
+
60
+ Insert helper menthod to `erb` file:
61
+ ```ruby
62
+ <%= olap_view_chart_by_mdx :table,
63
+ 'SET [~ROWS_Date] AS {[DateTime].[Date].[Date].[%DATE%]}',
64
+ {'%DATE%' => '20150530'} %>
65
+ ```
66
+
67
+ ### Use one MDX to many Charts
68
+
69
+ ```ruby
70
+ <% xmla = Olap::View.request 'SET [~ROWS_Date] AS {[DateTime].[Date].[Date].[%DATE%]}',
71
+ {'%DATE%' => '20150530'} %>
72
+ <div>
73
+ <h1>PieChart</h1>
74
+ <%= olap_view_chart_by_xmla :piechart, xmla %>
75
+ </div>
76
+ <div>
77
+ <h1>Table</h1>
78
+ <%= olap_view_chart_by_xmla :table, xmla %>
79
+ </div>
80
+ ```
81
+
82
+ ### Available parameters
83
+ In `olap_view_chart_by_mdx` and `olap_view_chart_by_xmla` following properties are available:
84
+
85
+ ```ruby
86
+ <%= olap_view_chart_by_xmla :table, xmla, properties %>
87
+ ```
88
+
89
+ `total: true` show total string in table chart
90
+ `rowspan: true` unites the cells with the same data from the dimenssions in table chart
91
+ `function: "text on JS"` execute ani js code into chart template
92
+ `dimention: "Source Name"` aggregate xmla data by dimesion
93
+ `measures: "[Measures].[Click]"` remove measure from xmla data
94
+ `options: {}` Google Charts draw options
95
+
22
96
 
23
- TODO: Write usage instructions here
24
97
 
25
98
  ## Contributing
26
99
 
@@ -25,7 +25,7 @@
25
25
  html += javascript_tag(render partial: "olap-view/#{chart}.js",
26
26
  locals: {id: id, data: xmla, properties: properties})
27
27
  else
28
- html = "<div id='#{id}'>#{Olap::View.options[:no_data]}</div>"
28
+ html = "<div id='#{id}'>#{olap_view_i18n_options[:no_data]}</div>"
29
29
  end
30
30
  html.html_safe
31
31
  end
@@ -33,7 +33,7 @@
33
33
  def olap_view_render_row row
34
34
  row.collect{|r|
35
35
  if r[:type] == 'dimension'
36
- "{v: '#{escape_javascript(r[:value] && !r[:value].empty? ? r[:value] : olap_view_unknown_element)}', p:{className: 'google-visualization-table-td #{r[:type]}'}}"
36
+ "{v: '#{escape_javascript(r[:value] && !r[:value].empty? ? r[:value] : olap_view_i18n_options[:undefined])}', p:{className: 'google-visualization-table-td #{r[:type]}'}}"
37
37
  else
38
38
  "{v: #{r[:value]}, f: '#{r[:fmt_value] || r[:value]}', p:{className: 'google-visualization-table-td #{r[:type]}'}}"
39
39
  end
@@ -54,12 +54,15 @@
54
54
  html.html_safe
55
55
  end
56
56
 
57
- private
58
57
  def olap_view_random_id
59
58
  (0...8).map { ('a'..'z').to_a[rand(26)] }.join
60
59
  end
61
60
 
62
61
  def olap_view_unknown_element
63
- Olap::View.options[:undefined].html_safe
62
+ olap_view_i18n_options[:undefined].html_safe
63
+ end
64
+
65
+ def olap_view_i18n_options
66
+ Hash[Olap::View.view_options.collect{|k, v| [k, I18n.t("olap.view.#{k}", default: v).html_safe]}]
64
67
  end
65
68
  end
@@ -0,0 +1,39 @@
1
+ (function(){
2
+ function draw<%= id %>() {
3
+ var name = 'combochart';
4
+ var data = new google.visualization.DataTable();
5
+
6
+ <%= olap_view_filling_table data, properties[:dimension], (properties[:measures] || []) %>
7
+
8
+ var measures_sum = [];
9
+ for (var i = 0; i < data.getNumberOfColumns(); i++) {
10
+ if (data.getColumnProperties(i).type == "measure") {
11
+ var sum = 0;
12
+ for (var j = 0; j < data.getNumberOfRows(); j++) {
13
+ sum += data.getValue(j, i);
14
+ }
15
+ measures_sum[measures_sum.length] = sum;
16
+ }
17
+ }
18
+
19
+ var chart = new google.visualization.ComboChart(document.getElementById('<%= id %>'));
20
+
21
+ var default_options = {
22
+ allowHtml: true,
23
+ height: 370,
24
+ animation: {duration: 200, startup: true }
25
+ };
26
+
27
+ <%= properties[:function] && properties[:function].html_safe %>
28
+
29
+ chart.draw(data, $.extend(true, default_options, <%= properties[:options] ? "JSON.parse('#{properties[:options].to_json}')".html_safe : '{}' %>));
30
+
31
+ }
32
+
33
+ google.load("visualization", "1", {
34
+ "packages": ["corechart"],
35
+ 'language': 'ru',
36
+ "callback" : function(){
37
+ draw<%= id %>();
38
+ }});
39
+ }());
@@ -63,8 +63,7 @@
63
63
  values_sum[values_sum.length] = {v: '', p: {className: "google-visualization-table-td dimension total"}};
64
64
  }
65
65
  }
66
- values_sum[0].v = '<%= escape_javascript Olap::View.options[:total].html_safe %>';
67
- // data.addRow(values_sum); add row to DataTable()
66
+ values_sum[0].v = '<%= escape_javascript olap_view_i18n_options[:total] %>';
68
67
 
69
68
  var html = "<thead><tr>";
70
69
  for (var i = 0; i < values_sum.length; i++){
@@ -1,5 +1,5 @@
1
1
  module Olap
2
2
  module View
3
- VERSION = "0.0.16"
3
+ VERSION = "0.0.19"
4
4
  end
5
5
  end
data/lib/olap/view.rb CHANGED
@@ -7,28 +7,26 @@ require "olap/view/parse"
7
7
  module Olap
8
8
  module View
9
9
 
10
- @@view_options = {
10
+ @@default_view_options = {
11
11
  no_data: "Not enough data to display",
12
12
  undefined: "-",
13
13
  total: "Total"
14
14
  }
15
15
 
16
- # Configure the default options to connect to XMLA server
17
- # Can be optionally used to setup connection options in one place in application,
16
+ # Configure the default view options
17
+ # Can be optionally used to setup options in one place in application,
18
18
  #
19
19
  # Example:
20
- # >> Olap::View.default_options = {no_data: 'Text for no data', undefined: 'Undefined element name', total: 'Total title'}
20
+ # >> Olap::View.default_view_options = {no_data: 'Text for no data', undefined: 'Undefined element name', total: 'Total title'}
21
21
  # >> Olap::View.request mdx
22
22
  # => #<Olap::View::Parse:0x007ffa2b9f60f0 @response=#<Olap::Xmla::Response:0x007ffa2b9f6118 @response={4 ...
23
23
  #
24
- #
25
- #
26
- def self.default_options= options = {}
27
- @@view_options.merge(options)
24
+ def self.default_view_options= options = {}
25
+ @@default_view_options.merge!(options)
28
26
  end
29
27
 
30
- def self.options
31
- @@view_options
28
+ def self.view_options
29
+ @@default_view_options
32
30
  end
33
31
 
34
32
  def self.request mdx, args = {}
data/olap-view.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["stepanovit"]
9
9
  spec.email = ["stepanov@wondersoft.ru"]
10
10
  spec.summary = %q{OLAP VIEW gem}
11
- spec.description = %q{RubyOnRails gem to visualize by Google Charts MDX queries on OLAP databases using XMLA connection. Can be used with any XMLA-compliant server, like Olaper or Mondrian.}
11
+ spec.description = %q{Ruby On Rails gem to visualize by Google Charts MDX queries on OLAP databases using XMLA connection. Can be used with any XMLA-compliant server, like Olaper or Mondrian.}
12
12
  spec.homepage = "https://github.com/Wondersoft/olap-view"
13
13
  spec.license = "MIT"
14
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: olap-view
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - stepanovit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-12 00:00:00.000000000 Z
11
+ date: 2016-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: RubyOnRails gem to visualize by Google Charts MDX queries on OLAP databases
55
+ description: Ruby On Rails gem to visualize by Google Charts MDX queries on OLAP databases
56
56
  using XMLA connection. Can be used with any XMLA-compliant server, like Olaper or
57
57
  Mondrian.
58
58
  email:
@@ -68,6 +68,7 @@ files:
68
68
  - Rakefile
69
69
  - app/assets/stylesheets/olap-view/olap-view.scss
70
70
  - app/helpers/olap_view_helper.rb
71
+ - app/views/olap-view/_combochart.js.erb
71
72
  - app/views/olap-view/_piechart.js.erb
72
73
  - app/views/olap-view/_table.js.erb
73
74
  - lib/olap/view.rb