rounding on timeseries

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

rounding on timeseries

Post by Reid Maker » Tue Jul 30, 2002 12:05 am

Hello,

I am trying to figure out how to get the chart from displaying 161.000000 in the values bar. I am using a BasicTimeSeries, and adding values using 'series.add(new Week(week, year), new Integer(tempW));' which should insert it as an integer, but it isn't helping. After I have the series, I make a TimeSeriesCollection, and use that in the graph.

any help would be appreciated...

thanks,

Reid Maker
rmaker@cs.brandeis.edu

David Gilbert

Re: rounding on timeseries

Post by David Gilbert » Tue Jul 30, 2002 10:06 pm

The number axis uses a collection of 'standard' tick units, and automatically selects one that should be appropriate for the axis range. By default, the collection returned by the TickUnits.createStandardTickUnits() method is used - this includes tick units with decimal precision.

If your data contains only integers, then a better collection to use is the one returned by the TickUnits.createIntegerTickUnits() method (or you can create your own collection). Do something like this:

XYPlot plot = myChart.getXYPlot();
NumberAxis axis = (NumberAxis)plot.getRangeAxis();
TickUnits ticks = TickUnits.createIntegerTickUnits();
axis.setStandardTickUnits(ticks);

Regards,

DG.

Locked