Jump to content

Min width of bars in bar graph


j3grewal

Recommended Posts

Hi,

Is there a way to set minimum width of bars in a bar graph (3D) in iReport? My bar graph will always have only three bars. I want to increase the width of bars so that the bars use up more of the chart area than apprearing far apart.

Also can I control the tranparency of the bars within chart properties?

Regards,
-jas

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Welcome to chart heck /tools/fckeditor/editor/images/smiley/msn/teeth_smile.gif

Jasper only exposes a small part of the JFreechart API. To access any properties outside of these you can write a chart customizer class.

 

This may not do exactly want you want but it will be enough to get you started. This assume that you have some Java programming skills.

public class <Your Class> extends JRAbstractChartCustomizer

{
 
    public void customize(JFreeChart chart, JRChart jasperChart) {
          
     //Chart is a bar chart
     if(jasperChart.getChartType() == JRChart.CHART_TYPE_BAR) {
           
            BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();
                       
            //Remove shadow effect from bar
            renderer.setShadowVisible(false);
           
            //Set maximum bar width
            renderer.setMaximumBarWidth(0.10);
           
           //Create no data message
            CategoryPlot categoryplot = (CategoryPlot) chart.getCategoryPlot();
           
            categoryplot.setNoDataMessage("No data available");
            categoryplot.setNoDataMessageFont(new Font("SansSerif",Font.BOLD,14));
            categoryplot.setNoDataMessagePaint(Color.WHITE);
           
            //Set background as transparent
            categoryplot.setBackgroundPaint(null);
                                   
            //Set left margin before first bar and right margin after last bar
            categoryAxis .setLowerMargin(0.02f);
            categoryAxis .setUpperMargin(0.02f);
                                   
     }         
    }
}
Link to comment
Share on other sites

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...