1

I was looking for some example how to extract data from database and use it in diagram created in Gruff, but failed. So I want to show in this diagram two things from data base:

Course.application.size - which would count all applications to this course

Student.size - which would show me how many students are in school

So, how should I put this data into following diagram?

g = Gruff::Pie.new

g.title = "Applications"
g.data("Applied", ???)
g.data("Students", ???)

send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "gruff.png")
Ricce
  • 69
  • 6

1 Answers1

0

Store the count in variable and use it as data in graph as shown below:

@course = Course.application.size

@student = Student.size

g = Gruff::Pie.new
g.title = "Applications"
g.data : "Applied", @course
g.data : "Students", @student
send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "gruff.png")
Ritesh Kumar
  • 2,183
  • 2
  • 20
  • 32