Problem with XYLineChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Jane
Posts: 14
Joined: Wed Jun 25, 2008 7:16 pm

Problem with XYLineChart

Post by Jane » Wed Jun 25, 2008 7:23 pm

It seems to me that when the XYLineChart was used to create plots, the data was
sorted with increasing X values. I need to plot in a sequence of increasing Y values.
How do I achieve that?

Thanks,

Jane

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 » Wed Jun 25, 2008 9:18 pm

It is the dataset class that is sorting by x-value. There is an option in the constructor to enable/disable this.
David Gilbert
JFreeChart Project Leader

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

Jane
Posts: 14
Joined: Wed Jun 25, 2008 7:16 pm

Post by Jane » Thu Jun 26, 2008 2:50 pm

Thank you very much for your reply.

I am very new here. I looked around in the guide and was only able to find
getDomainOrder with the interface XYDataset on page 809. Could you PLEASE give me
an example showing how to disable the sorting?

Thanks in advance.

Jane

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 Jun 26, 2008 2:57 pm

I am making a guess that you are using the XYSeries class (and XYSeriesCollection). It has this constructor that you can use when you create the series:

Code: Select all

public XYSeries(java.lang.Comparable key, boolean autoSort);
You need to pass 'false' for the 'autoSort' argument.
David Gilbert
JFreeChart Project Leader

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

Jane
Posts: 14
Joined: Wed Jun 25, 2008 7:16 pm

Post by Jane » Thu Jun 26, 2008 3:11 pm

Thanks a lot. It worked. :)

Locked