1. 首页
  2. 编程语言
  3. Java
  4. 根据统计数据生成柱状统计图

根据统计数据生成柱状统计图

上传者: 2018-12-09 01:09:53上传 RAR文件 6.07KB 热度 54次
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); graph ics.setColor(Color.blue); graphics.fill3DRect(X + 1 * columnWidth, columnHeight - h1, columnWidth,h1,true); graphics.setColor(Color.red); graphics.fill3DRect(X + 2 * columnWidth, columnHeight - h2, columnWidth, h2,true); graphics.setColor(Color.yellow); graphics.fill3DRect(X + 3 * columnWidth, columnHeight - h3, columnWidth, h3,true); graphics.setColor(Color.green); graphics.fill3DRect(X + 4 * columnWidth, columnHeight - h4, columnWidth, h4,true); graphics.setColor(Color.orange); graphics.fill3DRect(X + 5 * columnWidth, columnHeight - h5, columnWidth, h5,true); graphics.setColor(Color.cyan); //chartGraphics.createImage("E:\\MyEclipse\\apache-tomcat-6.0.14\\webapps\\pic\\chart.jpg"); }
用户评论