带热点提示的饼状图(即鼠标放在图型上可以看到当前数据项)
<%@
page contentType = "text/html;charset=UTF-8"
%>
<%@
page import = "org.jfree.data.general.DefaultPieDataset"
%>
<%@
page import = "org.jfree.chart.*"
%>
<%@
page import = "org.jfree.chart.plot.*"
%>
<%@
page import = "org.jfree.chart.servlet.ServletUtilities"
%>
<%@
page import = "org.jfree.chart.labels.StandardPieToolTipGenerator"
%>
<%@
page import = "org.jfree.chart.urls.StandardPieURLGenerator"
%>
<%@
page import = "org.jfree.chart.entity.StandardEntityCollection"
%>
<%@
page import = "java.io.*"
%>
<
html
>
< head
>
< meta http-equiv = Content-Type content = "text/html; charset=UTF-8"
>
< title ></ title
>
</ head
>
< body
>
<%
DefaultPieDataset data =
new
DefaultPieDataset();
data.setValue(
"高中以下"
, 370);
data.setValue(
"高中"
, 1530);
data.setValue(
"大专"
, 5700);
data.setValue(
"本科"
, 8280);
data.setValue(
"硕士"
, 4420);
data.setValue(
"博士"
, 80);
PiePlot3D plot =
new PiePlot3D(data);
//3D饼图
plot.setURLGenerator(
new StandardPieURLGenerator( "barview.jsp" ));
//设定链接
JFreeChart chart =
new JFreeChart( ""
,
JFreeChart.DEFAULT_TITLE_FONT, plot,
true
);
chart.setBackgroundPaint(java.awt.Color.white);
//可选,设置图片背景色
chart.setTitle(
"程序员学历情况调查表" );
//可选,设置图片标题
plot.setToolTipGenerator(
new
StandardPieToolTipGenerator());
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 usemap = "#map0"
>
</ p
>
</ body
>
</
html
>
已有 0 人发表留言,猛击->>这里<<-参与讨论
JavaEye推荐