Rotate labels of numberic and symbol axis by defined angle.

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
vijay
Posts: 13
Joined: Thu Nov 17, 2005 3:20 pm
Location: India

Rotate labels of numberic and symbol axis by defined angle.

Post by vijay » Wed Nov 30, 2005 6:52 am

Hi
Is it possible to have the labels of Symbol axis / numeric axis rotated by defined angle. I was able to accomplish this in CategoryAxis with the available apis. Is there a api or a interface which i can extend to accomplish this.

Thanks,
Vijay Venkataraman

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed Nov 30, 2005 12:01 pm

It hasn't been implemented, because with the auto tick unit selection mechanism it becomes a little more complex than the CategoryAxis case (which just displays all labels regardless). It wouldn't be impossible to implement, just a little difficult and time consuming which is why no one has done it yet.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

vijay
Posts: 13
Joined: Thu Nov 17, 2005 3:20 pm
Location: India

Post by vijay » Wed Nov 30, 2005 12:24 pm

Hi Dave,
Thanks for all the responses. I am able to get the labels rotate for now by overriding the method

On rc3 probably aka branch STABLE_1-0-0

Code: Select all

public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) 
This method is used internally in ValueAxis at

Code: Select all

   drawTickMarksAndLabels(Graphics2D g2, 
                                               double cursor,
                                               Rectangle2D plotArea,
                                               Rectangle2D dataArea, 
                                               RectangleEdge edge)
This is probably a hack. I havent completely succeeded in this endavour. I do have the labels rotated. I will have to work with the textAnchor and fix it too. For now it is a hack from my end. Once i get a better hang of things probably i will have them neatly placed at symbolAxis level.

Can you let me know, if this is ok or there is a better way to get to get this done. I am pretty much new to JFree Chart and getting to have grip of the different api and the architecture as such.

Thanks for the responses.

Vijay Venkataraman

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed Nov 30, 2005 12:31 pm

That approach doesn't seem too bad to me. The hard part (for NumberAxis) is choosing a tick size such that the tick labels don't overlap, and that gets done inside the refreshTicks() method. You can return whatever you like from an overridden version of refreshTicks(), as long as you take responsibility for label overlapping yourself.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked