学一个简单的JFreeChart使用方法

王朝other·作者佚名  2008-05-31
宽屏版  字体: |||超大  

在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

/**

*

* <pDiscription:[构造器方法描述]</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;

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有