Guest User

Untitled

a guest
Mar 13th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. require 'rubygems'
  2. require 'RMagick'
  3. require 'gruff'
  4. class IskController < ApplicationController
  5. def index
  6. @snapshots = Balance.find(:all, :limit => 168, :order => "id DESC").reverse
  7. if @snapshots.size > 0 then
  8. g = Gruff::Area.new('800x300')
  9. g.theme = {
  10. :colors => %w(#FFAB3F),
  11. :marker_color => '#CCC',
  12. :background_colors => '#1D1D1D',
  13. :font_color => 'white'
  14. }
  15. g.hide_legend = true
  16. g.hide_title = true
  17. g.y_axis_label = "Balance (ISK)"
  18. dates = @snapshots.collect{|s|s.date.to_date.to_formatted_s(:short)}
  19. g.labels = dates.to_hash_values {|v| dates.index(v)}
  20. g.data("Amount", @snapshots.collect{|s|s.balance})
  21. send_data(g.to_blob,
  22. :disposition => 'inline',
  23. :type => 'image/png',
  24. :filename => "balance.png")
  25. end
  26. end
  27.  
  28. end
Add Comment
Please, Sign In to add comment