<%@ 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();
}}%>