• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a Graph with a Trend Line

 
Steve Dyke
Ranch Hand
Posts: 1644
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1644
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still need some help with this issue.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Steve Dyke
Ranch Hand
Posts: 1644
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1644
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1644
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic