• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to sample and count peaks in a line graph  RSS feed

 
Rudy Rodriguez
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to count the number of peaks in a line graph, so I can keep track of certain events.

I am reading the data into a arraylist, and using Jexcelapi to chart the data in a line graph.

the data is based on time and gallons of water on hand.
Here is a sample of the data.

Could someone help me to figure out a efficient way to count the peak of the data.





Thanks
Rudy
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Math.max(int, int) is what you are looking for.

Define a double with Double.MIN_VALUE, iterate over the list and pass the variable that holds the peak and the current variable into the max method. The higher value is returned and will be assigned to the variable holding the max value.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!