File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Creating a Graph with a Trend Line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Creating a Graph with a Trend Line" Watch "Creating a Graph with a Trend Line" New topic
Author

Creating a Graph with a Trend Line

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1439
    
    1
I have a jFreeChart line chart that I would like to add a trend line to. I have searched but did not find much help on this subject. Can someone help me get this done?
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1439
    
    1
I still need some help with this issue.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41600
    
  55
JFreeChart can only render the data it has been given - so you'll need to supply a Dataset that has the points of the trend line. At that point it'll simply be a chart with two X/Y lines.

Or were you looking for a way to have JFC calculate the trend automatically from a given Dataset? It doesn't have provisions for that.


Ping & DNS - my free Android networking tools app
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1439
    
    1
Ulf Dittmer wrote:JFreeChart can only render the data it has been given - so you'll need to supply a Dataset that has the points of the trend line. At that point it'll simply be a chart with two X/Y lines.

Or were you looking for a way to have JFC calculate the trend automatically from a given Dataset? It doesn't have provisions for that.


Yes, I was hoping for JFC to do the work. But if it can't your first suggestion is the direction I will go.

Do you have any or can you direct me to any examples?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41600
    
  55
An example of an X/Y line chart with a dataset containing two lines can be found at http://faq.javaranch.com/java/JFreeChartDemo
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1439
    
    1
Ulf Dittmer wrote:An example of an X/Y line chart with a dataset containing two lines can be found at http://faq.javaranch.com/java/JFreeChartDemo


I have created charts with multiple data sets. What I need an example of is the trend line calculation to provide the data points for the XY trend line.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41600
    
  55
I see. Then the question becomes, how do you define a trend - an n-point moving average? Or do you want to fit a curve through the data points?
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1439
    
    1
Ulf Dittmer wrote:I see. Then the question becomes, how do you define a trend - an n-point moving average? Or do you want to fit a curve through the data points?


It was the moving average and with your help I have got what I need working. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating a Graph with a Trend Line