patty79(外语是硬道理):    可不可以也给我一份,急需!非常感谢!        Email:  [email protected]

解决方案 »

  1.   

    我也需要,方便的话也给一份:[email protected]。顺便帮楼主顶
      

  2.   

    [email protected]  我也要一份。嘿嘿!!!
    捎带着帮楼主顶顶...................
      

  3.   

    up
    帮忙发一份,谢谢了!
    [email protected]
      

  4.   

    可以用javascript实现,很方便的!网上可以搜到的!
      

  5.   

    我也要,呵呵
    帮忙发一份啊,搂主!
    [email protected]
    谢谢了!!!
      

  6.   

    JSP调用JavaBean在网页上动态生成柱状图://Graphics.jsp
    <jsp:useBean id="cg" scope="page" class="tu.ChartGraphics" />
    <jsp:useBean id="gd" scope="page" class="tu.GetData" />
    <%!
    int height[]=new int[5];
    %><%
    height=gd.getHightArray();
    cg.graphicsGeneration(height[0],height[1],height[2],height[3],height[4]);
    %>//ChartGraphics.java
    package tu;import java.io.*;import java.util.*;import com.sun.image.codec.jpeg.*;import java.awt.image.*;import java.awt.*;
    public class ChartGraphics {BufferedImage image;public void createImage(String fileLocation) {try {FileOutputStream fos = new FileOutputStream(fileLocation);BufferedOutputStream bos = new BufferedOutputStream(fos);JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);encoder.encode(image);bos.close(); } catch(Exception e) {System.out.println(e);}} 
    public void graphicsGeneration(int h1,int h2,int h3,int h4,int h5) {
    final int X=10;int imageWidth = 300;//图片的宽度int imageHeight = 300;//图片的高度 int columnWidth=30;//柱的宽度int columnHeight=200;//柱的最大高度
    ChartGraphics chartGraphics = new ChartGraphics(); chartGraphics.image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB); Graphics graphics = chartGraphics.image.getGraphics();graphics.setColor(Color.white);graphics.fillRect(0,0,imageWidth,imageHeight); graphics.setColor(Color.red);graphics.drawRect(X+1*columnWidth, columnHeight-h1, columnWidth, h1);graphics.drawRect(X+2*columnWidth, columnHeight-h2, columnWidth, h2);graphics.drawRect(X+3*columnWidth, columnHeight-h3, columnWidth, h3); graphics.drawRect(X+4*columnWidth, columnHeight-h4, columnWidth, h4);graphics.drawRect(X+5*columnWidth, columnHeight-h5, columnWidth, h5); chartGraphics.createImage("c:\\jsp\\chart.jpg");} }//GetData.java
    //读取Text文件中数据的 Java Bean
    package tu;import java.io.*;public class GetData {int heightArray[] = new int[5];public int[] getHightArray() {try {RandomAccessFile randomAccessFile = new RandomAccessFile ("c:\\jsp\\ColumnHeightArray.txt","r");for (int i=0;i<5;i++){heightArray[i] = Integer.parseInt(randomAccessFile.readLine());} } catch(Exception e) {System.out.println(e);}return heightArray;}}//jsp/ColumnHeightArray.txt:
    10
    200
    150
    20
    100