Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÓÃJFreeChartÔöÇ¿JSP±¨±íµÄÓû§ÌåÑé(2)

 Èý£®  ±ýͼ
ÔÚWebRootĿ¼Ï½¨Á¢ÃûΪpieµÄ×ÓĿ¼£¬ÓÃÀ´´æ·Å±¾½Ì³ÌÖбýͼµÄʵÀýjspÒ³Ãæ¡£ÏÂÃæÈÃÎÒÃÇÀ´¿´Ò»¸ö¼òµ¥µÄÈýά±ýͼ¡£Ê×ÏÈÔÚpieĿ¼Ï½¨Á¢Ò»¸öÃûΪsample1.jspµÄÒ³Ãæ¡£
ÔÚJFreeChartÖУ¬Óë±ýͼ»æÖÆÃÜÇÐÏà¹ØµÄÀàÈçÏ£º
1£©  PiePlot
±ýͼ»æÖÆÀ࣬¿ÉÒÔÓÃÀ´ÉèÖñýͼµÄÏà¹ØÊôÐÔ¡£ÀýÈ磺
PiePlot pieplot = (PiePlot)jfreechart.getPlot();
pieplot.setLabelFont(new Font("SansSerif", 0, 12));
pieplot.setNoDataMessage("No data available");
pieplot.setCircular(false);
pieplot.setLabelGap(0.02D);
2£©  DefaultPieDataset
ĬÈϵıýͼÊý¾Ý¼¯À࣬ÓÃÀ´´æ´¢±ýͼÏÔʾµÄÏà¹ØÊý¾ÝÐÅÏ¢¡£ÀýÈ磺
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Æ·µÂ", new Double(0.2D));
dataset.setValue("ÌåÓý", new Double(0.2D));
dataset.setValue("ÒôÀÖ", new Double(0.2D));
dataset.setValue("ÆäÓà³É¼¨", new Double(0.4D));
3£©  ChartFactory
¿ÉÀûÓøÃÖÆͼ¹¤³§ÀàcreatePieChartÀ´´´½¨Ò»¸ö±ýͼµÄJFreeChart¶ÔÏó£¬ÀýÈ磺
JFreeChart jfreechart = ChartFactory.createPieChart("±ýͼʾÀý", dataset, true, true, false);
       ÏÂÃæÈÃÎÒÃÇ¿´Ò»¸ö¼òµ¥µÄÀý×Ó£¬ÐÞ¸Äsample1.jspµÄÄÚÈÝÈçÏ£º
<%@ page contentType="text/html;charset=GBK"%>
<%@ page import="org.jfree.chart.*,
org.jfree.chart.plot.PiePlot,
org.jfree.data.general.DefaultPieDataset,
org.jfree.chart.servlet.ServletUtilities,
java.awt.*"%>
<%
//ÉèÖÃÊý¾Ý¼¯
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("³õÖи߼¶³ÌÐòÔ±", 0.55);
dataset.setValue("ÏîÄ¿¾­Àí", 0.1);
dataset.setValue("ϵͳ·ÖÎöʦ", 0.1);
dataset.setValue("Èí¼þ¼Ü¹¹Ê¦", 0.1);
dataset.setValue("ÆäËû", 0.2);
//ͨ¹ý¹¤³§ÀàÉú³ÉJFreeChart¶ÔÏó
JFreeChart chart = ChartFactory.createPieChart3D("ITÐÐÒµÖ°Òµ·Ö²¼Í¼", dataset, true, false, false);
PiePlot pieplot = (PiePlot) chart.getPlot();
pieplot.setLabelFont(new Font("ËÎÌå", 0, 12));
//ûÓÐÊý¾ÝµÄʱºòÏÔʾµÄÄÚÈÝ
pieplot.setNoDataMessage("ÎÞÊý¾ÝÏÔʾ");
pieplot.setCircular(false);
pieplot.setLabelGap(0.02D);
String filename = ServletUtilities.saveChartAsP


Ïà¹ØÎĵµ£º

JSPÊý¾ÝÌá½»ÂÒÂëÎÊÌâ

 Ô­Àí²»ËµÁË,ÍøÉÏÓкܶà,¶¼¿ÉÒÔ×Ô¼º²éµ½,ÖÁÓÚΪʲô»á³öÏÖÂÒÂë,ÊÇÒòΪJAVAÓÐʹÓùú¼Ê»¯,Óöµ½ÖÐÎÄʱ.....
ÏÂÃæ¸ø³öһЩ¼òµ¥µÄʵÓôúÂë,Ö»¹©²Î¿¼:
public class ChangeUtf8 {
 public static String getS(String Str){
        try{
       ......

JSPÄÚÖöÔÏó

servlet--------------------------------------------JSP
HttpServletRequest                             request
HttpServletResponse     &nbs ......

Jsp ELÓï·¨

Jsp ELÓï·¨
Àý£º
${sessionScope.user.sex}
ËùÓÐEL¶¼ÊÇÒÔ ${ ΪÆðʼ¡¢ÒÔ} Ϊ½áβµÄ¡£
ÉÏÊöEL·¶ÀýµÄÒâ˼ÊÇ£º´ÓSessionÈ¡µÃÓû§µÄÐÔ±ð¡£Èç¹ûʹÓÃ֮ǰJSP´úÂëµÄд·¨ÈçÏ£º
<%
User user = (User)session.getAttribute(”user”);
String sex = user.getSex( );
%>
Á½ÕßÏà±È½Ï֮ϣ¬¿ÉÒÔ·¢ÏÖELµÄÓï·¨± ......

jsp·ÖÒ³

ÉÏ¿ÎÀÏʦ½²½âÁËjsp·ÖÒ³ £¬¹ØÓÚ¼ÆËã×ÜÒ³Êý
 
 ËûµÄËã·¨ÊÇ  totalPage=(totalRecords+pageSize-1)/pageSize;  Ëû˵Èç¹û²»ºÃÀí½â£¬¾ÍÓà i f  else Åжϡ£
 
Ï¿ο´Êé
 
 Å¼È»ÏëÆðÁËÒÔÇ°£¬µÄÒ»¸öËã·¨
 
totalPage=(totalRecords%pageSize==0)?  (totalRecords/page ......

jsp×Ô¶¨ÒåǶÌ×±êÇ©

 1.¶¨Òå±êǩʵÏÖÀà
ParentTag.java
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
public c ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ