jQuery in Action, 2nd edition*
The moose likes Other Java Products and Servers and the fly likes Charting Packages - Tick Label Customization? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "Charting Packages - Tick Label Customization?" Watch "Charting Packages - Tick Label Customization?" New topic
Author

Charting Packages - Tick Label Customization?

Michael K. Wilson
Ranch Hand

Joined: Apr 23, 2008
Posts: 45
This is a follow-up to my previous post.

I decided to use JFreeChart and whereas I like it and all, it doesn't seem to support customizing the tick labels (as Strings) on the x axis. It only seems to be able to display numbers or dates.

Can anyone recommend a different Java based charting package which allows the programmer to customize tick labels and also let the developer specify the number of ticks which are displayable?

-Mike
[ May 26, 2008: Message edited by: Michael K. Wilson ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41092
    
  44
The way to customize the axes in JFreeChart is get the Plot object from the chart (chart.getPlot), and then to cast that to the appropriate subclass (XYPlot, CategoryPlot etc.). Then you can use the getDomainAxis and getRangeAxis methods to obtain ValueAxis and/or NumberAxis objects through which you can customize the axes.

If you're using cewolf you can do this in a ChartPostProcessor.


Ping & DNS - my free Android networking tools app
Michael K. Wilson
Ranch Hand

Joined: Apr 23, 2008
Posts: 45
Not so... When you get the DomainAxis, you can only set labels for numbers or dates. What I am looking for is to set String labels.



Thank you for responding!
[ May 26, 2008: Message edited by: Michael K. Wilson ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41092
    
  44
Ah, I read you post a bit too quick and missed the part about strings.

Maybe a CategoryPlot would be better suited than an XYPlot in this case?
Michael K. Wilson
Ranch Hand

Joined: Apr 23, 2008
Posts: 45
Category plots are well-suited for pie charts... What I am using is "time seried charts" (line based charts depending on time)...

Thanks guy!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41092
    
  44
You'll get a CategoryPlot for various chart types, not just pie charts. In this case, you could use a line chart. Then you'll have access to a CategoryAxis, which can handle any string you wish to display.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Charting Packages - Tick Label Customization?
 
Similar Threads
Wanted: Java2D example of zooming and panning with scroll bars
InterruptedException
New version of the cewolf chart tag library
CHEECKY but i need help FAST please!
Fav comic book character....