ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Adding 10 year average line.
Posted by Paul Huffman on Nov-16-2018 01:13
I had a request to add a 10 year average to some of my charts. Using PHP and MySQL queries for charts of counts by date.
Are there any examples of this in the  chart director docs?  Looking at my sources now,  trying to decide if I should create the average data array with a SQL query or calculate the ten year average in PHP.

  Re: Adding 10 year average line.
Posted by Paul Huffman on Nov-16-2018 08:22
I guess the query wasn't as hard as I thought.  DISTINCT isn't needed but GROUP BY is.  This SQL statement got me the results I was looking for.  Now to implement in the charting   script.

DAY (chkDt) AS DAY,
YEAR (chkDt) > 2006
AND YEAR (chkDt) < 2018
DAY (chkDt)

  Re: Adding 10 year average line.
Posted by Peter Kwan on Nov-16-2018 17:58
Hi Paul,

From your chart, it looks like you have some arrays of values from 05/01/2015 to 04/30/ 2016. For your average line, you can create an array of the same size. For each record in your query (which includes 3 columns for the month, day and avg), you can use your own code to determine the position should of that column in the array. For example, if the month is 5 and the day is 1, then you know it should be the first element of the day. If the month is 12 and day is 27, then it should be in the position that corresponds to 12/27/2015. In this way, you can get your avg data aligned properly with your other data.

Hope this can help.

Peter Kwan