|
下面通过查找资料做可两个Demo,只有饼图和柱状图的,其它的请各位自己研究了,大同小异. 下面来说说,首先到官方网站下不到开发必须的两个包:jcommon-1.0.0.jar,jfreechart-1.0.0-rc1.jar,就随便找了两个,版本不高,但是够用,下面就贴出调试过的代码<%@ page import="org.jfree.chart.labels.StandardPieSectionLabelGenerator"%> http://www.w3.org/TR/html4/loose.dtd"> <% DefaultPieDataset data = new DefaultPieDataset(); data.setValue("高中以下",3700); data.setValue("高中",1530); data.setValue("大专",5700); data.setValue("本科",8280); data.setValue("硕士",4420); data.setValue("博士",8000); PiePlot3D plot = new PiePlot3D(data);//3D饼图 plot.setURLGenerator(new StandardPieURLGenerator("barview.jsp"));//设定链接 JFreeChart chart = new JFreeChart("",JFreeChart.DEFAULT_TITLE_FONT, plot, true); // chart.setBackgroundPaint(Color.white);//可选,设置图片背景色 chart.setTitle("程序员学历情况调查表");//可选,设置图片标题 // plot.setToolTipGenerator(new StandardPieSectionLabelGenerator()); StandardEntityCollection sec = new StandardEntityCollection(); ChartRenderingInfo info = new ChartRenderingInfo(sec); response.setContentType("text/html;charset=UTF-8"); |