下载此文档

fusion图标使用手册.doc


文档分类:办公文档 | 页数:约13页 举报非法文档有奖
1/13
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/13 下载此文档
文档列表 文档介绍
ROR中图标FusionCharts的用法
作者 杨海军 2011年7月23日
一、安装FusionCharts
将FusionCharts文件夹(Download Package > Code > FusionCharts)拷贝到TimeTrackerApplication的public目录下。
将Download Package > Code > 。
将Download Package > Code > RoR > 。
至此,FusionCharts的安装就已经完成了。

require 'fusioncharts_helper'
include FusionChartsHelper
注意:在某些fusioncharts_helper文件中没有定义get_FC_color方法。如果没有就要自己定义。
二、指定一个到图表的链接
列表1
<td><%= link_to 'Time Chart', {:action=>'view_timesheet_chart',:id=>} %></td>
图1展示的是员工名单页面。在设置完数据库之后,开发者使用Ruby脚手架框架,可以很容易地实现这个功能。我们可以访问“http://yourserver:port/employees”来查看此页面。图1是屏幕部分截图。
图1
点击“Time Chart”链接将会调用employees控制器的view_timesheet_chart动作。列表2列出了它的代码。这个动作的作用是展示选中员工的工时表。它会向Employee模型查询指定员工在“2008-12-01”至“2008-12-07”这段时间的工时表,得到结果之后,渲染“”文件。为了简单起见,在本文中,这个时间范围是固定的。当然,现实世界中,这个时间范围应该是可由员工指定。
三、编写相关方法
编写控制器
列表2
EmployeesController
def view_timesheet_chart
start_date= "2008-12-01"
end_date="2008-12-07"
***@employee_id = params[:id]
employee_details_with_timesheets = (***@employee_id,start_date,end_date)
if(!?)
***@employee_details_with_timesheets =employee_details_with_timesheets[0]
else
***@employee_details_with_timesheets =nil;
end
headers["content-type"]="text/html"
end
这个动作以员工id为参数,它向Employee模型查询指定员工在特定时间范围内的工时表。我们将在Employee模型中加入如列表3所示的函数:
编写模型
列表3

def
(id,start_date, end_date)
conditions=" =? and log_date between ? and ?"
employee_details_with_timesheets=(:all, :include=>'timesheets',:conditions=> [conditions,id,start_date,end_date], :order=>'log_date asc')
return employee_details_with_timesheets
e

fusion图标使用手册 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数13
  • 收藏数0 收藏
  • 顶次数0
  • 上传人文库旗舰店
  • 文件大小314 KB
  • 时间2020-11-26