Forked from adamcooke/small_revenue_with_signups.rb
Created
November 8, 2009 20:16
-
-
Save jackregnart/229464 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
%h2 My Cool Chart | |
= charty :small_revenue_with_signups, {:month => Date.today.month, :year => Date.today.year} |
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
chart :small_revenue_with_signups do |c| | |
c.type = :line | |
## Defines the font size & actual font to use. The size & background colours are used in the | |
## the XML settings and in the HTML which is generated for this chart (unless overriden in the | |
## render). | |
c.font = 'Arial' | |
c.font_size = 11 | |
c.width = 400 | |
c.height = 180 | |
c.background_color = "#efefef" | |
## Various graph design settings & variables | |
c.plot_area = {:margins => {:left => 0, :top => 20, :right => 0, :bottom => 35}} | |
c.axes = {:x => {:color => "#cccccc", :width => 0}, :y_left => {:color => '#cccccc', :width => 2}} | |
c.grid = {:x => {:alpha => 0, :approx_count => 9}, :y_left => {:alpha => 0}, :y_right => {:alpha => 0}} | |
c.indicator = {:color => '#999999', :line_alpha => 50, :selection_color => '#0D8ECF', :selection_alpha => 20, :x_balloon_text_color => '#FFFFFF'} | |
c.vertical_lines = {:width => 70} | |
c.legend = { :enabled => false } | |
## Add a graph for showing the total number of signups on a specific day. | |
c.add_graph "Signups", :color => "#cccccc", :color_hover => '#999999', :selected => false, :vertical_lines => true, :line_alpha => 0 | |
## Add a graph for showing the total revenue collected on a specific day. | |
c.add_graph "Revenue", :color => "#0D8ECF", :color_hover => '#0D8ECF',:selected => true, :line_width => 2, :axis => 'right' | |
## The title of the graph. | |
c.add_label "Signups & Revenue", :x => 0, :y => 9, :align => 'right', :text_size => 10, :text_color => '#999999' do |v| | |
"Signups & Revenue (#{Time.utc(v[:year], v[:month]).strftime('%B %Y')})" | |
end | |
## Add axis points for each day of the month. | |
c.add_axis_points('xaxis') { |v| (1..Time.days_in_month(v[:month], v[:year])).to_a } | |
## Add the number of account signups for each day of the month. | |
c.add_data(1) { |v| Account.period_count(:daily, :signups_on, :month => v[:month], :year => v[:year]) } | |
## Add the total amount for invoices raised on each day of the month. | |
c.add_data(2) { |v| Finance::Invoice.period_count(:daily, :raised_on, :month => v[:month], :year => v[:year], :sum => :total) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment