jb0elec Posted April 4, 2013 Share Posted April 4, 2013 Hi all; i've created a chart ; and i want to add units to x and Y axis; and also i've another problem withdisplayed X axis( datetime) values that i want to custom to display valeur each 15 days. Link to comment Share on other sites More sharing options...
vitthal_vitthal Posted December 10, 2013 Share Posted December 10, 2013 Hi,You have to write Chart customizer class and have to call that class from iReport. Please find the below steps to achive this 1:Write chart customizer class java code(You can use Eclipes or netbean)2: Make a jar file.3:Add that jar file in iReport as well in Jasper Server.4: Call the class from the properties of Vertical Bar Chart in customizer class. Write a Java code in Eclips or Netbean:package com.TestExample; import java.text.DateFormat;import java.text.ParseException;import java.text.SimpleDateFormat;import net.sf.jasperreports.engine.JRChart;import net.sf.jasperreports.engine.JRChartCustomizer;import org.jfree.chart.axis.DateAxis;import org.jfree.chart.axis.DateTickUnit;import org.jfree.chart.axis.ValueAxis;import org.jfree.chart.plot.XYPlot; /** * * This chart customizer assumes you are using a TimeSeries Chart. * The customization force the use of a different range (i.e. from the start to the end of * the month). * * author Vitthal Muguli */public class TestTick implements JRChartCustomizer { @Override public void customize(org.jfree.chart.JFreeChart jfc, JRChart jrc) { DateAxis xAxis = new DateAxis(); DateTickUnit unit = null; try { DateFormat chartFormatter = new SimpleDateFormat("MM/dd/yyyy HH:mm"); xAxis.setDateFormatOverride(chartFormatter); unit = new DateTickUnit(DateTickUnit.DAY,15); System.out.println("::::::unit:::::"+unit); xAxis.setTickUnit(unit); xAxis.setVerticalTickLabels(true); ((XYPlot)jfc.getPlot()).setDomainAxis(xAxis); } catch (Exception ex) { ex.printStackTrace(); } } } 2 : Make a Jar file Right click on the project and click on clean and buildNet beans will automatically create jar file.Find this jar file in “dest” folder of your project3:Add jar file into IReport Go to the menu barTools –> Option –> iReport –>Class Path–> Add jarSelect the location of jar file. 4 : Call the class from the properties file Right click on on ur chart and go to properties (right side appears) —> go to customizer class–> in the blank space write the classname including the package.Example : com.TestExample.TestTick Let me know if you have any concern. 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