watsocd Posted March 17, 2008 Share Posted March 17, 2008 How can I change the line/pen width of the pens on a time series chart? ChuckEnergyChaser.com Link to comment Share on other sites More sharing options...
lucianc Posted March 17, 2008 Share Posted March 17, 2008 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 More sharing options...
watsocd Posted March 18, 2008 Author Share Posted March 18, 2008 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); }} ChuckEnergyChaser.com Link to comment Share on other sites More sharing options...
ohrvol Posted August 6, 2012 Share Posted August 6, 2012 Hi, please can you write more detailed steps ? I am not java develloper and I dont know what I have to do with this code. Thanks advance. Ondrej Link to comment Share on other sites More sharing options...
dcool Posted September 5, 2012 Share Posted September 5, 2012 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 More sharing options...
ohrvol Posted October 4, 2012 Share Posted October 4, 2012 thanks much :) Link to comment Share on other sites More sharing options...
ich_freue_mich Posted January 28, 2015 Share Posted January 28, 2015 Hello, I also also have the need to change the line width. The approach above actually affects all line in the chart. Is there an easy way to add a field to the properties of the chart plot so that I can define the width per series in the designer rather then hard-coded in Java? 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