作者inquisition (异教徒)
看板java
标题[问题] JFREECHART的设置URL问题(已解决)
时间Mon Jul 26 21:23:38 2010
各位先进大家好,我最近在撰写JFREECHART遇到了一些困扰。
希望能请大家指点迷津。
目前在练习PIE_CHART跟BAR_CHART都写出来了,但是在制作
GANTT_CHART时想使用滑鼠点选进度条能够换页,在这个部分遇到
了困难。
使用JSP、TOMCAT5
GANTT_CHART程式码如下:
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META NAME="Author" CONTENT="Alpha">
<TITLE>Gantt练习</TITLE>
</HEAD>
<BODY>
<%!
//时间处理
public Date getDate(int year, int month, int day)
{
Calendar calendar = Calendar.getInstance();
calendar.set(year, month-1, day);
Date date = calendar.getTime();
return date;
}
%>
<%
//开始设置DATA
TaskSeries s1 = new TaskSeries("预期进度");
TaskSeries s2 = new TaskSeries("实际进度");
s1.add(new Task("第一项项目",new
SimpleTimePeriod(getDate(2011,6,5),getDate(2011,7,8))));
s2.add(new Task("第一项项目",new
SimpleTimePeriod(getDate(2011,6,5),getDate(2011,7,8))));
s1.add(new Task("第二项项目",new SimpleTimePeriod(getDate(2011,6,6),
getDate(2011,7,8))));
s2.add(new Task("第二项项目",new SimpleTimePeriod(getDate(2011,6,6),
getDate(2011,7,8))));
TaskSeriesCollection collection = new TaskSeriesCollection();
collection.add(s1);
collection.add(s2);
String chartTitle = "甘特图标题";
JFreeChart chart = ChartFactory.createGanttChart
(
chartTitle, // 图表标题
"工作项目", // Y 座标标题
"时间", // X 座标标题
collection, // 定义绘制数据
true, // 定义图表是否包含图例
true, // 定义图表是否包含提示
true // 定义图表是否包含URL
);
//设置DATA完毕
int width=500, height=300;
chart.setAntiAlias(false);GradientPaint bgGP = new GradientPaint(0, 0,
Color.WHITE,width, height, Color.CYAN, false);
chart.setBackgroundPaint(bgGP);
CategoryPlot plot = chart.getCategoryPlot();
//plot.setURLGenerator(new StandardCategoryURLGenerator("123.jsp"));
DateAxis rangeAxis = (DateAxis)plot.getRangeAxis(); //取得横轴标题
DateFormat df = new SimpleDateFormat("yyyy-MM");
DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 60, df);
rangeAxis.setTickUnit(unit) ;
ChartRenderingInfo info = new ChartRenderingInfo(new
StandardEntityCollection());
PrintWriter w = new PrintWriter(out);//输出MAP信息
String filename =
ServletUtilities.saveChartAsJPEG(chart,width,height,info,session);
ChartUtilities.writeImageMap(w,"map0",info,false);
String graphURL = request.getContextPath() +
"/servlet/DisplayChart?filename=" + filename;
%>
<P ALIGN="CENTER">
<img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#map0">
</P>
</BODY>
</HTML>
目前遇到的问题是无法将滑鼠点选进度条後转向网址到123.jsp
目前都会跑到预设的index.html,不知道有没有人能指点迷津
非常感谢(鞠躬)
--
◣ ╭—╮
◢ ◣◢ ◣
▲ │就│
▂▃▄▅ ▍▄▃▂
▼▼▼ │这│
你看JACKEY的鼻子很大对吧? Y  ̄﹁  ̄□
□ ̄ Y╡
◤▼▼ ▼▏ │样│ ∠
◣ ︶ _╱
η │
—┬— ▏∠ 。│
▃▅▅▃ ▃▆▆ ╟╯
∕ ▏ ╰—╯
ψkana0102 目▄▄目 ◢◤ ◥▎【
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.64.178.177
1F:→ inquisition:已自己解决,我再发一篇解决的上来,感谢大家。 07/26 23:03
※ 编辑: inquisition 来自: 203.64.178.177 (07/26 23:04)