Help! Can't draw a chart using 0.9.4!

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

Help! Can't draw a chart using 0.9.4!

Post by Alexandre » Mon Nov 18, 2002 5:42 pm

Hello,

I've been using jFreeChart for some time, and this past weekend I decided to change to version 0.9.4.
After making some necessary changes to my code (especially regarding HorizontalDateAxis) I was finally ready to run the new code. To my (unpleasant) surprise, my program didn't finish... it runned for a LOT of time (5 min) before it crashed with "out of memory". I traced the problem to one line of code:

chart.draw(g2, new Rectangle2D.Double(0, 0, r.width(), r.height()), null);

where g2 is

Graphics2D g2 = cb.createGraphics(r.width(), r.height());

So, to put it simple, this function (draw) is not returning anymore. The chart is a very simple TimeSeriesCollection, with just one BasicTimeSeries.

One of the changes I had to make that I wasn't sure it would work was:
from
((HorizontalDateAxis)timeAxis).setTickUnit(new DateUnit(java.util.Calendar.DAY_OF_MONTH, 5)); ((HorizontalDateAxis)timeAxis).getTickLabelFormatter().applyPattern("d");

to
((HorizontalDateAxis)timeAxis).setTickUnit(
new DateTickUnit(java.util.Calendar.DAY_OF_MONTH, 5,
new java.text.SimpleDateFormat("d"))
);

I don't know if that's the problem... could anyone give me a help? Until then, I'll have to use old versions... :(

Dave Gilbert

Re: Help! Can't draw a chart using 0.9.4!

Post by Dave Gilbert » Mon Nov 18, 2002 11:24 pm

The problem is the constant you have used in the DateTickUnit class. Calendar.DAY_OF_MONTH is equal to 5, but DateTickUnit uses its own constants (NOT the Calendar constants) where DateTickUnit.SECOND is equal to 5. So what you have really requested is ticks every five seconds on your date axis - that could be a lot of ticks! Try using DateTickUnit.DAY instead.

Regards,

DG

Locked