Graphing non-functions on a line graph?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Mike Keller
Posts: 23
Joined: Mon Jul 06, 2009 12:59 pm

Graphing non-functions on a line graph?

Post by Mike Keller » Tue Jul 28, 2009 3:42 pm

I am graphing points on an XY plot sorted by time. I would like a lines from the last point added to the current point added. I have an image, shown below:

Image

I want to add the points numbered 1 through 5 in that order, and draw something like shown on the left. However, when I use the XYLinePlot, I get something like on the right.

I apologize for asking so many questions, but the forum has been helpful so far, and I really like JFreeChart and want it to be useful for my application.

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Re: Graphing non-functions on a line graph?

Post by skunk » Tue Jul 28, 2009 3:52 pm

What dataset implementation are you using? By default, XYSeries automatically sorts items as they are added.

Mike Keller
Posts: 23
Joined: Mon Jul 06, 2009 12:59 pm

Re: Graphing non-functions on a line graph?

Post by Mike Keller » Tue Jul 28, 2009 3:57 pm

skunk wrote:What dataset implementation are you using? By default, XYSeries automatically sorts items as they are added.
Huh, I am using an XYSeries though, and I haven't changed how it sorts them. Yet it's still getting graphed according to the second part of that image.

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Re: Graphing non-functions on a line graph?

Post by skunk » Tue Jul 28, 2009 4:41 pm

Code: Select all

public XYSeries(java.lang.Comparable key, boolean autoSort)
Try passing false for the autoSort parameter

Mike Keller
Posts: 23
Joined: Mon Jul 06, 2009 12:59 pm

Re: Graphing non-functions on a line graph?

Post by Mike Keller » Tue Jul 28, 2009 4:48 pm

That worked! Thanks for your help.

Locked