• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating a Graph with a Trend Line

 
Ranch Hand
Posts: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still need some help with this issue.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic