程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> 關於JAVA >> JFreeChart的用法

JFreeChart的用法

編輯:關於JAVA

一個簡單的用法

在jsp 頁面中可以封裝為一標簽

public class xxxxChartTag extends TagSupport
{

   private static final long serialVersionUID = 1L;
   private int width; //圖表寬度
   private int height; //圖表高度
   private String type; //圖表類型
   private DataVO datavo; //圖表數據對象
   private static final int EVAL_PAGE = 6;
   private String attrbuteName; //request對象名字
   private String chartType; //圖表顯示方式2D或3D
   /**
   *
   * <p>Discription:[構造器方法描述]</p>
   * @coustructor 方法.
   */
   public NtasChartTag()
   {
     super();
     width = 790;
     height = 460;
     attrbuteName = NtasConst.REQUEST_DATAVO_KEY;
     chartType="2D";
   }
   public int doStartTag() throws JspException
   {
     StringBuffer stringbuffer = new StringBuffer();
     HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
     HttpSession session = request.getSession(true);
     datavo = (DataVO) request.getAttribute(attrbuteName);
     NTASChartFactory NChartFactory = new NTASChartFactory(datavo, session);
     NChartFactory.setPicWidth(width);
     NChartFactory.setPicHeight(height);
     NChartFactory.setChartstyle(chartType);

     try
     {
       NChartFactory.createNTASChart(type);
     }
     catch (Exception e1)
     {
       e1.printStackTrace();
     }
     String picFileName = NChartFactory.getFileName();
     String getPicURL = NChartFactory.getPicURL();
     stringbuffer.append( NChartFactory.getChartMapHtml());
     stringbuffer.append("<img border="0" width="" + width + "" height="" + height + "" src="" + request.getContextPath()+getPicURL + "" useMap="#" + picFileName + ""/>");
     JspWriter out = pageContext.getOut();
     try
     {
       out.println(stringbuffer.toString());
     }
     catch (IOException e)
     {
       e.printStackTrace();
     }
     return EVAL_PAGE;
   }
    public int getHeight()
   {
     return height;
   }
    public String getType()
   {
     return type;
   }
    public int getWidth()
   {
     return width;
   }
  /  public void setHeight(int i)
   {
     height = i;
   }
    public void setType(String string)
   {
     type = string;
   }
    public void setWidth(int i)
   {
     width = i;
   }
    public String getAttrbuteName()
   {
     return attrbuteName;
   }
    public void setAttrbuteName(String string)
   {
     attrbuteName = string;
   }
   public String getChartType()
   {
     return chartType;
   }
public void setChartType(String string)
   {
     this.chartType = string;
   }
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved