2006 IR Open Dicussion Posted August 27, 2006 Share Posted August 27, 2006 By: alan mc k - alanmck Howto pass parameters to JRChartCustomizer? 2006-05-31 09:31 Hi, I've setup my JRAbstractChartCustomizer but I would like to parameterise it. I know you get use the getParameter() methods.. but where do I set the parameter in my jasper report file? Could someone give a small example. Thanks, Alan Link to comment Share on other sites More sharing options...
toolman Posted November 24, 2006 Share Posted November 24, 2006 if you extend "JRAbstractChartCustomizer" you can call this.getParameterValue("paramName"); Code:public class MyChartCustomizer extends JRAbstractChartCustomizer { public void customize(JFreeChart chart, JRChart jasperChart) { Object param = this.getParameterValue("paramName"«»); }} Adding parameters has nothing to do with chart creation specifically - look at the documentation for adding a parameter to a report :)Post edited by: toolman, at: 2006/11/24 00:20 Link to comment Share on other sites More sharing options...
atanupanda Posted February 6, 2007 Share Posted February 6, 2007 HiThis is Atanu. I am very new in ireport and also in java environment. In the ireport I have designed a template .like this. size=500]C:Documents and SettingsAtanuMy Documentsdata.jpgNow I want to plot a line graph on the basis of the each data like t1 t2 ---t5 and lcl, ucl, actual value for each row.That I have done. Now my problem is that I have to change the color of points of t1 t2 ---t5 on the basis of Lcl and Ucl . If the value of t1 ,or t2 or ----t5 are between Ucl and Lcl the color will be blue. And if it out side of Lcl and Ucl then it will be red..I want the following figure. Where the upper bold line is Ucl and lower bold line is Lcl. size=150]C:Documents and SettingsAtanuMy Documentsgraph.jpg Actually I have got a information that for that I have to write a customizer class for chart. Also I have write it . import net.sf.jasperreports.engine.*;import net.sf.jasperreports.view.JasperViewer;import net.sf.jasperreports.engine.JREmptyDataSource;import java.util.*;import java.sql.DriverManager;import java.sql.Connection;import java.sql.SQLException;import net.sf.jasperreports.engine.JRAbstractChartCustomizer;import javax.sql.*;import org.jfree.chart.axis.CategoryAxis;import org.jfree.chart.plot.CategoryPlot;import org.jfree.chart.renderer.category.*;import org.jfree.chart.renderer.*;import org.jfree.chart.ChartRenderingInfo;import org.jfree.chart.renderer.category.BarRenderer;import org.jfree.chart.renderer.category.LevelRenderer;import org.jfree.chart.renderer.category.LayeredBarRenderer;import java.sql.DriverManager;import java.sql.SQLException;import java.sql.Connection;import java.util.HashMap;import java.util.Map;import java.lang.String;import net.sf.jasperreports.engine.JRException;import net.sf.jasperreports.engine.JasperExportManager;import net.sf.jasperreports.view.JasperViewer;import net.sf.jasperreports.engine.xml.JRXmlLoader;import net.sf.jasperreports.engine.JasperCompileManager;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint;import net.sf.jasperreports.engine.design.JasperDesign;import net.sf.jasperreports.engine.JasperReport;import net.sf.jasperreports.engine.JRChartDataset; import net.sf.jasperreports.engine.JRChartPlot; import org.jfree.chart.renderer.category.BarRenderer3D; import org.jfree.chart.renderer.category.LineAndShapeRenderer;import org.jfree.chart.axis.CategoryLabelPositions; import org.jfree.chart.renderer.category.LineRenderer3D;import java.awt.*;import net.sf.jasperreports.engine.JRChart;import net.sf.jasperreports.engine.JRChartCustomizer;import org.jfree.chart.JFreeChart;import net.sf.jasperreports.engine.*;import java.awt.Color;import net.sf.jasperreports.engine.JRChart;import net.sf.jasperreports.engine.JRChartCustomizer; import org.jfree.chart.JFreeChart;import org.jfree.chart.axis.CategoryAxis;import org.jfree.chart.axis.CategoryLabelPositions;import org.jfree.chart.plot.CategoryPlot;import org.jfree.chart.renderer.category.BarRenderer3D;import java.lang.Object; public class LineChartCustomizer extends JRAbstractChartCustomizer { public void customize(JFreeChart chart, JRChart jasperChart) { LineAndShapeRenderer renderer = (LineAndShapeRenderer) chart.getCategoryPlot().getRenderer(); renderer.setSeriesPaint(1, Color.green); renderer.setSeriesPaint(4, Color.orange); chart.setTitle("Setting the title OSMOSYS!"); } } Now this customize class ok running successfully with creating jar files.Now I want to create a logic to check the value of t1 t2 t3 t5 with respect to UCL and LCL. How can I fetch data from report.Or is there any other way to do this.Is there any way to pass value from iReport to customizer class ? What should I do. Please please help me. It’s urget for me. Any help would be greatly appreciated. Thanks in advance. [file name=query.doc size=49152]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/query.doc[/file] size=159]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/graph.JPG Post edited by: atanupanda, at: 2007/02/06 09:35Post edited by: atanupanda, at: 2007/02/06 09:37 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now