akhanh Posted January 22, 2008 Share Posted January 22, 2008 Hi, i tried to change the range y-axis of a bar-chart.i create a 'class customizer implements JRChartCustomizer'a i tried to use it with' // getchart JRDesignChart i = (JRDesignChart) (jdesgn.getSummary().getElements()[0]); i.setCustomizerClass(new customizer().toString());'but it do not work. What i should write in i.setCustomizerClass(new customizer().toString()); ThanksAli Baba Link to comment Share on other sites More sharing options...
svenn Posted January 22, 2008 Share Posted January 22, 2008 Here two links that might help you out JFreeChart API http://www.jfree.org/jfreechart/api/javadoc/index.html forum http://www.jfree.org/phpBB2/index.php Link to comment Share on other sites More sharing options...
akhanh Posted January 23, 2008 Author Share Posted January 23, 2008 Hi, my problem is to find the interface to get a jfreechart from JR.Do you know how i get it? Link to comment Share on other sites More sharing options...
svenn Posted January 24, 2008 Share Posted January 24, 2008 I'm not sure how you get the particular properties that you are looking to modify. I've modified different properties. I've posted the class and method that I used. Hopefully this will give you a starting point to work from. Code:public class JasperChartCustomizer extends JRAbstractChartCustomizer{ public void customize(JFreeChart chart, JRChart jasperChart) { //Chart is a bar chart if(jasperChart.getChartType() == JRChart.CHART_TYPE_BAR) { } }} Link to comment Share on other sites More sharing options...
akhanh Posted January 24, 2008 Author Share Posted January 24, 2008 HI,this could work, but my problem is to set the customizer class.I have a custumizer extends JRAbstractChartCustomizerand i try to use it with JRDesignChart i = (JRDesignChart) (jdesgn.getSummary().getElements()[0]); i.setCustomizerClass("customizer");but i getException in thread "main" net.sf.jasperreports.engine.JRRuntimeException: Could not create chart customizer instance. i dont know i set the customizer class... Link to comment Share on other sites More sharing options...
svenn Posted January 24, 2008 Share Posted January 24, 2008 To point to your customizer go to your chart under Chart Properties. There is a box called Customizer class. You point to your class here. Link to comment Share on other sites More sharing options...
akhanh Posted January 24, 2008 Author Share Posted January 24, 2008 Hi,that works very fine. For all a summary:1. create:package tests; import net.sf.jasperreports.engine.JRAbstractChartCustomizer;import net.sf.jasperreports.engine.JRChart;import net.sf.jasperreports.engine.JRChartCustomizer; import org.jfree.chart.JFreeChart;import org.jfree.chart.axis.NumberAxis;import org.jfree.chart.plot.CategoryPlot;import org.jfree.data.Range; public class customizer extends JRAbstractChartCustomizer{ public void customize(JFreeChart jfreechart, JRChart arg1) {// Get the plot CategoryPlot plot = jfreechart.getCategoryPlot(); plot.getRangeAxis().setRange(10, 100); } } 2.: set it (see last post) in the chart the customizer class.In my example you must write tests.customizetests is the package name. Thats all and you get a y-axis range from 10 to 100.With the methods of plot (see above) you can change different values of the chart Ali Baba Link to comment Share on other sites More sharing options...
akhanh Posted January 24, 2008 Author Share Posted January 24, 2008 Hi,that works very fine. For all a summary:1. create:package tests; import net.sf.jasperreports.engine.JRAbstractChartCustomizer;import net.sf.jasperreports.engine.JRChart;import net.sf.jasperreports.engine.JRChartCustomizer; import org.jfree.chart.JFreeChart;import org.jfree.chart.axis.NumberAxis;import org.jfree.chart.plot.CategoryPlot;import org.jfree.data.Range; public class customizer extends JRAbstractChartCustomizer{ public void customize(JFreeChart jfreechart, JRChart arg1) {// Get the plot CategoryPlot plot = jfreechart.getCategoryPlot(); plot.getRangeAxis().setRange(10, 100); } } 2.: set it (see last post) in the chart the customizer class.In my example you must write tests.customizetests is the package name. Thats all and you get a y-axis range from 10 to 100.With the methods of plot (see above) you can change different values of the chart Ali Baba Link to comment Share on other sites More sharing options...
akhanh Posted January 24, 2008 Author Share Posted January 24, 2008 For an administrator:i dont know why:if i post something one time, it create two posts.in my last posts it create four times, but i press the submit button only one time... 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