Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'RMagick'
- require 'gruff'
- class IskController < ApplicationController
- def index
- @snapshots = Balance.find(:all, :limit => 168, :order => "id DESC").reverse
- if @snapshots.size > 0 then
- g = Gruff::Area.new('800x300')
- g.theme = {
- :colors => %w(#FFAB3F),
- :marker_color => '#CCC',
- :background_colors => '#1D1D1D',
- :font_color => 'white'
- }
- g.hide_legend = true
- g.hide_title = true
- g.y_axis_label = "Balance (ISK)"
- dates = @snapshots.collect{|s|s.date.to_date.to_formatted_s(:short)}
- g.labels = dates.to_hash_values {|v| dates.index(v)}
- g.data("Amount", @snapshots.collect{|s|s.balance})
- send_data(g.to_blob,
- :disposition => 'inline',
- :type => 'image/png',
- :filename => "balance.png")
- end
- end
- end
Add Comment
Please, Sign In to add comment