永
永不言败
Unregistered / Unconfirmed
GUEST, unregistred user!
尝试用jfreechart做分析统计,刚出手就遇到如下问题,请大虾指明改如何修改?
能发一个调试通过的jfreechart的例子给我,会加分,谢谢 邮箱:yinhongkuan@163.com
************jsp部分出错,代码如下:**********
<%
XYSeriesDemo myDemo=new XYSeriesDemo();
String filename = myDemo.getXYSeries("","XYSeries 演示",session, new PrintWriter(out));
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
%>
***********错误提示为:**************
org.apache.jasper.JasperException: org/jfree/data/XYDataset
***********javabean 部分编译通过,如下:**********
package test;
import javax.servlet.*;
import javax.servlet.http.*;
import java.awt.*;
import java.text.*;
import java.io.*;
import java.net.*;
import org.jfree.data.*;
import org.jfree.chart.*;
import org.jfree.chart.renderer.*;
import org.jfree.chart.axis.*;
import org.jfree.chart.servlet.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.entity.*;
import org.jfree.chart.urls.*;
import org.jfree.chart.ui.*;
public class XYSeriesDemo{
public XYSeriesDemo(){
}
public static String getXYSeries(String infoStr, String
titles,HttpSession session,
PrintWriter pw) throws Exception{
String filename = null;
/* 生成chart物件*/
XYSeries xyseries = new XYSeries("Random Data",true);
xyseries.add(1.0D, 500.19999999999999D);
xyseries.add(5D, 694.10000000000002D);
xyseries.add(4D, 100D);
xyseries.add(12.5D, 734.39999999999998D);
xyseries.add(17.300000000000001D, 453.19999999999999D);
xyseries.add(21.199999999999999D, 500.19999999999999D);
xyseries.add(21.899999999999999D, null);
xyseries.add(25.600000000000001D, 734.39999999999998D);
xyseries.add(30D, 453.19999999999999D);
XYSeriesCollection xyseriescollection = new (xyseries);
org.jfree.chart.JFreeChart myChart =ChartFactory.createXYLineChart("XY Series Demo", "X", "Y", xyseriescollection, PlotOrientation.VERTICAL, true, true, false);
Font font=new Font("黑体",Font.CENTER_BASELINE,20);
TextTitle tt=new TextTitle(titles);
tt.setFont(font);
myChart.setBackgroundPaint(java.awt.Color.white);//统计图片的底色
myChart.setTitle(tt);
/**/
// 把生成的文件写入到临时的目录中
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
filename = ServletUtilities.saveChartAsPNG(myChart, 500, 300, info, session);
// 把image map 写入到 PrintWriter
ChartUtilities.writeImageMap(pw, filename, info);
pw.flush();
return filename;
}
}
能发一个调试通过的jfreechart的例子给我,会加分,谢谢 邮箱:yinhongkuan@163.com
************jsp部分出错,代码如下:**********
<%
XYSeriesDemo myDemo=new XYSeriesDemo();
String filename = myDemo.getXYSeries("","XYSeries 演示",session, new PrintWriter(out));
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
%>
***********错误提示为:**************
org.apache.jasper.JasperException: org/jfree/data/XYDataset
***********javabean 部分编译通过,如下:**********
package test;
import javax.servlet.*;
import javax.servlet.http.*;
import java.awt.*;
import java.text.*;
import java.io.*;
import java.net.*;
import org.jfree.data.*;
import org.jfree.chart.*;
import org.jfree.chart.renderer.*;
import org.jfree.chart.axis.*;
import org.jfree.chart.servlet.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.entity.*;
import org.jfree.chart.urls.*;
import org.jfree.chart.ui.*;
public class XYSeriesDemo{
public XYSeriesDemo(){
}
public static String getXYSeries(String infoStr, String
titles,HttpSession session,
PrintWriter pw) throws Exception{
String filename = null;
/* 生成chart物件*/
XYSeries xyseries = new XYSeries("Random Data",true);
xyseries.add(1.0D, 500.19999999999999D);
xyseries.add(5D, 694.10000000000002D);
xyseries.add(4D, 100D);
xyseries.add(12.5D, 734.39999999999998D);
xyseries.add(17.300000000000001D, 453.19999999999999D);
xyseries.add(21.199999999999999D, 500.19999999999999D);
xyseries.add(21.899999999999999D, null);
xyseries.add(25.600000000000001D, 734.39999999999998D);
xyseries.add(30D, 453.19999999999999D);
XYSeriesCollection xyseriescollection = new (xyseries);
org.jfree.chart.JFreeChart myChart =ChartFactory.createXYLineChart("XY Series Demo", "X", "Y", xyseriescollection, PlotOrientation.VERTICAL, true, true, false);
Font font=new Font("黑体",Font.CENTER_BASELINE,20);
TextTitle tt=new TextTitle(titles);
tt.setFont(font);
myChart.setBackgroundPaint(java.awt.Color.white);//统计图片的底色
myChart.setTitle(tt);
/**/
// 把生成的文件写入到临时的目录中
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
filename = ServletUtilities.saveChartAsPNG(myChart, 500, 300, info, session);
// 把image map 写入到 PrintWriter
ChartUtilities.writeImageMap(pw, filename, info);
pw.flush();
return filename;
}
}