I wish we all could share our knowledge each other,especially the open project
*Brief introduction::extend the function of jfreechart-plugin to display the tips' info you've set in the web browser.
* And fix the bug of jpg undisplayed.(just use response.setContentType("image/jpeg") instead of response.setContentType("image/jpg"))
*
About struts2,we know it use the mechanism of plugin to hook others' third part. However we'll find some blemish or bugs with going deep into using them,for example,one is struts2-jasperreport-plugin-2.1.6 introduced by us in my blog's article http://redsnow-fenglin.iteye.com/blog/464213 and http://redsnow-fenglin.iteye.com/blog/461927, and the other one is the one which we're discussing now the struts2-jfreechart-plugin-2.1.8.1,whoe bug is that could not display the tips' info you've set in the web browser and the jpg's format.
Here, I just introduce the later instance. I extend the class ChartResult to extend the function of jfreechart-plugin to display the tips' info you've set in the web browser.And fix the bug of jpg undisplayed.(just use response.setContentType("image/jpeg") instead of response.setContentType("image/jpg")). There is an used example in the source coe of EnhancedChartResult.java, smple codes as following:
<!-- START SNIPPET: example -->
public class ExampleChartAction extends ActionSupport {
private JFreeChart chart;
public String execute() throws Exception {
String title = "Report Title Here";
String xAxisLabel = "X Axis Mark";
String yAxisLabel = "Y Axis Mark";
double[][] yKeysVale = new double[][] {{621,890,591,591,528,621}};
String[] yKeys = {"Error Files"};
String[] xKeys = {"2009-01","2009-02","2009-03","2009-04","2009-05","2009-06"};
CategoryDataset dataset = DatasetUtilities.createCategoryDataset(yKeys,xKeys,yKeysVale);
chart = ChartFactory.createLineChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false);
chart.setBackgroundPaint(Color.WHITE);
CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
// x轴 // 分类轴网格是否可见
categoryplot.setDomainGridlinesVisible(true);
// y轴 //数据轴网格是否可见
categoryplot.setRangeGridlinesVisible(true);
categoryplot.setRangeGridlinePaint(Color.WHITE);// 虚线色彩
categoryplot.setDomainGridlinePaint(Color.WHITE);// 虚线色彩
categoryplot.setBackgroundPaint(Color.lightGray);
// 设置轴和面板之间的距离
categoryplot.setAxisOffset(new RectangleInsets(0D, 0D, 0D, 0D));
// 获得renderer 注意这里是下转型到lineandshaperenderer!!
LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
lineandshaperenderer.setBaseShapesVisible(true); // series 点(即数据点)可见
lineandshaperenderer.setBaseLinesVisible(true); // series 点(即数据点)间有连线可见
lineandshaperenderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator("link.jsp","series","hits")); // 设置超链接
// 显示折点数据
lineandshaperenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
lineandshaperenderer.setBaseItemLabelsVisible(true);
// 横轴上的 Lable 45度倾斜
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
numberaxis.setAutoRangeIncludesZero(false);
return SUCCESS;
}
// this method will get called if we specify <param name="value">chart</param>
public JFreeChart getChart() {
return chart;
}
}
<result name="success" type="chart">
<param name="mode">enchanced</param>
<param name="value">chart</param>
<param name="type">png</param>
<param name="width">640</param>
<param name="height">480</param>
</result>
Tips: enchanced is the default value of the param mode , and another value you can use is stand,which stands for the original value of struts-plugin-2.1.8.jar.
<!-- END SNIPPET: example -->
If you want to know the more details , you could download the source code from the appurtenance.
Tips:My apache topic is http://www.quicktopic.com/43/H/23NsPYee3Y4Eg.
分享到:
- 2009-11-02 16:17
- 浏览 3863
- 评论(2)
- 论坛回复 / 浏览 (2 / 3121)
- 查看更多
相关推荐
struts2-jfreechart-plugin-2.1.8.1.jar
struts2-jfreechart-plugin-2.1.8.1
struts2-jfreechart-plugin-2.0.11.jarstruts2-jfreechart-plugin-2.0.11.jarstruts2-jfreechart-plugin-2.0.11.jar
struts2-jfreechart-plugin-2.3.4.1.jar
struts2-jfreechart-plugin-2.0.8.jar
struts2-jfreechart-plugin-2.1.6.jar
struts2 结合强大的图形报表开发包进行集成开发,能够降低系统的耦合和灵活的报表开发方式,展现不同的图形化报表,给企业带来更加精美的报表解决方案。
包含struts2-core-2.5.10.1.jar,struts2-jfreechart-plugin-2.5.10.1.jar,struts2-json-plugin-2.5.10.1.jar,struts2-junit-plugin-2.5.10.1.jar,struts2-bean-validation-plugin-2.5.10.1.jar,struts2-cdi-...
struts2-jfreechart-plugin-2.3.24.jar, struts2-pell-multipart-plugin-2.3.24.jar, struts2-plexus-plugin-2.3.24.jar, struts2-sitegraph-plugin-2.3.24.jar, struts2-sitemesh-plugin-2.3.24.jar, struts2-...
最新官方struts2-plugin jfreechart,分享于有需要的朋友
### 如何修改struts2-jfreechart-plugin 2.0.11 jar包 #### 一、概述 本文档将详细介绍如何对`struts2-jfreechart-plugin 2.0.11`版本的jar包进行修改。Struts2是一个基于Java的Web应用框架,而JFreeChart则是一款...
struts2整合jfreechart 的工具jar文件 struts2-jfreechart-plugin-2.3.15.3.jar
"struts2-jfreechart-plugin-2.1.6.jar.zip_jfreechart struts2_jfree" 这个标题表明这是一个关于Struts2与JFreeChart结合使用的插件,版本为2.1.6。这个插件简化了在Struts2应用中使用JFreeChart的过程,使得开发者...
struts2-jfreechart-plugin-2.5.2.jar, struts2-json-plugin-2.5.2.jar, struts2-junit-plugin-2.5.2.jar, struts2-osgi-admin-bundle-2.5.2.jar, struts2-osgi-demo-bundle-2.5.2.jar, struts2-osgi-plugin-2.5.2....
比较全的java开发包,要用到的朋友可以下载 ...struts2-convention-plugin-2.1.8.1.jar struts2-core-2.1.8.1.jar struts2-embeddedjsp-plugin-2.1.8.1.jar struts2-json-plugin-2.1.8.1.jar xwork-core-2.1.6.jar
struts2-gxp-plugin-2.5.10.jar,struts2-jasperreports-plugin-2.5.10.jar,struts2-javatemplates-plugin-2.5.10.jar,struts2-jfreechart-plugin-2.5.10.jar,struts2-json-plugin-2.5.10.jar,struts2-junit-plugin-...
struts2-junit-plugin-2.1.6.jar
struts2-jfreechart-plugin-2.3.30.jar, struts2-jsf-plugin-2.3.30.jar, struts2-json-plugin-2.3.30.jar, struts2-junit-plugin-2.3.30.jar, struts2-osgi-admin-bundle-2.3.30.jar, struts2-osgi-demo-bundle-...
Struts2是一个强大的Java web应用程序框架,它基于MVC(模型-视图-控制器)设计模式,用于构建可维护性和可扩展性高的企业级应用。Struts2的标签库是其核心特性之一,极大地简化了视图层的开发,提高了开发效率。本...
Struts2 -JFreeChartStruts2 -JFreeChartStruts2 -JFreeChartStruts2 -JFreeChartStruts2 -JFreeChartStruts2 -JFreeChartStruts2 -JFreeChartStruts2 -JFreeChartStruts2 -JFreeChart