how can i draw the average line in a time series?
There are a few ways to do this:
The disadvantage to performing the analysis in-line is that JasperReports plots a single value at a time. Any customizer you write will have to calculate the trend based on the past data points, rather than an analysis on all the data points at the end. This will cause a slight skew to the data line.
The disadvantage to using a statistics package is that you would have to find a way to integrate it with your database. (You would also have to learn the corresponding statistical functions to perform the analysis.)
The disadvantage here is that you might have to pay for the product, or support. The integration is likely the easiest.
If you have a PostgreSQL database, I would recommend installing PL/R. Use R to perform the aggregate data analysis and then send the result back to JasperReports for the time series chart.
What you are asking to do can be quite involved.