pumi_hasi Posted June 3, 2009 Share Posted June 3, 2009 Hi, I used iReport and jasper to create a bar chart which displays some graphical information depending on the user selection in the system.The number of bars in the bar chart get changed depending on the query results at each time.Being the defined chart width is a fixed value the bar width in the chart get changed each time.When there is only one bar in the chart, that bar is taking the full width from the chart width. So I want to dynamically change the chart width depending on the sql query results, or is there any way to keep the individual bar width fixed?Thank YouHasini Link to comment Share on other sites More sharing options...
dnvsrikanth Posted June 3, 2009 Share Posted June 3, 2009 Hi Hasini, Even I had this problem previously in reports. I overcomed this issue by using Customizer class to customize the graph. You need to know about the JFreeChart API to do this. There is a sample delivered with the JasperReports distribution to demonstrate the customization. check the demo/samples folder in the JasperReports distribution. DNV Srikanth Link to comment Share on other sites More sharing options...
sureshvarma Posted February 23, 2011 Share Posted February 23, 2011 Hi All,I am facing the problem with bar chat design,how can i set the fixed width to the bars in bar chart.Can any one give me the suggestion for over come this problem. Thanks,varma. Link to comment Share on other sites More sharing options...
svenn Posted February 23, 2011 Share Posted February 23, 2011 First the charting package does not allow you to set an absolute width. The best you can do is set a relative percentage width with respect to the total width of your chart.To do this you have to create a customizer class as dnvsrikanth suggested.In the customize method put the following codeif(jasperChart.getChartType() == JRChart.CHART_TYPE_BAR) { BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer(); //Set maximum bar widthrenderer.setMaximumBarWidth(0.10); } Link to comment Share on other sites More sharing options...
sureshvarma Posted February 24, 2011 Share Posted February 24, 2011 I dont know anything about customizer class,I am very new to this jasper.Can any one give the details about customizer class.Is there any chance provide the example customizer class.Thanks in advance, Varma. Link to comment Share on other sites More sharing options...
svenn Posted February 24, 2011 Share Posted February 24, 2011 If you have the professional version you can look at the samples provide with the distribution. Note that you have to have at least a basic understanding of java to do this.Here's a example I found on the web Link to comment Share on other sites More sharing options...
rlfisherpbtgroup.com Posted March 8, 2011 Share Posted March 8, 2011 I solved this one by UNIONing my query with some fake rows (zero values) and a LIMIT clause so I would get the correct maximum number of rows - the last rows being zero length to fill out the width. Link to comment Share on other sites More sharing options...
mchisty Posted July 13, 2011 Share Posted July 13, 2011 Post Edited by mchisty at 07/13/2011 00:49 Link to comment Share on other sites More sharing options...
mchisty Posted July 13, 2011 Share Posted July 13, 2011 I have a similar problem like yours. Could you please post your code fragment here? Really like to know how you solved it. Thanks. Link to comment Share on other sites More sharing options...
stlevkov Posted December 19, 2016 Share Posted December 19, 2016 +svenn 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