線圖

<%@ page contentType="text/html;charset=big5" %>
<%@page import = " org.jfree.chart.ChartUtilities"%>
<%@ page import="org.jfree.chart.JFreeChart,
org.jfree.chart.ChartUtilities,
org.jfree.chart.ChartFactory,
org.jfree.data.general.DefaultPieDataset"%>
  <html>
  <body>
  <%
String dataName[]=new String[]{"0-30","30-50","50-70","70以上"};
int dataValueCount[]={4,5,4,6};
DefaultPieDataset pieDataset = new DefaultPieDataset();
for(int i=0;i<dataName.length;i++)
pieDataset.setValue(dataName[i],dataValueCount[i]);
String titleString=" 年齡分布";
JFreeChart chart =ChartFactory.createPieChart3D(titleString,pieDataset,true, true,false);
ChartUtilities.writeChartAsJPEG(response.getOutputStream(),chart,500,300);
%>
  </body>
  </html>


 

 

<%@ page contentType="text/html;charset=big5"%>
<%@page import = " org.jfree.chart.ChartUtilities"%>
<%@ page import="org.jfree.chart.ChartFactory,
org.jfree.chart.JFreeChart,
org.jfree.chart.plot.PlotOrientation,
org.jfree.chart.servlet.ServletUtilities,
org.jfree.data.category.DefaultCategoryDataset"%>
<%
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(610, "廣州", "A肉");
dataset.addValue(220, "廣州", "B肉");
dataset.addValue(530, "廣州", "C肉");
dataset.addValue(340, "廣州", "D肉");
JFreeChart chart = ChartFactory.createBarChart3D("肉類銷售統計圖", "肉類","數量",dataset,PlotOrientation.VERTICAL,false,false,false);
ChartUtilities.writeChartAsJPEG(response.getOutputStream(),chart, 640 , 400 );
%>

 

 

<%@   page   language="java"   contentType="image/jpeg;charset=big5"  
  import="java.util.*,java.awt.*,java.awt.geom.*"  
  import="java.awt.image.*,com.sun.image.codec.jpeg.*"  
  %>  
  <%  
      int   width=600,height=500;  
      BufferedImage   image=new   BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);  
      Graphics   g=image.getGraphics();  
      Graphics2D   g2d=(Graphics2D)   g;  
      g.setColor(new   Color(240,249,255));  
      g.fillRect(0,0,width,height);  
      g.setColor(Color.white);  
      g.drawRect(10,35,width-20,height-46);  
      g.setColor(Color.black);  
      g.setFont(new   Font("宋體",Font.PLAIN,22));  
      g.drawString("水果銷售圖",15,25);  
      int   fruit_sales[]=new   int[5];  
      for(int   i=0;i<fruit_sales.length;i++){  
      fruit_sales[i]=1+(int)(Math.random()*100);  
      }  
      String   book_title[]={"苹果","香蕉","荔枝","猴桃","葡萄"};  
      Color   color[]=new   Color[5];  
      color[0]=new   Color(99,99,0);  
      color[1]=new   Color(255,169,66);  
      color[2]=new   Color(33,255,66);  
      color[3]=new   Color(33,0,255);  
      color[4]=new   Color(255,0,66);  
      g.setFont(new   Font("宋體",Font.BOLD,16));  
      g.drawString("水果售量",20,50);  
      g.drawString("水果分類",500,465);  
      g.setFont(new   Font("SanSSerif",Font.PLAIN,12));  
      int   salesValue=0;  
      for(int   i=418;i>0;i-=38){  
          g.setColor(Color.black);  
  g.drawString(""+salesValue,36,(i+27));  
  g.setColor(Color.lightGray);  
  g.drawLine(80,(i+27),520,(i+27));  
  salesValue+=10;  
      }  
      g.setColor(Color.black);  
      g.drawLine(80,40,80,445);  
      g.drawLine(80,445,550,445);  
      int   drawHigh[]=new   int[book_title.length];  
      int   drawwidth[]=new   int[book_title.length];  
      for(int   i=0;i<book_title.length;i++){  
          drawHigh[i]=445-(int)(Math.ceil(fruit_sales[i]*3.8));  
  drawwidth[i]=110+i*80;  
  g.setColor(color[i]);  
  g.fillOval(drawwidth[i]-7,drawHigh[i]-7,14,14);  
  g.setColor(Color.black);  
  g.drawString(book_title[i],110+i*80,465);  
      }  
      g2d.setXORMode(Color.white);  
      g2d.setStroke(new   BasicStroke(4.0f));  
      g2d.setPaint(Color.red);  
      g2d.drawPolyline(drawwidth,drawHigh,book_title.length);  
      g.dispose();  
      ServletOutputStream   sos=response.getOutputStream();  
      JPEGImageEncoder   encoder=JPEGCodec.createJPEGEncoder(sos);  
      encoder.encode(image);  
  %>  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值