This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JavaFX and the fly likes Change the Tick Label Value of X Axis in Java FX Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JavaFX
Bookmark "Change the Tick Label Value of X Axis in Java FX" Watch "Change the Tick Label Value of X Axis in Java FX" New topic
Author

Change the Tick Label Value of X Axis in Java FX

alex antony
Greenhorn

Joined: Jan 26, 2011
Posts: 12
Hi all,

I have tried out some samples with Java FX and it is exciting.I have been trying to generate a dynamic Graph using JavaFX .It Worked out Well and i was able to see the Graph Moving .But as the Graph Moves i Would also like to see my x-axis labels moving.But i dont know how to do it .

I am posting my code here.






These are the two classes that i am using main.fx and AnimatedLineChart.fx In the Main .fx i have created a timer thread for one second and it calls the AnimatedLineChart.fx and deletes the rightmost value and adds the new Value to the left hand side which creates a moving impression.But the concern is the X-Axis Labels dont change.How to do that


Any Help is highly Appreciated
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Am just guessing- Did you try overriding the formatTickLabel variable for xAxis- Like the way you have implemented for yAxis?


Mohamed Sanaulla | My Blog
alex antony
Greenhorn

Joined: Jan 26, 2011
Posts: 12
Thanks for the reply.

The Thing is The Tick Values for Y Axis will remain Constant but for the X-Axis it will change as the thread runs.

Thats why i dint override the formatticklabel method in the normal way that i did for y axis.

The Function addvalue is called by the thread each second and the actual value of the graph is updated through this function data.xVValue=data.XValue-1 ;So I would need a method that i call which can update the xAxis tick label value

I Tried this inside the for loop xAxis.formatTickLabel function (value) {} but doesnt seem to work

Any Suggestions !
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

You can have a look at tickMarks variable which accepts an array of TickMark. May be you can bind the tickMarks variable with some constant TickMark[] and keep changing the variables of the TickMark instances in the TickMark[].
alex antony
Greenhorn

Joined: Jan 26, 2011
Posts: 12
Sounds Great !.I Will try that and get to you back in case i hang still
 
jQuery in Action, 2nd edition
 
subject: Change the Tick Label Value of X Axis in Java FX