Hi All,
I am trying to draw a basic Time series graph. I would like to plot
monthly data. However I observed that , if the size of the graph
is increased , the graph range breakdowns to every 15 days.
How can I fix the range so that it always displays months , and
not 15 days or something else.
Eg:
I want the X-Axis to show range as
Jan 2001, Feb 2001, Mar 2001 .....
But now, sometimes i get
Jan 1 , Jan 16 , Mar 2 , .....
I am constructing BasicTimeSeries Object like this:
BasicTimeSeries t1 = new BasicTimeSeries("Annual", "Year", "Value", Month.class);
As you see, I am explicitly stating that data is monthly.
Can you please help me?
Cheers
-Ratnakar
How to Fix the Range Axis in TimeSeries Graph
Re: How to Fix the Range Axis in TimeSeries Graph
The tick units used on the axis are not guaranteed to match the intervals in your dataset. In fact, via the XYDataset interface (which is all that XYPlot relies on most of the time), there is no easy way to find out what the intervals are in your data. Furthermore, your data doesn't even have to have regular intervals.
Aside from that, you can "fix" the tick unit on your axis using the setTickUnit(...) method:
XYPlot plot = myChart.getXYPlot();
DateAxis axis = (DateAxis) plot.getDomainAxis();
DateTickUnit unit = new DateTickUnit(DateTickUnit.MONTH, 1);
axis.setTickUnit(unit);
The only thing you need to watch out for after doing that, is that the tick labels might overlap if you resize the chart.
Regards,
DG.
Aside from that, you can "fix" the tick unit on your axis using the setTickUnit(...) method:
XYPlot plot = myChart.getXYPlot();
DateAxis axis = (DateAxis) plot.getDomainAxis();
DateTickUnit unit = new DateTickUnit(DateTickUnit.MONTH, 1);
axis.setTickUnit(unit);
The only thing you need to watch out for after doing that, is that the tick labels might overlap if you resize the chart.
Regards,
DG.
Re: How to Fix the Range Axis in TimeSeries Graph
Thanx Dave that helped.
I dont think the overlap of labels should be any problem, as I am using
JFreeChart in a servlet Context, and once an image is generated, there is
no resize issue.
Cheers,
Ratnakar
I dont think the overlap of labels should be any problem, as I am using
JFreeChart in a servlet Context, and once an image is generated, there is
no resize issue.
Cheers,
Ratnakar