Olap::View
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.
Installation
Add this line to your application's Gemfile:
gem 'olap-view'And then execute:
$ bundle
Or install it yourself as:
$ gem install olap-view
Usage
Include required files in the application
Include Olap::View helper to application_helper.rb
include OlapViewHelperImport olap-view Sass file (for example, application.scss) to get all of olap-view style:
@import "olap-view/olap-view";Add Google Charts initialize into <head> tag in your laoyut (for examlpe, application.html.erb):
<head>
...
<%= olap_view_charts_init %>
</head>Configuration in Rails
Querying MDX
This gem use olap-xmla ( https://github.com/Wondersoft/olap-xmla ) and does not parse MDX, just passes it to XMLA server.
However, it can do substituting parameters in the query:
MDX_QUERY = 'SET [~ROWS_Date] AS {[DateTime].[Date].[Date].[%DATE%]}'
Olap::View.request MDX_QUERY, {'%DATE%' => '20150530'}Render Google Chart by MDX
At the moment only available :table, :piechart, :barchart and partially :combochart charts.
Insert helper menthod to erb file:
<%= olap_view_chart_by_mdx :table,
'SET [~ROWS_Date] AS {[DateTime].[Date].[Date].[%DATE%]}',
{'%DATE%' => '20150530'} %>Use one MDX to many Charts
<% xmla = Olap::View.request 'SET [~ROWS_Date] AS {[DateTime].[Date].[Date].[%DATE%]}',
{'%DATE%' => '20150530'} %>
<div>
<h1>PieChart</h1>
<%= olap_view_chart_by_xmla :piechart, xmla %>
</div>
<div>
<h1>Table</h1>
<%= olap_view_chart_by_xmla :table, xmla %>
</div>Available parameters
In olap_view_chart_by_mdx and olap_view_chart_by_xmla following properties are available:
<%= olap_view_chart_by_xmla :table, xmla, properties %> total: true show total string in table chart
rowspan: true unites the cells with the same data from the dimenssions in table chart
function: "text on JS" execute ani js code into chart template
dimension: "Source Name" aggregate xmla data by dimesion
merge_dimensions: true merge dimensions to one table
measures: "[Measures].[Click]" show only selected measure from xmla data and sort by order
options: {} Google Charts draw options
Contributing
- Fork it ( https://github.com/Wondersoft/olap-view/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request