- Impact
- 9
Chart has been working perfect until today.
The chart is suppose to display the the current as well last 11 months.. instead today the chart started displaying Nov 07 then Jan 09 Feb 09, March09 etc...
anyone see anything wrong with the code ?
$x = $xml->addChild('abscissa_data');
$year = date('Y');
$month = date('n');
$m = $month + 1;
$y = $year;
if ($m > 12)
$m = 1;
else
$y--;
$next_year = $y;
if (!$priceSpread) {
$e85 = $xml->addChild('ordinate_data');
$e85->addAttribute('seriesName', 'E85 Prices');
$e85->addAttribute('color', $e85_color);
$e85->addAttribute('size', '4');
$gas = $xml->addChild('ordinate_data');
$gas->addAttribute('seriesName', 'Gasoline Prices');
$gas->addAttribute('color', $gas_color);
$gas->addAttribute('size', '4');
}
else {
$price = $xml->addChild('ordinate_data');
$price->addAttribute('seriesName', 'Price Spread');
$price->addAttribute('color', $priceSpread_color);
$price->addAttribute('size', '4');
}
$time = array();
$time[$m] = mktime(0, 0, 0, $m, 1, $y);
for ($i = 0; $i < 12; $i++) {
$next_month = $m + 1;
if ($next_month > 12) {
$next_month = 1;
$next_year = $year + 1;
}
$time[$next_month] = mktime(0, 0, 0, $next_month, 1, $next_year);
$x_val = $x->addChild('x');
$x_val->addAttribute('value', date('M y',$time[$m]));
$Query = "Select ".$What." from `prices` where ".$Where."`timestamp` between '".$time[$m]."' and '".$time[$next_month]."'";
$Result = $Db->FetchArray($Query);
if ($priceSpread) {
$y_val = $price->addChild('y');
$y_val->addAttribute('value', $Result['priceSpread']?number_format($Result['priceSpread'], 2):'');
}
else {
$y_val = $e85->addChild('y');
$y_val->addAttribute('value', $Result['e85']?number_format($Result['e85'],2):'');
$y_val = $gas->addChild('y');
$y_val->addAttribute('value', $Result['gas']?number_format($Result['gas'],2):'');
}
$m = $next_month;
$year = $next_year;
}
echo $xml->asXML();
The chart is suppose to display the the current as well last 11 months.. instead today the chart started displaying Nov 07 then Jan 09 Feb 09, March09 etc...
anyone see anything wrong with the code ?
$x = $xml->addChild('abscissa_data');
$year = date('Y');
$month = date('n');
$m = $month + 1;
$y = $year;
if ($m > 12)
$m = 1;
else
$y--;
$next_year = $y;
if (!$priceSpread) {
$e85 = $xml->addChild('ordinate_data');
$e85->addAttribute('seriesName', 'E85 Prices');
$e85->addAttribute('color', $e85_color);
$e85->addAttribute('size', '4');
$gas = $xml->addChild('ordinate_data');
$gas->addAttribute('seriesName', 'Gasoline Prices');
$gas->addAttribute('color', $gas_color);
$gas->addAttribute('size', '4');
}
else {
$price = $xml->addChild('ordinate_data');
$price->addAttribute('seriesName', 'Price Spread');
$price->addAttribute('color', $priceSpread_color);
$price->addAttribute('size', '4');
}
$time = array();
$time[$m] = mktime(0, 0, 0, $m, 1, $y);
for ($i = 0; $i < 12; $i++) {
$next_month = $m + 1;
if ($next_month > 12) {
$next_month = 1;
$next_year = $year + 1;
}
$time[$next_month] = mktime(0, 0, 0, $next_month, 1, $next_year);
$x_val = $x->addChild('x');
$x_val->addAttribute('value', date('M y',$time[$m]));
$Query = "Select ".$What." from `prices` where ".$Where."`timestamp` between '".$time[$m]."' and '".$time[$next_month]."'";
$Result = $Db->FetchArray($Query);
if ($priceSpread) {
$y_val = $price->addChild('y');
$y_val->addAttribute('value', $Result['priceSpread']?number_format($Result['priceSpread'], 2):'');
}
else {
$y_val = $e85->addChild('y');
$y_val->addAttribute('value', $Result['e85']?number_format($Result['e85'],2):'');
$y_val = $gas->addChild('y');
$y_val->addAttribute('value', $Result['gas']?number_format($Result['gas'],2):'');
}
$m = $next_month;
$year = $next_year;
}
echo $xml->asXML();







