Jump to content
We've recently updated our Privacy Statement, available here ×

Rotated labels appear left-aligned


sfergus1
Go to solution Solved by sfergus1,

Recommended Posts

I have a bar graph with labels rotated a -45 degrees to read on an upward slope, left to right.  When I run it in preview mode in iReport it looks fine (see preview.pdf attachment), with all of the labels up against the bottom of the bar graph.  When I run it through our Jasper server, the labels appear to be left-aligned instead of right-aligned..  They're all pulled away from the horizontal axis, apparently ragged in their alignment, and the leftmost label is getting cut off (see final.pdf attachment).

I do have a chart customizer class for this document, which I use to color the positive values green and the negative ones red, keeping them all in a single series so I don't have to plot empty bars.  As part of this I have a custom bar renderer subclass.  However, I think I'm copying all of the relevant parameters in the constructor of my class (shown below), and I'm using the same jar file both with iReport and on the Jaspewr Reports server.

    public CustomBarRenderer(BarRenderer barRenderer, Paint[] colors) {

      this.colors = colors;
 
      // Copy settings for item labels
      this.setBaseItemLabelsVisible(barRenderer.getBaseItemLabelsVisible());
      this.setBasePositiveItemLabelPosition(barRenderer.getBasePositiveItemLabelPosition());
      this.setBaseNegativeItemLabelPosition(barRenderer.getBaseNegativeItemLabelPosition());
      this.setBaseItemLabelFont(barRenderer.getBaseItemLabelFont());
      this.setBaseItemLabelPaint(barRenderer.getBaseItemLabelPaint());
      this.setBaseItemLabelGenerator(barRenderer.getBaseItemLabelGenerator());
 
      // Copy other display settings
      this.setShadowVisible(barRenderer.getShadowsVisible());
      this.setMaximumBarWidth(.02);
    }
 
My JRXML for defining the category labels looks like this:
 
 
 
 
 
 
 
 
 
 

I don't see any attributes I can set to change from left to right aligned in the XML schema.

Any suggestions on how to correct this label alignment issue would be most appreciated.

Thanks, Steve

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

It looks like the problem was likely a build issue.  I think the exported font jar file the report expected wasn't included in the build, and the report was falling back to Helvetica, which was causing the positioning to be off.  I ran another report this morning and it appears okay.

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