Reputation: 366
I have displayed values on top of bars in a JFreeChart bar chart. If there are lot of bars, values are getting too congested if the label is horizontal. I need to display the values vertically. I tried below options but they didn't work:
ItemLabelPosition itemLabelPositionTwo=new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE1, TextAnchor.BASELINE_RIGHT,TextAnchor.BASELINE_RIGHT,+90.0);
ItemLabelPosition itemLabelPositionTwo=new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE1, TextAnchor.BASELINE_RIGHT,TextAnchor.BASELINE_RIGHT,+45.0);
ItemLabelPosition itemLabelPositionTwo=new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_RIGHT,TextAnchor.BASELINE_RIGHT,+45.0);
Any help on this very much appreciated.
I tried with Radians and below options. The maximum I was able to rotate is as below
ItemLabelPosition itemLabelPositionTwo=new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE6, TextAnchor.BASELINE_RIGHT,TextAnchor.BASELINE_RIGHT,-Math.PI/2);
ItemLabelPosition itemLabelPositionTwo=new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE7, TextAnchor.BASELINE_RIGHT,TextAnchor.BASELINE_RIGHT,-Math.PI*2);
ItemLabelPosition itemLabelPositionTwo=new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE8, TextAnchor.BASELINE_RIGHT,TextAnchor.BASELINE_RIGHT,Math.PI/2);
ItemLabelPosition itemLabelPositionTwo=new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE9, TextAnchor.BASELINE_RIGHT,TextAnchor.BASELINE_RIGHT,+270.0);
ItemLabelPosition itemLabelPositionTwo=new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE10, TextAnchor.BASELINE_RIGHT,TextAnchor.BASELINE_RIGHT,+360.0);
ItemLabelPosition itemLabelPositionTwo=new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE1, TextAnchor.BASELINE_RIGHT,TextAnchor.BASELINE_RIGHT,+Math.PI/2);
Upvotes: 1
Views: 1099
Reputation: 205785
The relevant ItemLabelPosition
constructor expects the angle
in radians; you probably want something like this:
ItemLabelPosition itemlabelposition = new ItemLabelPosition(
ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, -Math.PI / 2);
Upvotes: 2
Reputation: 1
Convert degrees to Radian and pass the converted value as parameter(angle) for ItemLabelPosition
ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,TextAnchor.BASELINE_CENTER,TextAnchor.BASELINE_CENTER,-1.5708); -- here 1.5708(Radian) is for 90°
Upvotes: 0