日期:2014-05-18  浏览次数:20652 次

怎样用jfreechart画二维饼图(即一张图片中有多个饼,如:学历、性别的二维统计)
rt

------解决方案--------------------
你是画不出图来?
还是不能将几个饼图做成一副图?


饼图我到是做过
但我是一个一个的做出来,显示才一个页面,没有做过将几个饼图做成一副图
------解决方案--------------------
你可以参考http://www.jfree.org/jfreechart/index.html网站上例子中PieChartDemo5.java和PieChartDemo6.java这两个例子是一维饼图的例子,改称二维应该比较简单。
------解决方案--------------------
jfreechart很好用 十行代码就搞定了
------解决方案--------------------
这是我一个小项目中的一段代码,你看能不能对你有所帮助,使用的是JFreeChart
<%
//PiePlot3D plot = new PiePlot3D(data);//3D饼图
PiePlot plot = new PiePlot(data);//2D
//plot.setURLGenerator(new StandardPieURLGenerator( "barview.jsp "));//设定链接
JFreeChart chart = new JFreeChart( " ",JFreeChart.DEFAULT_TITLE_FONT, plot, true);
chart.setBackgroundPaint(java.awt.Color.pink);//可选,设置图片背景色
chart.setTitle( "各个部门人员电话总数统计图 ");//可选,设置图片标题
plot.setToolTipGenerator(new StandardPieItemLabelGenerator());


StandardEntityCollection sec = new StandardEntityCollection();
ChartRenderingInfo info = new ChartRenderingInfo(sec);
PrintWriter w = new PrintWriter(out);//输出MAP信息
//500是图片长度,300是图片高度
String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info, session);
ChartUtilities.writeImageMap(w, "map0 ", info, false);
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename= " + filename;
%>
<P ALIGN= "CENTER ">
<img src= " <%= graphURL %> " width=500 height=300 border=0 align= "middle " usemap= "#map0 "> </P>
这里有一些相关代码,你看看:
http://hi.baidu.com/mianju/blog/category/Jfreechart
------解决方案--------------------
up