Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Is there a way in JavaFX 2 to force the tick labels along the x-axis of a bar chart to be always ver

mambhaDec 15 2013

I am using JavaFX to render bar charts within a Swing applicatin using JRE 1.7.0_45, JavaFx 2.2.45-b18.


In my chart, the NumberAxis is the y-axis, and the CategoryAxis is the x-axis meant to represent Strings (people's first and last names).

The chart has just one Series, and so I have turned off the legend via the call barChart.setLegendVisible(false);

Also, I have more data points to show along the x-axis than I can reasonably fit at once. Hence I show no more than, say, 20 names at a time. Thus, if there are more names than that, the user can select which set of names to display at a time, and render a new chart for each set. To keep the 'scale' the same along the NumberAxis while displaying each set, I determine the max. number and tick unit ahead of time for all the data points and create the number axis using the following call for each data set selected by the user:

NumberAxis yAxis= new NumberAxis(0, maxNumber, tickUnit);

Further, I want the tick labels along the x-axis to be vertical. So I do the following:

xAxis.setTickLabelRotation(90);

My problem is that the call to set the tick label rotation seems to have no effect on the rendering of my charts. It appears that the vertical or horizontal orientation of the x-axis labels is determined by the amount of space available for display. Thus, in my case, if 20 names are to be displayed, the names are rendered vertically, with each vertical bar having a certain width. However, if only 11 names are displayed, they are not only rendered horizontally, but also the tick label on each alternate bar is skipped. (And the bars are of larger width.)

As I said, whether I call xAxis.setTickLabelRotation(90) or not does not seem to matter.

What am I missing or doing wrong?

Is there some way to always force the orientation of the tick labels along the x-axis? Not having some of the tick labels show up under alternate bars is a huge problem for my application.

I wouldn't mind forcing the bar widths to be a certain value, if there is a way to do so and if it helps. (I haven't found a way to do this either.)


Any other suggestions?

Am I doing this wrong or is this a bug in the release I am using?

Thanks for any help and pointers.

Message was edited by: mambha I have written JIRA tickets about this issue: RT-35052 and RT-35061

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 12 2014
Added on Dec 15 2013
0 comments
943 views