请问如何把jfreechar返回的chart在JSP页面中单独显示

枫中叶 枫中叶 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
各位大侠:
请问如何把jfreechar返回的chart在JSP页面中单独显示,因为jfreechar所返回的chart就是一个图形了,但我想让他在另一个JSP页面中来显示出来,不想让它用chart来显示,因为这样就会有一个问题,当我提交时,它显示的是chart图形了,而不能操作了,我想用另一个单独的JSP页面来获得chart,在jsp中显示形图,请各位大侠指点一下,我的代码如下:


这是struts.xml中的代码:

<!-- 饼图 -->
<action name="test" class="com.test.struts.TestAction">
<result name="success" type="chart">
<param name="height">500</param>
<param name="width">800</param>
</result>
</action>

以下是action中的代码:

public class TestAction extends ActionSupport {

public static Testdaoimpl testdaoimpl;

private JFreeChart chart;

public void setTestdaoimpl(Testdaoimpl testdaoimpl) {

this.testdaoimpl = testdaoimpl;
}

public JFreeChart getChart() {

Resource resource = new ClassPathResource("applicationContext.xml");

ListableBeanFactory bean = new XmlBeanFactory(resource);

testdaoimpl = (Testdaoimpl)bean.getBean("testdaoimpl");

List list = testdaoimpl.listTest();

DefaultPieDataset dpd = new DefaultPieDataset();

for(int i=0;i<list.size();i++)
{
Info info = (Info)list.get(i);

//以下是从数据库中得到的数据
dpd.setValue("管理人员",info.getNum());

dpd.setValue("市场人员", info.getAge());

dpd.setValue("其它人员", info.getPage());
}

JFreeChart chart = ChartFactory.createPieChart3D("某公司人员组织结构图", dpd, true,
true, false);

return chart;
}

@Override
public String execute() throws Exception
{
return SUCCESS;
}
}
...全文
评论 1
收藏 已收藏
分享
返回顶部
枫中叶
Web 开发 81,107 成员 341,720 内容