简单的报表案例(为什么数字显示不出来)?

最近看了一下报表方面的东西想做一个关于彩票的报表分析.
以下是特殊号码的一个所占比例的一分析图表.
可是问题是在报表里面却看不到该特殊号码的记录条数为多少.这是为什么?
代码比较混乱,上面一个是拄形的,下面的是pie形的,我看教程中的代码也是用piedata.setvalue("苹果",103);
这样设置但是他们出来的结果图片里面是把103这个数字显示在图表上的.可我的确是显示不了这是为什么?

图如下:
[img]http://img3.pcpop.com/upimg3/2009/4/21/0007142088.jpg[/img]

<%@ page contentType="text/html;charset=GBK"%>
<%@ page import="org.jfree.data.category.DefaultCategoryDataset"%>

<%@ page import="org.jfree.chart.ChartFactory" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="org.jfree.util.TableOrder" %>
<%@ page import="org.jfree.chart.JFreeChart"%>
<%@ page import="org.jfree.chart.plot.PlotOrientation"%>
<%@ page import="org.jfree.chart.ChartRenderingInfo"%>
<%@ page import="org.jfree.chart.servlet.ServletUtilities"%>
<%@ page import="org.jfree.chart.entity.StandardEntityCollection"%>


<%

if(request.getAttribute("spnumreport")!=null){
HashMap hs = (HashMap)request.getAttribute("spnumreport");


try{
if(hs!=null){
DefaultCategoryDataset data = new DefaultCategoryDataset();
DefaultPieDataset datapie = new DefaultPieDataset();

String zero="1",one="1",two="1",three="1",four="1",five="1",six="1",seven="1",eight="1",nine="1";
zero=hs.get("0").toString();
one=hs.get("1").toString();
two=hs.get("2").toString();
three=hs.get("3").toString();
four=hs.get("4").toString();
five=hs.get("5").toString();
six=hs.get("6").toString();
seven=hs.get("7").toString();
eight=hs.get("8").toString();
nine=hs.get("9").toString();
data.setValue(Integer.parseInt(zero),"0","chenzhiqian_spnum");
data.setValue(Integer.parseInt(one),"1","chenzhiqian_spnum");
data.setValue(Integer.parseInt(two),"2","chenzhiqian_spnum");
data.setValue(Integer.parseInt(three),"3","chenzhiqian_spnum");
data.setValue(Integer.parseInt(four),"4","chenzhiqian_spnum");
data.setValue(Integer.parseInt(five),"5","chenzhiqian_spnum");
data.setValue(Integer.parseInt(six),"6","chenzhiqian_spnum");
data.setValue(Integer.parseInt(seven),"7","chenzhiqian_spnum");
data.setValue(Integer.parseInt(eight),"8","chenzhiqian_spnum");
data.setValue(Integer.parseInt(nine),"9","chenzhiqian_spnum");


datapie.setValue("0",Integer.parseInt(zero));
datapie.setValue("1",Integer.parseInt(one));
datapie.setValue("2",Integer.parseInt(two));
datapie.setValue("3",Integer.parseInt(three));
datapie.setValue("4",Integer.parseInt(four));
datapie.setValue("5",Integer.parseInt(five));
datapie.setValue("6",Integer.parseInt(six));
datapie.setValue("7",Integer.parseInt(seven));
datapie.setValue("8",Integer.parseInt(eight));
datapie.setValue("9",Integer.parseInt(nine));


JFreeChart chart = ChartFactory.createBarChart("test","spnum","value",data,PlotOrientation.VERTICAL,true,true,false);

JFreeChart chartpie =ChartFactory.createPieChart("pietest",datapie, true, true, false);

chartpie.setTitle("chartpie test");


chart.setBackgroundPaint(java.awt.Color.white);//可选,设置图片背景色
//TextTitle _title = new TextTitle(title);
chart.setTitle("desin report");//可选,设置图片标题

ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
//500是图片长度,300是图片高度

String filenamepie = ServletUtilities.saveChartAsPNG(chartpie, 500, 300, info, session);
String graphURLpie = request.getContextPath() + "/DisplayChart?filename=" + filenamepie;

String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info, session);
String graphURL = request.getContextPath() + "/DisplayChart?filename=" + filename;
%>


测试


 
























































特殊号
数字
0
<%=zero%>
1
<%=one%>
2
<%=two%>
3
<%=three%>
4
<%=four%>
5
<%=five%>
6
<%=six%>
7
<%=seven%>
8
<%=eight%>
9
<%=nine%>

 




<%}else{
out.println("HS为空");
}

}catch(Exception ex){

ex.printStackTrace();
}}%>

你可能感兴趣的:(项目心得,jfreechart,Servlet)