shaoen01 Posted October 12, 2008 Share Posted October 12, 2008 Hi,I am just wondering how do i upload or insert a customizer class for bar chart? Thanks Link to comment Share on other sites More sharing options...
andysusanto Posted October 14, 2008 Share Posted October 14, 2008 what version of ireport that your used ?,you just copy your classes itu "WEB-INFclasses". After that just put your package classes into Chart Properties Regards, Andy Susanto Link to comment Share on other sites More sharing options...
golreich Posted October 14, 2008 Share Posted October 14, 2008 Hi, I take advance of the recent topic reply to beg for a help.I would like to change the position of the labels of the chart bars.I created a custom class called "ChartCustomizer.java" and exported it in a jar that I called "chartCustomizer.jar". I put this jar into the same folder of my jrxml file and wrote the full name of the package contained in the jar. In this case "utility.Chartcustomizer". I also tried to write the name of the jar in "import directives" I tried to write the name of the package also in the classpaht of the program.In every single case, the report does not work, and it always gives an error: ClassnotfoundException.I hope you can help me. I must tell that I'm using Webratio as main application.Code:net.sf.jasperreports.engine.JRRuntimeException: Could not create chart customizer instance. at net.sf.jasperreports.engine.fill.JRFillChart.<init>(JRFillChart.java:325) at net.sf.jasperreports.engine.fill.JRFillObjectFactory.visitChart(JRFillObjectFactory.java:715) at net.sf.jasperreports.engine.base.JRBaseChart.visit(JRBaseChart.java:574) at net.sf.jasperreports.engine.JRAbstractObjectFactory.getVisitResult(JRAbstractObjectFactory.java:91) at net.sf.jasperreports.engine.fill.JRFillElementGroup.<init>(JRFillElementGroup.java:86) at net.sf.jasperreports.engine.fill.JRFillElementContainer.<init>(JRFillElementContainer.java:91) at net.sf.jasperreports.engine.fill.JRFillBand.<init>(JRFillBand.java:87) at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getBand(JRFillObjectFactory.java:518) at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:541) at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:77) at net.sf.jasperreports.engine.fill.JRFillSubreport.initSubreportFiller(JRFillSubreport.java:377) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:351) at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:257) at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:275) at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:426) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillSummarySamePage(JRVerticalFiller.java:920) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillSummary(JRVerticalFiller.java:854) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportEnd(JRVerticalFiller.java:286) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:120) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:891) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:814) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:582) at com.webratio.struts.reports.jasper.ReportTag.doAfterBody(ReportTag.java:207) at org.apache.jsp.page9f_jsp._jspx_meth_report_005fReport_005f0(page9f_jsp.java:161) at org.apache.jsp.page9f_jsp._jspService(page9f_jsp.java:90) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301) at org.apache.struts.chain.commands.servlet.PerformForward.handleAsForward(PerformForward.java:99) at org.apache.struts.chain.commands.servlet.PerformForward.perform(PerformForward.java:82) at org.apache.struts.chain.commands.AbstractPerformForward.execute(AbstractPerformForward.java:51) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:48) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:280) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858) at com.webratio.struts.servlets.WRActionServlet.doGet(WRActionServlet.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685) at java.lang.Thread.run(Thread.java:619)Caused by: java.lang.ClassNotFoundException: utility.ChartCostumizer at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:179) at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:119) at net.sf.jasperreports.engine.fill.JRFillChart.<init>(JRFillChart.java:322) ... 64 more Link to comment Share on other sites More sharing options...
shaoen01 Posted October 14, 2008 Author Share Posted October 14, 2008 Hey golreich, I did face a similar problem and i have managed to overcome this classnotfound exception. Basically, you compile your java file (customizer.java) and get the ".class" file. Based on where the location of your jasper or jrxml file is residing, place the ".class" file generated above. Go to ireport and double click on your chart> edit chart properties> chart properties Under chart properties you will see a "Customizer class" under the COMMON. Enter the name of your ".class" file without including ".class". In the case of your submitted error, it should be "ChartCostumizer". This should be able to do the trick. If it still gives the class not found exception, try inputting "utility.ChartCostumizer", which i assume utility is your package name. Link to comment Share on other sites More sharing options...
shaoen01 Posted October 14, 2008 Author Share Posted October 14, 2008 I am just wondering if i will be able to use a parameter to set the destination of the chart customizer class? Or must the customizer class be in the same directory as the ".jrxml" file? I tried to do use "$P{path}" and insert it into the customizer class in chart properties, but it doesn't seem to work. Any ideas? Link to comment Share on other sites More sharing options...
golreich Posted October 15, 2008 Share Posted October 15, 2008 hi shaoen01, I followed your suggestion, but unfortunately it did not work.Anyway, I don't understand the second chance you told me, because putting the name of the complete package has sense just if you are using the jar (and the path is necessary to find the .class file in the jar) Anyway, I tried that trick too, but it does not work.Still ClassNotFoundException.Here, I don't know what to do. Link to comment Share on other sites More sharing options...
golreich Posted October 15, 2008 Share Posted October 15, 2008 I've no idea. To me it would be grate just to make it work...I am on the way of hating ireport. Link to comment Share on other sites More sharing options...
shaoen01 Posted October 15, 2008 Author Share Posted October 15, 2008 Hi, Well, you actually don't even need to create a jar file if you are using the ".class" file. Did you use javac or other java compilers to get the customizer.class file? Once you have done that, did you manage to find the "Customizer class" in the chart properties? Also, are you sure that your coding for the custiomizer.java is correct? Link to comment Share on other sites More sharing options...
golreich Posted October 15, 2008 Share Posted October 15, 2008 Thanks for the reply shaoen...Yes, I did everything you said, but it does not want to work...I bet the code is correct, anyway I could not verify it, since it does not find the ".class" file. :S Link to comment Share on other sites More sharing options...
shaoen01 Posted October 15, 2008 Author Share Posted October 15, 2008 The .class file and the .jrxml file has to be in the same directory and folder for you to call it. Why don't you try this sample class below and build it to get the .class file. Then just create a sample barchart just for testing purposes. And then try it out and see how it goes.I don't understand why it can't be found because i faced exactly the same problem you had and solved it via this way. Code:/* * To change this template, choose Tools | Templates * and open the template in the editor. *//* * ============================================================================ * GNU Lesser General Public License * ============================================================================ * * JasperReports - Free Java report-generating library. * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * JasperSoft Corporation * 303 Second Street, Suite 450 North * San Francisco, CA 94107 * http://www.jaspersoft.com */import net.sf.jasperreports.engine.JRChartCustomizer;import net.sf.jasperreports.engine.JRChart;import org.jfree.chart.JFreeChart;import org.jfree.chart.renderer.category.BarRenderer;import org.jfree.chart.plot.CategoryPlot;import org.jfree.chart.axis.NumberAxis;import java.awt.*;import org.jfree.chart.axis.CategoryAxis;/** * @author Teodor Danciu (teodord@users.sourceforge.net) * @version $Id:BarChartCustomizer.java 2317 2008-08-27 09:06:42Z teodord $ */public class BarChartCustomizer implements JRChartCustomizer{ private Number tickUnits=0; public void customize(JFreeChart chart, JRChart jasperChart) { BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer(); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.blue); renderer.setMaximumBarWidth(10); //renderer.set //renderer.setItemMargin(0.50); //myHorizontalAxis.setAutoTickUnits(false);//myHorizontalAxis.setTickUnits(new Double(10)); CategoryPlot plot = chart.getCategoryPlot();//NumberAxis myHorizontalAxis =//(NumberAxis) plot.getAxis(Plot.HORIZONTAL_AXIS);NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();//rangeAxis.setTickUnit(20);//rangeAxis.createIntegerTickUnits();rangeAxis.setStandardTickUnits(rangeAxis.createIntegerTickUnits());rangeAxis.setAutoRangeIncludesZero(true);//rangeAxis.setRange(100, plot.); //CategoryPlot plot = chart.getCategoryPlot();CategoryAxis axis = plot.getDomainAxis();//rangeAxis.set//renderer.setseriesaxis.setLowerMargin(0.02); // two percentaxis.setCategoryMargin(0.05); // ten percentaxis.setUpperMargin(0.02); // two percent//renderer.setbar }} 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