用JFreeChart画统计分析曲线图报错分析转自我的新浪博客

来源:互联网 发布:成功瘦身知乎 编辑:程序博客网 时间:2024/04/28 10:51

 

exception

java.lang.IllegalArgumentException: The 'quality' must be in the range 0.0f to 1.0f
        org.jfree.chart.encoders.SunJPEGEncoderAdapter.setQuality(SunJPEGEncoderAdapter.java:102)
        org.jfree.chart.encoders.ImageEncoderFactory.newInstance(ImageEncoderFactory.java:131)
        org.jfree.chart.encoders.EncoderUtil.writeBufferedImage(EncoderUtil.java:152)
        org.jfree.chart.ChartUtilities.writeChartAsJPEG(ChartUtilities.java:474)
        com.company.chart.ChartGender.createTimeGraphByServlet(ChartGender.java:57)
        com.servlet.Statistic.doGet(Statistic.java:48)
        com.servlet.Statistic.service(Statistic.java:19)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

 

解决办法:

 ChartUtilities.writeChartAsJPEG(res.getOutputStream(),100,chart,graphWidth,graphHigh,null);
限制quality必须小于等于1,所以修改一下,把100改成 0.1f就可以显示了。