Jump to content
Changes to the Jaspersoft community edition download ×

how to use customizer classes


andysusanto

Recommended Posts

  • 2 weeks later...
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Create a new class with this sample text:

 

Code:

import net.sf.jasperreports.engine.JRChartCustomizer;
import net.sf.jasperreports.engine.JRChartDataset;
import net.sf.jasperreports.engine.JRChartPlot;
import net.sf.jasperreports.engine.JRChart;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.renderer.category.BarRenderer;

import java.awt.*;

/**
* @author Teodor Danciu (teodord@users.sourceforge.net)
* @version $Id: ChartsApp.java 1381 2006-09-06 00:15:13 +0300 (Wed, 06 Sep 2006) bklawans $
*/
public class BarChartCustomizer implements JRChartCustomizer
{

public void customize(JFreeChart chart, JRChart jasperChart)
{
BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();
renderer.setSeriesPaint(0, Color.green);
renderer.setSeriesPaint(1, Color.orange);
}
}

 

You then have to export that class into a jar file. This file can be added onto your classpath or put in your class directory. Then tell Jasper what the classname is. If you are using iReport, the field is under chart properties. With the example above, two of your categories should have changed colors.

Link to comment
Share on other sites

hai,

 

thx, for your replay

 

 

i follow your step.

 

but i get an error when i compile with ireport

 

Error filling print... Could not create chart customizer instance.

net.sf.jasperreports.engine.JRRuntimeException: Could not create chart customizer instance. at net.sf.jasperreports.engine.fill.JRFillChart.<init>(JRFillChart.java:326) at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getChart(JRFillObjectFactory.java:582) at net.sf.jasperreports.engine.base.JRBaseChart.getCopy(JRBaseChart.java:552) at net.sf.jasperreports.engine.fill.JRFillElementGroup.<init>(JRFillElementGroup.java:88) at net.sf.jasperreports.engine.fill.JRFillElementContainer.<init>(JRFillElementContainer.java:90) at net.sf.jasperreports.engine.fill.JRFillBand.<init>(JRFillBand.java:77) at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getBand(JRFillObjectFactory.java:385) at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:431) at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:73) at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:55) at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:147) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:57) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:234) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:815) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: com.mastersystem.reports.customizer.testing at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:90) at net.sf.jasperreports.engine.fill.JRFillChart.<init>(JRFillChart.java:323) ... 15 more

Print was not filled. Try using an EmptyDataSource...

 

my step

1. create a jar file an, i add into ireport lib.

2. i add ireport ide from options>classpath

3. i add customizer class on chart properties com.mastersystem.reports.customizer.testing

 

did i miss a step from you ?

 

TIA

Link to comment
Share on other sites

  • 8 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...