我正在寻找一些示例,如何从数据库中提取数据,并在Gruff中创建的图表中使用这些数据,但是失败了。因此,我想在这个图表中展示数据库中的两件事:
Course.application.size --它将计算本课程的所有应用程序
Student.size -它会告诉我有多少学生在学校
那么,我应该如何将这些数据放入下面的图表中呢?
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")发布于 2015-09-28 17:50:57
将计数存储在变量中,并将其用作图表中的数据,如下所示:
@course = Course.application.size
@学生会= 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")https://stackoverflow.com/questions/28561324
复制相似问题