日期:2014-05-20  浏览次数:20746 次

一个关于jfreechart的饼图,热点链接
jfreechart的饼图,点击各个模块,做后台交互


<MAP NAME="chartMap">
<AREA SHAPE="RECT" COORDS="81,15,126,254" href="?series=0&category=100" title="100 = 7,048" 
 onclick="javascript:clickChart('100');return false;">
<AREA SHAPE="RECT" COORDS="143,27,188,255" href="?series=0&category=200" title="200 = 6,721" 
 onclick="javascript: clickChart ('200');return false;">
<AREA SHAPE="RECT" COORDS="205,54,250,255" href="?series=0&category=300" title="300 = 5,929" 
 onclick="javascript: clickChart ('300');return false;">
<AREA SHAPE="RECT" COORDS="267,85,312,255" href="?series=0&category=400" title="400 = 5,005" 
 onclick="javascript: clickChart ('400');return false;">
<AREA SHAPE="RECT" COORDS="329,17,374,255" href="?series=0&category=Diet" title="Diet = 7,017" onclick="javascript: 
 clickChart ('Diet');return false;">
</MAP>


------解决方案--------------------
没有画过,只用过chartDirector
------解决方案--------------------
我也只用过chartDirector
------解决方案--------------------
DefaultPieDataset data = new DefaultPieDataset();
data.setValue(5月, 20);
data.setValue(6月, 50);
data.setValue(7月, 100);
PiePlot plot = new PiePlot(data);
JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
chart.setBackgroundPaint(java.awt.Color.white); //可选,设置图片背景色
chart.setTitle(a.getSurvey().getProblem()); //可选,设置图片标题
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
//500是图片长度,300是图片高度
String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info, request.getSession());
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;

request.setAttribute("graphURL", graphURL);

 <img src="${graphURL}" border=0 >


web.xml 配置


<servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/servlet/DisplayChart</url-pattern>
</servlet-mapping>


不知道对你有没有用啊