how to avoid non-decimal values in axis labels

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
art

how to avoid non-decimal values in axis labels

Post by art » Mon Jan 20, 2003 5:10 pm

hi,

i tried to modify the rangeaxis of an vertical bar chart (created with
jfreechart version 0.9.4) to NOT display any non-integer values
(by setting the minimum spacing between two labels to 1).

you can find an image of my drawn chart @
http://www.novanet.at/art/jfree/za.gif

the point is: this chart represents the number of people which
choosed the option 1,2,3 ... - there is no way that option x has
been choosen by 0,05 people =)

thanks for any response
art

David Gilbert

Re: how to avoid non-decimal values in axis labels

Post by David Gilbert » Mon Jan 20, 2003 6:21 pm

You can replace the TickUnits collection on the range axis with an integer-only collection:

CategoryPlot plot = myChart.getCategoryPlot();
NumberAxis axis = (NumberAxis) getRangeAxis();
TickUnits collection = NumberAxis.createIntegerTickUnits(); // or create your own custom collection
axis.setStandardTickUnits(collection);

Regards,

Dave Gilbert

art

Re: how to avoid non-decimal values in axis labels

Post by art » Mon Jan 20, 2003 6:50 pm

exactly what i wanted!

damn, i knew that the solution is simple but i still overlooked it.

thanks for the quick response!

art

Locked