Jump to content
Changes to the Jaspersoft community edition download ×

Charts- change line/pen width


watsocd

Recommended Posts

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

JasperReports doesn't expose those JFreeChart attributes, therefore you'll have to write a chart customizer that directly uses the JFreeChart APIs to set the desired attribute:

Code:

public class TSChartCustomizer extends JRAbstractChartCustomizer
{
public void customize(JFreeChart chart, JRChart jasperChart)
{
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();
BasicStroke stroke = new BasicStroke(3f);
renderer.setStroke(stroke);
}
}

 

Regards,

Lucian

Link to comment
Share on other sites

Thank you. Here is my completed code for others.

 

Code:
import java.awt.BasicStroke;

import net.sf.jasperreports.engine.JRAbstractChartCustomizer;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRChartCustomizer;

import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.JFreeChart;

public class TSChartCustomizer extends JRAbstractChartCustomizer
{
public void customize(JFreeChart chart, JRChart jasperChart)
{
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();
BasicStroke stroke = new BasicStroke(3f);
renderer.setSeriesStroke(1, stroke);
}
}

 

Chuck

EnergyChaser.com

Link to comment
Share on other sites

  • 4 years later...
  • 5 weeks later...

Take the code above, compile it to a java .class file.  

You'll need to have locate the correct jar files for the referenced libraries.

You should find most of them in your WEB-INF/lib folder

../apache-tomcat/webapps/jasperserver-pro/WEB-INF/lib

 

Put the class file into a .jar file

    jar -c TSChartCustomizer.class > TSChartCustomizer.jar

 

Add the new .jar file to the iReports classpath

 

In the .jrxml report change the chart customizer class property to TSChartCustomizer

 

 Mdahlman has a very great step by step here:

http://mdahlman.wordpress.com/2010/08/18/chart-customizers-1/



Post Edited by dcool at 09/05/2012 16:03
Link to comment
Share on other sites

  • 4 weeks later...
  • 2 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...