
Trendline Charts

INPUT:
    Two tables each with a datetime column and a number column

VARIABLES:
   columnOne - Name of the datetime column
   columnTwo - Name of the number/values column

   line1 - Name of line series 1
   line2 - Name of line series 2

   trendline1 - Name of trendline series 1 (the dotted line that accompanies line1)
   trendline2 - Name of trendline series 2 (the dotted line that accompanies line2)

   results - table that contains the datetime column and number column for line1
   resultsTwo - table that contains the datetime column and number column for line2

   forecast - if set to 'true', the lines will try to extend upto the intersection point (if they can intersect to the right side of the chart)


EXAMPLE SCRIPT:

set sql <<EOF
    select dd.date_of_trans, sum(fact.estimated_effort) 
    from artifact_transaction_fact fact
        inner join date_dimension dd on (dd.date_of_trans + 1) between fact.effective_from and fact.effective_till 
        inner join status_dimension sd on fact.status_key = sd.status_key
        inner join pf_bridge pf_b on pf_b.child = fact.pf_key
        inner join pf_dimension parent_pfd on pf_b.parent = parent_pfd.pf_Key
        inner join tracker_dimension td on fact.tracker_key = td.tracker_key
        inner join etl_job ej on ej.job_key = fact.job_key and ej.status = 1
    where [:var:whereClause:]
        parent_pfd.id = 'plan1001' and
        td.id in ('tracker1001') and 
        dd.date_Of_trans >= '2013-09-13'
        and dd.date_of_trans <= '2013-09-16 08:56:21'
    group by dd.date_of_trans
    order by dd.date_of_trans
EOF

try
do
   sql -dm $sql
      copy as results
      return
   
   set whereClause sd.status_value_class = 'Close' and
   
   sql -dm $sql
      copy as resultsTwo
      return
   
   #Setting required variables
   set columnOne date_of_trans
   set columnTwo sum
   
   set line1 Total Effort Estimated
   set line2 Total Effort Closed
   
   set trendline1 Scope Change Trend
   set trendline2 Velocity
   
   set forecast true
catch
   message info No Data
done 
