2 qq863017854 QQ863017854 于 2016.05.04 13:56 提问

jsp 中用jfreechart 运行出错 求大神解答 或求折线例子

代码如下

     DefaultCategoryDataset linedataset = new DefaultCategoryDataset();
//  各曲线名称
String series1 = "订单量与时间";
String series2 = "发生金额与时间";
    //  DefaultCategoryDataset dataset = new DefaultCategoryDataset();
     while(rs.next()){
  //   dataset.addValue(rs.getInt(2),rs.getDate(1)," ");
  linedataset.addValue(rs.getInt(2), series1, rs.getDate(1));
   linedataset.addValue(rs.getInt(3), series2, rs.getDate(1));
     num=num+rs.getInt(2);
     money=money+rs.getFloat(3);
    %>
     <tr>
    <td width=45% align="center"><%out.print(rs.getDate(1));%></td>
    <td width=30% align="center"><%out.print(rs.getInt(2));%></td>
    <td width=30% align="center"><%out.print(rs.getFloat(3));%></td>
        </tr>   
   <% 
   } 
   //定义图表对象
JFreeChart chart = ChartFactory.createLineChart("","","",linedataset,PlotOrientation.VERTICAL,false,false,false);
CategoryPlot plot = chart.getCategoryPlot();
/*字体乱码异常解决代码*/
chart.getTitle().setFont(new Font("宋体", Font.BOLD, 15));
   chart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
   CategoryAxis domainAxis = plot.getDomainAxis();   
   /*------设置X轴坐标上的文字-----------*/ 
   domainAxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 11));   
   /*------设置X轴的标题文字------------*/ 
   domainAxis.setLabelFont(new Font("宋体", Font.PLAIN, 12));   
   NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();   
   /*------设置Y轴坐标上的文字-----------*/ 
   numberaxis.setTickLabelFont(new Font("黑体", Font.PLAIN, 12));   

   /*------设置Y轴的标题文字------------*/ 
   numberaxis.setLabelFont(new Font("黑体", Font.PLAIN, 12));

/*字体乱码异常解决代码*/  

// 各种属性设置...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
rangeAxis.setAutoRangeIncludesZero(true);
rangeAxis.setUpperMargin(0.20);
rangeAxis.setLabelAngle(Math.PI / 2.0); 
//
String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, null, session);
String graphURL = request.getContextPath() + "/DisplayChart?filename=" + filename;
 HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 113 in the jsp file: /dingdanjieguo.jsp
The method createLineChart(String, String, String, CategoryDataset, PlotOrientation, boolean, boolean, boolean) in the type ChartFactory is not applicable for the arguments (String, String, String, DefaultCategoryDataset, PlotOrientation, boolean, boolean, boolean)
110:    <% 
111:    } 
112:    //瀹氫箟鍥捐〃瀵硅薄
113: JFreeChart chart = ChartFactory.createLineChart("","","",linedataset,PlotOrientation.VERTICAL,false,false,false);
114: CategoryPlot plot = chart.getCategoryPlot();
115: /*瀛椾綋涔辩爜寮傚父瑙e喅浠g爜*/
116: chart.getTitle().setFont(new Font("瀹嬩綋", Font.BOLD, 15));
An error occurred at line: 117 in the jsp file: /dingdanjieguo.jsp
The method setItemFont(Font) is undefined for the type Legend
114: CategoryPlot plot = chart.getCategoryPlot();
115: /*瀛椾綋涔辩爜寮傚父瑙e喅浠g爜*/
116: chart.getTitle().setFont(new Font("瀹嬩綋", Font.BOLD, 15));
117:    chart.getLegend().setItemFont(new Font("榛戜綋", Font.BOLD, 15));
118:    CategoryAxis domainAxis = plot.getDomainAxis();   
119:    /*------璁剧疆X杞村潗鏍囦笂鐨勬枃瀛�----------*/ 
120:    domainAxis.setTickLabelFont(new Font("榛戜綋", Font.PLAIN, 11));   


Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

1个回答

jia20003
jia20003   2016.05.04 15:10
已采纳

是你的Jasper Report的编译不通过,检查一个report的内容与格式,还有数据源等。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
jfreeChart 柱状图和折线图结合
import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.geom.Ellipse2D; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.
JFreeChart画图+jsp页面显示
使用JFreeChart java后台绘制折线图 并在Jsp页面中显示
易语言钓鱼源码
求大神买走 求大神买走 易语言钓鱼源码
【JFreeChart】JFreeChart—输出时序图
时序图(Time Series Chart)是按照时间轴显示的图形。通常可以按照年、月、日等时间周来显示。 实现代码: TimeChartServlet.java package com.lmb.jfreechart; import java.awt.BasicStroke; import java.io.IOException; import javax.servlet.Ser...
web项目中运用java jfreechart生成各种样式报表的教程demo代码下载
原文:web项目中运用java jfreechart生成各种样式报表的教程demo代码下载 源代码下载地址:http://www.zuidaima.com/share/1830391204793344.htm 一、导入如下jar包 二、启动项目运行效果如下图:
【JSP中使用Jfreechart绘制折线、饼图和柱状图】
<% //实现饼状图 DefaultPieDataset data = new DefaultPieDataset(); data.setValue("六月", 500); data.setValue("七月", 580); data.setValue("八月", 828); PiePlot plot = new PiePlot(data); JFreeChart chart
JFreeChart设置曲线颜色方法
JFreeChart _chart = ChartFactory.createTimeSeriesChart(......);   XYPlot _xyplot=(XYPlot) _chart.getPlot();   XYLineAndShapeRenderer xylinerenderer=(XYLineAndShapeRenderer)_xyplot.getRenderer();  
jfreechart调整线条颜色
使用JFreeChart时常常会觉得系统自定义的颜色不符合需求,这时就需要自定义颜色了。 1.折线图,堆积柱状图,柱状图。 JFreeChart chart = ........; CategoryPlot plot = chart.getCategoryPlot(); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.
jfreechart柱状图+折线图
public static void main(String[] args) { //创建主题样式 ,以下代码用于解决中文乱码问题 StandardChartTheme standardChartTheme=new StandardChartTheme("CN"); //设置标题字体 standardChartTheme.setExtraLargeFont
c++模板计算折线长度
//point.h struct st { double x, y; }; template class point {     private:         T *data; int MaxSize; public: point(int Size=10); void Display(); void Length();         void Set(