[url=http://www.jfree.org/eastwood/]eastwood[/url]是[url=http://code.google.com/intl/zh-CN/apis/chart/]google图表api[/url]的开源的独立的实现,基于jfreechart。eastwood使得调用jfreechart不用再深入到什么plot、Axis、Renderer的细节中去,用更简单优雅的方式画图。
默认配置的eastwood会有中文乱码问题,解决方法如下:
将jfreechart升级到1.0.10,eastwood升级到1.1.0,然后在web.xml里面配置
<servlet>
<servlet-name>chart</servlet-name>
<servlet-class>org.jfree.eastwood.ChartServlet</servlet-class>
<init-param>
<param-name>fontResource</param-name>
<param-value>/WEB-INF/classes/wqy-zenhei.ttc</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>chart</servlet-name>
<url-pattern>/chart</url-pattern>
</servlet-mapping>
这里的wqy-zenhei.ttc可以是任何一种支持中文的字体文件,我用文泉驿。
如果是用tomcat,要在它的server.xml里面处理get中文乱码问题。
对于firefox,这样配置已经没有中文乱码问题了,但是对于ie,对中文要这样编码
URLEncoder.encode("费用","utf-8")
ps,eastwood已1年多没有发布新版本,有人就去问项目是否停止了,jfreechart开发者的回答让人心酸。一个著名的开源项目开发者还要为生计奔波。
[quote]Postby david.gilbert » Tue Jun 23, 2009 10:42 am
It isn't discontinued, just very quiet. There's only been limited interest in the project, and for financial reasons I have had to focus my energies on tasks that generate some income rather than just creating more free stuff. I committed some stuff to Subversion last month, and would like to make a new release of Eastwood some time...but I have another project on right now.[/quote]