Hi
I tried your suggestion but it didn't produce what I was after.
I have only 1 column per day and I wanted to add a cumulative line/curve to this simple bar chart.
I've been playing around with this myself and have managed to get a chart which does what I wish but is it the best way?
I created a string of the cumulative daily value:
declare cum varchar(500);
SET @runtot:=0;
select
group_concat(@runtot := @runtot + a.Hours)
into cum
from
(select day(b.daymonth) as "Day",
ifnull(sum(if ((timediff(a.lab_end,a.lab_start))>=0,
((time_to_sec(timediff(a.lab_end,a.lab_start)))/3600)*a.lab_numops,(((time_to_sec(timediff("24:00:00",a.lab_start)))/3600) + (time_to_sec(timediff(a.lab_end,"00:00:00")))/3600)*a.lab_numops)),0) as "Hours"
from calendar b
left outer join tbl_fpolab a on b.daymonth = a.lab_date
group by b.daymonth) a;
I then added the following chart options:
select 'dbr.title',"";
SELECT 'dbr.chart', 'Column','Monthly \'Productive\' Hours';
select 'dbr.chart.options', 'chartdirector', '
$linelayer = $c->addLineLayer();
$linelayer->moveFront();
$linelayer->setLineWidth(3);
$linelayer->setUseYAxis2();
';
select 'dbr.chart.options', 'chartdirector', concat("$linelayer->addDataSet(array(",cum,"),0xFF0000, \"Target\");");
select 'dbr.chart.options','axis', 'Day of the Month', 'Daily Hours Used', 'Cumulative Hours Used';
SET @runtot:=0;
select
a.Day as "Day[Day]",
a.Hours as "Prod.Hours[PHrs
from
(select day(b.daymonth) as "Day",
ifnull(sum(if ((timediff(a.lab_end,a.lab_start))>=0,
((time_to_sec(timediff(a.lab_end,a.lab_start)))/3600)*a.lab_numops,(((time_to_sec(timediff("24:00:00",a.lab_start)))/3600) + (time_to_sec(timediff(a.lab_end,"00:00:00")))/3600)*a.lab_numops)),0) as "Hours"
from calendar b
left outer join tbl_fpolab a on b.daymonth = a.lab_date
group by b.daymonth) a;
Cheers
Jake