Skip to content

Commit

Permalink
adding column and pie charts, TODO:update readme
Browse files Browse the repository at this point in the history
david-cys committed Oct 28, 2013
1 parent d11e499 commit 6f517ac
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/views/rails_admin/main/_chart.html.erb
Original file line number Diff line number Diff line change
@@ -4,7 +4,10 @@
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'growth_rate'
<% if @abstract_model.model.chart_type == "column" %>
type: 'column',
<% end %>
renderTo: 'growth_rate'
},
title: {
text: '<%= @abstract_model.to_s.pluralize %>'
@@ -20,6 +23,7 @@
},
<% if @abstract_model.model.xaxis == "datetime" %>
type: 'datetime'
<% elsif @abstract_model.model.chart_type == "pie" %>
<% else %>
categories: <%=raw @abstract_model.model.xaxis.to_json %>
<% end %>
@@ -58,7 +62,15 @@
}
}
},
series: <%=raw @abstract_model.model.graph_data(100.days.ago).to_json %>,
<% if @abstract_model.model.chart_type == "pie" %>
series: [{
type: 'pie',
name: 'Number of <%= @abstract_model.to_s.pluralize %>',
data: <%=raw @abstract_model.model.graph_data(100.days.ago).to_json %>
}],
<% else %>
series: <%=raw @abstract_model.model.graph_data(100.days.ago).to_json %>,
<% end %>
navigation: {
menuItemStyle: {
fontSize: '10px'
4 changes: 4 additions & 0 deletions lib/rails_admin_charts.rb
Original file line number Diff line number Diff line change
@@ -36,6 +36,10 @@ def xaxis
def label_rotation
"0"
end

def chart_type
""
end
end
end

0 comments on commit 6f517ac

Please sign in to comment.