Created
July 23, 2008 18:29
-
-
Save mlins/1841 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GraphsController < ApplicationController | |
def top | |
@graph = open_flash_chart_object(1200, 500, '/graphs/bar_chart') | |
end | |
def bar_chart | |
top = Customer.find(:all, :select => 'sum(CMS.ORD_TOTAL) AS total, CUST.COMPANY', :group => 'CMS.CUSTNUM, CUST.COMPANY', :joins => [:orders], :limit => 10, :order => 'total DESC') | |
bar = BarOutline.new(50, '#9933CC', '#8010A0') | |
bar.key('Sales', 10) | |
labels = Array.new | |
top.each do |t| | |
bar.data << (t.total) | |
labels << t.COMPANY.gsub('&', ' and ').chomp | |
end | |
g = Graph.new | |
g.title("Top Dealers", "{font-size:20px}") | |
g.data_sets << bar | |
g.set_x_labels(labels) | |
g.set_x_label_style(8, '#9933CC', 0,1) | |
g.set_x_axis_steps(1) | |
g.set_y_max(1500000) | |
g.set_y_label_steps(10) | |
g.set_y_legend("Dollars", 12, "#736AFF") | |
render :text => g.render | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment