LineChart Date Order Problem

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
mrburns2002
Posts: 6
Joined: Tue Feb 10, 2009 12:50 pm

LineChart Date Order Problem

Post by mrburns2002 » Tue Feb 10, 2009 12:55 pm

Hi,

I try to insert values into my linechart like this:

Code: Select all

avg_pathlength_dataset.addValue(curr_weight, current_word, curr_date);
curr_date is a String with the date in this format : YYYYMMDD

But at the end of the day I get a chart with mixed date order. How can I order the dates from the "smallest" date to the "highes" date?

THANKS!

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Feb 10, 2009 4:17 pm

Are you using a CategoryDataset? That isn't ideal for date-based data. Instead, use an XYPlot with a TimeSeriesCollection.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

mrburns2002
Posts: 6
Joined: Tue Feb 10, 2009 12:50 pm

Post by mrburns2002 » Wed Feb 11, 2009 5:25 pm

david.gilbert wrote:Are you using a CategoryDataset? That isn't ideal for date-based data. Instead, use an XYPlot with a TimeSeriesCollection.
Thanks and how would that look like? Yes, I use CategoryDataset
Can you give me an example?

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Feb 12, 2009 9:12 am

org.jfree.chart.demo.TimeSeriesDemo1.java is included in the distribution. Aside from that, you'll find many other demos included with the JFreeChart Developer Guide.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked