MyException - 我的异常网
当前位置:我的异常网» J2EE » 用jsp怎的生成柱状图,饼状图,折线图

用jsp怎的生成柱状图,饼状图,折线图(3)

www.MyException.Cn  网友分享于:2013-12-22  浏览:982次

"历史信息{1} 16:00,{2})", new SimpleDateFormat("MM-dd"),
numFormater);
r.setToolTipGenerator(tipGenerator);
// 设置X轴(日期轴)
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("MM-dd"));
ChartRenderingInfo info = new ChartRenderingInfo(
new StandardEntityCollection());
try {
fileName = ServletUtilities.saveChartAsPNG(chart, 500, 300, info,
session);// 生成图片
// Write the image map to the PrintWriter
ChartUtilities.writeImageMap(pw, fileName, info, false);
} catch (IOException e) {
e.printStackTrace();
}
pw.flush();
return fileName;// 返回生成图片的文件名
}

private XYDataset createDateSet(ArrayList al) {
TimeSeriesCollection dataset = new TimeSeriesCollection();// 时间曲线数据集合
TimeSeries s1 = new TimeSeries("销售曲线", Day.class);// 创建时间数据源,每一个//TimeSeries在图上是一条曲线
// s1.add(new Day(day,month,year),value),添加数据点信息
HashMap hm = null;
for (Iterator it = al.iterator(); it.hasNext();) {
hm = (HashMap) it.next();
String day=hm.get("day_nr").toString();
if(day.indexOf("总计")>-1){
}else{
int day_nr=Integer.parseInt(day);
int zmonth=Integer.parseInt(hm.get("zmonth").toString());
int zyear=Integer.parseInt(hm.get("zyear").toString());
int value=Integer.parseInt(hm.get("netwr").toString());
s1.add(new Day(day_nr, zmonth, zyear),value );
}
}
// s1.add(new Day(1, 2, 2006), 123.51);
// s1.add(new Day(2, 2, 2006), 122.1);
// s1.add(new Day(3, 2, 2006), 120.86);
// s1.add(new Day(4, 2, 2006), 122.50);
// s1.add(new Day(5, 2, 2006), 123.12);
// s1.add(new Day(6, 2, 2006), 123.9);
// s1.add(new Day(7, 2, 2006), 124.47);
// s1.add(new Day(8, 2, 2006), 124.08);
// s1.add(new Day(9, 2, 2006), 123.55);
// s1.add(new Day(10, 2, 2006), 122.53);
dataset.addSeries(s1);
dataset.setDomainIsPointsInTime(true);
return dataset;
}
}

------解决方案--------------------
JFreechat等可以,其实 jfreechat也是用的awt和swing包下面的绘制函数,楼主有兴趣可以看看 jfreechat的源码
------解决方案--------------------
我这里也写了一个
http://www.blogjava.net/landor2004/archive/2009/04/08/264386.html
------解决方案--------------------
直接jfreechart 的好用,例子也不少
------解决方案--------------------
用jfreechart插件,开源的,这个东西其实网上很多了,所以起来还是挺简单的,插件是一个好东西啊!
------解决方案--------------------
jfreechat自带的demo里面都有,用decompile 反编译一下就可以看到源代码了。

我这里有个报表专区,有兴趣去看看
http://www.java2000.net/f30
------解决方案--------------------
何必那么麻烦FusionCharts flash 报表组件完全配置 jsp/servelt生成xml文件
<html>
<head>
<title>FusionWidgets Chart Gallery - Gantt Chart</title>
<script language="JavaScript" src="FusionCharts8.js"></script>
<link rel='stylesheet' href='Styles8.css' />
</head>
<body bgcolor="#ffffff">
<table width='700' align='center' cellpadding='2' cellspacing='0'>
<tr>
<td align="center" class="textBold">Gantt Chart</td>
</tr>
<tr>
<td align="center">
<div id="chartdiv" align="center" class="text">
<p>&nbsp;</p>
<p>FusionWidgets needs Adobe Flash Player to run. If you're unable to see the chart here, it means that your browser does not seem to have the Flash Player Installed. You can downloaded it <a href="http://www.adobe.com/products/flashplayer/" target="_blank"><u>here</u></a> for free.</p>

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有